- final String expectedUrl = "/A1-ADAPTER-API:getPolicyStatus";
- verify(asyncRestClientMock).postWithAuthHeader(expectedUrl, inputJsonString, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
+ private Gson gson() {
+ return SdncOscA1Client.gson;
+ }
+
+ private String loadFile(String fileName) throws IOException {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ URL url = loader.getResource(fileName);
+ File file = new File(url.getFile());
+ return new String(Files.readAllBytes(file.toPath()));
+ }
+
+ private void whenPostReturnOkResponse() {
+ whenAsyncPostThenReturn(Mono.just(createOkResponseString(true)));
+ }
+
+ private void whenPostReturnOkResponseNoBody() {
+ whenAsyncPostThenReturn(Mono.just(createOkResponseString(false)));
+ }
+
+ private String createOkResponseWithBody(Object body) {
+ AdapterOutput output = ImmutableAdapterOutput.builder() //
+ .body(gson().toJson(body)) //
+ .httpStatus(HttpStatus.OK.value()) //
+ .build();
+ return SdncJsonHelper.createOutputJsonString(output);
+ }
+
+ private String createOkResponseString(boolean withBody) {
+ Builder responseBuilder = ImmutableAdapterOutput.builder().httpStatus(HttpStatus.OK.value());
+ if (withBody) {
+ responseBuilder.body(HttpStatus.OK.name());
+ } else {
+ responseBuilder.body(Optional.empty());
+ }
+ return SdncJsonHelper.createOutputJsonString(responseBuilder.build());