@Test public void newArrayListsHaveNoElements() { assertThat(new ArrayList<Integer>().size(), is(0)); } @Test public void sizeReturnsNumberOfElements() { List<Object> instance = new ArrayList<Object>(); instance.add(new Object()); instance.add(new Object()); assertThat(instance.size(), is(2)); }
@Test public void lookupEmailAddresses() { assertThat(new CartoonCharacterEmailLookupService().getResults("looney"), allOf( not(empty()), containsInAnyOrder( allOf(instanceOf(Map.class), hasEntry("id", "56"), hasEntry("email", "[email protected]")), allOf(instanceOf(Map.class), hasEntry("id", "76"), hasEntry("email", "[email protected]")) ) )); }