@Test public void toCityDtoMapperTest() { Attraction attraction = AttractionTestBuilder.anAttraction().build(); ReflectionTestUtils.setField(attraction, "id", 1l); City city = CityTestBuilder.aCity().build(); ReflectionTestUtils.setField(city, "id", 2l); city.addAttraction(attraction); CityDto cityDto = dtoMapper.toCityDto(city); assertThat(cityDto).isNotNull(); assertThat(cityDto.getName()).isEqualTo(city.getName()); assertThat(cityDto.getDescription()).isEqualTo(city.getDescription()); assertThat(cityDto.getAttractions().size()).isEqualTo(1); AttractionDto attract = cityDto.getAttractions().iterator().next(); assertThat(attract.getName()).isEqualTo(attraction.getName()); }
@Test public void toCountryDtoMapperTest() { City city = CityTestBuilder.aCity().build(); ReflectionTestUtils.setField(city, "id", 2l); Country country = CountryTestBuilder.aCountry().build(); ReflectionTestUtils.setField(country, "id", 1l); country.addCity(city); CountryDto countryDto = dtoMapper.toCountryDto(country); assertThat(countryDto).isNotNull(); assertThat(countryDto.getName()).isEqualTo(country.getName()); assertThat(countryDto.getDescription()).isEqualTo(country.getDescription()); assertThat(countryDto.getCities().size()).isEqualTo(1); CityDto mappedcity = countryDto.getCities().iterator().next(); assertThat(mappedcity.getName()).isEqualTo(city.getName()); }