示例#1
0
 public void testReferenceAsDescriptionsListWithValidValuesInKey_validateViewPropertiesOnModify()
     throws Exception {
   execute("Mode.detailAndFirst");
   assertValue("shipment.KEY", "");
   Shipment shipment = (Shipment) Shipment.findAll().iterator().next();
   setValue("shipment.KEY", toKeyString(shipment));
   execute("CRUD.save");
   assertError("Value for Advice in Delivery is required");
   setValue("advice", "Modifying");
   execute("CRUD.save");
   assertNoErrors();
   execute("Mode.list");
   execute("Mode.detailAndFirst");
   assertValue("shipment.KEY", toKeyString(shipment));
   assertDescriptionValue("shipment.KEY", shipment.getDescription());
   // Restoring
   setValue("shipment.KEY", "");
   setValue("advice", "Restoring");
   execute("CRUD.save");
   assertNoErrors();
 }
 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);
 }