@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")); }
@Test public void shouldGenerateUniqueId() throws JSONException { Child child = new Child(null, "rapidftr", null); child = spy(child); doReturn("xyz").when(child).createUniqueId(); child.generateUniqueId(); assertThat(child.getUniqueId(), equalTo("xyz")); }
@Test public void shouldNotOverwriteIdIfAlreadyPresent() throws JSONException { Child child = new Child("id1", "owner1", null); child.generateUniqueId(); assertThat(child.getUniqueId(), equalTo("id1")); }
@Test public void shouldDecodeIDFromJSON() throws JSONException { Child child = new Child("{ 'unique_identifier' : 'test1' }"); assertThat(child.getUniqueId(), is("test1")); }