Search in sources :

Example 1 with StockLocation

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

the class StockUnitEaoIT method testFindByNoLogicTransaction.

@Test
public void testFindByNoLogicTransaction() throws Exception {
    utx.begin();
    em.joinTransaction();
    Stock s = new Stock(0, "TEEEEEEEEEEEEEEEEEEEEEst");
    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, "teeeeeeeeeeest"));
    LogicTransaction lt = new LogicTransaction();
    lt.setDossierId(1);
    lt.add(s4);
    em.persist(lt);
    utx.commit();
    List<StockUnit> sts = sus.findByNoLogicTransaction();
    assertEquals(3, sts.size());
    List<Integer> uuids = sus.findByNoLogicTransactionAsUniqueUnitId();
    assertEquals(3, uuids.size());
}
Also used : StockLocation(eu.ggnet.dwoss.stock.ee.entity.StockLocation) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Test(org.junit.Test)

Example 2 with StockLocation

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

the class StockUnitEaoIT method testSumByTransaction.

@Test
public void testSumByTransaction() throws Exception {
    utx.begin();
    em.joinTransaction();
    Stock s0 = new Stock(0, "1111111111111111111111111111");
    Stock s1 = new Stock(1, "2222222222222222222222222222");
    em.persist(s0);
    em.persist(s1);
    StockLocation s0l0 = new StockLocation("Lagerplatz");
    s0.addStockLocation(s0l0);
    StockUnit su0 = new StockUnit("g1", 1);
    su0.setRefurbishId("23");
    su0.setName("Name");
    StockUnit su1 = new StockUnit("g2", 2);
    su1.setRefurbishId("42");
    su1.setName("Name");
    StockUnit su2 = new StockUnit("g3", 3);
    su2.setRefurbishId("42");
    su2.setName("Name");
    s0.addUnit(su0, s0l0);
    s0.addUnit(su1, s0l0);
    s0.addUnit(su2, s0l0);
    em.persist(su0);
    em.persist(su1);
    em.persist(su2);
    StockTransaction st = new StockTransaction(StockTransactionType.TRANSFER);
    st.setDestination(s1);
    st.setSource(s0);
    st.addStatus(new StockTransactionStatus(StockTransactionStatusType.PREPARED, new Date()));
    em.persist(st);
    st.addPosition(new StockTransactionPosition(su0));
    st.addPosition(new StockTransactionPosition(su1));
    utx.commit();
    assertThat(sus.countByTransaction(s0.getId(), StockTransactionType.TRANSFER, StockTransactionStatusType.PREPARED)).isEqualTo(2);
}
Also used : StockLocation(eu.ggnet.dwoss.stock.ee.entity.StockLocation) 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)

Example 3 with StockLocation

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

the class StockLocationEaoIT method testFind.

@Test
public void testFind() throws Exception {
    StockLocationEao sls = new StockLocationEao(em);
    utx.begin();
    em.joinTransaction();
    Stock laden = new Stock(0);
    laden.setName("Laden");
    for (String name : STOCK_LOCATION_NAMES) {
        laden.addStockLocation(new StockLocation(name));
    }
    em.persist(laden);
    Stock lager = new Stock(1);
    lager.setName("Lager");
    for (String name : STOCK_LOCATION_NAMES) {
        lager.addStockLocation(new StockLocation(name));
    }
    em.persist(lager);
    utx.commit();
    utx.begin();
    em.joinTransaction();
    List<StockLocation> stockLocations = sls.findAll();
    assertEquals(STOCK_LOCATION_NAMES.length * 2, stockLocations.size());
    stockLocations = sls.find("%0");
    assertEquals(2, stockLocations.size());
    assertEquals(STOCK_LOCATION_NAMES[0], stockLocations.get(0).getName());
    stockLocations = sls.find("*0");
    assertEquals(2, stockLocations.size());
    assertEquals(STOCK_LOCATION_NAMES[0], stockLocations.get(0).getName());
    stockLocations = sls.find("*5");
    assertEquals(2, stockLocations.size());
    assertEquals(STOCK_LOCATION_NAMES[5], stockLocations.get(0).getName());
    stockLocations = sls.find(laden, "*0");
    assertEquals(1, stockLocations.size());
    assertEquals(STOCK_LOCATION_NAMES[0], stockLocations.get(0).getName());
    assertEquals(laden, stockLocations.get(0).getStock());
    utx.commit();
}
Also used : StockLocation(eu.ggnet.dwoss.stock.ee.entity.StockLocation) StockLocationEao(eu.ggnet.dwoss.stock.ee.eao.StockLocationEao) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Test(org.junit.Test)

Example 4 with StockLocation

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

the class StockUnitEaoIT method testFindByIdentifierAndStock.

@Test
public void testFindByIdentifierAndStock() throws Exception {
    utx.begin();
    em.joinTransaction();
    Stock s = new Stock(0, "TEEEEEEEEEEEEEEEST");
    em.persist(s);
    StockLocation sl = new StockLocation("Lagerplatz");
    s.addStockLocation(sl);
    StockUnit s1 = new StockUnit("G1", 1);
    s1.setRefurbishId("23");
    StockUnit s2 = new StockUnit("G2", 2);
    s2.setRefurbishId("42");
    s.addUnit(s1, sl);
    s.addUnit(s2, sl);
    em.persist(new Stock(1, "TEEEEEEEEST"));
    utx.commit();
    int id1 = s1.getId();
    int id2 = s2.getId();
    assertFalse(id1 == id2);
    s1 = sus.findByUniqueUnitId(1);
    s2 = sus.findByUniqueUnitId(2);
    assertThat(s1).isNotNull();
    assertThat(s2).isNotNull();
    assertEquals(id1, s1.getId());
    assertEquals(id2, s2.getId());
    List<StockUnit> units = sus.findByStockId(s.getId());
    assertEquals(2, units.size());
    s1 = sus.findByRefurbishId("23");
    s2 = sus.findByRefurbishId("42");
    assertNotNull(s1);
    assertNotNull(s2);
    assertEquals(id1, s1.getId());
    assertEquals(id2, s2.getId());
    assertNull(sus.findByRefurbishId("123"));
    assertNull(sus.findByRefurbishId(null));
}
Also used : StockLocation(eu.ggnet.dwoss.stock.ee.entity.StockLocation) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Test(org.junit.Test)

Example 5 with StockLocation

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

Aggregations

Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)6 StockLocation (eu.ggnet.dwoss.stock.ee.entity.StockLocation)6 Test (org.junit.Test)5 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)4 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)2 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)2 StockTransactionPosition (eu.ggnet.dwoss.stock.ee.entity.StockTransactionPosition)2 StockTransactionStatus (eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus)2 Date (java.util.Date)2 StockLocationEao (eu.ggnet.dwoss.stock.ee.eao.StockLocationEao)1 ArrayList (java.util.ArrayList)1