@Test public void testToDto() { CargoRouteDtoAssembler assembler = new CargoRouteDtoAssembler(); Location origin = SampleLocations.STOCKHOLM; Location destination = SampleLocations.MELBOURNE; Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification( origin, destination, new Date())); Itinerary itinerary = new Itinerary( Arrays.asList(new Leg(SampleVoyages.CM001, origin, SampleLocations.SHANGHAI, new Date(), new Date()), new Leg(SampleVoyages.CM001, SampleLocations.ROTTERDAM, destination, new Date(), new Date()))); cargo.assignToRoute(itinerary); CargoRoute dto = assembler.toDto(cargo); assertEquals(2, dto.getLegs().size()); net.java.cargotracker.interfaces.booking.facade.dto.Leg legDto = dto .getLegs().get(0); assertEquals("CM001", legDto.getVoyageNumber()); assertEquals("SESTO", legDto.getFrom()); assertEquals("CNSHA", legDto.getTo()); legDto = dto.getLegs().get(1); assertEquals("CM001", legDto.getVoyageNumber()); assertEquals("NLRTM", legDto.getFrom()); assertEquals("AUMEL", legDto.getTo()); }
public CargoRoute toDto(Cargo cargo) { CargoRoute dto = new CargoRoute( cargo.getTrackingId().getIdString(), cargo.getOrigin().getName() + " (" + cargo.getOrigin().getUnLocode().getIdString() + ")", cargo.getRouteSpecification().getDestination().getName() + " (" + cargo.getRouteSpecification().getDestination().getUnLocode().getIdString() + ")", cargo.getRouteSpecification().getArrivalDeadline(), cargo.getDelivery().getRoutingStatus() .sameValueAs(RoutingStatus.MISROUTED), cargo.getDelivery().getTransportStatus() .sameValueAs(TransportStatus.CLAIMED), cargo.getDelivery().getLastKnownLocation().getName() + " (" + cargo.getDelivery().getLastKnownLocation().getUnLocode().getIdString() + ")", cargo.getDelivery().getTransportStatus().name()); for (Leg leg : cargo.getItinerary().getLegs()) { dto.addLeg( leg.getVoyage().getVoyageNumber().getIdString(), leg.getLoadLocation().getUnLocode().getIdString(), leg.getLoadLocation().getName(), leg.getUnloadLocation().getUnLocode().getIdString(), leg.getUnloadLocation().getName(), leg.getLoadTime(), leg.getUnloadTime()); } return dto; }
CargoRouteDtoAssembler { public CargoRoute toDto(Cargo cargo) { CargoRoute dto = new CargoRoute( cargo.getTrackingId().getIdString(), cargo.getOrigin().getName() + " (" + cargo.getOrigin().getUnLocode().getIdString() + ")", cargo.getRouteSpecification().getDestination().getName() + " (" + cargo.getRouteSpecification().getDestination().getUnLocode().getIdString() + ")", cargo.getRouteSpecification().getArrivalDeadline(), cargo.getDelivery().getRoutingStatus() .sameValueAs(RoutingStatus.MISROUTED), cargo.getDelivery().getTransportStatus() .sameValueAs(TransportStatus.CLAIMED), cargo.getDelivery().getLastKnownLocation().getName() + " (" + cargo.getDelivery().getLastKnownLocation().getUnLocode().getIdString() + ")", cargo.getDelivery().getTransportStatus().name()); for (Leg leg : cargo.getItinerary().getLegs()) { dto.addLeg( leg.getVoyage().getVoyageNumber().getIdString(), leg.getLoadLocation().getUnLocode().getIdString(), leg.getLoadLocation().getName(), leg.getUnloadLocation().getUnLocode().getIdString(), leg.getUnloadLocation().getName(), leg.getLoadTime(), leg.getUnloadTime()); } return dto; } }
CargoRouteDtoAssembler { public CargoRoute toDto(Cargo cargo) { CargoRoute dto = new CargoRoute( cargo.getTrackingId().getIdString(), cargo.getOrigin().getName() + " (" + cargo.getOrigin().getUnLocode().getIdString() + ")", cargo.getRouteSpecification().getDestination().getName() + " (" + cargo.getRouteSpecification().getDestination().getUnLocode().getIdString() + ")", cargo.getRouteSpecification().getArrivalDeadline(), cargo.getDelivery().getRoutingStatus() .sameValueAs(RoutingStatus.MISROUTED), cargo.getDelivery().getTransportStatus() .sameValueAs(TransportStatus.CLAIMED), cargo.getDelivery().getLastKnownLocation().getName() + " (" + cargo.getDelivery().getLastKnownLocation().getUnLocode().getIdString() + ")", cargo.getDelivery().getTransportStatus().name()); for (Leg leg : cargo.getItinerary().getLegs()) { dto.addLeg( leg.getVoyage().getVoyageNumber().getIdString(), leg.getLoadLocation().getUnLocode().getIdString(), leg.getLoadLocation().getName(), leg.getUnloadLocation().getUnLocode().getIdString(), leg.getUnloadLocation().getName(), leg.getLoadTime(), leg.getUnloadTime()); } return dto; }  }
CargoRouteDtoAssembler { public CargoRoute toDto(Cargo cargo) { CargoRoute dto = new CargoRoute( cargo.getTrackingId().getIdString(), cargo.getOrigin().getName() + " (" + cargo.getOrigin().getUnLocode().getIdString() + ")", cargo.getRouteSpecification().getDestination().getName() + " (" + cargo.getRouteSpecification().getDestination().getUnLocode().getIdString() + ")", cargo.getRouteSpecification().getArrivalDeadline(), cargo.getDelivery().getRoutingStatus() .sameValueAs(RoutingStatus.MISROUTED), cargo.getDelivery().getTransportStatus() .sameValueAs(TransportStatus.CLAIMED), cargo.getDelivery().getLastKnownLocation().getName() + " (" + cargo.getDelivery().getLastKnownLocation().getUnLocode().getIdString() + ")", cargo.getDelivery().getTransportStatus().name()); for (Leg leg : cargo.getItinerary().getLegs()) { dto.addLeg( leg.getVoyage().getVoyageNumber().getIdString(), leg.getLoadLocation().getUnLocode().getIdString(), leg.getLoadLocation().getName(), leg.getUnloadLocation().getUnLocode().getIdString(), leg.getUnloadLocation().getName(), leg.getLoadTime(), leg.getUnloadTime()); } return dto; }  CargoRoute toDto(Cargo cargo); }
CargoRouteDtoAssembler { public CargoRoute toDto(Cargo cargo) { CargoRoute dto = new CargoRoute( cargo.getTrackingId().getIdString(), cargo.getOrigin().getName() + " (" + cargo.getOrigin().getUnLocode().getIdString() + ")", cargo.getRouteSpecification().getDestination().getName() + " (" + cargo.getRouteSpecification().getDestination().getUnLocode().getIdString() + ")", cargo.getRouteSpecification().getArrivalDeadline(), cargo.getDelivery().getRoutingStatus() .sameValueAs(RoutingStatus.MISROUTED), cargo.getDelivery().getTransportStatus() .sameValueAs(TransportStatus.CLAIMED), cargo.getDelivery().getLastKnownLocation().getName() + " (" + cargo.getDelivery().getLastKnownLocation().getUnLocode().getIdString() + ")", cargo.getDelivery().getTransportStatus().name()); for (Leg leg : cargo.getItinerary().getLegs()) { dto.addLeg( leg.getVoyage().getVoyageNumber().getIdString(), leg.getLoadLocation().getUnLocode().getIdString(), leg.getLoadLocation().getName(), leg.getUnloadLocation().getUnLocode().getIdString(), leg.getUnloadLocation().getName(), leg.getLoadTime(), leg.getUnloadTime()); } return dto; }  CargoRoute toDto(Cargo cargo);  }