Package org.jboss.seam.example.seampay

Examples of org.jboss.seam.example.seampay.Payment


    @Test
    public void testInactive() {
        PaymentProcessor processor = new PaymentProcessor();
       
        Payment payment = createTestPayment(new BigDecimal("100"), Frequency.ONCE);
        payment.setActive(false);               
               
        assert payment.getAccount().getBalance().equals(INITIAL_BALANCE);       
              
        processor.processPayment(payment);
       
        assert payment.getAccount().getBalance().equals(INITIAL_BALANCE);
        assert payment.getLastPaid() == null;
    }
View Full Code Here


   
    @Test
    public void testPayOnce() {
        PaymentProcessor processor = new PaymentProcessor();
       
        Payment payment = createTestPayment(new BigDecimal("100"), Frequency.ONCE);

        assert payment.getAccount().getBalance().equals(INITIAL_BALANCE);

        processor.processPayment(payment);
              
        assert payment.getAccount().getBalance().equals(new BigDecimal("900"));
        assert !payment.getActive();
        assert payment.getLastPaid() != null;
    }
View Full Code Here

   
    @Test
    public void testPayMultiple() {
        PaymentProcessor processor = new PaymentProcessor();
       
        Payment payment = createTestPayment(new BigDecimal("100"), Frequency.WEEKLY);

        assert payment.getAccount().getBalance().equals(INITIAL_BALANCE);

        processor.processPayment(payment);
              
        assert payment.getAccount().getBalance().equals(new BigDecimal("900"));
        assert payment.getActive();
        assert payment.getLastPaid() != null;
       
        Date firstPayment = payment.getLastPaid();
       
        pause(); // just need to make sure we are some small time in the future
       
        processor.processPayment(payment);
    
        assert payment.getAccount().getBalance().equals(new BigDecimal("800"));
        assert payment.getActive();
        assert payment.getLastPaid().after(firstPayment);
    }
View Full Code Here

    protected Payment createTestPayment(BigDecimal amount, Frequency frequency) {
        Account account = new Account();
        account.setAccountNumber(ACCOUNT_NUMBER);
        setField(account, "balance", INITIAL_BALANCE);
       
        Payment payment = new Payment();
        payment.setAccount(account);
        payment.setAmount(amount);
        payment.setPaymentFrequency(frequency);       
       
        return payment;
    }
View Full Code Here

                Account account = (Account) getValue("#{selectedAccount}");
                assert account !=null;
                assert account.getId() == 1;
                assert account.getPayments().size() == 0;
              
                Payment payment = (Payment) getValue("#{newPayment}");
                assert payment.getPayee().equals("Somebody");
                assert payment.getAccount() != null;
                assert payment.getAccount().getId() == 1;
               
            }           
        }.run();
       
       
        new FacesRequest("/search.xhtml", id) {
            @Override
            protected void beforeRequest() {
                setParameter("accountId", "1");
            }
           
            @Override
            protected void applyRequestValues() throws Exception {
                setValue("#{newPayment.payee}", "IRS");
                setValue("#{newPayment.amount}", new BigDecimal("100.00"));
                setValue("#{newPayment.paymentFrequency}", Frequency.ONCE);
            }

            @Override
            protected void invokeApplication() throws Exception {
                invokeMethod("#{paymentHome.saveAndSchedule}");
            }

            @Override
            protected void renderResponse() throws Exception {
                assert ((Boolean)getValue("#{accountHome.idDefined}"));               
                Account account = (Account) getValue("#{selectedAccount}");               
                assert account !=null;
                assert account.getId() == 1;
                assert account.getPayments().size() == 1;              
               
                Payment payment = (Payment) getValue("#{newPayment}");
                assert payment.getPayee().equals("IRS");
                assert payment.getAmount().equals(new BigDecimal("100.00"));
                assert payment.getAccount() != null;
                assert payment.getAccount().getId() == 1;
            }           
        }.run();
       
       
        // test that the payment is around
View Full Code Here

TOP

Related Classes of org.jboss.seam.example.seampay.Payment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.