Search in sources :

Example 1 with Operator

use of eu.ggnet.dwoss.rights.api.Operator in project dwoss by gg-net.

the class GuardianTest method testAuthentication.

@Test
public void testAuthentication() {
    SampleGuardianCos access = new SampleGuardianCos();
    Operator operator = new Operator("test1", 1, Arrays.asList(AtomicRight.values()));
    TestListener listener = new TestListener();
    access.addUserChangeListener(listener);
    ClassWithSetEnabled ad1 = new ClassWithSetEnabled();
    ClassWithSetEnabledAndImageIds ad2 = new ClassWithSetEnabledAndImageIds();
    access.add(ad1, IMPORT_IMAGE_IDS);
    access.add(ad2);
    assertFalse("No authentication jet, should be disabled", ad1.isEnabled());
    assertFalse("No authentication jet, should be disabled", ad2.isEnabled());
    access.setRights(operator);
    assertTrue("Successfull authenticated, should be enabled", ad1.isEnabled());
    assertTrue("Successfull authenticated, should be enabled", ad2.isEnabled());
    access.logout();
    assertFalse("No authentication jet, should be disabled", ad1.isEnabled());
    assertFalse("No authentication jet, should be disabled", ad2.isEnabled());
    access.remove(ad2);
    // This is like successful authentication
    access.quickAuthenticate(operator.getQuickLoginKey());
    assertTrue("Successfull authenticated, should be enabled", ad1.isEnabled());
    assertFalse("Successfull authenticated, but ad2 is removed, should be disabled", ad2.isEnabled());
    assertEquals("User should be equal", operator.getUsername(), listener.lastUser);
}
Also used : Operator(eu.ggnet.dwoss.rights.api.Operator) Test(org.junit.Test)

Example 2 with Operator

use of eu.ggnet.dwoss.rights.api.Operator in project dwoss by gg-net.

the class GuardianTest method testHasRight.

@Test
public void testHasRight() {
    SampleGuardianCos access = new SampleGuardianCos();
    Operator operator = new Operator("test1", 1, Arrays.asList(AtomicRight.CREATE_ANNULATION_INVOICE));
    access.setRights(operator);
    assertTrue("Right is not present.", access.hasRight(AtomicRight.CREATE_ANNULATION_INVOICE));
}
Also used : Operator(eu.ggnet.dwoss.rights.api.Operator) Test(org.junit.Test)

Example 3 with Operator

use of eu.ggnet.dwoss.rights.api.Operator in project dwoss by gg-net.

the class DocumentUpdateViewTryout method main.

public static void main(String[] args) {
    // Test different settings of booking accounts in ledgers and in positions
    // Test comment
    Dl.remote().add(CustomerService.class, new CustomerServiceStub());
    try {
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | UnsupportedLookAndFeelException e) {
    // If Nimbus is not available, you can set the GUI to another look and feel.
    }
    UiCore.startSwing(() -> {
        JLabel l = new JLabel("Main Application");
        l.setFont(new Font("DejaVu Sans", 0, 48));
        return l;
    });
    Dossier dos = new Dossier();
    dos.setPaymentMethod(PaymentMethod.DIRECT_DEBIT);
    final Document doc = new Document(DocumentType.ORDER, SEND_ORDER, new DocumentHistory("UnitTest", "Ein Kommentar"));
    dos.add(doc);
    Address address = new Address("Max Mustermann\nMusterstrass 11\n22222 Musterstadt");
    doc.setInvoiceAddress(address);
    doc.setShippingAddress(address);
    doc.setTaxType(GENERAL_SALES_TAX_DE_SINCE_2007);
    doc.append(Position.builder().type(UNIT).amount(1).description("Intel Core I7 i7-4500U (1.8 Ghz), Memory (in MB): 8192, Intel Graphics Series HD on Board, Festplatte(n): 750GB HDD," + " Display: 15.6\" (39,62 cm), Crystal Bright, HD (1366x768), 16:9, , Farbe: silber, Ausstattung: Touchscreen, USB 3, Bluetooth," + " Kartenleser, WLAN b + g + n, Webcam, Videokonnektor(en) : HDMI, VGA, Windows 8.1 64").name("Acer Aspire E1-572P-74508G75Dnii (NX.MFSED.003) SopoNr:123456 SN:NXMFSED00312312122EF001S").bookingAccount(L_1000_STD_UNIT).uniqueUnitId(1).uniqueUnitProductId(1).price(100).tax(doc.getSingleTax()).build());
    doc.append(Position.builder().type(UNIT).amount(1).description("Intel Core I7 i7-4500U (1.8 Ghz), Memory (in MB): 8192, Intel Graphics Series HD on Board, Festplatte(n): 750GB HDD," + " Display: 15.6\" (39,62 cm), Crystal Bright, HD (1366x768), 16:9, , Farbe: silber, Ausstattung: Touchscreen, USB 3, Bluetooth," + " Kartenleser, WLAN b + g + n, Webcam, Videokonnektor(en) : HDMI, VGA, Windows 8.1 64").name("Acer Aspire E1-572P-74508G75Dnii (NX.MFSED.003) SopoNr:12345 SN:NXMFSED00312312122EF001S").bookingAccount(L_1000_STD_UNIT).uniqueUnitId(2).uniqueUnitProductId(2).price(100).tax(doc.getSingleTax()).build());
    doc.append(Position.builder().type(UNIT).amount(1).description("Intel Core I7 i7-4500U (1.8 Ghz), Memory (in MB): 8192, Intel Graphics Series HD on Board, Festplatte(n): 750GB HDD," + " Display: 15.6\" (39,62 cm), Crystal Bright, HD (1366x768), 16:9, , Farbe: silber, Ausstattung: Touchscreen, USB 3, Bluetooth," + " Kartenleser, WLAN b + g + n, Webcam, Videokonnektor(en) : HDMI, VGA, Windows 8.1 64").name("Acer Aspire E1-572P-74508G75Dnii (NX.MFSED.003) SopoNr:1234 SN:NXMFSED00312312122EF001S").bookingAccount(L_1000_STD_UNIT).price(100).uniqueUnitId(3).uniqueUnitProductId(3).tax(0.07).build());
    doc.append(Position.builder().type(SERVICE).amount(1).description("Intel Core I7 i7-4500U (1.8 Ghz), Memory (in MB): 8192, Intel Graphics Series HD on Board, Festplatte(n): 750GB HDD," + " Display: 15.6\" (39,62 cm), Crystal Bright, HD (1366x768), 16:9, , Farbe: silber, Ausstattung: Touchscreen, USB 3, Bluetooth," + " Kartenleser, WLAN b + g + n, Webcam, Videokonnektor(en) : HDMI, VGA, Windows 8.1 64").name("Service Acer Aspire E1-572P-74508G75Dnii").price(100).bookingAccount(L_1001_HW_SW_STORE).tax(0).build());
    doc.append(Position.builder().type(SHIPPING_COST).amount(1).description("Versandkosten").name("Versandkosten").price(10).bookingAccount(L_1002_VERSANDKOSTEN).tax(doc.getSingleTax()).build());
    Dl.remote().add(Mandators.class, new Mandators() {

        @Override
        public PostLedger loadPostLedger() {
            return new PostLedger(PostLedger.add().positionTypes(UNIT).taxTypes(GENERAL_SALES_TAX_DE_SINCE_2007).primaryLedger(L_1000_STD_UNIT), PostLedger.add().positionTypes(UNIT).taxTypes(UNTAXED).primaryLedger(2001, "Geräte ohne Ust."), PostLedger.add().positionTypes(UNIT, SERVICE, PRODUCT_BATCH, SHIPPING_COST, UNIT_ANNEX).taxTypes(REVERSE_CHARGE).primaryLedger(3000, "Reverse Charge"), PostLedger.add().positionTypes(SERVICE).taxTypes(GENERAL_SALES_TAX_DE_SINCE_2007).primaryLedger(2002, "Dienstleistung Store").alternativeLedger(L_1000_STD_UNIT).alternativeLedger(L_1002_VERSANDKOSTEN).alternativeLedger(L_1001_HW_SW_STORE), PostLedger.add().positionTypes(PRODUCT_BATCH).taxTypes(GENERAL_SALES_TAX_DE_SINCE_2007).primaryLedger(L_1001_HW_SW_STORE), PostLedger.add().positionTypes(SHIPPING_COST).taxTypes(GENERAL_SALES_TAX_DE_SINCE_2007).primaryLedger(L_1002_VERSANDKOSTEN));
        }

        @Override
        public DefaultCustomerSalesdata loadSalesdata() {
            return new DefaultCustomerSalesdata(ShippingCondition.DEFAULT, PaymentCondition.CUSTOMER, PaymentMethod.DIRECT_DEBIT, null, null);
        }

        // <editor-fold defaultstate="collapsed" desc="Unused Methods">
        @Override
        public ShippingTerms loadShippingTerms() {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public Mandator loadMandator() {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public ReceiptCustomers loadReceiptCustomers() {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public SpecialSystemCustomers loadSystemCustomers() {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public Contractors loadContractors() {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    Dl.remote().add(RedTapeWorker.class, new RedTapeWorkerStub());
    Dl.remote().add(RedTapeAgent.class, null);
    Dl.remote().add(UnitOverseer.class, null);
    Dl.local().add(Guardian.class, new AbstractGuardian() {

        {
            setRights(new Operator("All Rights", 1, Arrays.asList(AtomicRight.values())));
        }

        @Override
        public void login(String user, char[] pass) throws AuthenticationException {
        }
    });
    DocumentUpdateView view = new DocumentUpdateView(doc);
    DocumentUpdateController controller = new DocumentUpdateController(view, doc);
    view.setController(controller);
    view.setCustomerValues(1);
    Ui.exec(() -> {
        Ui.build().title("Dokument bearbeiten").swing().eval(() -> OkCancelWrap.vetoResult(view)).opt().ifPresent(System.out::println);
    });
}
Also used : Operator(eu.ggnet.dwoss.rights.api.Operator) AuthenticationException(eu.ggnet.saft.core.auth.AuthenticationException) Font(java.awt.Font) LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) CustomerServiceStub(tryout.stub.CustomerServiceStub) RedTapeWorkerStub(tryout.stub.RedTapeWorkerStub) AbstractGuardian(eu.ggnet.dwoss.common.AbstractGuardian) DocumentUpdateController(eu.ggnet.dwoss.redtapext.ui.cao.document.DocumentUpdateController) DocumentUpdateView(eu.ggnet.dwoss.redtapext.ui.cao.document.DocumentUpdateView) Mandators(eu.ggnet.dwoss.mandator.Mandators)

Example 4 with Operator

use of eu.ggnet.dwoss.rights.api.Operator in project dwoss by gg-net.

the class ShipmentDialogTryout method testShipment.

@Test
public void testShipment() throws Exception {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    Dl.local().add(Guardian.class, new AbstractGuardian() {

        {
            setRights(new Operator("Testuser", 0, Arrays.asList(AtomicRight.values())));
        }

        @Override
        public void login(String user, char[] pass) throws AuthenticationException {
        }
    });
    StockUpiImpl su = new StockUpiImpl();
    su.setActiveStock(new PicoStock(0, "Demostock"));
    Dl.local().add(StockUpi.class, su);
    Dl.remote().add(StockAgent.class, new StockAgentStub());
    ShipmentController controller = new ShipmentController();
    ShipmentDialog dialog = new ShipmentDialog(new javax.swing.JFrame(), controller);
    dialog.setVisible(true);
}
Also used : Operator(eu.ggnet.dwoss.rights.api.Operator) AuthenticationException(eu.ggnet.saft.core.auth.AuthenticationException) PicoStock(eu.ggnet.dwoss.stock.api.PicoStock) AbstractGuardian(eu.ggnet.dwoss.common.AbstractGuardian) StockUpiImpl(eu.ggnet.dwoss.stock.upi.impl.StockUpiImpl) Test(org.junit.Test)

Example 5 with Operator

use of eu.ggnet.dwoss.rights.api.Operator in project dwoss by gg-net.

the class RedTapeTryout method main.

public static void main(String[] args) {
    Dl.local().add(RemoteLookup.class, new RemoteLookup() {

        @Override
        public <T> boolean contains(Class<T> clazz) {
            return false;
        }

        @Override
        public <T> T lookup(Class<T> clazz) {
            return null;
        }
    });
    Dl.remote().add(RedTapeAgent.class, new RedTapeAgentStub());
    Dl.remote().add(RedTapeWorker.class, new RedTapeWorkerStub());
    Dl.remote().add(UniversalSearcher.class, new UniversalSearcherStub());
    Dl.remote().add(CustomerService.class, new CustomerServiceStub());
    Dl.remote().add(DocumentSupporter.class, new DocumentSupporter() {

        @Override
        public void mail(Document document, DocumentViewType jtype) throws UserInfoException, RuntimeException {
            System.out.println("Mailing " + document);
        }

        @Override
        public JasperPrint render(Document document, DocumentViewType viewType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public Dossier briefed(Document detached, String arranger) {
            detached.add(Document.Flag.CUSTOMER_BRIEFED);
            detached.add(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
            return detached.getDossier();
        }

        @Override
        public FileJacket toXls(String identifier) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    Dl.local().add(Guardian.class, new AbstractGuardian() {

        @Override
        public void login(String user, char[] pass) throws AuthenticationException {
            setRights(new Operator(user, 1, Arrays.asList(AtomicRight.values())));
        }
    });
    Dl.remote().add(StockAgent.class, null);
    Dl.remote().add(UniqueUnitAgent.class, null);
    // Dl.remote().add(LegacyRemoteBridge.class, null);
    Dl.remote().add(ShippingCostService.class, null);
    Mandators mandatorSupporterMock = mock(Mandators.class);
    when(mandatorSupporterMock.loadSalesdata()).thenReturn(new DefaultCustomerSalesdata(ShippingCondition.DEFAULT, PaymentCondition.CUSTOMER, PaymentMethod.DIRECT_DEBIT, Arrays.asList(SalesChannel.CUSTOMER, SalesChannel.RETAILER), null));
    Dl.remote().add(Mandators.class, mandatorSupporterMock);
    CustomerUpi ccos = mock(CustomerUpi.class);
    when(ccos.createCustomer(any())).thenReturn(0L);
    when(ccos.updateCustomer(any(), anyLong())).thenReturn(true);
    Dl.local().add(CustomerUpi.class, ccos);
    UiCore.startSwing(() -> new JLabel("Main Applikation"));
    Ui.exec(() -> {
        Ui.build().swing().show(() -> RedTapeController.build().getView());
    });
}
Also used : Operator(eu.ggnet.dwoss.rights.api.Operator) DocumentViewType(eu.ggnet.dwoss.mandator.api.DocumentViewType) AuthenticationException(eu.ggnet.saft.core.auth.AuthenticationException) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) FileJacket(eu.ggnet.dwoss.util.FileJacket) CustomerUpi(eu.ggnet.dwoss.customer.upi.CustomerUpi) JasperPrint(net.sf.jasperreports.engine.JasperPrint) JLabel(javax.swing.JLabel) DefaultCustomerSalesdata(eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata) AbstractGuardian(eu.ggnet.dwoss.common.AbstractGuardian) RemoteLookup(eu.ggnet.saft.core.cap.RemoteLookup) Mandators(eu.ggnet.dwoss.mandator.Mandators) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) UserInfoException(eu.ggnet.dwoss.util.UserInfoException)

Aggregations

Operator (eu.ggnet.dwoss.rights.api.Operator)6 AbstractGuardian (eu.ggnet.dwoss.common.AbstractGuardian)4 AuthenticationException (eu.ggnet.saft.core.auth.AuthenticationException)4 Test (org.junit.Test)3 Mandators (eu.ggnet.dwoss.mandator.Mandators)2 CustomerUpi (eu.ggnet.dwoss.customer.upi.CustomerUpi)1 DocumentViewType (eu.ggnet.dwoss.mandator.api.DocumentViewType)1 DefaultCustomerSalesdata (eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata)1 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)1 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)1 DocumentUpdateController (eu.ggnet.dwoss.redtapext.ui.cao.document.DocumentUpdateController)1 DocumentUpdateView (eu.ggnet.dwoss.redtapext.ui.cao.document.DocumentUpdateView)1 PicoStock (eu.ggnet.dwoss.stock.api.PicoStock)1 StockUpiImpl (eu.ggnet.dwoss.stock.upi.impl.StockUpiImpl)1 FileJacket (eu.ggnet.dwoss.util.FileJacket)1 UserInfoException (eu.ggnet.dwoss.util.UserInfoException)1 RemoteLookup (eu.ggnet.saft.core.cap.RemoteLookup)1 Font (java.awt.Font)1 JButton (javax.swing.JButton)1 JLabel (javax.swing.JLabel)1