Esempio n. 1
0
  @Test
  public void shouldRemoveFieldIfJSONArrayIsEmtpy() throws JSONException {
    Child child = new Child();
    child.put("name", new JSONArray(Arrays.asList("one")));
    assertThat(child.values().names().length(), equalTo(1));

    child.put("name", new JSONArray());
    assertNull(child.values().names());
  }
Esempio n. 2
0
  @Test
  public void shouldRemoveFieldIfBlank() throws JSONException {
    Child child = new Child();
    child.put("name", "test");
    assertThat(child.values().names().length(), equalTo(1));

    child.put("name", "\r  \n  \r  \n");
    assertNull(child.values().names());
  }
Esempio n. 3
0
  @Test
  public void valuesShouldReturnAllExceptSystemFields() throws JSONException, IOException {
    Child child = new Child();
    child.put("test1", "value1");
    for (Database.ChildTableColumn column : Database.ChildTableColumn.systemFields()) {
      child.put(column.getColumnName(), "test");
    }

    assertThat(child.values(), equalJSONIgnoreOrder("{\"test1\":\"value1\"}"));
  }