Search in sources :

Example 1 with Notebook

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

the class DifferentVaildationIT method testDifference.

@Test
public void testDifference() throws Exception {
    // A Notebook which is valid, but not persitable
    Notebook notebook = new Notebook();
    notebook.setPartNo("LX.AAAAA.BBB");
    notebook.setVideoPorts(EnumSet.allOf(BasicSpec.VideoPort.class));
    notebook.setComment("Ein Kommentar");
    notebook.setCpu(new Cpu(Cpu.Series.CORE, "Eine CPU", Cpu.Type.MOBILE, 123.1, 2));
    notebook.setGpu(new Gpu(Gpu.Type.MOBILE, Gpu.Series.RADEON_HD_4000, "Eine Graphiccarte"));
    notebook.setOs(Desktop.Os.LINUX);
    notebook.setMemory(12345);
    notebook.add(Desktop.Hdd.ROTATING_0500);
    notebook.add(Desktop.Odd.BLURAY_COMBO);
    notebook.setExtras(Desktop.Extra.KAMERA);
    notebook.setDisplay(new Display(Display.Size._10_1, Display.Resolution.VGA, Display.Type.MATT, Display.Ration.FOUR_TO_THREE));
    Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
    assertTrue(validator.validate(notebook).isEmpty());
    try {
        utx.begin();
        em.joinTransaction();
        em.persist(notebook);
        utx.commit();
        fail("Notebook should not be persitable");
    } catch (Exception ex) {
        // This is correct
        try {
            utx.rollback();
        } catch (Exception e) {
        // Ignore
        }
    }
    // Now it's persitable
    utx.begin();
    em.joinTransaction();
    ProductSeries ps = new ProductSeries(TradeName.ACER, ProductGroup.NOTEBOOK, "TravelMate");
    em.persist(ps);
    ProductFamily pf = new ProductFamily("TravelMate 8700");
    pf.setSeries(ps);
    em.persist(pf);
    ProductModel pm = new ProductModel("TravelMate 8741-81222132");
    pm.setFamily(pf);
    em.persist(pm);
    notebook.setModel(pm);
    em.persist(notebook);
    utx.commit();
}
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) Gpu(eu.ggnet.dwoss.spec.ee.entity.piece.Gpu) Validator(javax.validation.Validator) ProductModel(eu.ggnet.dwoss.spec.ee.entity.ProductModel) Display(eu.ggnet.dwoss.spec.ee.entity.piece.Display) Test(org.junit.Test)

Example 2 with Notebook

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

the class PersistenceIT method testPersistence.

@Test
public void testPersistence() throws Exception {
    utx.begin();
    em.joinTransaction();
    // A Notebook
    ProductSeries ps = new ProductSeries(TradeName.ACER, ProductGroup.NOTEBOOK, "TravelMate");
    em.persist(ps);
    ProductFamily pf = new ProductFamily("TravelMate 8700");
    pf.setSeries(ps);
    em.persist(pf);
    ProductModel pm = new ProductModel("TravelMate 8741-81222132");
    pm.setFamily(pf);
    em.persist(pm);
    Notebook notebook = new Notebook();
    notebook.setPartNo("LX.AAAAA.BBB");
    notebook.setModel(pm);
    notebook.setVideoPorts(EnumSet.allOf(BasicSpec.VideoPort.class));
    notebook.setComment("Ein Kommentar");
    notebook.setCpu(new Cpu(Cpu.Series.CORE, "Eine CPU", Cpu.Type.MOBILE, 123.1, 2));
    notebook.setGpu(new Gpu(Gpu.Type.MOBILE, Gpu.Series.RADEON_HD_4000, "Eine Graphiccarte"));
    notebook.setOs(Desktop.Os.LINUX);
    notebook.setMemory(12345);
    notebook.add(Desktop.Hdd.ROTATING_0500);
    notebook.add(Desktop.Odd.BLURAY_COMBO);
    notebook.setExtras(Desktop.Extra.KAMERA);
    notebook.setDisplay(new Display(Display.Size._10_1, Display.Resolution.VGA, Display.Type.MATT, Display.Ration.FOUR_TO_THREE));
    em.persist(notebook);
    // An AllInOne
    ps = new ProductSeries(TradeName.ACER, ProductGroup.ALL_IN_ONE, "AllInOne");
    em.persist(ps);
    pf = new ProductFamily("Z5600");
    pf.setSeries(ps);
    em.persist(pf);
    pm = new ProductModel("Z6523");
    pm.setFamily(pf);
    em.persist(pm);
    Notebook allInOne = new Notebook();
    allInOne.setPartNo("PX.AASAA.BBB");
    allInOne.setModel(pm);
    allInOne.setVideoPorts(EnumSet.allOf(BasicSpec.VideoPort.class));
    allInOne.setComment("Ein Kommentar");
    allInOne.setCpu(new Cpu(Cpu.Series.CELERON, "Eine CPU", Cpu.Type.MOBILE, 123.1, 2));
    allInOne.setGpu(new Gpu(Gpu.Type.MOBILE, Gpu.Series.RADEON_HD_4000, "Eine Graphiccarte"));
    allInOne.setOs(Desktop.Os.LINUX);
    allInOne.setMemory(12345);
    allInOne.add(Desktop.Hdd.ROTATING_0500);
    allInOne.add(Desktop.Odd.BLURAY_COMBO);
    allInOne.setExtras(Desktop.Extra.KAMERA);
    allInOne.setDisplay(new Display(Display.Size._10_1, Display.Resolution.VGA, Display.Type.MATT, Display.Ration.FOUR_TO_THREE));
    em.persist(allInOne);
    // A Desktop
    ProductSeries veriton = new ProductSeries(TradeName.ACER, ProductGroup.DESKTOP, "Veriton");
    em.persist(veriton);
    ProductFamily m400 = new ProductFamily("M400");
    m400.setSeries(veriton);
    em.persist(m400);
    ProductModel M480G = new ProductModel("M480G");
    M480G.setFamily(m400);
    em.persist(M480G);
    Gpu gpu = new Gpu(Gpu.Type.MOBILE, Gpu.Series.RADEON_HD_4000, "Eine Graphiccarte");
    em.persist(gpu);
    Cpu cpu = new Cpu(Cpu.Series.CORE, "Eine CPU", Cpu.Type.MOBILE, 123.1, 2);
    cpu.setEmbeddedGpu(gpu);
    em.persist(cpu);
    Desktop M480G_1 = new Desktop("PX.99999.321", 2L);
    M480G_1.setModel(M480G);
    M480G_1.setVideoPorts(EnumSet.allOf(BasicSpec.VideoPort.class));
    M480G_1.setComment("Ein Kommentar");
    M480G_1.setCpu(cpu);
    M480G_1.setGpu(gpu);
    M480G_1.setOs(Desktop.Os.LINUX);
    M480G_1.setMemory(12345);
    M480G_1.add(Desktop.Hdd.ROTATING_0500);
    M480G_1.add(Desktop.Odd.BLURAY_COMBO);
    M480G_1.setExtras(Desktop.Extra.KAMERA);
    em.persist(M480G_1);
    // A Monitor
    ProductSeries a = new ProductSeries(TradeName.ACER, ProductGroup.MONITOR, "A");
    em.persist(a);
    ProductFamily a230 = new ProductFamily("A230");
    a230.setSeries(a);
    em.persist(a230);
    ProductModel a231Hbmd = new ProductModel("A231Hbmd");
    a231Hbmd.setFamily(a230);
    em.persist(a231Hbmd);
    Monitor A231spec = new Monitor(new Display(Display.Size._11_6, Display.Resolution.VGA, Display.Type.CRYSTAL_BRIGHT, Display.Ration.SIXTEEN_TO_NINE));
    A231spec.setModel(a231Hbmd);
    A231spec.setPartNo("ET.VA1HE.008");
    A231spec.setProductId(3L);
    A231spec.setVideoPorts(EnumSet.allOf(BasicSpec.VideoPort.class));
    A231spec.setComment("Ein Kommentar");
    em.persist(A231spec);
    // A Bundle
    ProductSeries box = new ProductSeries(TradeName.ACER, ProductGroup.DESKTOP_BUNDLE, "Veriton");
    em.persist(box);
    ProductFamily boxf = new ProductFamily("M480");
    boxf.setSeries(box);
    em.persist(boxf);
    ProductModel boxm = new ProductModel("M480G + A231MuhMäh");
    boxm.setFamily(boxf);
    em.persist(boxm);
    DesktopBundle bundle = new DesktopBundle();
    bundle.setPartNo("BL.32199.321");
    bundle.setProductId(1L);
    bundle.setDesktop(M480G_1);
    bundle.setMonitor(A231spec);
    bundle.setModel(boxm);
    em.persist(bundle);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    CriteriaQuery<ProductSeries> cq = em.getCriteriaBuilder().createQuery(ProductSeries.class);
    cq.select(cq.from(ProductSeries.class));
    List<ProductSeries> serieses = em.createQuery(cq).getResultList();
    assertFalse(serieses.isEmpty());
    for (ProductSeries series : serieses) {
        assertNotNull(series.getFamilys());
        assertFalse(series.getFamilys().isEmpty());
        for (ProductFamily family : series.getFamilys()) {
            assertNotNull(family.getModels());
            assertFalse(family.getModels().isEmpty());
            for (ProductModel model : family.getModels()) {
                assertNotNull(model.getSpecs());
                assertFalse(model.getSpecs().isEmpty());
                for (ProductSpec spec : model.getSpecs()) {
                    assertNotNull(spec.getPartNo());
                    assertNotNull(spec.getModel());
                    assertNotNull(spec.getModel().getFamily());
                    assertNotNull(spec.getModel().getFamily().getSeries());
                    assertNotNull(spec.getModel().getFamily().getSeries().getBrand());
                    assertNotNull(spec.getModel().getFamily().getSeries().getGroup());
                }
            }
        }
    }
    utx.commit();
}
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) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) DesktopBundle(eu.ggnet.dwoss.spec.ee.entity.DesktopBundle) Gpu(eu.ggnet.dwoss.spec.ee.entity.piece.Gpu) Monitor(eu.ggnet.dwoss.spec.ee.entity.Monitor) Desktop(eu.ggnet.dwoss.spec.ee.entity.Desktop) ProductSeries(eu.ggnet.dwoss.spec.ee.entity.ProductSeries) ProductModel(eu.ggnet.dwoss.spec.ee.entity.ProductModel) Display(eu.ggnet.dwoss.spec.ee.entity.piece.Display) Test(org.junit.Test)

Example 3 with Notebook

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

the class ReceiptProductLogicProductSpecIT method testCreateProductSpec.

@Test
public void testCreateProductSpec() throws Exception {
    final long GTIN = 123456782;
    // Create a CPU and GPU and persist it.
    Cpu cpu = productProcessor.create(new Cpu(Cpu.Series.AMD_V, "TestCPU", Cpu.Type.MOBILE, 2.0, 5));
    Gpu gpu = productProcessor.create(new Gpu(Gpu.Type.MOBILE, Gpu.Series.GEFORCE_100, "TestGPU"));
    // Persist Display
    Display display = new Display(Display.Size._10_1, Display.Resolution.VGA, Display.Type.MATT, Display.Ration.FOUR_TO_THREE);
    ProductModel productModel = new ProductModel("M", new ProductFamily("F", new ProductSeries(ACER, NOTEBOOK, "S")));
    Notebook notebook = new Notebook();
    notebook.setDisplay(display);
    notebook.setGpu(gpu);
    notebook.setCpu(cpu);
    notebook.setMemory(2048);
    notebook.setOs(Desktop.Os.LINUX);
    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 = productProcessor.create(notebook, productModel, 0);
    assertNotNull(testSpec);
    Notebook notebook2 = new Notebook();
    notebook2.setDisplay(display);
    notebook2.setGpu(gpu);
    notebook2.setCpu(cpu);
    notebook2.setMemory(2048);
    notebook2.setOs(Desktop.Os.LINUX);
    notebook2.add(Desktop.Hdd.SSD_0016);
    notebook2.add(Desktop.Hdd.ROTATING_2000);
    notebook2.add(Desktop.Odd.DVD_ROM);
    notebook2.setExtras(ProductSpec.Extra.E_SATA, ProductSpec.Extra.HIGHT_CHANGEABLE);
    notebook2.setPartNo("LX.ASDFG.GH2");
    notebook2.setModel(productModel);
    ProductSpec testSpec2 = productProcessor.create(notebook2, productModel, GTIN);
    assertNotNull(testSpec2);
    assertNotSame(testSpec2, testSpec);
    Product product = uuAgent.findById(Product.class, testSpec2.getProductId());
    assertThat(product).isNotNull().returns(GTIN, Product::getGtin);
}
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) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) 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) Test(org.junit.Test)

Example 4 with Notebook

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

the class ReceiptProductLogicProductSpecIT method testCreateProductSpecException.

@Test(expected = RuntimeException.class)
public void testCreateProductSpecException() {
    // Create a CPU and GPU and persist it.
    Cpu cpu = productProcessor.create(new Cpu(Cpu.Series.AMD_V, "TestCPU", Cpu.Type.MOBILE, 2.0, 5));
    Gpu gpu = productProcessor.create(new Gpu(Gpu.Type.MOBILE, Gpu.Series.GEFORCE_100, "TestGPU"));
    // Persist Display
    Display display = new Display(Display.Size._10_1, Display.Resolution.VGA, Display.Type.MATT, Display.Ration.FOUR_TO_THREE);
    ProductModel productModel = new ProductModel("M", new ProductFamily("F", new ProductSeries(PACKARD_BELL, NOTEBOOK, "S")));
    Notebook notebook = new Notebook();
    notebook.setDisplay(display);
    notebook.setGpu(gpu);
    notebook.setCpu(cpu);
    notebook.setMemory(2048);
    notebook.setOs(Desktop.Os.LINUX);
    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);
    productProcessor.create(notebook, productModel, 0);
    productProcessor.create(notebook, productModel, 0);
    fail("Error 040: No Exception Found at: CreateProductSpec");
}
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) 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) Test(org.junit.Test)

Example 5 with Notebook

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

the class ReceiptProductLogicProductSpecIT method testUpdateProductSpecModelChange.

@Test
public void testUpdateProductSpecModelChange() {
    ProductModel productModel = productProcessor.create(ACER, NOTEBOOK, null, null, "TestModel");
    Cpu cpu = productProcessor.create(new Cpu(Cpu.Series.AMD_V, "TestCPU", Cpu.Type.MOBILE, 2.0, 5));
    Gpu gpu = productProcessor.create(new Gpu(Gpu.Type.MOBILE, Gpu.Series.GEFORCE_100, "TestGPU"));
    Notebook notebook = new Notebook();
    notebook.setDisplay(new Display(Display.Size._10_1, Display.Resolution.VGA, Display.Type.MATT, Display.Ration.FOUR_TO_THREE));
    notebook.setGpu(gpu);
    notebook.setCpu(cpu);
    notebook.setMemory(2048);
    notebook.setOs(Desktop.Os.LINUX);
    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.GHP");
    notebook.setModel(productModel);
    ProductSpec spec = productProcessor.create(notebook, productModel, 0);
    ProductFamily family = spec.getModel().getFamily();
    ProductModel productModel2 = productProcessor.create(ACER, NOTEBOOK, family.getSeries(), family, "TestModel2");
    spec = productProcessor.refresh(spec, productModel2);
    long model2Id = spec.getModel().getId();
    String comment = "MuhBlub";
    ((Notebook) spec).setComment(comment);
    productProcessor.update(spec, 0);
    List<ProductSeries> series = specAgent.findAllEager(ProductSeries.class);
    assertNotNull(series);
    assertEquals(1, series.size());
    assertNotNull(series.get(0));
    assertNotNull(series.get(0).getFamilys());
    assertEquals(1, series.get(0).getFamilys().size());
    assertNotNull(series.get(0).getFamilys().toArray()[0]);
    List<ProductSpec> specs = specAgent.findAllEager(ProductSpec.class);
    assertNotNull(specs);
    assertEquals(1, specs.size());
    assertEquals(model2Id, specs.get(0).getModel().getId());
    assertEquals(comment, ((Notebook) specs.get(0)).getComment());
}
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) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) ProductSeries(eu.ggnet.dwoss.spec.ee.entity.ProductSeries) 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) Test(org.junit.Test)

Aggregations

Notebook (eu.ggnet.dwoss.spec.ee.entity.Notebook)7 Cpu (eu.ggnet.dwoss.spec.ee.entity.piece.Cpu)7 Display (eu.ggnet.dwoss.spec.ee.entity.piece.Display)7 Gpu (eu.ggnet.dwoss.spec.ee.entity.piece.Gpu)7 ProductFamily (eu.ggnet.dwoss.spec.ee.entity.ProductFamily)6 ProductModel (eu.ggnet.dwoss.spec.ee.entity.ProductModel)6 ProductSeries (eu.ggnet.dwoss.spec.ee.entity.ProductSeries)6 Test (org.junit.Test)6 ProductSpec (eu.ggnet.dwoss.spec.ee.entity.ProductSpec)5 Desktop (eu.ggnet.dwoss.spec.ee.entity.Desktop)1 DesktopBundle (eu.ggnet.dwoss.spec.ee.entity.DesktopBundle)1 Monitor (eu.ggnet.dwoss.spec.ee.entity.Monitor)1 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)1 Validator (javax.validation.Validator)1 Ignore (org.junit.Ignore)1