public static Shipment randomShipment() { Shipment s = create(Shipment.class); s.setExternalReferenceId(generateKey(7)); s.setFromAddress(randomAddress()); s.setToAddress(randomAddress()); s.setShippingServiceName(randomShippingService().getName()); for (int i = 0; i < rand.nextInt(5) + 1; i++) { Parcel p = create(Parcel.class); p.setShipmentId(rand.nextInt(5000)); p.setContents(randomize(CONTENTS)); p.setWidth(rand.nextInt(5) + 1); p.setHeight(rand.nextInt(5) + 1); p.setLength(rand.nextInt(5) + 1); p.setWeight(rand.nextInt(5) + 1); p.setParcelStatus(randomEnum(ParcelStatus.values())); s.getParcels().add(p); } return (s); }