@Test void map_fromObject() { var pet = new Pet(); pet.setPetId(PET_ID); pet.setName(PET_NAME); pet.setPetType(PET_TYPE); pet.setStatus(PetStatus.AVAILABLE); var order = new Order(); order.setOrderId(ORDER_ID); order.setPet(pet); order.setStatus(OrderStatus.DELIVERED); var orderDTO = ORDER_MAPPER.map(order); Assertions.assertAll(() -> { Assertions.assertNotNull(orderDTO); Assertions.assertEquals(order.getOrderId(), orderDTO.getOrderId()); Assertions.assertEquals(order.getStatus().name(), orderDTO.getStatus().name()); var petDTO = orderDTO.getPet(); Assertions.assertNotNull(petDTO); Assertions.assertEquals(pet.getPetId(), petDTO.getPetId()); Assertions.assertEquals(pet.getName(), petDTO.getName()); Assertions.assertEquals(pet.getPetType(), petDTO.getPetType()); Assertions.assertEquals(pet.getStatus().name(), petDTO.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);  }