diff options
author | arul.nambi <arul.nambi@amdocs.com> | 2017-09-01 13:18:55 -0400 |
---|---|---|
committer | arul.nambi <arul.nambi@amdocs.com> | 2017-09-01 13:19:10 -0400 |
commit | 02b460468fe94e344c357af9d98e40640474be62 (patch) | |
tree | 12ff1cb8d761d4d64034b51b80523f104f418ca2 /src | |
parent | 1ab4d44603a91a84a34e34b5fc896fe8a227bca4 (diff) |
[AAI-259] Changing self link
Issure-ID: AAI-259
Change-Id: Iceab79a87852579b732f2d2c03dd0cb19e6c6814
Signed-off-by: arul.nambi <arul.nambi@amdocs.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/openecomp/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java | 18 | ||||
-rw-r--r-- | src/test/java/org/openecomp/sparky/dal/aai/config/ActiveInventoryConfigTest.java | 31 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/main/java/org/openecomp/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java b/src/main/java/org/openecomp/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java index 763842c..aa50443 100644 --- a/src/main/java/org/openecomp/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java +++ b/src/main/java/org/openecomp/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java @@ -75,7 +75,25 @@ public class PerformNodeSelfLinkProcessingTask implements Supplier<NodeProcessin txn.setOpResult(opResult); return txn; } + /** + * Rebuild the self link: + * + * <li>build the base url with the configured scheme + authority (server:port) + * <li>recombine baseUrl + originalEncodedLink + queryStringParameters + * + */ + final String urlSchemeAndAuthority = aaiConfig.repairSelfLink(""); + + String parameters = txn.getRequestParameters(); + link = urlSchemeAndAuthority + link; + + if (parameters != null) { + link += parameters; + } + + + if (logger.isDebugEnabled()) { logger.debug(AaiUiMsgs.DEBUG_GENERIC, "Collecting " + link); } diff --git a/src/test/java/org/openecomp/sparky/dal/aai/config/ActiveInventoryConfigTest.java b/src/test/java/org/openecomp/sparky/dal/aai/config/ActiveInventoryConfigTest.java index 483c792..be51f74 100644 --- a/src/test/java/org/openecomp/sparky/dal/aai/config/ActiveInventoryConfigTest.java +++ b/src/test/java/org/openecomp/sparky/dal/aai/config/ActiveInventoryConfigTest.java @@ -179,4 +179,35 @@ public class ActiveInventoryConfigTest { assertEquals("https://aai-host:9191/aai/v10/business/customers/customer/1234", config.repairSelfLink("/aai/v10/business/customers/customer/1234")); } + + @Test + public void validateResourcePathExtraction() throws Exception { + // https with API version + assertEquals("/aai/v10/business/customers/customer/1234", ActiveInventoryConfig + .extractResourcePath("https://aai-host:9191/aai/v10/business/customers/customer/1234")); + + // https without API version + assertEquals("/business/customers/customer/1234", ActiveInventoryConfig + .extractResourcePath("https://aai-host:9191/business/customers/customer/1234")); + + // http with API version + assertEquals("/aai/v10/business/customers/customer/1234", ActiveInventoryConfig + .extractResourcePath("http://aai-host:9191/aai/v10/business/customers/customer/1234")); + + // http without API verison + assertEquals("/business/customers/customer/1234", ActiveInventoryConfig + .extractResourcePath("http://aai-host:9191/business/customers/customer/1234")); + + // no scheme, host, or port + assertEquals("business/customers/customer/1234", ActiveInventoryConfig + .extractResourcePath("business/customers/customer/1234")); + + // no scheme, host, or port with API version + assertEquals("/aai/v10/business/customers/customer/1234", ActiveInventoryConfig + .extractResourcePath("/aai/v10/business/customers/customer/1234")); + + // no scheme, host, or port with API version + assertEquals("", ActiveInventoryConfig + .extractResourcePath("")); + } }
\ No newline at end of file |