99import org .junit .jupiter .api .DisplayName ;
1010import org .junit .jupiter .api .Test ;
1111
12+ import com .back .domain .problem .problem .enums .DifficultyLevel ;
1213import com .back .domain .tag .tag .dto .TagResponse ;
1314import com .back .domain .tag .tag .entity .Tag ;
1415import com .back .domain .tag .tag .repository .TagRepository ;
@@ -19,20 +20,33 @@ class TagServiceTest {
1920 private final TagService tagService = new TagService (tagRepository );
2021
2122 @ Test
22- @ DisplayName ("태그 목록 조회 시 code/label을 태그 이름으로 반환한다" )
23+ @ DisplayName ("태그 목록 조회 시 code/label과 난이도 목록을 함께 반환한다" )
2324 void getTags_returnsTagList () {
2425 Tag arrayTag = mock (Tag .class );
2526 Tag graphTag = mock (Tag .class );
2627 Tag blankTag = mock (Tag .class );
28+ TagRepository .TagDifficultyView arrayEasy = mock (TagRepository .TagDifficultyView .class );
29+ TagRepository .TagDifficultyView arrayHard = mock (TagRepository .TagDifficultyView .class );
30+ TagRepository .TagDifficultyView graphMedium = mock (TagRepository .TagDifficultyView .class );
2731
2832 when (arrayTag .getName ()).thenReturn ("array" );
2933 when (graphTag .getName ()).thenReturn ("graph" );
3034 when (blankTag .getName ()).thenReturn (" " );
35+ when (arrayEasy .getTagName ()).thenReturn ("array" );
36+ when (arrayEasy .getDifficulty ()).thenReturn (DifficultyLevel .EASY );
37+ when (arrayHard .getTagName ()).thenReturn ("array" );
38+ when (arrayHard .getDifficulty ()).thenReturn (DifficultyLevel .HARD );
39+ when (graphMedium .getTagName ()).thenReturn ("graph" );
40+ when (graphMedium .getDifficulty ()).thenReturn (DifficultyLevel .MEDIUM );
3141
3242 when (tagRepository .findAllByOrderByNameAsc ()).thenReturn (List .of (arrayTag , graphTag , blankTag ));
43+ when (tagRepository .findTagDifficulties ()).thenReturn (List .of (arrayEasy , arrayHard , graphMedium ));
3344
3445 List <TagResponse > response = tagService .getTags ();
3546
36- assertThat (response ).containsExactly (new TagResponse ("array" , "array" ), new TagResponse ("graph" , "graph" ));
47+ assertThat (response )
48+ .containsExactly (
49+ new TagResponse ("array" , "array" , List .of ("EASY" , "HARD" )),
50+ new TagResponse ("graph" , "graph" , List .of ("MEDIUM" )));
3751 }
3852}
0 commit comments