diff options
author | Dan Timoney <dtimoney@att.com> | 2021-10-29 15:04:35 -0400 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2021-10-29 15:04:41 -0400 |
commit | 1267516ac4ce6402a0d175328563d5557fd59c96 (patch) | |
tree | 0ed5d136977ea47f531412fd02941d627e35f03e /adaptors/aai-service/provider/src/test | |
parent | 9bdc825f7b9c1689aae71fcb01bf08aa6bcba995 (diff) |
Sync local changes to support GRA microservice
Sync changes made downstream to support GRA microservice
Issue-ID: CCSDK-3504
Signed-off-by: Dan Timoney <dtimoney@att.com>
Change-Id: I854b5437c4a60023bd161e3625e08ff6e0771945
Diffstat (limited to 'adaptors/aai-service/provider/src/test')
3 files changed, 91 insertions, 0 deletions
diff --git a/adaptors/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutorTest.java b/adaptors/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutorTest.java index f60b2da64..9af277c49 100644 --- a/adaptors/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutorTest.java +++ b/adaptors/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutorTest.java @@ -6,6 +6,8 @@ import java.util.Properties; import org.junit.BeforeClass; import org.junit.Test; +import org.onap.ccsdk.sli.adaptors.aai.update.BulkUpdateRequestItemBody; + import static org.junit.Assert.assertNotNull; public class AAIClientRESTExecutorTest { @@ -94,7 +96,23 @@ public class AAIClientRESTExecutorTest { assertNotNull(nameValues); } + @Test + public void testBulkUpdate() { + + BulkUpdateRequest request = new BulkUpdateRequest(); + BulkUpdateRequestItemBody body = new BulkUpdateRequestItemBody(); + body.setOrchestrationStatus("active"); + + request.addUpdate("patch", "https://localhost/test", body); + + + try { + aaiExecute.bulkUpdate(request); + } catch (AAIServiceException e) { + + } + } @Test public void testLOGwriteFirstTrace() { diff --git a/adaptors/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/GenericVnfTest.java b/adaptors/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/GenericVnfTest.java index a90227cba..0011a296f 100755 --- a/adaptors/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/GenericVnfTest.java +++ b/adaptors/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/GenericVnfTest.java @@ -239,5 +239,11 @@ public class GenericVnfTest { return Boolean.TRUE; } + @Override + public String bulkUpdate(BulkUpdateRequest request) throws AAIServiceException { + + return "success"; + } + } } diff --git a/adaptors/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/update/BulkUpdateRequestDataTest.java b/adaptors/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/update/BulkUpdateRequestDataTest.java new file mode 100644 index 000000000..f26df4cf2 --- /dev/null +++ b/adaptors/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/update/BulkUpdateRequestDataTest.java @@ -0,0 +1,67 @@ +package org.onap.ccsdk.sli.adaptors.aai.update; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.junit.Test; +import org.onap.aai.inventory.v24.Subnet; + +public class BulkUpdateRequestDataTest { + @Test + public void testAddRequestItem() throws JsonProcessingException { + + String action = "patch"; + String uri = "https://localhost/test"; + BulkUpdateRequestItemBody body = new BulkUpdateRequestItemBody(); + body.setOrchestrationStatus("active"); + ObjectMapper mapper = new ObjectMapper(); + + String expectedMessage = "{\"operations\": [ { " + + "\"action\": \"patch\"," + + "\"uri\": \"https://localhost/test\"," + + "\"body\": {" + + "\"orchestration-status\": \"active\"}}]}"; + + // Create an item + BulkUpdateRequestData requestData = new BulkUpdateRequestData(); + + requestData.addRequestItem(action, uri, body); + + // Check jackson mapping + String requestDataStr = mapper.writeValueAsString(requestData); + assertEquals(expectedMessage.replaceAll("\\s", ""), requestDataStr.replaceAll("\\s", "")); + + + } + + @Test + public void testObjectMapperReadValue() throws JsonProcessingException { + String action = "patch"; + String uri = "https://localhost/test"; + BulkUpdateRequestItemBody body = new BulkUpdateRequestItemBody(); + body.setOrchestrationStatus("active"); + ObjectMapper mapper = new ObjectMapper(); + + String valAsString = "{\"operations\": [ { " + + "\"action\": \"patch\"," + + "\"uri\": \"https://localhost/test\"," + + "\"body\": {" + + "\"orchestration-status\": \"active\"}}]}"; + + BulkUpdateRequestData requestData = mapper.readValue(valAsString, BulkUpdateRequestData.class); + + List<BulkUpdateRequestItem> requestItems = requestData.getOperations(); + assertEquals(1, requestItems.size()); + + BulkUpdateRequestItem requestItem = requestItems.get(0); + assertEquals(action, requestItem.getAction()); + assertEquals(uri, requestItem.getUri()); + assertEquals(mapper.writeValueAsString(body).replaceAll("\\s", ""), + mapper.writeValueAsString(requestItem.getBody()).replaceAll("\\s", "")); + + } +} |