@@ -0,0 +1,1616 @@
+package devopsdistilled.operp.client.items.controllers;%0A%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertNull;%0Aimport static org.junit.Assert.assertThat;%0A%0Aimport javax.inject.Inject;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.test.context.ContextConfiguration;%0Aimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner;%0A%0Aimport devopsdistilled.operp.client.context.AppContext;%0Aimport devopsdistilled.operp.client.items.ItemController;%0Aimport devopsdistilled.operp.client.items.models.ItemModel;%0Aimport devopsdistilled.operp.server.data.entity.items.Item;%0A%0A@RunWith(SpringJUnit4ClassRunner.class)%0A@ContextConfiguration(classes = %7B AppContext.class %7D)%0Apublic class ItemControllerTest %7B%0A%0A%09@Inject%0A%09private ItemController itemController;%0A%0A%09@Inject%0A%09private ItemModel itemModel;%0A%0A%09private Item item;%0A%0A%09@Before%0A%09public void setUp() throws Exception %7B%0A%0A%09%09item = new Item();%0A%0A%09%09assertNotNull(itemModel);%0A%09%09assertNotNull(itemController);%0A%09%7D%0A%0A%09@Test%0A%09public void testDeleteItem() %7B%0A%09%09/*%0A%09%09 * For this test to run, Unique constraints in Item Entity should be%0A%09%09 * removed.%0A%09%09 */%0A%0A%09%09item = itemModel.saveAndUpdateModel(item); // this works fine; Tested%0A%0A%09%09int beforeDeleteCount = itemModel.getEntities().size();%0A%09%09itemController.deleteItem(item);%0A%09%09int afterDeleteCount = itemModel.getEntities().size();%0A%09%09assertThat(beforeDeleteCount, is(afterDeleteCount + 1));%0A%0A%09%09Item returnedItem = itemModel.getService().findOne(item.getItemId());%0A%09%09assertNull(returnedItem);%0A%0A%09%7D%0A%7D%0A

Add Test to test ItemController.deleteItem() (Also tests EntityModel.deleteAndUpdateModel() )