use of com.ingenico.connect.gateway.sdk.java.Marshaller in project connect-sdk-java by Ingenico-ePayments.
the class WebhooksHelperTest method testUnmarshalApiVersionMismatch.
@Test(expected = ApiVersionMismatchException.class)
public void testUnmarshalApiVersionMismatch() throws IOException {
Marshaller marshaller = Mockito.mock(Marshaller.class);
Mockito.when(marshaller.unmarshal(Matchers.anyString(), Matchers.<Class<?>>any())).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
String responseJson = invocation.getArgumentAt(0, String.class);
Class<?> type = invocation.getArgumentAt(1, Class.class);
WebhooksEvent event = (WebhooksEvent) DefaultMarshaller.INSTANCE.unmarshal(responseJson, type);
event.setApiVersion("v0");
return event;
}
});
WebhooksHelper helper = createHelper(marshaller);
InMemorySecretKeyStore.INSTANCE.storeSecretKey(KEY_ID, SECRET_KEY);
String body = new String(readResource("valid-body"), CHARSET);
List<RequestHeader> requestHeaders = Arrays.asList(new RequestHeader(SIGNATURE_HEADER, SIGNATURE), new RequestHeader(KEY_ID_HEADER, KEY_ID));
helper.unmarshal(body, requestHeaders);
}
Aggregations