@Test public void testGetAllRegions() { var region1 = new RegionEntity(); region1.setRegionId(1); region1.setRegionName("地域1"); region1.setCreationTimestamp(LocalDateTime.now()); var region2 = new RegionEntity(); region2.setRegionId(2); region2.setRegionName("地域2"); region2.setCreationTimestamp(LocalDateTime.now()); var regionList = List.of(region1, region2); given(repository.findAll()).willReturn(regionList); var result = api.getAllRegions(); assertThat(result.getRegionList()).hasSize(2); }
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) public RegionsDto getAllRegions() { LOGGER.info("REGION GET ALL API"); var allRegions = service.getAllRegions(); var dtoList = new ArrayList<RegionDto>(); allRegions.forEach(region -> { var dto = new RegionDto(region); dtoList.add(dto); }); var regionsDto = new RegionsDto(dtoList); return regionsDto; }
RegionApi { @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) public RegionsDto getAllRegions() { LOGGER.info("REGION GET ALL API"); var allRegions = service.getAllRegions(); var dtoList = new ArrayList<RegionDto>(); allRegions.forEach(region -> { var dto = new RegionDto(region); dtoList.add(dto); }); var regionsDto = new RegionsDto(dtoList); return regionsDto; } }
RegionApi { @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) public RegionsDto getAllRegions() { LOGGER.info("REGION GET ALL API"); var allRegions = service.getAllRegions(); var dtoList = new ArrayList<RegionDto>(); allRegions.forEach(region -> { var dto = new RegionDto(region); dtoList.add(dto); }); var regionsDto = new RegionsDto(dtoList); return regionsDto; }  }
RegionApi { @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) public RegionsDto getAllRegions() { LOGGER.info("REGION GET ALL API"); var allRegions = service.getAllRegions(); var dtoList = new ArrayList<RegionDto>(); allRegions.forEach(region -> { var dto = new RegionDto(region); dtoList.add(dto); }); var regionsDto = new RegionsDto(dtoList); return regionsDto; }  @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) RegionsDto getAllRegions(); }
RegionApi { @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) public RegionsDto getAllRegions() { LOGGER.info("REGION GET ALL API"); var allRegions = service.getAllRegions(); var dtoList = new ArrayList<RegionDto>(); allRegions.forEach(region -> { var dto = new RegionDto(region); dtoList.add(dto); }); var regionsDto = new RegionsDto(dtoList); return regionsDto; }  @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) RegionsDto getAllRegions();  }