class RegionServiceTest {
private RegionService regionService;
@Mock private RegionRepository regionRepository;
@BeforeEach public void setUp(){ MockitoAnnotations.openMocks(this );
regionService = new RegionService(regionRepository); }
@Test public void 지역정보들을_가져온다() { List<Region> mockRegions = new ArrayList<>(); mockRegions.add(Region.builder() .name("Seoul") .build()); given(regionRepository.findAll()).willReturn(mockRegions);
List<Region> regions = regionService.getRegions(); Region region = regions.get(0); assertThat(region.getName()).isEqualTo("Seoul"); } }
|