Exemplo n.º 1
0
 @Test
 public void isIdSetReturnsTrue() {
   TdProductShipment model = new TdProductShipment();
   model.setProductShipmentId(ValueGenerator.getUniqueInteger());
   assertNotNull(model.getProductShipmentId());
   assertTrue(model.isIdSet());
 }
Exemplo n.º 2
0
  public String[] read(long unique) {
    try {
      while (true) {
        String line = reader.readLine();
        if (line == null) return null;

        if (line.trim().length() == 0) continue;

        String[] result = parser.parse(line);

        if (result.length == 0) continue;

        // resolve any global variable references
        for (int rx = 0; rx < result.length; rx++) {
          String val = result[rx];
          if (val.endsWith("}") && (val.startsWith("{") || val.startsWith("${"))) {
            // Object resolved = globals.get(val.replaceAll("\\$|\\{|\\}", ""));
            Object resolved = ValueGenerator.resolveValue(val, globals);
            result[rx] = (resolved != null ? resolved.toString() : "");
            // Logger.getLogger("readValue").info(String.format("resolved var %s -> %s", val,
            // result[rx]));
          }
        }

        return result;
      }
    } catch (Exception e) {
      Logger.getLogger("FileFormatter.read").info("Error reading line: " + e.toString());
      e.printStackTrace();
      return null;
    }
  }
 @Test
 public void isIdSetReturnsTrue() {
   Document model = new Document();
   model.setId(ValueGenerator.getUniqueString(32));
   assertNotNull(model.getId());
   assertTrue(model.isIdSet());
 }
  @Test
  public void equalsUsingPk() {
    Document model1 = new Document();
    Document model2 = new Document();

    String id = ValueGenerator.getUniqueString(32);
    model1.setId(id);
    model2.setId(id);

    model1.setDocumentContentType("a");
    model2.setDocumentContentType("a");

    model1.setDocumentSize(1);
    model2.setDocumentSize(1);

    model1.setDocumentFileName("a");
    model2.setDocumentFileName("a");

    model1.setDocumentBinary("d".getBytes());
    model2.setDocumentBinary("d".getBytes());

    model1.setVersion(1);
    model2.setVersion(1);
    assertTrue(model1.isIdSet());
    assertTrue(model2.isIdSet());
    assertTrue(model1.hashCode() == model2.hashCode());
    assertTrue(model1.equals(model2));
    assertTrue(model2.equals(model1));
  }
Exemplo n.º 5
0
  @Test
  public void equalsUsingPk() {
    TdProductShipment model1 = new TdProductShipment();
    TdProductShipment model2 = new TdProductShipment();

    Integer productShipmentId = ValueGenerator.getUniqueInteger();
    model1.setProductShipmentId(productShipmentId);
    model2.setProductShipmentId(productShipmentId);

    model1.setShipmentMrpCost(1f);
    model2.setShipmentMrpCost(1f);

    model1.setShipmentDiscount(1f);
    model2.setShipmentDiscount(1f);

    model1.setShipmentPolicy("a");
    model2.setShipmentPolicy("a");

    model1.setShipmentSpecialNote("a");
    model2.setShipmentSpecialNote("a");

    model1.setShipmentDuration(1);
    model2.setShipmentDuration(1);

    model1.setShipmentType(1);
    model2.setShipmentType(1);

    model1.setShipmentStatus(true);
    model2.setShipmentStatus(true);

    model1.setCustom1("a");
    model2.setCustom1("a");

    model1.setCustom2("a");
    model2.setCustom2("a");

    model1.setCreationDate(new Date());
    model2.setCreationDate(new Date());

    model1.setUpdationDate(new Date());
    model2.setUpdationDate(new Date());
    assertTrue(model1.isIdSet());
    assertTrue(model2.isIdSet());
    assertTrue(model1.hashCode() == model2.hashCode());
    assertTrue(model1.equals(model2));
    assertTrue(model2.equals(model1));
  }
Exemplo n.º 6
0
  @Test
  public void manyToOne_setShipmentVendor() {
    TdProductShipment many = new TdProductShipment();

    // init
    TdShipmentVendor one = new TdShipmentVendor();

    one.setShipmentVendorId(ValueGenerator.getUniqueInteger());
    many.setShipmentVendor(one);

    // make sure it is propagated properly
    assertNotNull(many.getShipmentVendorId());
    assertEquals(one, many.getShipmentVendor());
    assertSame(many.getShipmentVendorId(), one.getShipmentVendorId());
    // now set it to back to null
    many.setShipmentVendor(null);

    // make sure null is propagated properly
    assertNull(many.getShipmentVendor());

    // make sure it is propagated on fk column as well
    assertNull(many.getShipmentVendorId());
  }
  @Test
  public void manyToOne_setAccount() {
    Document many = new Document();

    // init
    Account one = new Account();

    one.setId(ValueGenerator.getUniqueString(32));
    many.setAccount(one);

    // make sure it is propagated properly
    assertNotNull(many.getAccountId());
    assertEquals(one, many.getAccount());
    assertSame(many.getAccountId(), one.getId());
    // now set it to back to null
    many.setAccount(null);

    // make sure null is propagated properly
    assertNull(many.getAccount());

    // make sure it is propagated on fk column as well
    assertNull(many.getAccountId());
  }