@Test void map_fromDTO() { var petDTO = new PetDTO(); petDTO.setPetId(PET_ID); petDTO.setName(PET_NAME); petDTO.setPetType(PET_TYPE); petDTO.setStatus(PetStatusDTO.AVAILABLE); var orderDTO = new OrderDTO(); orderDTO.setOrderId(ORDER_ID); orderDTO.setPet(petDTO); orderDTO.setStatus(OrderStatusDTO.DELIVERED); var order = ORDER_MAPPER.map(orderDTO); Assertions.assertAll(() -> { Assertions.assertNotNull(order); Assertions.assertEquals(orderDTO.getOrderId(), order.getOrderId()); Assertions.assertEquals(orderDTO.getStatus().name(), order.getStatus().name()); var pet = order.getPet(); Assertions.assertNotNull(pet); Assertions.assertEquals(petDTO.getPetId(), pet.getPetId()); Assertions.assertEquals(petDTO.getName(), pet.getName()); Assertions.assertEquals(petDTO.getPetType(), pet.getPetType()); Assertions.assertEquals(petDTO.getStatus().name(), pet.getStatus().name()); }); }
public Order map(OrderDTO dto) { var order = new Order(); order.setOrderId(dto.getOrderId()); if (dto.getPet() != null) { order.setPet(petMapper.map(dto.getPet())); } order.setStatus(OrderStatus.valueOf(dto.getStatus().name())); return order; }
OrderMapper { public Order map(OrderDTO dto) { var order = new Order(); order.setOrderId(dto.getOrderId()); if (dto.getPet() != null) { order.setPet(petMapper.map(dto.getPet())); } order.setStatus(OrderStatus.valueOf(dto.getStatus().name())); return order; } }
OrderMapper { public Order map(OrderDTO dto) { var order = new Order(); order.setOrderId(dto.getOrderId()); if (dto.getPet() != null) { order.setPet(petMapper.map(dto.getPet())); } order.setStatus(OrderStatus.valueOf(dto.getStatus().name())); return order; } OrderMapper(PetMapper petMapper); }
OrderMapper { public Order map(OrderDTO dto) { var order = new Order(); order.setOrderId(dto.getOrderId()); if (dto.getPet() != null) { order.setPet(petMapper.map(dto.getPet())); } order.setStatus(OrderStatus.valueOf(dto.getStatus().name())); return order; } OrderMapper(PetMapper petMapper); Order map(OrderDTO dto); OrderDTO map(Order order); }
OrderMapper { public Order map(OrderDTO dto) { var order = new Order(); order.setOrderId(dto.getOrderId()); if (dto.getPet() != null) { order.setPet(petMapper.map(dto.getPet())); } order.setStatus(OrderStatus.valueOf(dto.getStatus().name())); return order; } OrderMapper(PetMapper petMapper); Order map(OrderDTO dto); OrderDTO map(Order order);  }