- String resultHolder = "";
-
- String responseContent = "sample : SAMPLE RESULT STRING";
- Mockito.doReturn(mockedClient).when(mockedHttpsAuthClient).getClient(HttpClientMode.WITHOUT_KEYSTORE);
- Mockito.doReturn("sample").when(propertyGetter).apply(SchedulerProperties.SCHEDULER_USER_NAME_VAL);
- Mockito.doReturn("paS$w0Rd").when(propertyGetter).apply(SchedulerProperties.SCHEDULER_PASSWORD_VAL);
- Mockito.doReturn(sampleTargetUrl).when(propertyGetter).apply(SchedulerProperties.SCHEDULER_SERVER_URL_VAL);
- Mockito.doReturn(200).when(mockedResponse).getStatus();
- Mockito.doReturn(responseContent).when(mockedResponse).readEntity(String.class);
- Mockito.doReturn(mockedResponse).when(mockedBuilder).delete();
- Mockito.when(mockedBuilder.header(Matchers.any(), Matchers.any())).thenReturn(mockedBuilder);
- Mockito.doReturn(mockedBuilder).when(mockedBuilder).headers(commonHeaders);
- Mockito.doReturn(mockedBuilder).when(mockedBuilder).accept(APPLICATION_JSON);
- Mockito.doReturn(mockedBuilder).when(mockedWebTarget).request();
- Mockito.doReturn(mockedWebTarget).when(mockedClient).target(sampleTargetUrl + "test");
-
- serverUtil.prepareDeleteCall("/test", responseContent, Action.ok());
-
- schedulerInterface.Delete(resultHolder, sampleSourceId, "test", sampleRestObj);
-
- assertResponseData(sampleRestObj, responseContent, 200);
+ serverUtil.prepareDeleteCall("/test", RESPONSE_CONTENT, Action.ok());
+
+ schedulerInterface.Delete("", SAMPLE_SOURCE_ID, "", sampleRestObj);
+
+ assertResponseHasExpectedBodyAndStatus(sampleRestObj, RESPONSE_CONTENT, 200);
+ }
+
+ @Test
+ public void shouldRaiseExceptionWhenErrorOccursDuringDelete() throws JsonProcessingException, ParseException {
+ prepareEnvForTest();
+ RestObject<String> sampleRestObj = new RestObject<>();
+ serverUtil.prepareDeleteCall("/test", ERROR_RESPONSE, Action.status(HttpStatus.INTERNAL_SERVER_ERROR_500));
+
+ schedulerInterface.Delete("", SAMPLE_SOURCE_ID, "", sampleRestObj);
+
+ assertResponseHasExpectedBodyAndStatus(sampleRestObj, ERROR_RESPONSE, 500);