Implemented policy get-status 30/2830/3
authorPatrikBuhr <patrik.buhr@est.tech>
Tue, 17 Mar 2020 14:30:40 +0000 (15:30 +0100)
committerPatrikBuhr <patrik.buhr@est.tech>
Wed, 18 Mar 2020 09:44:07 +0000 (10:44 +0100)
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 <patrik.buhr@est.tech>
policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java
policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java
sdnc-a1-controller/northbound/nonrt-ric-api/model/src/main/yang/NONRT-RIC-API.yang
sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/provider/NonrtRicApiProvider.java
sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/restadapter/NearRicUrlProvider.java
sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/test/java/org/onap/sdnc/northbound/NonrtRicApiProviderTest.java

index ac52d6a..06259c7 100644 (file)
@@ -129,7 +129,17 @@ public class SdncOscA1Client implements A1Client {
 
     @Override
     public Mono<String> 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<String> 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);
index f5b3b25..885db0f 100644 (file)
@@ -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<String> 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<Mono<String>> whenAsyncPostThenReturn(Mono<String> response) {
         return when(asyncRestClientMock.postWithAuthHeader(anyString(), anyString(), anyString(), anyString()))
             .thenReturn(response);
index 40005d2..a9cf825 100644 (file)
@@ -23,17 +23,22 @@ module A1-ADAPTER-API {
 \r
     prefix a1-adapter-api;\r
 \r
-    import ietf-inet-types { prefix "inet"; revision-date "2013-07-15"; }\r
+    import ietf-inet-types {\r
+        prefix "inet";\r
+        revision-date "2013-07-15";\r
+    }\r
 \r
-    import ietf-yang-types { prefix yang; }\r
+    import ietf-yang-types {\r
+        prefix yang;\r
+    }\r
 \r
     revision "2020-01-22" {\r
         description\r
-        "A1 adapter";\r
+          "A1 adapter";\r
     }\r
 \r
-    //Get an array of integer policy type ids\r
-    //Each item in the returned array will be regarded as one policy-type-id.\r
+    // Get an array of integer policy type ids\r
+    // Each item in the returned array will be regarded as one policy-type-id.\r
     rpc getPolicyTypeIdentities {\r
         input {\r
             leaf near-rt-ric-url {\r
@@ -48,8 +53,8 @@ module A1-ADAPTER-API {
         }\r
     }\r
 \r
-    //Get an array of integer policy ids\r
-    //Each item in the returned array will be regarded as one policy-id.\r
+    // Get an array of integer policy ids\r
+    // Each item in the returned array will be regarded as one policy-id.\r
     rpc getPolicyIdentities {\r
         input {\r
             leaf near-rt-ric-url {\r
@@ -64,7 +69,7 @@ module A1-ADAPTER-API {
         }\r
     }\r
 \r
-    //Get a policy type\r
+    // Get a policy type\r
     rpc getPolicyType {\r
         input {\r
             leaf near-rt-ric-url {\r
@@ -81,7 +86,7 @@ module A1-ADAPTER-API {
         }\r
     }\r
 \r
-    //Create a policy\r
+    // Create a policy\r
     rpc putPolicy {\r
         input {\r
             leaf near-rt-ric-url {\r
@@ -104,7 +109,7 @@ module A1-ADAPTER-API {
         }\r
     }\r
 \r
-    //Delete a policy\r
+    // Delete a policy\r
     rpc deletePolicy {\r
         input {\r
             leaf near-rt-ric-url {\r
@@ -115,4 +120,21 @@ module A1-ADAPTER-API {
             }\r
         }\r
     }\r
+\r
+    // Get a policy status\r
+    rpc getPolicyStatus {\r
+        input {\r
+            leaf near-rt-ric-url {\r
+                type string;\r
+            }\r
+            leaf policy-id {\r
+                type string;\r
+            }\r
+        }\r
+        output {\r
+            leaf policy-status {\r
+                type string;\r
+            }\r
+        }\r
+    }\r
 }
\ No newline at end of file
index 95acacb..7e47b98 100644 (file)
@@ -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
  *
  * <pre>
  *
@@ -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<RpcResult<GetPolicyTypeIdentitiesOutput>> 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<GetPolicyIdentitiesOutput> rpcResult = RpcResultBuilder
-        .<GetPolicyIdentitiesOutput>status(true).withResult(responseBuilder.build()).build();
+    RpcResult<GetPolicyIdentitiesOutput> rpcResult = RpcResultBuilder.<GetPolicyIdentitiesOutput>status(true)
+        .withResult(responseBuilder.build()).build();
     return Futures.immediateFuture(rpcResult);
   }
 
   @Override
   public ListenableFuture<RpcResult<GetPolicyTypeOutput>> 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<String> 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<String> 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<PutPolicyOutput> rpcResult = RpcResultBuilder
-        .<PutPolicyOutput>status(true).withResult(responseBuilder.build()).build();
+    RpcResult<PutPolicyOutput> rpcResult = RpcResultBuilder.<PutPolicyOutput>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<DeletePolicyOutput> rpcResult = RpcResultBuilder
-        .<DeletePolicyOutput>status(true).withResult(responseBuilder.build()).build();
+    RpcResult<DeletePolicyOutput> rpcResult = RpcResultBuilder.<DeletePolicyOutput>status(true)
+        .withResult(responseBuilder.build()).build();
+    return Futures.immediateFuture(rpcResult);
+  }
+
+  @Override
+  public ListenableFuture<RpcResult<GetPolicyStatusOutput>> getPolicyStatus(GetPolicyStatusInput input) {
+    log.debug("Policy Id : {} ", input.getPolicyId());
+    GetPolicyStatusOutputBuilder responseBuilder = new GetPolicyStatusOutputBuilder();
+    String uri = nearRicUrlProvider.getPolicyStatusUrl(input.getNearRtRicUrl(), input.getPolicyId());
+    ResponseEntity<String> response = restAdapter.get(uri, String.class);
+    if (response.hasBody()) {
+      log.info("Response getPolicyStatus : {} ", response.getBody());
+      responseBuilder.setPolicyStatus(response.getBody());
+    }
+    RpcResult<GetPolicyStatusOutput> rpcResult = RpcResultBuilder.<GetPolicyStatusOutput>status(true)
+        .withResult(responseBuilder.build()).build();
     return Futures.immediateFuture(rpcResult);
   }
 }
index b74d103..c4ca335 100644 (file)
@@ -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";
   }
 }
index 3dc1efd..1146407 100644 (file)
@@ -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<Object> getPolicyTypeIdentitiesResponse = new ResponseEntity<>(policyTypeIdentities, HttpStatus.OK);
     when(restAdapter.get(eq(uri), eq(List.class))).thenReturn(getPolicyTypeIdentitiesResponse);
-    ListenableFuture<RpcResult<GetPolicyTypeIdentitiesOutput>> result =
-        nonrtRicApiProvider.getPolicyTypeIdentities(inputBuilder.build());
+    ListenableFuture<RpcResult<GetPolicyTypeIdentitiesOutput>> 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<Object> getPolicyIdentitiesResponse = new ResponseEntity<>(policyIdentities, HttpStatus.OK);
     when(restAdapter.get(eq(uri), eq(List.class))).thenReturn(getPolicyIdentitiesResponse);
-    ListenableFuture<RpcResult<GetPolicyIdentitiesOutput>> result =
-        nonrtRicApiProvider.getPolicyIdentities(inputBuilder.build());
+    ListenableFuture<RpcResult<GetPolicyIdentitiesOutput>> 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<Object> getPolicyTypeResponse = new ResponseEntity<>(testPolicyType, HttpStatus.OK);
     when(restAdapter.get(eq(uri), eq(String.class))).thenReturn(getPolicyTypeResponse);
-    ListenableFuture<RpcResult<GetPolicyTypeOutput>> result =
-        nonrtRicApiProvider.getPolicyType(inputBuilder.build());
+    ListenableFuture<RpcResult<GetPolicyTypeOutput>> 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<String> putPolicyResponse = new ResponseEntity<>(testPolicy, HttpStatus.CREATED);
     when(restAdapter.put(eq(uri), eq(testPolicy), eq(String.class))).thenReturn(putPolicyResponse);
-    ListenableFuture<RpcResult<PutPolicyOutput>> result =
-        nonrtRicApiProvider.putPolicy(inputBuilder.build());
+    ListenableFuture<RpcResult<PutPolicyOutput>> 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<Object> getPolicyStatusResponse = new ResponseEntity<>(testPolicyStatus, HttpStatus.OK);
+    when(restAdapter.get(eq(uri), eq(String.class))).thenReturn(getPolicyStatusResponse);
+    ListenableFuture<RpcResult<GetPolicyStatusOutput>> result = nonrtRicApiProvider
+        .getPolicyStatus(inputBuilder.build());
+    Assert.assertEquals(testPolicyStatus, result.get().getResult().getPolicyStatus());
+  }
+
 }