Skip to content

Commit

Permalink
test : ProjectService 테스트 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
youKeon committed Oct 1, 2023
1 parent fdb6530 commit c6dbd39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.graphy.backend.domain.project.domain.Project;
import com.graphy.backend.domain.project.domain.ProjectTags;
import com.graphy.backend.domain.project.domain.Tag;
import com.graphy.backend.domain.project.domain.Tags;
import com.graphy.backend.domain.project.dto.request.CreateProjectRequest;
import com.graphy.backend.domain.project.dto.request.GetProjectsRequest;
import com.graphy.backend.domain.project.dto.request.UpdateProjectRequest;
Expand Down Expand Up @@ -72,30 +73,30 @@ void updateProject() throws Exception {
.content("content")
.build();

List<String> techTags = new ArrayList<>(Arrays.asList("Spring", "Django"));

UpdateProjectRequest request = UpdateProjectRequest.builder()
.projectName("afterUpdate")
.description("des")
.thumbNail("thumb")
.content("content")
.techTags(new ArrayList<>(Arrays.asList("Spring", "Django")))
.techTags(techTags)
.build();

Tag tag1 = Tag.builder().tech("Spring").build();
Tag tag2 = Tag.builder().tech("Django").build();
Tag tag1 = Tag.builder().tech("Vue").build();
Tag tag2 = Tag.builder().tech("Java").build();


//when
when(projectRepository.findById(project.getId())).thenReturn(Optional.of(project));
when(tagService.findTagByTech("Spring")).thenReturn(tag1);
when(tagService.findTagByTech("Django")).thenReturn(tag2);
when(tagService.findTagListByName(techTags)).thenReturn(new Tags(List.of(tag1, tag2)));

UpdateProjectResponse result = projectService.modifyProject(project.getId(), request);

assertThat(result.getProjectName()).isEqualTo(project.getProjectName());
assertThat(result.getDescription()).isEqualTo(project.getDescription());
assertThat(result.getThumbNail()).isEqualTo(project.getThumbNail());
assertThat(result.getTechTags()).isEqualTo(new ArrayList<>(Arrays.asList("Spring", "Django")));
assertThat(result.getTechTags()).isEqualTo(new ArrayList<>(Arrays.asList("Vue", "Java")));
}

@Test
Expand All @@ -118,6 +119,10 @@ void createProject() throws Exception {

//when
when(projectRepository.save(any(Project.class))).thenReturn(project);
when(tagService.findTagListByName(techTags)).thenReturn(new Tags(List.of(
Tag.builder().tech("Spring").build(),
Tag.builder().tech("Django").build()
)));
CreateProjectResponse result = projectService.addProject(request, member);

//then
Expand Down
16 changes: 0 additions & 16 deletions backend/src/test/resources/application-test.yml

This file was deleted.

0 comments on commit c6dbd39

Please sign in to comment.