Package com.niyamit.spreedly.paymentmethods

Examples of com.niyamit.spreedly.paymentmethods.PaymentMethod


        final String accessSecret = "accessSecret";
        final SpreedlyInvoker spreedlyInvoker = new SpreedlyInvoker(environmentKey, accessSecret, client);
        final String targetUrl = "http://target.url";
        final String method = "POST";
        final Transaction transaction = new Transaction();
        final PaymentMethod returnPaymentMethod = new PaymentMethod();
       
        //set up mocks
        final WebTarget webTarget = mock(WebTarget.class);
        when(client.target(targetUrl)).thenReturn(webTarget);
        final Invocation.Builder builder = mock(Invocation.Builder.class);
        when(webTarget.request()).thenReturn(builder);
        when(builder.header(anyString(), any())).thenReturn(builder);
        final Response response = mock(Response.class);
        when(builder.method(eq(method), any(Entity.class))).thenReturn(response);
        when(response.getStatus()).thenReturn(200); //success response
        when(response.readEntity(PaymentMethod.class)).thenReturn(returnPaymentMethod);
       
        //method under test
        final PaymentMethod responsePaymentMethod = spreedlyInvoker.invoke(targetUrl, method, transaction, PaymentMethod.class);
       
        //assertions
        assertNotNull(responsePaymentMethod);
        assertEquals(returnPaymentMethod, responsePaymentMethod);
       
View Full Code Here


    }
   
    @Test
    public void testAdd() {
        //set up data
        final PaymentMethod paymentMethod = objectFactory.createPaymentMethod();
        paymentMethod.setEmail("jpicard@ufp.net");
        final CreditCard creditCard = objectFactory.createCreditCard();
        creditCard.setFirstName("Jean-Luc");
        creditCard.setLastName("Picard");
        creditCard.setNumber("5555555555554444");
        creditCard.setVerificationValue("423");
        creditCard.setMonth("3");
        creditCard.setYear("2032");
        paymentMethod.setCreditCard(creditCard);
//        paymentMethod.setData("<paymentMethodId>448</paymentMethodId>");
        paymentMethod.setRetained(Boolean.TRUE);

        //call method under test
        final Transaction transaction = spreedlyPaymentMethodService.add(paymentMethod);

        //assertions
View Full Code Here

    public Transaction createTransaction() {
        return new Transaction();
    }

    public PaymentMethod createPaymentMethod() {
        return new PaymentMethod();
    }
View Full Code Here

TOP

Related Classes of com.niyamit.spreedly.paymentmethods.PaymentMethod

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.