Search in sources :

Example 6 with StockTransactionPosition

use of eu.ggnet.dwoss.stock.ee.entity.StockTransactionPosition 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

StockTransactionPosition (eu.ggnet.dwoss.stock.ee.entity.StockTransactionPosition)6 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)6 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)5 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)5 StockTransactionStatus (eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus)4 Date (java.util.Date)4 Test (org.junit.Test)4 StockTransactionEao (eu.ggnet.dwoss.stock.ee.eao.StockTransactionEao)2 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)2 StockLocation (eu.ggnet.dwoss.stock.ee.entity.StockLocation)2 StockLocationDiscoverer (eu.ggnet.dwoss.stock.ee.emo.StockLocationDiscoverer)1 StockTransactionEmo (eu.ggnet.dwoss.stock.ee.emo.StockTransactionEmo)1 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)1 StockTransactionParticipation (eu.ggnet.dwoss.stock.ee.entity.StockTransactionParticipation)1 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)1