@Test public void testCreateInstance() throws RemoteApiException { Map<String, String> headerParams = new HashMap<>(); headerParams.put("sessionToken", MOCK_SESSION); IntegrationInstance instance = mockInstance(); IntegrationInstanceSubmissionCreate create = new IntegrationInstanceSubmissionCreate(); create.setConfigurationId(instance.getConfigurationId()); create.setOptionalProperties(instance.getOptionalProperties()); String path = "/v1/configuration/" + MOCK_CONFIGURATION_ID + "/instance"; doReturn(MOCK_CONFIGURATION_ID).when(httpClient).escapeString(MOCK_CONFIGURATION_ID); doReturn(instance).when(httpClient) .doPost(path, headerParams, Collections.<String, String>emptyMap(), create, IntegrationInstance.class); IntegrationInstance result = apiClient.createInstance(MOCK_SESSION, create); assertEquals(instance, result); }
public IntegrationInstance createInstance(String sessionToken, IntegrationInstanceSubmissionCreate instance) throws RemoteApiException { checkAuthToken(sessionToken); if (instance == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, CREATE_INSTANCE); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, CREATE_INSTANCE); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (StringUtils.isEmpty(instance.getConfigurationId())) { String reason = logMessage.getMessage(ID_EMPTY, CONFIGURATION_ID); String solution = logMessage.getMessage(ID_SOLUTION, CONFIGURATION_ID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/configuration/" + apiClient.escapeString(instance.getConfigurationId()) + "/instance"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), instance, IntegrationInstance.class); }
IntegrationInstanceApiClient extends BaseIntegrationInstanceApiClient { public IntegrationInstance createInstance(String sessionToken, IntegrationInstanceSubmissionCreate instance) throws RemoteApiException { checkAuthToken(sessionToken); if (instance == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, CREATE_INSTANCE); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, CREATE_INSTANCE); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (StringUtils.isEmpty(instance.getConfigurationId())) { String reason = logMessage.getMessage(ID_EMPTY, CONFIGURATION_ID); String solution = logMessage.getMessage(ID_SOLUTION, CONFIGURATION_ID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/configuration/" + apiClient.escapeString(instance.getConfigurationId()) + "/instance"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), instance, IntegrationInstance.class); } }
IntegrationInstanceApiClient extends BaseIntegrationInstanceApiClient { public IntegrationInstance createInstance(String sessionToken, IntegrationInstanceSubmissionCreate instance) throws RemoteApiException { checkAuthToken(sessionToken); if (instance == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, CREATE_INSTANCE); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, CREATE_INSTANCE); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (StringUtils.isEmpty(instance.getConfigurationId())) { String reason = logMessage.getMessage(ID_EMPTY, CONFIGURATION_ID); String solution = logMessage.getMessage(ID_SOLUTION, CONFIGURATION_ID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/configuration/" + apiClient.escapeString(instance.getConfigurationId()) + "/instance"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), instance, IntegrationInstance.class); } IntegrationInstanceApiClient(HttpApiClient apiClient, LogMessageSource logMessage); }
IntegrationInstanceApiClient extends BaseIntegrationInstanceApiClient { public IntegrationInstance createInstance(String sessionToken, IntegrationInstanceSubmissionCreate instance) throws RemoteApiException { checkAuthToken(sessionToken); if (instance == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, CREATE_INSTANCE); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, CREATE_INSTANCE); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (StringUtils.isEmpty(instance.getConfigurationId())) { String reason = logMessage.getMessage(ID_EMPTY, CONFIGURATION_ID); String solution = logMessage.getMessage(ID_SOLUTION, CONFIGURATION_ID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/configuration/" + apiClient.escapeString(instance.getConfigurationId()) + "/instance"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), instance, IntegrationInstance.class); } IntegrationInstanceApiClient(HttpApiClient apiClient, LogMessageSource logMessage); IntegrationInstance createInstance(String sessionToken,
      IntegrationInstanceSubmissionCreate instance); }
IntegrationInstanceApiClient extends BaseIntegrationInstanceApiClient { public IntegrationInstance createInstance(String sessionToken, IntegrationInstanceSubmissionCreate instance) throws RemoteApiException { checkAuthToken(sessionToken); if (instance == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, CREATE_INSTANCE); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, CREATE_INSTANCE); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } if (StringUtils.isEmpty(instance.getConfigurationId())) { String reason = logMessage.getMessage(ID_EMPTY, CONFIGURATION_ID); String solution = logMessage.getMessage(ID_SOLUTION, CONFIGURATION_ID); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/configuration/" + apiClient.escapeString(instance.getConfigurationId()) + "/instance"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), instance, IntegrationInstance.class); } IntegrationInstanceApiClient(HttpApiClient apiClient, LogMessageSource logMessage); IntegrationInstance createInstance(String sessionToken,
      IntegrationInstanceSubmissionCreate instance); static final String CREATE_INSTANCE; }