From deb5bb7b792ba3ac90e4c622cd804c83e4647b92 Mon Sep 17 00:00:00 2001 From: PatrikBuhr Date: Tue, 17 Mar 2020 15:30:40 +0100 Subject: [PATCH] Implemented policy get-status Implemented policy get-status in the controller and in the adaptor in the policy agent. Change-Id: Ibed0013d6116382e428b9244eacec36ab3ec65a4 Issue-ID: NONRTRIC-155 Signed-off-by: PatrikBuhr --- .../policyagent/clients/SdncOscA1Client.java | 14 +++++- .../policyagent/clients/SdncOscA1ClientTest.java | 25 ++++++++++ .../model/src/main/yang/NONRT-RIC-API.yang | 42 +++++++++++++---- .../northbound/provider/NonrtRicApiProvider.java | 55 ++++++++++++++-------- .../northbound/restadapter/NearRicUrlProvider.java | 23 ++++----- .../sdnc/northbound/NonrtRicApiProviderTest.java | 42 +++++++++++------ 6 files changed, 144 insertions(+), 57 deletions(-) diff --git a/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java b/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java index ac52d6ae..06259c7a 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java @@ -129,7 +129,17 @@ public class SdncOscA1Client implements A1Client { @Override public Mono getPolicyStatus(Policy policy) { - return Mono.error(new Exception("Status not implemented in the SDNC controller")); + SdncOscAdapterInput inputParams = ImmutableSdncOscAdapterInput.builder() // + .nearRtRicUrl(ricConfig.baseUrl()) // + .policyId(policy.id()) // + .build(); + String inputJsonString = JsonHelper.createInputJsonString(inputParams); + logger.debug("POST getPolicyStatus inputJsonString = {}", inputJsonString); + + return restClient + .postWithAuthHeader(URL_PREFIX + "getPolicyStatus", inputJsonString, a1ControllerUsername, + a1ControllerPassword) // + .flatMap(response -> JsonHelper.getValueFromResponse(response, "policy-status")); } private Flux getPolicyIds() { @@ -140,7 +150,7 @@ public class SdncOscA1Client implements A1Client { logger.debug("POST getPolicyIdentities inputJsonString = {}", inputJsonString); return restClient - .postWithAuthHeader("/A1-ADAPTER-API:getPolicyIdentities", inputJsonString, a1ControllerUsername, + .postWithAuthHeader(URL_PREFIX + "getPolicyIdentities", inputJsonString, a1ControllerUsername, a1ControllerPassword) // .flatMap(response -> JsonHelper.getValueFromResponse(response, "policy-id-list")) // .flatMapMany(JsonHelper::parseJsonArrayOfString); diff --git a/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java b/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java index f5b3b251..885db0f6 100644 --- a/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java +++ b/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java @@ -20,6 +20,7 @@ package org.oransc.policyagent.clients; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -34,6 +35,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.stubbing.OngoingStubbing; +import org.oransc.policyagent.repository.Policy; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -237,6 +239,29 @@ public class SdncOscA1ClientTest { CONTROLLER_USERNAME, CONTROLLER_PASSWORD); } + @Test + public void testGetStatus() { + SdncOscAdapterInput inputParams = ImmutableSdncOscAdapterInput.builder() // + .nearRtRicUrl(RIC_1_URL) // + .policyId(POLICY_1_ID) // + .build(); + String inputJsonString = A1ClientHelper.createInputJsonString(inputParams); + + String status = "STATUS"; + Mono policyStatusResp = A1ClientHelper.createOutputJsonResponse("policy-status", status); + whenAsyncPostThenReturn(policyStatusResp); + + Policy policy = A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID); + + String returnedStatus = clientUnderTest.getPolicyStatus(policy).block(); + + assertEquals(status, returnedStatus, "unexpexted status"); + + final String expectedUrl = "/A1-ADAPTER-API:getPolicyStatus"; + verify(asyncRestClientMock).postWithAuthHeader(expectedUrl, inputJsonString, CONTROLLER_USERNAME, + CONTROLLER_PASSWORD); + } + private OngoingStubbing> whenAsyncPostThenReturn(Mono response) { return when(asyncRestClientMock.postWithAuthHeader(anyString(), anyString(), anyString(), anyString())) .thenReturn(response); diff --git a/sdnc-a1-controller/northbound/nonrt-ric-api/model/src/main/yang/NONRT-RIC-API.yang b/sdnc-a1-controller/northbound/nonrt-ric-api/model/src/main/yang/NONRT-RIC-API.yang index 40005d21..a9cf825d 100644 --- a/sdnc-a1-controller/northbound/nonrt-ric-api/model/src/main/yang/NONRT-RIC-API.yang +++ b/sdnc-a1-controller/northbound/nonrt-ric-api/model/src/main/yang/NONRT-RIC-API.yang @@ -23,17 +23,22 @@ module A1-ADAPTER-API { prefix a1-adapter-api; - import ietf-inet-types { prefix "inet"; revision-date "2013-07-15"; } + import ietf-inet-types { + prefix "inet"; + revision-date "2013-07-15"; + } - import ietf-yang-types { prefix yang; } + import ietf-yang-types { + prefix yang; + } revision "2020-01-22" { description - "A1 adapter"; + "A1 adapter"; } - //Get an array of integer policy type ids - //Each item in the returned array will be regarded as one policy-type-id. + // Get an array of integer policy type ids + // Each item in the returned array will be regarded as one policy-type-id. rpc getPolicyTypeIdentities { input { leaf near-rt-ric-url { @@ -48,8 +53,8 @@ module A1-ADAPTER-API { } } - //Get an array of integer policy ids - //Each item in the returned array will be regarded as one policy-id. + // Get an array of integer policy ids + // Each item in the returned array will be regarded as one policy-id. rpc getPolicyIdentities { input { leaf near-rt-ric-url { @@ -64,7 +69,7 @@ module A1-ADAPTER-API { } } - //Get a policy type + // Get a policy type rpc getPolicyType { input { leaf near-rt-ric-url { @@ -81,7 +86,7 @@ module A1-ADAPTER-API { } } - //Create a policy + // Create a policy rpc putPolicy { input { leaf near-rt-ric-url { @@ -104,7 +109,7 @@ module A1-ADAPTER-API { } } - //Delete a policy + // Delete a policy rpc deletePolicy { input { leaf near-rt-ric-url { @@ -115,4 +120,21 @@ module A1-ADAPTER-API { } } } + + // Get a policy status + rpc getPolicyStatus { + input { + leaf near-rt-ric-url { + type string; + } + leaf policy-id { + type string; + } + } + output { + leaf policy-status { + type string; + } + } + } } \ No newline at end of file diff --git a/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/provider/NonrtRicApiProvider.java b/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/provider/NonrtRicApiProvider.java index 95acacb2..7e47b980 100644 --- a/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/provider/NonrtRicApiProvider.java +++ b/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/provider/NonrtRicApiProvider.java @@ -43,6 +43,9 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev20012 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyIdentitiesInput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyIdentitiesOutput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyIdentitiesOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyStatusInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyStatusOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyStatusOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyTypeIdentitiesInput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyTypeIdentitiesOutput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyTypeIdentitiesOutputBuilder; @@ -59,10 +62,10 @@ import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; /** - * Defines a base implementation for your provider. This class overrides the generated interface - * from the YANG model and implements the request model for the A1 interface. This class identifies - * the Near-RIC throught the IP passed over the payload and calls the corresponding Near-RIC over - * Rest API + * Defines a base implementation for your provider. This class overrides the + * generated interface from the YANG model and implements the request model for + * the A1 interface. This class identifies the Near-RIC throught the IP passed + * over the payload and calls the corresponding Near-RIC over Rest API * *
  *
@@ -88,8 +91,7 @@ public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService {
   private RestAdapter restAdapter;
   private NearRicUrlProvider nearRicUrlProvider;
 
-  public NonrtRicApiProvider(DataBroker dataBroker,
-      NotificationPublishService notificationPublishService,
+  public NonrtRicApiProvider(DataBroker dataBroker, NotificationPublishService notificationPublishService,
       RpcProviderRegistry rpcProviderRegistry) {
     log.info("Creating provider for {}", APP_NAME);
     executor = Executors.newFixedThreadPool(1);
@@ -130,8 +132,7 @@ public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService {
   public void setNotificationService(NotificationPublishService notificationService) {
     this.notificationService = notificationService;
     if (log.isDebugEnabled()) {
-      log.debug("Notification Service set to {}",
-          notificationService == null ? NULL_PARAM : NON_NULL_PARAM);
+      log.debug("Notification Service set to {}", notificationService == null ? NULL_PARAM : NON_NULL_PARAM);
     }
   }
 
@@ -159,7 +160,7 @@ public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService {
 
   @Override
   public ListenableFuture> getPolicyTypeIdentities(
-          GetPolicyTypeIdentitiesInput input) {
+      GetPolicyTypeIdentitiesInput input) {
     log.info("Start of getPolicyTypeIdentities");
     GetPolicyTypeIdentitiesOutputBuilder responseBuilder = new GetPolicyTypeIdentitiesOutputBuilder();
     String uri = nearRicUrlProvider.policyTypesUrl(String.valueOf(input.getNearRtRicUrl()));
@@ -185,18 +186,17 @@ public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService {
       responseBuilder.setPolicyIdList(response.getBody());
     }
     log.info("End of getPolicyIdentities");
-    RpcResult rpcResult = RpcResultBuilder
-        .status(true).withResult(responseBuilder.build()).build();
+    RpcResult rpcResult = RpcResultBuilder.status(true)
+        .withResult(responseBuilder.build()).build();
     return Futures.immediateFuture(rpcResult);
   }
 
   @Override
   public ListenableFuture> getPolicyType(GetPolicyTypeInput input) {
-    log.info("Start of getPolicyType");
-    log.info("Policy Type Id : {} ", input.getPolicyTypeId());
+    log.info("Start of getPolicyType; Policy Type Id : {} ", input.getPolicyTypeId());
     GetPolicyTypeOutputBuilder responseBuilder = new GetPolicyTypeOutputBuilder();
     String uri = nearRicUrlProvider.getPolicyTypeUrl(String.valueOf(input.getNearRtRicUrl()),
-            String.valueOf(input.getPolicyTypeId()));
+        String.valueOf(input.getPolicyTypeId()));
     ResponseEntity response = restAdapter.get(uri, String.class);
     if (response.hasBody()) {
       log.info("Response getPolicyType : {} ", response.getBody());
@@ -213,7 +213,7 @@ public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService {
     log.info("Start of putPolicy");
     PutPolicyOutputBuilder responseBuilder = new PutPolicyOutputBuilder();
     String uri = nearRicUrlProvider.putPolicyUrl(String.valueOf(input.getNearRtRicUrl()),
-            String.valueOf(input.getPolicyId()), String.valueOf(input.getPolicyTypeId()));
+        String.valueOf(input.getPolicyId()), String.valueOf(input.getPolicyTypeId()));
     log.info("PUT Request input.getPolicy() : {} ", input.getPolicy());
     ResponseEntity response = restAdapter.put(uri, input.getPolicy(), String.class);
     if (response.hasBody()) {
@@ -221,8 +221,8 @@ public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService {
       responseBuilder.setReturnedPolicy(response.getBody());
     }
     log.info("End of putPolicy");
-    RpcResult rpcResult = RpcResultBuilder
-        .status(true).withResult(responseBuilder.build()).build();
+    RpcResult rpcResult = RpcResultBuilder.status(true)
+        .withResult(responseBuilder.build()).build();
     return Futures.immediateFuture(rpcResult);
   }
 
@@ -231,11 +231,26 @@ public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService {
     log.info("Start of deletePolicy");
     DeletePolicyOutputBuilder responseBuilder = new DeletePolicyOutputBuilder();
     String uri = nearRicUrlProvider.deletePolicyUrl(String.valueOf(input.getNearRtRicUrl()),
-            String.valueOf(input.getPolicyId()));
+        String.valueOf(input.getPolicyId()));
     restAdapter.delete(uri);
     log.info("End of deletePolicy");
-    RpcResult rpcResult = RpcResultBuilder
-        .status(true).withResult(responseBuilder.build()).build();
+    RpcResult rpcResult = RpcResultBuilder.status(true)
+        .withResult(responseBuilder.build()).build();
+    return Futures.immediateFuture(rpcResult);
+  }
+
+  @Override
+  public ListenableFuture> getPolicyStatus(GetPolicyStatusInput input) {
+    log.debug("Policy Id : {} ", input.getPolicyId());
+    GetPolicyStatusOutputBuilder responseBuilder = new GetPolicyStatusOutputBuilder();
+    String uri = nearRicUrlProvider.getPolicyStatusUrl(input.getNearRtRicUrl(), input.getPolicyId());
+    ResponseEntity response = restAdapter.get(uri, String.class);
+    if (response.hasBody()) {
+      log.info("Response getPolicyStatus : {} ", response.getBody());
+      responseBuilder.setPolicyStatus(response.getBody());
+    }
+    RpcResult rpcResult = RpcResultBuilder.status(true)
+        .withResult(responseBuilder.build()).build();
     return Futures.immediateFuture(rpcResult);
   }
 }
diff --git a/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/restadapter/NearRicUrlProvider.java b/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/restadapter/NearRicUrlProvider.java
index b74d1031..c4ca335a 100644
--- a/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/restadapter/NearRicUrlProvider.java
+++ b/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/restadapter/NearRicUrlProvider.java
@@ -49,8 +49,7 @@ public class NearRicUrlProvider {
    * @return the policytypes url
    */
   public String policyTypesUrl(final String nearRtRicUrl) {
-    return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policytypes")
-            .build().toString();
+    return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policytypes").build().toString();
   }
 
   /**
@@ -60,8 +59,7 @@ public class NearRicUrlProvider {
    * @return the policies url
    */
   public String policiesUrl(final String nearRtRicUrl) {
-    return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policies")
-            .build().toString();
+    return UriComponentsBuilder.fromUriString(getBaseUrl(nearRtRicUrl)).pathSegment("policies").build().toString();
   }
 
   /**
@@ -72,32 +70,35 @@ public class NearRicUrlProvider {
    * @return the policy type url
    */
   public String getPolicyTypeUrl(final String nearRtRicUrl, final String policyTypeId) {
-    return UriComponentsBuilder.fromUriString(policyTypesUrl(nearRtRicUrl)).pathSegment(policyTypeId)
-        .build().toString();
+    return UriComponentsBuilder.fromUriString(policyTypesUrl(nearRtRicUrl)).pathSegment(policyTypeId).build()
+        .toString();
   }
 
   /**
    * Retrieve the url of putPolicy
    *
    * @param nearRtRicUrl the near-rt-ric url
-   * @param policyId Policy Id
+   * @param policyId     Policy Id
    * @param policyTypeId Policy Type Id
    * @return the putPolicy url
    */
   public String putPolicyUrl(final String nearRtRicUrl, final String policyId, final String policyTypeId) {
     return UriComponentsBuilder.fromUriString(policiesUrl(nearRtRicUrl))
-            .pathSegment(policyId + "?policyTypeId=" + policyTypeId).build().toString();
+        .pathSegment(policyId + "?policyTypeId=" + policyTypeId).build().toString();
   }
 
   /**
    * Retrieve the url of deletePolicy
    *
    * @param nearRtRicUrl the near-rt-ric url
-   * @param policyId Policy Id
+   * @param policyId     Policy Id
    * @return the deletePolicy url
    */
   public String deletePolicyUrl(final String nearRtRicUrl, final String policyId) {
-    return UriComponentsBuilder.fromUriString(policiesUrl(nearRtRicUrl)).pathSegment(policyId)
-            .build().toString();
+    return UriComponentsBuilder.fromUriString(policiesUrl(nearRtRicUrl)).pathSegment(policyId).build().toString();
+  }
+
+  public String getPolicyStatusUrl(String nearRtRicUrl, String policyId) {
+    return policiesUrl(nearRtRicUrl) + "/" + policyId + "/status";
   }
 }
diff --git a/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/test/java/org/onap/sdnc/northbound/NonrtRicApiProviderTest.java b/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/test/java/org/onap/sdnc/northbound/NonrtRicApiProviderTest.java
index 3dc1efd1..11464071 100644
--- a/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/test/java/org/onap/sdnc/northbound/NonrtRicApiProviderTest.java
+++ b/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/test/java/org/onap/sdnc/northbound/NonrtRicApiProviderTest.java
@@ -42,6 +42,8 @@ import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBro
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyIdentitiesInputBuilder;
 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyIdentitiesOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyStatusInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyStatusOutput;
 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyTypeIdentitiesInputBuilder;
 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyTypeIdentitiesOutput;
 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyTypeInputBuilder;
@@ -78,13 +80,11 @@ public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
   private static String policyTypeId = "STD_QoSNudging_0.1.0";
   private static String policyId = "3d2157af-6a8f-4a7c-810f-38c2f824bf12";
 
-
   @Before
   public void setUp() throws Exception {
     nearRicUrlProvider = new NearRicUrlProvider();
     dataBroker = getDataBroker();
-    nonrtRicApiProvider = new NonrtRicApiProvider(dataBroker, mockNotificationPublishService,
-        mockRpcProviderRegistry);
+    nonrtRicApiProvider = new NonrtRicApiProvider(dataBroker, mockNotificationPublishService, mockRpcProviderRegistry);
   }
 
   @Test
@@ -97,8 +97,8 @@ public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
     policyTypeIdentities.add(policyTypeId);
     ResponseEntity getPolicyTypeIdentitiesResponse = new ResponseEntity<>(policyTypeIdentities, HttpStatus.OK);
     when(restAdapter.get(eq(uri), eq(List.class))).thenReturn(getPolicyTypeIdentitiesResponse);
-    ListenableFuture> result =
-        nonrtRicApiProvider.getPolicyTypeIdentities(inputBuilder.build());
+    ListenableFuture> result = nonrtRicApiProvider
+        .getPolicyTypeIdentities(inputBuilder.build());
     Assert.assertEquals(policyTypeIdentities, result.get().getResult().getPolicyTypeIdList());
   }
 
@@ -112,8 +112,8 @@ public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
     policyIdentities.add(policyId);
     ResponseEntity getPolicyIdentitiesResponse = new ResponseEntity<>(policyIdentities, HttpStatus.OK);
     when(restAdapter.get(eq(uri), eq(List.class))).thenReturn(getPolicyIdentitiesResponse);
-    ListenableFuture> result =
-        nonrtRicApiProvider.getPolicyIdentities(inputBuilder.build());
+    ListenableFuture> result = nonrtRicApiProvider
+        .getPolicyIdentities(inputBuilder.build());
     Assert.assertEquals(policyIdentities, result.get().getResult().getPolicyIdList());
   }
 
@@ -124,12 +124,11 @@ public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
     inputBuilder.setPolicyTypeId(policyTypeId);
     Whitebox.setInternalState(nonrtRicApiProvider, "restAdapter", restAdapter);
     String uri = nearRicUrlProvider.getPolicyTypeUrl(inputBuilder.build().getNearRtRicUrl(),
-            String.valueOf(inputBuilder.build().getPolicyTypeId()));
+        String.valueOf(inputBuilder.build().getPolicyTypeId()));
     String testPolicyType = "{}";
     ResponseEntity getPolicyTypeResponse = new ResponseEntity<>(testPolicyType, HttpStatus.OK);
     when(restAdapter.get(eq(uri), eq(String.class))).thenReturn(getPolicyTypeResponse);
-    ListenableFuture> result =
-        nonrtRicApiProvider.getPolicyType(inputBuilder.build());
+    ListenableFuture> result = nonrtRicApiProvider.getPolicyType(inputBuilder.build());
     Assert.assertEquals(testPolicyType, result.get().getResult().getPolicyType());
   }
 
@@ -142,12 +141,27 @@ public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
     inputBuilder.setPolicyTypeId(policyTypeId);
     inputBuilder.setPolicy(testPolicy);
     Whitebox.setInternalState(nonrtRicApiProvider, "restAdapter", restAdapter);
-    String uri = nearRicUrlProvider.putPolicyUrl(inputBuilder.build().getNearRtRicUrl(),
-            inputBuilder.getPolicyId(), inputBuilder.getPolicyTypeId());
+    String uri = nearRicUrlProvider.putPolicyUrl(inputBuilder.build().getNearRtRicUrl(), inputBuilder.getPolicyId(),
+        inputBuilder.getPolicyTypeId());
     ResponseEntity putPolicyResponse = new ResponseEntity<>(testPolicy, HttpStatus.CREATED);
     when(restAdapter.put(eq(uri), eq(testPolicy), eq(String.class))).thenReturn(putPolicyResponse);
-    ListenableFuture> result =
-        nonrtRicApiProvider.putPolicy(inputBuilder.build());
+    ListenableFuture> result = nonrtRicApiProvider.putPolicy(inputBuilder.build());
     Assert.assertEquals(testPolicy, result.get().getResult().getReturnedPolicy());
   }
+
+  @Test
+  public void testGetPolicyStatus() throws InterruptedException, ExecutionException {
+    GetPolicyStatusInputBuilder inputBuilder = new GetPolicyStatusInputBuilder();
+    inputBuilder.setNearRtRicUrl(nearRtRicUrl);
+    inputBuilder.setPolicyId(policyId);
+    Whitebox.setInternalState(nonrtRicApiProvider, "restAdapter", restAdapter);
+    String uri = nearRicUrlProvider.getPolicyStatusUrl(nearRtRicUrl, policyId);
+    String testPolicyStatus = "STATUS";
+    ResponseEntity getPolicyStatusResponse = new ResponseEntity<>(testPolicyStatus, HttpStatus.OK);
+    when(restAdapter.get(eq(uri), eq(String.class))).thenReturn(getPolicyStatusResponse);
+    ListenableFuture> result = nonrtRicApiProvider
+        .getPolicyStatus(inputBuilder.build());
+    Assert.assertEquals(testPolicyStatus, result.get().getResult().getPolicyStatus());
+  }
+
 }
-- 
2.16.6