Search in sources :

Example 26 with ProductSeries

use of eu.ggnet.dwoss.spec.ee.entity.ProductSeries in project dwoss by gg-net.

the class ReceiptProductLogicPossibleDeadlockIT method testDeadlockProductSpec.

@Test
@Ignore
public void testDeadlockProductSpec() throws Exception {
    // 
    // 
    // Test will run into a Deadlock if no Product Modell is setted!
    // It will Display no Error but we hope for an Exception!
    // To Recreated the Deadlock comment the Line Between the "Comment This" Comments
    // 
    // 
    // Possible Reason that it will here appear a deadlock ist a bug in EJB that by a Validator Exception not return a exception
    // but hang there. Maybe fixed in next version.
    // TODO when used new Version of EJB then testet deadlock again!
    // 
    Display display = new Display(Display.Size._10_1, Display.Resolution.VGA, Display.Type.MATT, Display.Ration.FOUR_TO_THREE);
    ProductModel productModel = new ProductModel("TestModel");
    productModel.setFamily(new ProductFamily("TestFamily"));
    // Create a CPU and GPU and persist it.
    utx.begin();
    em.joinTransaction();
    Cpu cpu = new Cpu(Cpu.Series.CORE, "TestCPU", Cpu.Type.MOBILE, 2.0, 5);
    Gpu gpu = new Gpu(Gpu.Type.MOBILE, Gpu.Series.GEFORCE_100, "TestGPU");
    ProductSeries productSeries = new ProductSeries(TradeName.ONESELF, ProductGroup.MISC, "TestSeries");
    ProductFamily productFamily = new ProductFamily("TestFamily", productSeries);
    // Comment This
    // productModel.setFamily(productFamily);
    // Comment This
    em.persist(cpu);
    em.persist(gpu);
    em.persist(productSeries);
    em.persist(productFamily);
    em.persist(productModel);
    utx.commit();
    Notebook notebook = new Notebook(display, Desktop.Os.LINUX, cpu, null, gpu, null, 2048, null);
    notebook.add(Desktop.Hdd.SSD_0016);
    notebook.add(Desktop.Hdd.ROTATING_2000);
    notebook.add(Desktop.Odd.DVD_ROM);
    notebook.setExtras(ProductSpec.Extra.E_SATA, ProductSpec.Extra.HIGHT_CHANGEABLE);
    notebook.setPartNo("LX.ASDFG.GHJ");
    notebook.setModel(productModel);
    ProductSpec testSpec = productLogic.create(notebook, productModel, 0);
    assertThat(testSpec).isNotNull();
}
Also used : ProductFamily(eu.ggnet.dwoss.spec.ee.entity.ProductFamily) Notebook(eu.ggnet.dwoss.spec.ee.entity.Notebook) Cpu(eu.ggnet.dwoss.spec.ee.entity.piece.Cpu) ProductSeries(eu.ggnet.dwoss.spec.ee.entity.ProductSeries) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) Gpu(eu.ggnet.dwoss.spec.ee.entity.piece.Gpu) ProductModel(eu.ggnet.dwoss.spec.ee.entity.ProductModel) Display(eu.ggnet.dwoss.spec.ee.entity.piece.Display) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 27 with ProductSeries

use of eu.ggnet.dwoss.spec.ee.entity.ProductSeries in project dwoss by gg-net.

the class ProductSeriesEmoIT method testRequestBrandGroupName.

@Test
public void testRequestBrandGroupName() throws Exception {
    TradeName b1 = TradeName.APPLE;
    ProductGroup g1 = ProductGroup.PROJECTOR;
    String n1 = "SERIES";
    TradeName b2 = TradeName.LENOVO;
    ProductGroup g2 = ProductGroup.DESKTOP;
    String n2 = "SERIES";
    utx.begin();
    em.joinTransaction();
    em.persist(new ProductSeries(b1, g1, n1));
    utx.commit();
    utx.begin();
    em.joinTransaction();
    ProductSeriesEmo seriesEmo = new ProductSeriesEmo(em);
    ProductSeries productSeries = seriesEmo.request(b1, g1, n1);
    assertNotNull(productSeries);
    assertEquals(b1, productSeries.getBrand());
    assertEquals(g1, productSeries.getGroup());
    assertEquals(n1, productSeries.getName());
    utx.commit();
    utx.begin();
    em.joinTransaction();
    productSeries = seriesEmo.request(b2, g2, n2);
    assertNotNull(productSeries);
    assertEquals(b2, productSeries.getBrand());
    assertEquals(g2, productSeries.getGroup());
    assertEquals(n2, productSeries.getName());
    utx.commit();
    utx.begin();
    em.joinTransaction();
    seriesEmo.request(b2, g2, n2);
    seriesEmo.request(b2, g2, n2);
    seriesEmo.request(b2, g2, n2);
    List<ProductSeries> pss = new ProductSeriesEao(em).findAll();
    assertNotNull(pss);
    assertEquals("Only Two Elements should exist", 2, pss.size());
    utx.commit();
}
Also used : TradeName(eu.ggnet.dwoss.rules.TradeName) ProductGroup(eu.ggnet.dwoss.rules.ProductGroup) ProductSeriesEao(eu.ggnet.dwoss.spec.ee.eao.ProductSeriesEao) ProductSeries(eu.ggnet.dwoss.spec.ee.entity.ProductSeries) ProductSeriesEmo(eu.ggnet.dwoss.spec.ee.emo.ProductSeriesEmo) Test(org.junit.Test)

Example 28 with ProductSeries

use of eu.ggnet.dwoss.spec.ee.entity.ProductSeries in project dwoss by gg-net.

the class ProductSpecTest method testValidateProductSpec.

@Test
public void testValidateProductSpec() {
    ProductSeries veriton = new ProductSeries(TradeName.ACER, ProductGroup.DESKTOP, "Veriton");
    ProductFamily lfamiliy = new ProductFamily("Veriton L");
    lfamiliy.setSeries(veriton);
    ProductModel l640 = new ProductModel("Veriton L640");
    l640.setFamily(lfamiliy);
    ProductSpec s = new BasicSpec("LX.AAAAA.BBB", 1L);
    s.setModel(l640);
    assertThat(validator.validate(s)).isEmpty();
    s.setPartNo("LX.AAAAA.OOB");
    assertTrue("The letter O should be allowed", validator.validate(s).isEmpty());
    s.setPartNo("  LLL");
    assertFalse(s.getPartNo() + " should be invalid", validator.validate(s).isEmpty());
    s.setPartNo("RA LL");
    assertFalse(s.getPartNo() + " should be invalid", validator.validate(s).isEmpty());
}
Also used : ProductFamily(eu.ggnet.dwoss.spec.ee.entity.ProductFamily) BasicSpec(eu.ggnet.dwoss.spec.ee.entity.BasicSpec) ProductSeries(eu.ggnet.dwoss.spec.ee.entity.ProductSeries) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) ProductModel(eu.ggnet.dwoss.spec.ee.entity.ProductModel) Test(org.junit.Test)

Example 29 with ProductSeries

use of eu.ggnet.dwoss.spec.ee.entity.ProductSeries in project dwoss by gg-net.

the class ProductModelEaoIT method testFind.

@Test
public void testFind() throws Exception {
    utx.begin();
    em.joinTransaction();
    ProductFamily family = new ProductFamily("Family1");
    ProductSeries series = new ProductSeries(TradeName.SAMSUNG, ProductGroup.MISC, "TestSeries");
    em.persist(series);
    family.setSeries(series);
    em.persist(family);
    ProductModel model = new ProductModel("Model 1");
    model.setFamily(family);
    em.persist(model);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    ProductModelEao productModelEao = new ProductModelEao(em);
    ProductModel productModel = productModelEao.find("Model 1");
    assertNotNull(productModel);
    assertEquals(model, productModel);
    assertNull(productModelEao.find("No Model"));
    utx.commit();
}
Also used : ProductFamily(eu.ggnet.dwoss.spec.ee.entity.ProductFamily) ProductModelEao(eu.ggnet.dwoss.spec.ee.eao.ProductModelEao) ProductSeries(eu.ggnet.dwoss.spec.ee.entity.ProductSeries) ProductModel(eu.ggnet.dwoss.spec.ee.entity.ProductModel) Test(org.junit.Test)

Example 30 with ProductSeries

use of eu.ggnet.dwoss.spec.ee.entity.ProductSeries in project dwoss by gg-net.

the class ProductSeriesEaoIT method testFindBrandGroupName.

@Test
public void testFindBrandGroupName() throws Exception {
    utx.begin();
    em.joinTransaction();
    ProductSeries series = new ProductSeries(TradeName.SAMSUNG, ProductGroup.MISC, "GG-Net uber Multicore");
    em.persist(series);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    ProductSeriesEao seriesEao = new ProductSeriesEao(em);
    ProductSeries productSeries = seriesEao.find(series.getBrand(), series.getGroup(), series.getName());
    assertNull(seriesEao.find(TradeName.SAMSUNG, ProductGroup.MISC, "Gibbet nich"));
    assertNotNull(productSeries);
    assertEquals(series, productSeries);
    utx.commit();
}
Also used : ProductSeriesEao(eu.ggnet.dwoss.spec.ee.eao.ProductSeriesEao) ProductSeries(eu.ggnet.dwoss.spec.ee.entity.ProductSeries) Test(org.junit.Test)

Aggregations

ProductSeries (eu.ggnet.dwoss.spec.ee.entity.ProductSeries)32 ProductFamily (eu.ggnet.dwoss.spec.ee.entity.ProductFamily)23 Test (org.junit.Test)17 ProductModel (eu.ggnet.dwoss.spec.ee.entity.ProductModel)15 Cpu (eu.ggnet.dwoss.spec.ee.entity.piece.Cpu)8 Gpu (eu.ggnet.dwoss.spec.ee.entity.piece.Gpu)8 ProductSeriesEao (eu.ggnet.dwoss.spec.ee.eao.ProductSeriesEao)7 ProductSpec (eu.ggnet.dwoss.spec.ee.entity.ProductSpec)7 Notebook (eu.ggnet.dwoss.spec.ee.entity.Notebook)6 Display (eu.ggnet.dwoss.spec.ee.entity.piece.Display)6 ProductFamilyEao (eu.ggnet.dwoss.spec.ee.eao.ProductFamilyEao)4 Desktop (eu.ggnet.dwoss.spec.ee.entity.Desktop)3 EntityManager (javax.persistence.EntityManager)3 TradeName (eu.ggnet.dwoss.rules.TradeName)2 ProductModelEao (eu.ggnet.dwoss.spec.ee.eao.ProductModelEao)2 ProductSpecEao (eu.ggnet.dwoss.spec.ee.eao.ProductSpecEao)2 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)2 Mandators (eu.ggnet.dwoss.mandator.Mandators)1 eu.ggnet.dwoss.mandator.api.value (eu.ggnet.dwoss.mandator.api.value)1 ProductProcessor (eu.ggnet.dwoss.receipt.ee.ProductProcessor)1