use of com.ingenico.connect.gateway.sdk.java.defaultimpl.AuthorizationType in project connect-sdk-java by Ingenico-ePayments.
the class FactoryTest method testCreateCommunicator.
@Test
public void testCreateCommunicator() {
@SuppressWarnings("resource") Communicator communicator = Factory.createCommunicator(PROPERTIES_URI, API_KEY_ID, SECRET_API_KEY);
Assert.assertSame(DefaultMarshaller.INSTANCE, communicator.getMarshaller());
Session session = ReflectionUtil.getField(communicator, "session", Session.class);
@SuppressWarnings("resource") Connection connection = session.getConnection();
Assert.assertTrue(connection instanceof DefaultConnection);
DefaultConnectionTest.assertConnection((DefaultConnection) connection, -1, -1, 100, null);
Authenticator authenticator = session.getAuthenticator();
Assert.assertTrue(authenticator instanceof DefaultAuthenticator);
Assert.assertEquals(AuthorizationType.V1HMAC, ReflectionUtil.getField(authenticator, "authorizationType", AuthorizationType.class));
Assert.assertEquals(API_KEY_ID, ReflectionUtil.getField(authenticator, "apiKeyId", String.class));
Assert.assertEquals(SECRET_API_KEY, ReflectionUtil.getField(authenticator, "secretApiKey", String.class));
MetaDataProvider metaDataProvider = session.getMetaDataProvider();
Assert.assertEquals(MetaDataProvider.class, metaDataProvider.getClass());
Collection<RequestHeader> requestHeaders = metaDataProvider.getServerMetaDataHeaders();
Assert.assertEquals(1, requestHeaders.size());
RequestHeader requestHeader = requestHeaders.iterator().next();
Assert.assertEquals("X-GCS-ServerMetaInfo", requestHeader.getName());
}
Aggregations