Examples of SimpleObj


Examples of org.dozer.vo.map.SimpleObj

    // Should behave like Vo --> Vo, matching on common attr(key) names.
    Map<String, String> nested2 = newInstance(HashMap.class);
    nested2.put("field1", "mapnestedfield1");
    nested2.put("field2", null);

    SimpleObj src = newInstance(SimpleObj.class);
    src.setNested2(nested2);

    SimpleObjPrime result = mapper.map(src, SimpleObjPrime.class);
    assertNotNull(result.getNested2());
    assertEquals(nested2.get("field1"), result.getNested2().getField1());

    SimpleObj result2 = mapper.map(result, SimpleObj.class);
    assertEquals(src, result2);
  }
View Full Code Here

Examples of org.dozer.vo.map.SimpleObj

    Map<String, String> nested2 = newInstance(HashMap.class);
    nested2.put("field1", "mapnestedfield1value");
    nested2.put("field2", "mapnestedfield2value");

    SimpleObj src = newInstance(SimpleObj.class);
    src.setNested2(nested2);

    SimpleObjPrime result = mapper.map(src, SimpleObjPrime.class);
    assertNull(result.getNested2().getField1());// field exclude in mappings file
    assertEquals(nested2.get("field2"), result.getNested2().getField2());
  }
View Full Code Here

Examples of org.dozer.vo.map.SimpleObj

    mapper = getMapper("mapMapping5.xml");

    Map<String, String> src = newInstance(HashMap.class);
    src.put("stringValue", "somevalue");

    SimpleObj dest = mapper.map(src, SimpleObj.class, "test-id");

    assertEquals("wrong value found for field1", "somevalue", dest.getField1());
  }
View Full Code Here

Examples of org.dozer.vo.map.SimpleObj

    mapper = getMapper("mapMapping5.xml");

    Map<String, String> src = newInstance(HashMap.class);
    assertTrue(src.isEmpty());

    SimpleObj dest = new SimpleObj();
    dest.setField1("existingValue");
    mapper.map(src, dest, "test-id");

    assertEquals("existingValue", dest.getField1());
  }
View Full Code Here

Examples of org.dozer.vo.map.SimpleObj

    mapper = getMapper("mapMapping5.xml");

    Map<String, String> src = newInstance(HashMap.class);
    src.put("stringValue", "overwritten");

    SimpleObj dest = new SimpleObj();
    dest.setField1("existingValue");
    mapper.map(src, dest, "test-id");

    assertEquals("overwritten", dest.getField1());
  }
View Full Code Here

Examples of test.utils.json.SimpleObj

public class TestParser {
 
  @Test
  public void testStr() {
    SimpleObj i = new SimpleObj();
    i.setName("PengtaoQiu\nAlvin\nhttp://fireflysource.com");
    String jsonStr = Json.toJson(i);
    System.out.println(jsonStr);
    SimpleObj i2 = Json.toObject(jsonStr, SimpleObj.class);
    Assert.assertThat(i2.getName(), is("PengtaoQiu\nAlvin\nhttp://fireflysource.com"));
  }
View Full Code Here

Examples of test.utils.json.SimpleObj

    Assert.assertThat(JsonStringWriter.escapeSpecialCharacter(ch1), is("\\u0001"));
    Assert.assertThat(JsonStringWriter.escapeSpecialCharacter(ch2), is("\\u0000"));
    Assert.assertThat(JsonStringWriter.escapeSpecialCharacter(ch3), is("\\u000f"));
    Assert.assertThat(JsonStringWriter.escapeSpecialCharacter(ch4), is("\\u0010"));
   
    SimpleObj i = new SimpleObj();
    i.setName("PengtaoQiu\nAlvin\nhttp://fireflysource.com" + String.valueOf(ch1) + String.valueOf(ch2) + String.valueOf(ch3) + String.valueOf(ch4) + String.valueOf(ch));
    String jsonStr = Json.toJson(i);
    System.out.println(jsonStr);
    SimpleObj i2 = Json.toObject(jsonStr, SimpleObj.class);
    Assert.assertThat((int)i2.getName().charAt(i2.getName().length() - 1), is(31));
    Assert.assertThat((int)i2.getName().charAt(i2.getName().length() - 2), is(16));
    Assert.assertThat((int)i2.getName().charAt(i2.getName().length() - 3), is(15));
    Assert.assertThat((int)i2.getName().charAt(i2.getName().length() - 4), is(0));
    Assert.assertThat((int)i2.getName().charAt(i2.getName().length() - 5), is(1));
   
    System.out.println(Json.toJson(i2));
  }
View Full Code Here

Examples of test.utils.json.SimpleObj

    System.out.println(Json.toJson(i2));
  }
 
  @Test
  public void test() {
    SimpleObj i = new SimpleObj();
    i.setAge(10);
    i.setId(33442);
    i.setNumber(30);
    i.setName("PengtaoQiu\nAlvin");
    i.setType((short)-33);
    i.setWeight(55.47f);
    i.setHeight(170.5);
    String jsonStr = Json.toJson(i);
   
    SimpleObj i2 = Json.toObject(jsonStr, SimpleObj.class);
    Assert.assertThat(i2.getAge(), is(10));
    Assert.assertThat(i2.getId(), is(33442));
    Assert.assertThat(i2.getNumber(), is(30));
    Assert.assertThat(i2.getDate(), is(0L));
    Assert.assertThat(i2.getName(), is("PengtaoQiu\nAlvin"));
    Assert.assertThat(i2.getType(), is((short)-33));
    Assert.assertThat(i2.getHeight(), is(170.5));
    Assert.assertThat(i2.getWeight(), is(55.47f));
  }
View Full Code Here

Examples of test.utils.json.SimpleObj

    Assert.assertThat(i2.getWeight(), is(55.47f));
  }
 
  @Test
  public void test2() {
    SimpleObj i = new SimpleObj();
    i.setAge(10);
    i.setId(33442);
    i.setNumber(30);
    i.setName("PengtaoQiu\nAlvin");
   
    SimpleObj i2 = new SimpleObj();
    i2.setAge(20);
    i2.setId(12341);
    i2.setNumber(33);
    i2.setName("Tom");
    i.setContact1(i2);
    String jsonStr = Json.toJson(i);
   
    SimpleObj temp = Json.toObject(jsonStr, SimpleObj.class);
    Assert.assertThat(temp.getId(), is(33442));
    Assert.assertThat(temp.getContact1().getId(), is(12341));
    Assert.assertThat(temp.getContact1().getName(), is("Tom"));
    Assert.assertThat(temp.getContact1().getAge(), is(20));
    Assert.assertThat(temp.getContact2(), nullValue());
  }
View Full Code Here

Examples of test.utils.json.SimpleObj

  }
 
  @Test
  public void test3() {
    String jsonStr = "{\"id\":33442,\"date\":null,\"add1\":{}, \"add2\":{}, \"add3\":{}, \"add4\":{}, \"add5\":null,\"add6\":\"sdfsdf\",\"contact2\":{}, \"number\":30,\"height\":\" 33.24 \",\"name\":\"PengtaoQiu\nAlvin\",\"type\":null,\"weight\":40.3}";
    SimpleObj temp = Json.toObject(jsonStr, SimpleObj.class);
    Assert.assertThat(temp.getName(), is("PengtaoQiu\nAlvin"));
    Assert.assertThat(temp.getId(), is(33442));
    Assert.assertThat(temp.getWeight(), is(40.3F));
    Assert.assertThat(temp.getHeight(), is(33.24));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.