Example #1
0
  /** Test for execute() */
  public void testExecute() {
    Properties p = new Properties();
    String field1 = "f1"; // $NON-NLS-1$
    p.setProperty("field1", field1); // $NON-NLS-1$

    BeanWith2Fields bean = new BeanWith2Fields();
    CopyFromProperties<BeanWith2Fields> copy = new CopyFromProperties<BeanWith2Fields>(p);
    copy.execute(bean);
    Assert.assertEquals(field1, bean.getField1());
  }
  /** Test for createModification() when no additional parameters exist. */
  @Test
  public void testCreateModification_withParams() {
    Properties p = sample();
    String field1 = "field1"; // $NON-NLS-1$
    String field2 = "field2"; // $NON-NLS-1$
    String v1 = "value1"; // $NON-NLS-1$
    Integer v2 = 2;
    p.setProperty(field1, v1);
    p.setProperty(field2, v2.toString());

    BatchProcessParmFactoryImpl impl = new BatchProcessParmFactoryImpl();
    Modification<Object> mod = impl.createModification(p, Object.class);
    assertNotNull(mod);
    BeanWith2Fields bean = new BeanWith2Fields();
    mod.execute(bean);
    Assert.assertEquals(v1, bean.getField1());
    Assert.assertEquals(v2, bean.getField2());
  }