/*
* Copyright (C) 2014 GG-Net GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package tryout;
import java.awt.Dimension;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import javax.persistence.LockModeType;
import javax.swing.JButton;
import org.junit.Test;
import eu.ggnet.dwoss.stock.StockAgent;
import eu.ggnet.dwoss.stock.entity.*;
import eu.ggnet.dwoss.stock.transactions.CreateSelectionController;
import eu.ggnet.saft.core.*;
/**
*
* @author oliver.guenther
*/
public class CreateSelectionTryout {
@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();
});
Client.addSampleStub(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) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public StockUnit findStockUnitByRefurbishIdEager(String refurbishId) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType, int start, int amount) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public List<StockUnit> findStockUnitsByRefurbishIdEager(List<String> refurbishIds) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T> T persist(T t) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T> T merge(T t) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T> void delete(T t) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public StockTransaction findOrCreateRollInTransaction(int stockId, String userName, String comment) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T> long count(Class<T> entityClass) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T> List<T> findAll(Class<T> entityClass, int start, int amount) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T> T findById(Class<T> entityClass, Object id) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T> T findById(Class<T> entityClass, Object id, LockModeType lockModeType) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id, LockModeType lockModeType) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
// </editor-fold>
});
UiCore.startSwing(() -> b);
Ui.choiceFxml(CreateSelectionController.class)
.onOk(c -> {
System.out.println(c);
return null;
})
.exec();
l.await();
}
}