@Test public void testCreateInstanceNullSessionToken() { String expectedMessage = String.format("Missing the required parameter %s", SESSION_TOKEN_HEADER_PARAM); String expectedSolution = String.format("Please check if the required field '%s' is not empty", SESSION_TOKEN_HEADER_PARAM); when(logMessage.getMessage(MISSING_PARAMETER, SESSION_TOKEN_HEADER_PARAM)).thenReturn( expectedMessage); when(logMessage.getMessage(MISSING_PARAMETER_SOLUTION, SESSION_TOKEN_HEADER_PARAM)).thenReturn( expectedSolution); try { apiClient.createInstance(null, null); fail(); } catch (RemoteApiException e) { assertEquals(400, e.getCode()); assertEquals(ExceptionMessageFormatter.format("Commons", expectedMessage, expectedSolution), e.getMessage()); } }
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; }