use of eu.ggnet.dwoss.stock.ee.entity.StockUnit 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));
}
use of eu.ggnet.dwoss.stock.ee.entity.StockUnit 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());
}
use of eu.ggnet.dwoss.stock.ee.entity.StockUnit 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.");
}
use of eu.ggnet.dwoss.stock.ee.entity.StockUnit in project dwoss by gg-net.
the class CreateSelectionTryout method tryout.
@Test
public void tryout() throws InterruptedException {
JButton b = new JButton("Press to close");
b.setPreferredSize(new Dimension(200, 50));
CountDownLatch l = new CountDownLatch(1);
b.addActionListener(e -> {
l.countDown();
});
Dl.remote().add(StockAgent.class, new StockAgent() {
@Override
public <T> List<T> findAll(Class<T> entityClass) {
if (entityClass.equals(Stock.class))
return (List<T>) Arrays.asList(new Stock(0, "Rotes Lager"), new Stock(1, "Blaues Lager"));
return null;
}
// <editor-fold defaultstate="collapsed" desc="Unused Methodes">
@Override
public StockUnit findStockUnitByUniqueUnitIdEager(Integer uniqueUnitId) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public StockUnit findStockUnitByRefurbishIdEager(String refurbishId) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<StockUnit> findStockUnitsByRefurbishIdEager(List<String> refurbishIds) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T persist(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T merge(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> void delete(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public StockTransaction findOrCreateRollInTransaction(int stockId, String userName, String comment) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> long count(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAll(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
UiCore.startSwing(() -> b);
Ui.exec(() -> {
Ui.build().fxml().eval(CreateSelectionController.class).opt().ifPresent(System.out::println);
});
l.await();
}
use of eu.ggnet.dwoss.stock.ee.entity.StockUnit in project dwoss by gg-net.
the class CreateSimpleActionTryout method tryout.
@Test
public void tryout() throws InterruptedException {
JPanel p = new JPanel();
JButton b = new JButton("Press to close");
b.setPreferredSize(new Dimension(200, 50));
CountDownLatch l = new CountDownLatch(1);
b.addActionListener(e -> {
l.countDown();
});
p.add(new JButton(new CreateSimpleAction()));
p.add(b);
Dl.remote().add(StockAgent.class, new StockAgent() {
@Override
public <T> List<T> findAll(Class<T> entityClass) {
if (entityClass.equals(Stock.class))
return (List<T>) Arrays.asList(new Stock(0, "Rotes Lager"), new Stock(1, "Blaues Lager"));
return null;
}
@Override
public List<StockUnit> findStockUnitsByRefurbishIdEager(List<String> refurbishIds) {
if (refurbishIds.contains("1")) {
Stock s = new Stock(0, "Lager1");
StockUnit s1 = new StockUnit("1", "Gerät Eins", 1);
s1.setStock(s);
return Arrays.asList(s1);
}
return Collections.EMPTY_LIST;
}
// <editor-fold defaultstate="collapsed" desc="Unused Methodes">
@Override
public StockUnit findStockUnitByUniqueUnitIdEager(Integer uniqueUnitId) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public StockUnit findStockUnitByRefurbishIdEager(String refurbishId) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T persist(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T merge(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> void delete(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public StockTransaction findOrCreateRollInTransaction(int stockId, String userName, String comment) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> long count(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAll(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Dl.remote().add(StockTransactionProcessor.class, new StockTransactionProcessor() {
@Override
public SortedMap<Integer, String> perpareTransfer(List<StockUnit> stockUnits, int destinationStockId, String arranger, String comment) throws UserInfoException {
SortedMap<Integer, String> r = new TreeMap<>();
r.put(1, "1");
return r;
}
// <editor-fold defaultstate="collapsed" desc="Unused Methodes">
@Override
public List<Integer> rollIn(List<StockTransaction> detachtedTransactions, String arranger) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void cancel(StockTransaction transaction, String arranger, String comment) throws UserInfoException {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void commission(List<StockTransaction> transactions, String picker, String deliverer) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void receive(List<StockTransaction> transactions, String deliverer, String reciever) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removeFromPreparedTransaction(String refurbishId, String arranger, String comment) throws UserInfoException {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Guardian guardianMock = mock(Guardian.class);
given(guardianMock.getUsername()).willAnswer(i -> "Testuser");
Dl.local().add(Guardian.class, guardianMock);
UiCore.startSwing(() -> p);
l.await();
}
Aggregations