@Test public void test7() { Layout l = Layout.createDefault(); String s = StringUtils.insertWhitespaces(l.serialize(), 1.0f, 3); Layout ls = Layout.deserialize(s); assertThat(ls, not(sameInstance(l))); assertThat(ls, equalTo(l)); assertThat(ls.equals(l), is(true)); assertThat(ls.hashCode(), equalTo(l.hashCode())); }
@Test public void test1() { Layout l = Layout.createDefault(); List<Item> items = l.getItems(); assertThat(items.size(), equalTo(l.getNumberOfItems())); assertThat(l.getNumberOfItems(), not(equalTo(0))); for (int i = 0; i < items.size(); i++) { Item item = items.get(i); assertThat(l.hasItem(item), is(true)); assertThat(l.getIndex(item), equalTo(i)); } Layout l2 = new Layout(items); assertThat(l2, not(sameInstance(l))); assertThat(l2.getNumberOfItems(), equalTo(l.getNumberOfItems())); assertThat(l2, equalTo(l)); assertThat(l, equalTo(l2)); assertThat(l2.hashCode(), equalTo(l.hashCode())); Layout l3 = l2.createClone(); assertThat(l3, not(sameInstance(l2))); assertThat(l3, not(sameInstance(l))); assertThat(l3, equalTo(l2)); assertThat(l3, equalTo(l)); assertThat(l3.hashCode(), equalTo(l2.hashCode())); assertThat(l3.hashCode(), equalTo(l.hashCode())); Layout l4 = Layout.deserialize(l3.serialize()); assertThat(l4, not(sameInstance(l3))); assertThat(l4, equalTo(l3)); assertThat(l4, equalTo(l2)); assertThat(l4, equalTo(l)); Layout l5 = Layout.deserialize(new StringReader(l4.serialize())); assertThat(l5, not(sameInstance(l3))); assertThat(l5, equalTo(l3)); assertThat(l5, equalTo(l2)); assertThat(l5, equalTo(l)); assertThat(l5, equalTo(Layout.createDefault())); }