-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/test/java/com/soptie/server/maker/service/MakerServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.soptie.server.maker.service; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.doReturn; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import com.soptie.server.maker.adapter.MakerFinder; | ||
import com.soptie.server.maker.entity.Maker; | ||
import com.soptie.server.maker.service.dto.MakerListAcquireServiceResponse; | ||
import com.soptie.server.support.fixture.MakerFixture; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class MakerServiceTest { | ||
|
||
@InjectMocks | ||
private MakerService makerService; | ||
|
||
@Mock | ||
private MakerFinder makerFinder; | ||
|
||
@Test | ||
@DisplayName("[성공] 모든 메이커 테마를 조회한다.") | ||
void acquireAllTheme() { | ||
// given | ||
long makerId1 = 1L; | ||
long makerId2 = 2L; | ||
long themeId1 = 1L; | ||
long themeId2 = 2L; | ||
String name = "maker"; | ||
String job = "job"; | ||
String profileImageUrl = "profileImageUrl"; | ||
String description = "description"; | ||
String content = "content"; | ||
List<String> tags = List.of("#tag1", "#tag2", "#tag3"); | ||
Maker maker1 = MakerFixture.maker() | ||
.id(makerId1) | ||
.name(name) | ||
.job(job) | ||
.profileImageUrl(profileImageUrl) | ||
.description(description) | ||
.content(content) | ||
.themeId(themeId1) | ||
.tags(tags) | ||
.build(); | ||
|
||
Maker maker2 = MakerFixture.maker() | ||
.id(makerId2) | ||
.name(name) | ||
.job(job) | ||
.profileImageUrl(profileImageUrl) | ||
.description(description) | ||
.content(content) | ||
.themeId(themeId2) | ||
.tags(tags) | ||
.build(); | ||
|
||
doReturn(List.of(maker1, maker2)).when(makerFinder).findAll(); | ||
|
||
// when | ||
MakerListAcquireServiceResponse result = makerService.acquireAll(); | ||
|
||
// then | ||
assertThat(result.makers().size()).isEqualTo(2); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/test/java/com/soptie/server/support/fixture/MakerFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.soptie.server.support.fixture; | ||
|
||
import java.util.List; | ||
|
||
import com.soptie.server.maker.entity.Maker; | ||
|
||
public class MakerFixture { | ||
|
||
private Long id; | ||
private String name; | ||
private String job; | ||
private String profileImageUrl; | ||
private String description; | ||
private String content; | ||
private Long themeId; | ||
private List<String> tags; | ||
|
||
private MakerFixture() { | ||
} | ||
|
||
public static MakerFixture maker() { | ||
return new MakerFixture(); | ||
} | ||
|
||
public MakerFixture id(Long id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
public MakerFixture name(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public MakerFixture job(String job) { | ||
this.job = job; | ||
return this; | ||
} | ||
|
||
public MakerFixture profileImageUrl(String profileImageUrl) { | ||
this.profileImageUrl = profileImageUrl; | ||
return this; | ||
} | ||
|
||
public MakerFixture description(String description) { | ||
this.description = description; | ||
return this; | ||
} | ||
|
||
public MakerFixture content(String content) { | ||
this.content = content; | ||
return this; | ||
} | ||
|
||
public MakerFixture themeId(Long themeId) { | ||
this.themeId = themeId; | ||
return this; | ||
} | ||
|
||
public MakerFixture tags(List<String> tags) { | ||
this.tags = tags; | ||
return this; | ||
} | ||
|
||
public Maker build() { | ||
return new Maker(id, name, job, profileImageUrl, description, content, themeId, tags); | ||
} | ||
} |