@Test void convert() { OpeningHoursDto openingHours = ModelUtils.getOpeningHoursDto(); CategoryDto category = CategoryDto.builder() .name("category") .build(); PhotoAddDto photo = new PhotoAddDto(); photo.setName("photo"); DiscountValueDto discountValue = ModelUtils.getDiscountValueDto(); discountValue.setSpecification(new SpecificationNameDto("specif")); LocationAddressAndGeoDto address = ModelUtils.getLocationAddressAndGeoDto(); PlaceAddDto placeAddDto = PlaceAddDto.builder() .category(category) .name("place") .photos(Collections.singletonList(photo)) .discountValues(Collections.singleton(discountValue)) .location(address) .openingHoursList(Collections.singleton(openingHours)) .build(); OpeningHours openingHours1 = ModelUtils.getOpeningHours(); DiscountValue discountValue1 = ModelUtils.getDiscountValue(); discountValue1.setSpecification(ModelUtils.getSpecification()); Photo photoTest = ModelUtils.getPhoto(); Place place = new Place(); place.setName("place"); place.setLocation(ModelUtils.getLocation()); place.setCategory(Category.builder() .name("category") .build()); place.setOpeningHoursList(Collections.singleton(openingHours1)); place.setDiscountValues(Collections.singleton(discountValue1)); place.setPhotos(Collections.singletonList(photoTest)); place.getOpeningHoursList().forEach(h -> h.setPlace(place)); place.getPhotos().forEach(photo11 -> photo11.setUser(place.getAuthor())); assertEquals(place, proposePlaceMapper.convert(placeAddDto)); }
@Override protected Place convert(PlaceAddDto placeAddDto) { Place place = new Place(); place.setName(placeAddDto.getName()); place.setLocation(UtilsMapper.map(placeAddDto.getLocation(), Location.class)); place.setCategory(UtilsMapper.map(placeAddDto.getCategory(), Category.class)); place.setOpeningHoursList(UtilsMapper.mapAllToSet(placeAddDto.getOpeningHoursList(), OpeningHours.class)); place.setDiscountValues(UtilsMapper.mapAllToSet(placeAddDto.getDiscountValues(), DiscountValue.class)); place.setPhotos(UtilsMapper.mapAllToList(placeAddDto.getPhotos(), Photo.class)); place.getOpeningHoursList().forEach(h -> h.setPlace(place)); place.getPhotos().forEach(photo -> photo.setUser(place.getAuthor())); return place; }
ProposePlaceMapper extends AbstractConverter<PlaceAddDto, Place> { @Override protected Place convert(PlaceAddDto placeAddDto) { Place place = new Place(); place.setName(placeAddDto.getName()); place.setLocation(UtilsMapper.map(placeAddDto.getLocation(), Location.class)); place.setCategory(UtilsMapper.map(placeAddDto.getCategory(), Category.class)); place.setOpeningHoursList(UtilsMapper.mapAllToSet(placeAddDto.getOpeningHoursList(), OpeningHours.class)); place.setDiscountValues(UtilsMapper.mapAllToSet(placeAddDto.getDiscountValues(), DiscountValue.class)); place.setPhotos(UtilsMapper.mapAllToList(placeAddDto.getPhotos(), Photo.class)); place.getOpeningHoursList().forEach(h -> h.setPlace(place)); place.getPhotos().forEach(photo -> photo.setUser(place.getAuthor())); return place; } }
ProposePlaceMapper extends AbstractConverter<PlaceAddDto, Place> { @Override protected Place convert(PlaceAddDto placeAddDto) { Place place = new Place(); place.setName(placeAddDto.getName()); place.setLocation(UtilsMapper.map(placeAddDto.getLocation(), Location.class)); place.setCategory(UtilsMapper.map(placeAddDto.getCategory(), Category.class)); place.setOpeningHoursList(UtilsMapper.mapAllToSet(placeAddDto.getOpeningHoursList(), OpeningHours.class)); place.setDiscountValues(UtilsMapper.mapAllToSet(placeAddDto.getDiscountValues(), DiscountValue.class)); place.setPhotos(UtilsMapper.mapAllToList(placeAddDto.getPhotos(), Photo.class)); place.getOpeningHoursList().forEach(h -> h.setPlace(place)); place.getPhotos().forEach(photo -> photo.setUser(place.getAuthor())); return place; }  }
ProposePlaceMapper extends AbstractConverter<PlaceAddDto, Place> { @Override protected Place convert(PlaceAddDto placeAddDto) { Place place = new Place(); place.setName(placeAddDto.getName()); place.setLocation(UtilsMapper.map(placeAddDto.getLocation(), Location.class)); place.setCategory(UtilsMapper.map(placeAddDto.getCategory(), Category.class)); place.setOpeningHoursList(UtilsMapper.mapAllToSet(placeAddDto.getOpeningHoursList(), OpeningHours.class)); place.setDiscountValues(UtilsMapper.mapAllToSet(placeAddDto.getDiscountValues(), DiscountValue.class)); place.setPhotos(UtilsMapper.mapAllToList(placeAddDto.getPhotos(), Photo.class)); place.getOpeningHoursList().forEach(h -> h.setPlace(place)); place.getPhotos().forEach(photo -> photo.setUser(place.getAuthor())); return place; }   }
ProposePlaceMapper extends AbstractConverter<PlaceAddDto, Place> { @Override protected Place convert(PlaceAddDto placeAddDto) { Place place = new Place(); place.setName(placeAddDto.getName()); place.setLocation(UtilsMapper.map(placeAddDto.getLocation(), Location.class)); place.setCategory(UtilsMapper.map(placeAddDto.getCategory(), Category.class)); place.setOpeningHoursList(UtilsMapper.mapAllToSet(placeAddDto.getOpeningHoursList(), OpeningHours.class)); place.setDiscountValues(UtilsMapper.mapAllToSet(placeAddDto.getDiscountValues(), DiscountValue.class)); place.setPhotos(UtilsMapper.mapAllToList(placeAddDto.getPhotos(), Photo.class)); place.getOpeningHoursList().forEach(h -> h.setPlace(place)); place.getPhotos().forEach(photo -> photo.setUser(place.getAuthor())); return place; }    }