@@ -0,0 +1,1466 @@
+package devopsdistilled.operp.client.items.model;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%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.models.ItemModel;%0Aimport devopsdistilled.operp.server.data.entity.items.Item;%0A%0A@RunWith(SpringJUnit4ClassRunner.class)%0A@ContextConfiguration(classes = %7B AppContext.class %7D)%0Apublic class ItemModelTest %7B%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%09%09item = new Item();%0A%0A%09%09assertNotNull(itemModel);%0A%09%7D%0A%0A%09@Test%0A%09public void testSaveAndUpdateModel() %7B%0A%0A%09%09// This test won't run if Unique constraints are set in Item Entity.%0A%09%09// Unique Constraints were removed to test this Test.%0A%0A%09%09itemModel.update();%0A%09%09int initialItemsSize = itemModel.getEntities().size();%0A%09%09item.setItemName(%22Test Item%22);%0A%09%09Item savedItem = itemModel.saveAndUpdateModel(item);%0A%09%09assertNotNull(savedItem);%0A%09%09System.out.println(savedItem.getItemId());%0A%09%09int afterUpdateSize = itemModel.getEntities().size();%0A%09%09// assertThat(initialItemsSize, is(afterUpdateSize - 1));%0A%09%09assertEquals(new Long(initialItemsSize), new Long(afterUpdateSize - 1));%0A%09%7D%0A%0A%7D%0A

Add Unit Test to test ItemModel.saveAndUpdateModel()