Search in sources :

Example 6 with StockTransactionStatus

use of eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus in project dwoss by gg-net.

the class StockTransactionFormaterTryout method start.

@Override
public void start(Stage primaryStage) throws Exception {
    Stock s1 = new Stock(0, "Lager0");
    Stock s2 = new Stock(1, "Lager1");
    StockTransaction st1 = new StockTransaction(StockTransactionType.ROLL_IN);
    st1.setDestination(s1);
    st1.addStatus(new StockTransactionStatus(StockTransactionStatusType.PREPARED, new Date()));
    st1.addStatus(new StockTransactionStatus(StockTransactionStatusType.COMPLETED, new Date()));
    st1.setComment("Bla Bla");
    st1.addUnit(new StockUnit("123456", "Acer Aspire 4412", 1));
    st1.addUnit(new StockUnit("AA231", "Der Apfel", 0));
    WebView view = new WebView();
    view.getEngine().loadContent(StockTransactionFormater.toHtml(st1));
    primaryStage.setScene(new Scene(new BorderPane(view)));
    primaryStage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) StockTransactionStatus(eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Date(java.util.Date) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction)

Example 7 with StockTransactionStatus

use of eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus in project dwoss by gg-net.

the class StockTransactionUtilTest method testEqualMessage.

@Test
public void testEqualMessage() {
    StockTransaction t1 = new StockTransaction();
    StockTransaction t2 = new StockTransaction();
    Stock s1 = new Stock(1);
    Stock s2 = new Stock(2);
    t1.setSource(s1);
    t2.setSource(s1);
    t1.setDestination(s2);
    t2.setDestination(s2);
    t1.setType(StockTransactionType.TRANSFER);
    t2.setType(StockTransactionType.TRANSFER);
    t1.addStatus(new StockTransactionStatus(PREPARED, new Date()));
    t2.addStatus(new StockTransactionStatus(PREPARED, new Date()));
    assertNull(StockTransactionUtil.equalStateMessage(t1, t2));
    t1.setSource(s2);
    assertNotNull(StockTransactionUtil.equalStateMessage(t1, t2));
    t1.setSource(s1);
    assertNull(StockTransactionUtil.equalStateMessage(t1, t2));
    t1.setDestination(s1);
    assertNotNull(StockTransactionUtil.equalStateMessage(t1, t2));
    t1.setDestination(s2);
    assertNull(StockTransactionUtil.equalStateMessage(t1, t2));
    t1.setType(StockTransactionType.ROLL_IN);
    assertNotNull(StockTransactionUtil.equalStateMessage(t1, t2));
    t1.setType(StockTransactionType.TRANSFER);
    assertNull(StockTransactionUtil.equalStateMessage(t1, t2));
    t2.addStatus(new StockTransactionStatus(FAILED, new Date()));
    assertNotNull(StockTransactionUtil.equalStateMessage(t1, t2));
}
Also used : StockTransactionStatus(eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Date(java.util.Date) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) Test(org.junit.Test)

Example 8 with StockTransactionStatus

use of eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus in project dwoss by gg-net.

the class StockTransactionEmoIT method testRequestDestroyPrepared.

@Test
public void testRequestDestroyPrepared() throws Exception {
    List<Stock> stocks = gen.makeStocksAndLocations(2);
    StockTransactionEmo stockTransactionEmo = new StockTransactionEmo(em);
    utx.begin();
    em.joinTransaction();
    StockTransaction st1 = stockTransactionEmo.requestDestroyPrepared(stocks.get(0).getId(), "Hugo", "Ein toller Komentar");
    assertNotNull(st1);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    StockTransaction st2 = stockTransactionEmo.requestDestroyPrepared(stocks.get(0).getId(), "Hugo", "Ein toller Komentar");
    assertNotNull(st2);
    assertEquals(st1.getId(), st2.getId());
    st2.addStatus(new StockTransactionStatus(COMPLETED, new Date()));
    utx.commit();
    utx.begin();
    em.joinTransaction();
    StockTransaction st3 = stockTransactionEmo.requestDestroyPrepared(stocks.get(0).getId(), "Hugo", "Ein toller Komentar");
    assertNotNull(st3);
    assertFalse(st1.getId() == st3.getId());
    utx.commit();
}
Also used : StockTransactionStatus(eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) StockTransactionEmo(eu.ggnet.dwoss.stock.ee.emo.StockTransactionEmo) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) Test(org.junit.Test)

Example 9 with StockTransactionStatus

use of eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus in project dwoss by gg-net.

the class StockUnitEaoIT method testFindByNoTransaction.

@Test
public void testFindByNoTransaction() throws Exception {
    utx.begin();
    em.joinTransaction();
    Stock s = new Stock(0, "TEEEEEEEEEEEEEEST");
    em.persist(s);
    StockLocation sl = new StockLocation("Lagerplatz");
    s.addStockLocation(sl);
    StockUnit s1 = new StockUnit("G1", 1);
    StockUnit s2 = new StockUnit("G2", 2);
    StockUnit s3 = new StockUnit("G3", 3);
    StockUnit s4 = new StockUnit("G4", 4);
    s.addUnit(s1, sl);
    s.addUnit(s2, sl);
    s.addUnit(s3, sl);
    s.addUnit(s4, sl);
    em.persist(s);
    em.persist(new Stock(1, "TEEEEEEEEEST2"));
    LogicTransaction lt = new LogicTransaction();
    lt.setDossierId(1);
    lt.add(s4);
    em.persist(lt);
    StockTransaction st = new StockTransaction(StockTransactionType.TRANSFER);
    st.setSource(s);
    st.addStatus(new StockTransactionStatus(StockTransactionStatusType.PREPARED, new Date()));
    em.persist(st);
    st.addPosition(new StockTransactionPosition(s1));
    utx.commit();
    List<StockUnit> sts = sus.findByNoTransaction();
    assertEquals(2, sts.size());
}
Also used : StockLocation(eu.ggnet.dwoss.stock.ee.entity.StockLocation) StockTransactionStatus(eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) StockTransactionPosition(eu.ggnet.dwoss.stock.ee.entity.StockTransactionPosition) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Date(java.util.Date) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) Test(org.junit.Test)

Example 10 with StockTransactionStatus

use of eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus in project dwoss by gg-net.

the class ValidationTest method testStockUnit.

@Test
public void testStockUnit() {
    StockUnit su = new StockUnit("Bla", 0);
    Set<? extends ConstraintViolation> violations = validator.validate(su);
    if (violations.isEmpty())
        fail("No violation, but StockUnit has neither Stock nor Position");
    Stock s = new Stock(1, "Teststock");
    su.setStock(s);
    violations = validator.validate(su);
    if (!violations.isEmpty())
        fail("Violation, but StockUnit has Stock. msg: " + buildMessage(violations));
    su.setStock(null);
    violations = validator.validate(su);
    if (violations.isEmpty())
        fail("No violation, but StockUnit has neither Stock nor Position");
    StockTransactionPosition stp = new StockTransactionPosition(su);
    if (validator.validate(su).isEmpty())
        fail("No violation, but StockUnit has invalid Position");
    StockTransaction t = new StockTransaction();
    t.addPosition(stp);
    if (validator.validate(su).isEmpty())
        fail("No violation, but StockTransaction is still invalid (no status, no type)");
    t.addStatus(new StockTransactionStatus(StockTransactionStatusType.PREPARED, new Date()));
    if (validator.validate(su).isEmpty())
        fail("No violation, but StockTransaction is still invalid (no type)");
    t.setType(StockTransactionType.TRANSFER);
    violations = validator.validate(su);
    if (!violations.isEmpty())
        fail("Violation, but StockUnit has valid Position and Transaction. msg: " + buildMessage(violations));
    su.setStock(s);
    violations = validator.validate(su);
    if (!violations.isEmpty())
        fail("Violation, Special Case: StockUnit has Stock and Transaction(Prepared) which is ok. msg: " + buildMessage(violations));
    t.addStatus(new StockTransactionStatus(StockTransactionStatusType.COMMISSIONED, new Date()));
    if (validator.validate(su).isEmpty())
        fail("No violation, but now StockUnit has Stock and StockTransaction( not prepared), which is not ok.");
}
Also used : StockTransactionStatus(eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus) StockTransactionPosition(eu.ggnet.dwoss.stock.ee.entity.StockTransactionPosition) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Date(java.util.Date) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) Test(org.junit.Test)

Aggregations

StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)10 StockTransactionStatus (eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus)10 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)9 Date (java.util.Date)8 Test (org.junit.Test)8 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)5 StockTransactionPosition (eu.ggnet.dwoss.stock.ee.entity.StockTransactionPosition)4 StockTransactionEmo (eu.ggnet.dwoss.stock.ee.emo.StockTransactionEmo)2 StockLocation (eu.ggnet.dwoss.stock.ee.entity.StockLocation)2 StockTransactionParticipation (eu.ggnet.dwoss.stock.ee.entity.StockTransactionParticipation)2 StockTransactionEao (eu.ggnet.dwoss.stock.ee.eao.StockTransactionEao)1 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)1 StockLocationDiscoverer (eu.ggnet.dwoss.stock.ee.emo.StockLocationDiscoverer)1 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)1 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)1 Scene (javafx.scene.Scene)1 BorderPane (javafx.scene.layout.BorderPane)1 WebView (javafx.scene.web.WebView)1