|
5 | 5 | import static org.mockito.BDDMockito.*;
|
6 | 6 |
|
7 | 7 | import java.time.LocalDate;
|
| 8 | +import java.util.ArrayList; |
8 | 9 | import java.util.List;
|
9 | 10 | import java.util.Optional;
|
10 | 11 | import java.util.Set;
|
| 12 | +import java.util.stream.Collectors; |
11 | 13 |
|
12 | 14 | import org.junit.jupiter.api.DisplayName;
|
13 | 15 | import org.junit.jupiter.api.Test;
|
|
60 | 62 | import com.ajou.hertz.domain.instrument.electric_guitar.entity.ElectricGuitar;
|
61 | 63 | import com.ajou.hertz.domain.instrument.entity.Instrument;
|
62 | 64 | import com.ajou.hertz.domain.instrument.exception.InstrumentNotFoundByIdException;
|
| 65 | +import com.ajou.hertz.domain.instrument.mapper.InstrumentMapper; |
63 | 66 | import com.ajou.hertz.domain.instrument.repository.InstrumentRepository;
|
64 | 67 | import com.ajou.hertz.domain.instrument.service.InstrumentQueryService;
|
65 | 68 | import com.ajou.hertz.domain.user.constant.Gender;
|
@@ -401,6 +404,25 @@ class InstrumentQueryServiceTest {
|
401 | 404 | assertThat(actualResult).isEqualTo(expectedResult);
|
402 | 405 | }
|
403 | 406 |
|
| 407 | + @Test |
| 408 | + void 해당_유저의_악기_판매_내역을_조회한다() throws Exception { |
| 409 | + // given |
| 410 | + Long sellerId = 1L; |
| 411 | + List<Instrument> instrumentList = createInstrumentList(); |
| 412 | + List<InstrumentDto> expectedResult = instrumentList.stream() |
| 413 | + .map(InstrumentMapper::toDto) |
| 414 | + .collect(Collectors.toList()); |
| 415 | + given(instrumentRepository.findAllBySellerId(sellerId)).willReturn(instrumentList); |
| 416 | + |
| 417 | + // when |
| 418 | + List<InstrumentDto> actualResult = sut.findAllBySellerId(sellerId); |
| 419 | + |
| 420 | + // then |
| 421 | + then(instrumentRepository).should().findAllBySellerId(sellerId); |
| 422 | + verifyEveryMocksShouldHaveNoMoreInteractions(); |
| 423 | + assertThat(actualResult.size()).isEqualTo(expectedResult.size()); |
| 424 | + } |
| 425 | + |
404 | 426 | private void verifyEveryMocksShouldHaveNoMoreInteractions() {
|
405 | 427 | then(instrumentRepository).shouldHaveNoMoreInteractions();
|
406 | 428 | }
|
@@ -595,4 +617,13 @@ private AudioEquipmentFilterConditions createAudioEquipmentFilterConditions() th
|
595 | 617 | AudioEquipmentType.AUDIO_EQUIPMENT
|
596 | 618 | );
|
597 | 619 | }
|
| 620 | + |
| 621 | + private List<Instrument> createInstrumentList() throws Exception { |
| 622 | + List<Instrument> instruments = new ArrayList<>(); |
| 623 | + User seller = createUser(1L); |
| 624 | + instruments.add(createElectricGuitar(1L, seller)); |
| 625 | + instruments.add(createElectricGuitar(2L, seller)); |
| 626 | + return instruments; |
| 627 | + } |
| 628 | + |
598 | 629 | }
|
0 commit comments