@Before public void setUp() throws IOException, ConnectionException, HubSpotConnectorException, HubSpotConnectorNoAccessTokenException { // Load the .properties final Properties prop = new Properties(); final ClassLoader loader = Thread.currentThread().getContextClassLoader(); final InputStream stream = loader.getResourceAsStream("hubspotconnectorit.properties"); prop.load(stream); // Save the props in the class attributes final String authResult = prop.getProperty("hubspot.it.authresult"); credentialsMap = new ObjectStoreWithClone<Serializable>(); connector = new HubSpotConnector(); connector.setClientId(prop.getProperty("hubspot.it.clientid")); connector.setHubId(prop.getProperty("hubspot.it.hubid")); connector.setScope(prop.getProperty("hubspot.it.scope")); connector.setCallbackUrl(prop.getProperty("hubspot.it.callbackurl")); connector.setObjectStore(credentialsMap); connector.initialize(); try { connector.authenticate(USER_ID, null, null, null, null, null); } catch (final Throwable e) { } // Expected exception because we are not passing a map for the headers. Only intention is to // initialize the client if (StringUtils.isEmpty(authResult)) { final Map<String, Object> m = new HashMap<String, Object>(); final String url = connector.authenticate(USER_ID, null, null, null, null, m); throw new RuntimeException( "Call this url and gather the URL response as the authresult: " + url); } else { connector.authenticateResponse(authResult); } }