Example #1
0
  @Test
  public void testSaveAllDataProperties() {
    BasicObject object = JsonUtils.from(yawp, DATA_OBJECT_JSON, BasicObject.class);

    yawp.save(object);

    BasicObject retrievedObject = object.getId().fetch();
    retrievedObject.assertObject("xpto", "text xpto", 1, 1l, 1.1, true, "2013/12/26 23:55:01");
  }
Example #2
0
  @Test(expected = NoResultException.class)
  public void testDelete() {
    BasicObject object = new BasicObject();

    yawp.save(object);
    yawp.destroy(object.getId());

    yawp(BasicObject.class).fetch(object.getId());
  }
Example #3
0
  @Test
  public void testSaveWithEnum() {
    BasicObject object = new BasicObject();
    object.setStatus(Status.RUNNING);
    yawp.save(object);

    BasicObject retrievedObject = yawp(BasicObject.class).first();
    assertEquals(Status.RUNNING, retrievedObject.getStatus());
  }
Example #4
0
  @Test
  public void testJsonProperty() {
    BasicObject object = new BasicObject();
    object.setJsonValue(new Pojo("xpto"));

    yawp.save(object);

    BasicObject retrievedObject = object.getId().fetch();
    assertEquals("xpto", retrievedObject.getJsonValue().getStringValue());
  }
Example #5
0
  @Test
  public void testJsonArrayProperty() {
    BasicObject object = new BasicObject();

    List<Pojo> list = new ArrayList<Pojo>();
    list.add(new Pojo("xpto1"));
    list.add(new Pojo("xpto2"));
    object.setJsonList(list);

    yawp.save(object);

    BasicObject retrievedObject = object.getId().fetch();
    assertEquals("xpto1", retrievedObject.getJsonList().get(0).getStringValue());
    assertEquals("xpto2", retrievedObject.getJsonList().get(1).getStringValue());
  }
Example #6
0
  @Test
  public void testJsonMapWithLongKeyAndObjectValue() {
    BasicObject object = new BasicObject();

    Map<Long, Pojo> map = new HashMap<Long, Pojo>();

    map.put(1l, new Pojo("xpto1"));
    map.put(2l, new Pojo("xpto2"));

    object.setJsonMap(map);

    yawp.save(object);

    BasicObject retrievedObject = object.getId().fetch();
    assertEquals("xpto1", retrievedObject.getJsonMap().get(1l).getStringValue());
    assertEquals("xpto2", retrievedObject.getJsonMap().get(2l).getStringValue());
  }
Example #7
0
 @POST
 public String withJsonAndParams(
     IdRef<Parent> parentId, BasicObject object, Map<String, String> params) {
   return object.getStringValue() + " " + params.get("x") + " - " + object.getId();
 }