package devopsdistilled.operp.server.data.service;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

public class ItemServiceTest {

	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void testCreateItem() {
		fail("Not yet implemented");
	}

}

@@ -56,242 +56,2593 @@
 ort 
-org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport static org.junit.Assert.*;%0A%0Apublic class ItemServiceTest %7B%0A%0A%09@Before%0A%09public void setUp() throws Exception %7B%0A%09%7D%0A%0A%09@Test%0A%09public void testCreateItem() %7B%0A%09%09fail(%22Not yet implemented%22
+static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertNotNull;%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;%0Aimport org.springframework.transaction.annotation.Transactional;%0A%0Aimport devopsdistilled.operp.server.context.JpaContext;%0Aimport devopsdistilled.operp.server.data.entity.items.Brand;%0Aimport devopsdistilled.operp.server.data.entity.items.Item;%0Aimport devopsdistilled.operp.server.data.entity.items.Product;%0Aimport devopsdistilled.operp.server.data.service.items.BrandService;%0Aimport devopsdistilled.operp.server.data.service.items.ItemService;%0Aimport devopsdistilled.operp.server.data.service.items.ProductService;%0A%0A@RunWith(SpringJUnit4ClassRunner.class)%0A@ContextConfiguration(classes = %7B JpaContext.class %7D)%0Apublic class ItemServiceTest %7B%0A%0A%09@Inject%0A%09private ItemService itemService;%0A%0A%09@Inject%0A%09private BrandService brandService;%0A%0A%09@Inject%0A%09private ProductService productService;%0A%0A%09private Item item;%0A%0A%09private Product product;%0A%0A%09private Brand brand;%0A%0A%09@Before%0A%09public void setUp() throws Exception %7B%0A%09%09item = new Item();%0A%09%09brand = new Brand();%0A%09%09product = new Product();%0A%0A%09%09assertNotNull(itemService);%0A%09%09assertNotNull(brandService);%0A%09%09assertNotNull(productService);%0A%09%7D%0A%0A%09@Test%0A%09@Transactional%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%09product.setProductName(%22Test Product%22);%0A%09%09product = productService.save(product);%0A%09%09assertNotNull(product.getProductId());%0A%0A%09%09Product dbProduct = productService.findOne(product.getProductId());%0A%09%09assertNotNull(dbProduct);%0A%09%09assertThat(new Integer(0), is(dbProduct.compareTo(product)));%0A%0A%09%09brand.setBrandName(%22Test Brand%22);%0A%09%09brand = brandService.save(brand);%0A%09%09assertNotNull(brand.getBrandID());%0A%0A%09%09Brand dbBrand = brandService.findOne(brand.getBrandID());%0A%09%09assertNotNull(dbBrand);%0A%09%09assertThat(new Integer(0), is(dbBrand.compareTo(brand)));%0A%0A%09%09// productService.getRepo().detach(product);%0A%0A%09%09Product detProduct = new Product();%0A%09%09detProduct.setProductId(product.getProductId());%0A%09%09detProduct.setProductName(product.getProductName());%0A%09%09// To test if save() is successful even with detached product%0A%09%09item.setProduct(detProduct);%0A%09%09item.setBrand(brand);%0A%0A%09%09item = itemService.save(item);%0A%09%09assertNotNull(item);%0A%09%09assertNotNull(item.getItemId()
 );%0A
+%0A
 %09%7D%0A
-%0A
 %7D%0A

Add Test to see if detached if persist