@Test public void testToDtoNoItinerary() throws Exception { CargoRouteDtoAssembler assembler = new CargoRouteDtoAssembler(); Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification( SampleLocations.STOCKHOLM, SampleLocations.MELBOURNE, new Date())); CargoRoute dto = assembler.toDto(cargo); assertEquals("XYZ", dto.getTrackingId()); assertEquals("Stockholm", dto.getOrigin()); assertEquals("Melbourne", dto.getFinalDestination()); assertTrue(dto.getLegs().isEmpty()); }
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);  }