Search in sources :

Example 1 with TokenResponse

use of com.ingenico.connect.gateway.sdk.java.domain.token.TokenResponse in project connect-sdk-java by Ingenico-ePayments.

the class DefaultMarshallerTest method testUnmarshalWithExtraFields.

@Test
public void testUnmarshalWithExtraFields() {
    TokenResponseWithExtraField original = new TokenResponseWithExtraField();
    Address billingAddress = new Address();
    billingAddress.setCountryCode("NL");
    CustomerToken customer = new CustomerToken();
    customer.setBillingAddress(billingAddress);
    TokenCardData data = new TokenCardData();
    TokenCard card = new TokenCard();
    card.setCustomer(customer);
    card.setData(data);
    original.setCard(card);
    original.setExtraField("extra-field-value");
    String json = DefaultMarshaller.INSTANCE.marshal(original);
    TokenResponse unmarshalled = DefaultMarshaller.INSTANCE.unmarshal(json, TokenResponse.class);
    Assert.assertNotNull(unmarshalled.getCard());
    Assert.assertNotNull(unmarshalled.getCard().getCustomer());
    Assert.assertNotNull(unmarshalled.getCard().getCustomer().getBillingAddress());
    Assert.assertEquals("NL", unmarshalled.getCard().getCustomer().getBillingAddress().getCountryCode());
    Assert.assertNotNull(unmarshalled.getCard().getData());
}
Also used : TokenCard(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCard) TokenCardData(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCardData) Address(com.ingenico.connect.gateway.sdk.java.domain.definitions.Address) TokenResponse(com.ingenico.connect.gateway.sdk.java.domain.token.TokenResponse) CustomerToken(com.ingenico.connect.gateway.sdk.java.domain.token.definitions.CustomerToken) Test(org.junit.Test)

Aggregations

Address (com.ingenico.connect.gateway.sdk.java.domain.definitions.Address)1 TokenResponse (com.ingenico.connect.gateway.sdk.java.domain.token.TokenResponse)1 CustomerToken (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.CustomerToken)1 TokenCard (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCard)1 TokenCardData (com.ingenico.connect.gateway.sdk.java.domain.token.definitions.TokenCardData)1 Test (org.junit.Test)1