Search in sources :

Example 16 with Cpu

use of eu.ggnet.dwoss.spec.ee.entity.piece.Cpu 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)

Example 17 with Cpu

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

the class ReceiptProductLogicIT method testCreateCpu.

@Test
public void testCreateCpu() {
    Cpu cpu = productLogic.create(new Cpu(Cpu.Series.CORE, EnumSet.of(Cpu.Type.MOBILE), "Muuuh"));
    assertNotNull(cpu);
    assertTrue(cpu.getId() > 0);
    productLogic.create(new Cpu(Cpu.Series.CORE, EnumSet.of(Cpu.Type.DESKTOP), "Maaah"));
    productLogic.create(new Cpu(Cpu.Series.ATHLON, EnumSet.of(Cpu.Type.MOBILE), "Miiih"));
    List<Cpu> cpus = specAgent.findAll(Cpu.class);
    assertNotNull(cpus);
    assertEquals(3, cpus.size());
}
Also used : Cpu(eu.ggnet.dwoss.spec.ee.entity.piece.Cpu) Test(org.junit.Test)

Example 18 with Cpu

use of eu.ggnet.dwoss.spec.ee.entity.piece.Cpu 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 19 with Cpu

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

the class PieceTest method testCpu.

@Test
public void testCpu() {
    Cpu cpu = new Cpu();
    Set<ConstraintViolation<Cpu>> violations = validator.validate(cpu);
    assertEquals(2, violations.size());
    Set<String> properties = new HashSet<>();
    for (ConstraintViolation<Cpu> constraintViolation : violations) {
        properties.add(constraintViolation.getPropertyPath().toString());
    }
    assertTrue(properties.contains("series"));
    assertTrue(properties.contains("model"));
    cpu.setSeries(Cpu.Series.AMD_V);
    violations = validator.validate(cpu);
    assertEquals(1, violations.size());
    assertTrue(violations.iterator().next().getPropertyPath().toString().equals("model"));
    cpu.setModel("");
    violations = validator.validate(cpu);
    assertEquals(1, violations.size());
    assertTrue(violations.iterator().next().getPropertyPath().toString().equals("model"));
    cpu.setModel("  ");
    violations = validator.validate(cpu);
    assertEquals(1, violations.size());
    assertTrue(violations.iterator().next().getPropertyPath().toString().equals("model"));
    cpu.setModel("i3-324");
    violations = validator.validate(cpu);
    assertTrue(violations.isEmpty());
}
Also used : Cpu(eu.ggnet.dwoss.spec.ee.entity.piece.Cpu) HashSet(java.util.HashSet)

Example 20 with Cpu

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

the class SpecTest method testNotebook.

@Test
public void testNotebook() {
    Notebook notebook = new Notebook();
    notebook.setColor(BasicSpec.Color.RED);
    notebook.setModel(basicSpec.getModel());
    notebook.setPartNo(basicSpec.getPartNo());
    notebook.setComment("TestBasicNotebook");
    notebook.setExtras(ProductSpec.Extra.KAMERA, ProductSpec.Extra.CONVERTABLE);
    notebook.setDisplay(new Display(Display.Size._10_1, Display.Resolution.VGA, Display.Type.MATT, Display.Ration.FOUR_TO_THREE));
    desktop.add(Desktop.Hdd.SSD_0016);
    notebook.add(Desktop.Odd.DVD_ROM);
    notebook.setMemory(4096);
    notebook.setOs(Desktop.Os.WINDOWS_7_STARTER_32);
    notebook.setGpu(new Gpu(Gpu.Type.MOBILE, Gpu.Series.GEFORCE_300, "TestNotebookGPU"));
    notebook.setCpu(new Cpu(Cpu.Series.CORE_I7, "TestDesktopCPU", Cpu.Type.DESKTOP, 2.4, 4));
    Set<ProductSpec.Extra> extras = EnumSet.noneOf(ProductSpec.Extra.class);
    extras.add(ProductSpec.Extra.USB_3);
    extras.add(ProductSpec.Extra.UMTS);
    notebook.setExtras(extras);
    assertTrue("ViolationException: Notebook look like this: " + notebook.toString() + "\nViolations: " + ConstraintViolationFormater.toSingleLine(validator.validate(notebook)), validator.validate(notebook).isEmpty());
}
Also used : 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) Gpu(eu.ggnet.dwoss.spec.ee.entity.piece.Gpu) Display(eu.ggnet.dwoss.spec.ee.entity.piece.Display)

Aggregations

Cpu (eu.ggnet.dwoss.spec.ee.entity.piece.Cpu)21 Gpu (eu.ggnet.dwoss.spec.ee.entity.piece.Gpu)11 Test (org.junit.Test)11 ProductModel (eu.ggnet.dwoss.spec.ee.entity.ProductModel)9 ProductFamily (eu.ggnet.dwoss.spec.ee.entity.ProductFamily)8 ProductSeries (eu.ggnet.dwoss.spec.ee.entity.ProductSeries)8 Notebook (eu.ggnet.dwoss.spec.ee.entity.Notebook)7 ProductSpec (eu.ggnet.dwoss.spec.ee.entity.ProductSpec)7 Display (eu.ggnet.dwoss.spec.ee.entity.piece.Display)7 CpuEao (eu.ggnet.dwoss.spec.ee.eao.CpuEao)6 Desktop (eu.ggnet.dwoss.spec.ee.entity.Desktop)5 ProductSpecEao (eu.ggnet.dwoss.spec.ee.eao.ProductSpecEao)3 GpuEao (eu.ggnet.dwoss.spec.ee.eao.GpuEao)2 DisplayEmo (eu.ggnet.dwoss.spec.ee.emo.DisplayEmo)2 ProductModelEmo (eu.ggnet.dwoss.spec.ee.emo.ProductModelEmo)2 DesktopBundle (eu.ggnet.dwoss.spec.ee.entity.DesktopBundle)2 DisplayAble (eu.ggnet.dwoss.spec.ee.entity.DisplayAble)2 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)2 EntityManager (javax.persistence.EntityManager)2 ProductProcessorStub (eu.ggnet.dwoss.receipt.stub.ProductProcessorStub)1