### Question:
NonUniqueResultException extends PersistenceException { @Override public String getMessage() { return message; } NonUniqueResultException(final Class<? extends Item> itemClass, final Collection<? extends Item> items); @Override String getMessage(); boolean hasResults();  }### Answer:
@Test public void shouldReturnMessage_withNoItemIds() { final Class<Item> itemClass = Item.class; final Collection<Item> itemArray = new ArrayList<Item>(); final NonUniqueResultException nonUniqueResultException = new NonUniqueResultException(itemClass, itemArray); final String validMessage = nonUniqueResultException.getMessage(); assertNotNull(validMessage); assertTrue(validMessage.contains(itemClass.getName())); }
@Test public void shouldReturnMessage_withIds() { final Class<Item> itemClass = Item.class; final Item stubItem = new StubItem(); final Item stubItem2 = new StubItem(); final Collection<Item> itemArray = Arrays.asList(stubItem, stubItem2); final NonUniqueResultException nonUniqueResultException = new NonUniqueResultException(itemClass, itemArray); final String validMessage = nonUniqueResultException.getMessage(); assertNotNull(validMessage); assertTrue(validMessage.contains(stubItem.toString())); assertTrue(validMessage.contains(stubItem2.toString())); assertTrue(validMessage.contains(itemClass.getName())); }