Skip to content

Commit 3d331c2

Browse files
committed
PLUGIN-1936: Renamed method from parseResponseToResultListOfJsonObject to parseInputStreamToJsonList
1 parent a5b9371 commit 3d331c2

8 files changed

Lines changed: 19 additions & 19 deletions

File tree

src/main/java/io/cdap/plugin/servicenow/apiclient/ServiceNowTableAPIClientImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public List<Map<String, String>> parseResponseToResultListOfMap(String responseB
181181
return GSON.fromJson(ja, type);
182182
}
183183

184-
public List<JsonObject> parseResponseToResultListOfJsonObject(InputStream in) {
184+
public List<JsonObject> parseInputStreamToJsonList(InputStream in) {
185185
APIResponse apiResponse = GSON.fromJson(new JsonReader(new InputStreamReader(in, StandardCharsets.UTF_8)),
186186
APIResponse.class);
187187
return apiResponse.getResult();

src/test/java/io/cdap/plugin/servicenow/connector/ServiceNowConnectorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void testGenerateSpec() throws Exception {
145145
InputStream inputStream = new ByteArrayInputStream(body);
146146
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
147147
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
148-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
148+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
149149
OAuthClient oAuthClient = Mockito.mock(OAuthClient.class);
150150
PowerMockito.whenNew(ServiceNowTableAPIClientImpl.class).withAnyArguments().thenReturn(restApi);
151151
OAuthJSONAccessTokenResponse accessTokenResponse = Mockito.mock(OAuthJSONAccessTokenResponse.class);

src/test/java/io/cdap/plugin/servicenow/sink/ServiceNowRecordWriterTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void testWriteWithUnSuccessfulApiResponse() throws Exception {
9696
RestAPIResponse restAPIResponse = new RestAPIResponse(
9797
headers, null, null);
9898
Mockito.when(restApi.executePost(Mockito.any())).thenReturn(restAPIResponse);
99-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
99+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
100100
OAuthClient oAuthClient = Mockito.mock(OAuthClient.class);
101101
PowerMockito.whenNew(ServiceNowTableAPIClientImpl.class).withAnyArguments().thenReturn(restApi);
102102
OAuthJSONAccessTokenResponse accessTokenResponse = Mockito.mock(OAuthJSONAccessTokenResponse.class);
@@ -140,7 +140,7 @@ public void testWriteWithSuccessFulApiResponse() throws Exception {
140140
Map<String, String> headers = new HashMap<>();
141141
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, null, null);
142142
Mockito.when(restApi.executePost(Mockito.any(RestAPIRequest.class))).thenReturn(restAPIResponse);
143-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
143+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
144144
OAuthClient oAuthClient = Mockito.mock(OAuthClient.class);
145145
PowerMockito.whenNew(OAuthClient.class).
146146
withArguments(Mockito.any(URLConnectionClient.class)).thenReturn(oAuthClient);
@@ -188,7 +188,7 @@ public void testWriteWithUnservicedRequests() throws Exception {
188188
Map<String, String> headers = new HashMap<>();
189189
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, null, null);
190190
Mockito.when(restApi.executePost(Mockito.any(RestAPIRequest.class))).thenReturn(restAPIResponse);
191-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
191+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
192192
OAuthClient oAuthClient = Mockito.mock(OAuthClient.class);
193193
PowerMockito.whenNew(OAuthClient.class).
194194
withArguments(Mockito.any(URLConnectionClient.class)).thenReturn(oAuthClient);

src/test/java/io/cdap/plugin/servicenow/sink/ServiceNowSinkTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void testConfigurePipeline() throws Exception {
9797
MockFailureCollector collector = new MockFailureCollector();
9898
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
9999
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
100-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
100+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
101101
serviceNowSink.configurePipeline(mockPipelineConfigurer);
102102
Assert.assertNull(restAPIResponse.getException());
103103
Assert.assertEquals(0, collector.getValidationFailures().size());
@@ -136,7 +136,7 @@ public void testPrepareRun() throws Exception {
136136
Mockito.when(context.getInputSchema()).thenReturn(schema);
137137
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
138138
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
139-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
139+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
140140
OAuthClient oAuthClient = Mockito.mock(OAuthClient.class);
141141
PowerMockito.whenNew(OAuthClient.class).
142142
withArguments(Mockito.any(URLConnectionClient.class)).thenReturn(oAuthClient);

src/test/java/io/cdap/plugin/servicenow/source/ServiceNowInputFormatTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public void testFetchTableInfo() throws Exception {
150150
Schema schema = Schema.parseJson(schemaString);
151151
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
152152
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
153-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
153+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
154154
Mockito.when(restApi.fetchTableSchema("table", SourceValueType.SHOW_ACTUAL_VALUE)).thenReturn(schema);
155155
OAuthClient oAuthClient = Mockito.mock(OAuthClient.class);
156156
PowerMockito.whenNew(OAuthClient.class).
@@ -256,7 +256,7 @@ public void testFetchTableInfoReportingMode() throws Exception {
256256
Schema schema = Schema.parseJson(schemaString);
257257
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
258258
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
259-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
259+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
260260
Mockito.when(restApi.fetchTableSchema("proc_po", SourceValueType.SHOW_ACTUAL_VALUE)).thenReturn(schema);
261261
Mockito.when(restApi.fetchTableSchema("proc_po_item",
262262
SourceValueType.SHOW_ACTUAL_VALUE)).thenReturn(schema);
@@ -303,7 +303,7 @@ public void testFetchTableInfoWithEmptyTableName() throws Exception {
303303
InputStream inputStream = new ByteArrayInputStream(body);
304304
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
305305
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
306-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
306+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
307307
OAuthClient oAuthClient = Mockito.mock(OAuthClient.class);
308308
PowerMockito.mockStatic(ServiceNowInputFormat.class);
309309
PowerMockito.whenNew(OAuthClient.class).

src/test/java/io/cdap/plugin/servicenow/source/ServiceNowMultiSourceConfigTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public void testValidate() throws Exception {
187187
InputStream inputStream = new ByteArrayInputStream(body);
188188
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
189189
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
190-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
190+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
191191
serviceNowMultiSourceConfig.validate(mockFailureCollector);
192192
Assert.assertEquals(0, mockFailureCollector.getValidationFailures().size());
193193

@@ -318,7 +318,7 @@ public void testValidateReferenceName() throws Exception {
318318
InputStream inputStream = new ByteArrayInputStream(body);
319319
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
320320
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
321-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
321+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
322322
try {
323323
serviceNowMultiSourceConfig.validate(mockFailureCollector);
324324
Assert.fail("Exception is not thrown with valid reference name");
@@ -421,7 +421,7 @@ public void testValidateWhenTableFieldNameIsEmpty() throws Exception {
421421
InputStream inputStream = new ByteArrayInputStream(body);
422422
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
423423
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
424-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
424+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
425425
serviceNowMultiSourceConfig.validate(mockFailureCollector);
426426
Assert.assertEquals(1, mockFailureCollector.getValidationFailures().size());
427427
Assert.assertEquals("Table name field must be specified.",

src/test/java/io/cdap/plugin/servicenow/source/ServiceNowMultiSourceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void testConfigurePipeline() throws Exception {
162162
InputStream inputStream = new ByteArrayInputStream(body);
163163
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
164164
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
165-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
165+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
166166
serviceNowMultiSource.configurePipeline(mockPipelineConfigurer);
167167
Assert.assertNull(mockPipelineConfigurer.getOutputSchema());
168168
Assert.assertEquals(0, mockFailureCollector.getValidationFailures().size());
@@ -184,7 +184,7 @@ public void testConfigurePipelineWithEmptyTable() throws Exception {
184184
InputStream inputStream = new ByteArrayInputStream(body);
185185
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
186186
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
187-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
187+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
188188
try {
189189
serviceNowMultiSource.configurePipeline(mockPipelineConfigurer);
190190
Assert.fail("Exception is not thrown for Non-Empty Tables");
@@ -290,7 +290,7 @@ public void testPrepareRun() throws Exception {
290290
Mockito.when(ServiceNowMultiInputFormat.setInput(Mockito.any(), Mockito.any())).thenReturn((tableInfo));
291291
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
292292
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
293-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
293+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
294294
OAuthClient oAuthClient = Mockito.mock(OAuthClient.class);
295295
PowerMockito.whenNew(OAuthClient.class).
296296
withArguments(Mockito.any(URLConnectionClient.class)).thenReturn(oAuthClient);

src/test/java/io/cdap/plugin/servicenow/source/ServiceNowSourceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public void testConfigurePipeline() throws Exception {
177177
Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(tableInfo);
178178
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
179179
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
180-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
180+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
181181
OAuthClient oAuthClient = Mockito.mock(OAuthClient.class);
182182
PowerMockito.whenNew(OAuthClient.class).
183183
withArguments(Mockito.any(URLConnectionClient.class)).thenReturn(oAuthClient);
@@ -217,7 +217,7 @@ public void testConfigurePipelineWithEmptyTable() throws Exception {
217217
InputStream inputStream = new ByteArrayInputStream(body);
218218
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
219219
Mockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
220-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
220+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
221221
try {
222222
serviceNowSource.configurePipeline(mockPipelineConfigurer);
223223
Assert.fail("Exception is not thrown for Non-Empty Tables");
@@ -307,7 +307,7 @@ public void testPrepareRun() throws Exception {
307307
InputStream inputStream = new ByteArrayInputStream(body);
308308
RestAPIResponse restAPIResponse = new RestAPIResponse(headers, inputStream, null);
309309
PowerMockito.when(restApi.executeGetWithRetries(Mockito.any())).thenReturn(restAPIResponse);
310-
Mockito.when(restApi.parseResponseToResultListOfJsonObject(restAPIResponse.getResponseStream())).thenReturn(result);
310+
Mockito.when(restApi.parseInputStreamToJsonList(restAPIResponse.getResponseStream())).thenReturn(result);
311311
OAuthClient oAuthClient = Mockito.mock(OAuthClient.class);
312312
PowerMockito.whenNew(OAuthClient.class).
313313
withArguments(Mockito.any(URLConnectionClient.class)).thenReturn(oAuthClient);

0 commit comments

Comments
 (0)