Exemplo n.º 1
0
 @Test
 public void shouldGenerateWithIdAndOwnerAndContent() throws JSONException {
   Child child = new Child("id1", "owner1", "{ 'test1' : 'value1' }");
   assertThat(child.getUniqueId(), is("id1"));
   assertThat(child.getOwner(), is("owner1"));
   assertThat(child.getString("test1"), is("value1"));
 }
Exemplo n.º 2
0
  public void shouldReturnListOfChangeLogsBasedOnChanges() throws JSONException {
    Child oldChild = new Child("id", "user", "{'name' : 'old-name'}");
    Child updatedChild = new Child("id", "user", "{'name' : 'updated-name'}");
    List<Child.History> histories = updatedChild.changeLogs(oldChild);

    JSONObject changesMap = (JSONObject) histories.get(0).get(CHANGES);
    HashMap fromTo = (HashMap) changesMap.get("name");

    assertThat(histories.size(), is(1));
    assertThat(histories.get(0).get(USER_NAME).toString(), is(updatedChild.getOwner()));
    assertThat(changesMap.names().get(0).toString(), is("name"));
    assertThat(fromTo.get(FROM).toString(), is("old-name"));
    assertThat(fromTo.get(TO).toString(), is("updated-name"));
  }
Exemplo n.º 3
0
 @Test
 public void shouldDecodeOwnerFromJSON() throws JSONException {
   Child child = new Child("{ 'created_by' : 'test1' }");
   assertThat(child.getOwner(), is("test1"));
 }