@Test(expected = InvalidRequestException.class) public void failedToDeserializeRetrievedConfig() { when(mockStatusLine.getStatusCode()).thenReturn(HttpStatus.SC_OK); when(HTTPTransformer.transformHttpEntityToString(any())).thenReturn(TestConstants.CONFIG); when(mockConfigSerializer.deserialize(TestConstants.CONFIG)) .thenThrow(new InvalidRequestException(TestConstants.DUMMY_ERROR_MESSAGE)); test.retrieveStoredConfig(); }
public Map<String, ComprehendConfiguration> retrieveStoredConfig() { Response esConfigResponse = esClient.performRequest(HttpGet.METHOD_NAME, String.format("%s%s", Constants.CONFIG_PATH, "/_source")); if (esConfigResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { return Collections.emptyMap(); } String retrievedConfig = HTTPTransformer.transformHttpEntityToString(esConfigResponse.getEntity()); PreprocessingConfigRequest retrievedConfigRequest = configSerializer.deserialize(retrievedConfig); return ConfigSerializer.transformConfigRequestToConfigMap(retrievedConfigRequest); }
ConfigRetriever { public Map<String, ComprehendConfiguration> retrieveStoredConfig() { Response esConfigResponse = esClient.performRequest(HttpGet.METHOD_NAME, String.format("%s%s", Constants.CONFIG_PATH, "/_source")); if (esConfigResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { return Collections.emptyMap(); } String retrievedConfig = HTTPTransformer.transformHttpEntityToString(esConfigResponse.getEntity()); PreprocessingConfigRequest retrievedConfigRequest = configSerializer.deserialize(retrievedConfig); return ConfigSerializer.transformConfigRequestToConfigMap(retrievedConfigRequest); } }
ConfigRetriever { public Map<String, ComprehendConfiguration> retrieveStoredConfig() { Response esConfigResponse = esClient.performRequest(HttpGet.METHOD_NAME, String.format("%s%s", Constants.CONFIG_PATH, "/_source")); if (esConfigResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { return Collections.emptyMap(); } String retrievedConfig = HTTPTransformer.transformHttpEntityToString(esConfigResponse.getEntity()); PreprocessingConfigRequest retrievedConfigRequest = configSerializer.deserialize(retrievedConfig); return ConfigSerializer.transformConfigRequestToConfigMap(retrievedConfigRequest); }  }
ConfigRetriever { public Map<String, ComprehendConfiguration> retrieveStoredConfig() { Response esConfigResponse = esClient.performRequest(HttpGet.METHOD_NAME, String.format("%s%s", Constants.CONFIG_PATH, "/_source")); if (esConfigResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { return Collections.emptyMap(); } String retrievedConfig = HTTPTransformer.transformHttpEntityToString(esConfigResponse.getEntity()); PreprocessingConfigRequest retrievedConfigRequest = configSerializer.deserialize(retrievedConfig); return ConfigSerializer.transformConfigRequestToConfigMap(retrievedConfigRequest); }  Map<String, ComprehendConfiguration> retrieveStoredConfig(); }
ConfigRetriever { public Map<String, ComprehendConfiguration> retrieveStoredConfig() { Response esConfigResponse = esClient.performRequest(HttpGet.METHOD_NAME, String.format("%s%s", Constants.CONFIG_PATH, "/_source")); if (esConfigResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { return Collections.emptyMap(); } String retrievedConfig = HTTPTransformer.transformHttpEntityToString(esConfigResponse.getEntity()); PreprocessingConfigRequest retrievedConfigRequest = configSerializer.deserialize(retrievedConfig); return ConfigSerializer.transformConfigRequestToConfigMap(retrievedConfigRequest); }  Map<String, ComprehendConfiguration> retrieveStoredConfig();  }