InventoryService { public InventoryCategory getCategory(String name) { if (name == null) { return null; } return inventoryRepository.findByName(name); }  InventoryCategory getCategory(String name); List<InventoryCategory> getAllCategories(); void addCategory(InventoryCategory category);  }
@Test @ExpectedDatabase(value = "../setup-db.xml", assertionMode = DatabaseAssertionMode.NON_STRICT) public void getCategoryShouldFindDefaultOne() { InventoryCategory category = inventoryService.getCategory("default_category"); Assert.assertEquals("default description", category.getCategoryDescription()); }
@Test @DatabaseSetup("extra_category_with_items.xml") @ExpectedDatabase(value = "extra_and_default_category-expected.xml", assertionMode = DatabaseAssertionMode.NON_STRICT) public void getCategoryAfterExtraSetupShouldFindBoth() { InventoryCategory category = inventoryService.getCategory("default_category"); Assert.assertEquals("default description", category.getCategoryDescription()); category = inventoryService.getCategory("extra_category"); Assert.assertEquals(1002, category.getId()); Assert.assertEquals("extra description", category.getCategoryDescription()); }