Search in sources :

Example 11 with LockModeType

use of javax.persistence.LockModeType 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();
}
Also used : JPanel(javax.swing.JPanel) JButton(javax.swing.JButton) StockTransactionType(eu.ggnet.dwoss.stock.ee.entity.StockTransactionType) Guardian(eu.ggnet.saft.core.auth.Guardian) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) StockTransactionStatusType(eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatusType) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction) Dimension(java.awt.Dimension) CountDownLatch(java.util.concurrent.CountDownLatch) StockAgent(eu.ggnet.dwoss.stock.ee.StockAgent) LockModeType(javax.persistence.LockModeType) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) CreateSimpleAction(eu.ggnet.dwoss.stock.transactions.CreateSimpleAction) StockTransactionProcessor(eu.ggnet.dwoss.stock.ee.StockTransactionProcessor) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Test(org.junit.Test)

Aggregations

LockModeType (javax.persistence.LockModeType)11 Test (org.junit.Test)4 StockAgent (eu.ggnet.dwoss.stock.ee.StockAgent)3 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)3 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)3 StockTransactionStatusType (eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatusType)3 StockTransactionType (eu.ggnet.dwoss.stock.ee.entity.StockTransactionType)3 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)3 Dimension (java.awt.Dimension)3 Mandators (eu.ggnet.dwoss.mandator.Mandators)2 ProductProcessorStub (eu.ggnet.dwoss.receipt.stub.ProductProcessorStub)2 ReportAgent (eu.ggnet.dwoss.report.ee.ReportAgent)2 ReportParameter (eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter)2 SearchParameter (eu.ggnet.dwoss.report.ee.ReportAgent.SearchParameter)2 Report (eu.ggnet.dwoss.report.ee.entity.Report)2 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)2 DocumentType (eu.ggnet.dwoss.rules.DocumentType)2 TradeName (eu.ggnet.dwoss.rules.TradeName)2 SpecAgent (eu.ggnet.dwoss.spec.ee.SpecAgent)2 SpecGenerator (eu.ggnet.dwoss.spec.ee.assist.gen.SpecGenerator)2