diff options
author | Kuleshov, Elena <evn@att.com> | 2020-04-16 11:02:28 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2020-04-16 11:02:29 -0400 |
commit | d255e437b624bb88eab336b1c0b74372e821e99c (patch) | |
tree | 2c76c81fb8d87a8b5ea5265bff1f451a82a73e50 /adapters/mso-catalog-db-adapter/src/test/java | |
parent | b0f5ac59c297f81b7f17c1f367e64257ef7be2d2 (diff) |
Implement processing_flags table and corresponding
Implement processing_flags table and corresponding interfaces.
Implement rest interface for processingFlags table to toggle the value.
Correct hashcode calculation for ProcessingFlags bean.
Use newFabricConfigurationApi flag for managing FabricConfiguration BB
logic.
Remove readOnly specification from updating the processing_flags table
Make sure update_timestamp field updates automatically.
Issue-ID: SO-2814
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I00697f8edf62c2d3d725daa710c17f03595eac51
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/test/java')
2 files changed, 50 insertions, 0 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java index 69a23a0eba..04161e9df9 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java @@ -27,6 +27,7 @@ import javax.ws.rs.core.Response; import org.json.JSONException; import org.junit.Test; import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest; +import org.onap.so.db.catalog.beans.ProcessingFlags; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; @@ -36,6 +37,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; +import com.fasterxml.jackson.databind.ObjectMapper; public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { @@ -55,6 +57,8 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources"; + private static final String ECOMP_MSO_CATALOG_PROCESSING_FLAGS = "ecomp/mso/catalog/v2/processingFlags"; + TestRestTemplate restTemplate = new TestRestTemplate("test", "test"); HttpHeaders headers = new HttpHeaders(); @@ -805,6 +809,44 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value()); } + @Test + public void testGetProcessingFlagsByFlag() throws Exception { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder + .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)).pathSegment("TESTFLAG"); + + ResponseEntity<String> response = + restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + ObjectMapper mapper = new ObjectMapper(); + ProcessingFlags processingFlagsResponse = mapper.readValue(response.getBody(), ProcessingFlags.class); + + assertEquals(processingFlagsResponse.getFlag(), "TESTFLAG"); + assertEquals(processingFlagsResponse.getValue(), "NO"); + assertEquals(processingFlagsResponse.getEndpoint(), "TESTENDPOINT"); + assertEquals(processingFlagsResponse.getDescription(), "TEST FLAG"); + } + + @Test + public void testSetProcessingFlagsFlagValue() throws JSONException { + ProcessingFlags updatedProcessingFlag = new ProcessingFlags(); + updatedProcessingFlag.setFlag("TESTFLAG"); + updatedProcessingFlag.setValue("YES"); + HttpEntity<ProcessingFlags> entity = new HttpEntity<ProcessingFlags>(updatedProcessingFlag, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder + .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)).pathSegment("TESTFLAG"); + + ResponseEntity<String> response = + restTemplate.exchange(builder.toUriString(), HttpMethod.PUT, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + } + private String createURLWithPort(String uri) { return "http://localhost:" + port + uri; } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index 03ef24ded0..d6f2c6dbcc 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -43,6 +43,7 @@ import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.PnfResource; import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.beans.ProcessingFlags; import org.onap.so.db.catalog.beans.ServerType; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceRecipe; @@ -771,5 +772,12 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { } + @Test + public void testGetProcessingFlagsFromFlag() { + ProcessingFlags processingFlags = client.findProcessingFlagsByFlag("TESTFLAG"); + assertNotNull(processingFlags); + assertEquals(processingFlags.getEndpoint(), "TESTENDPOINT"); + } + } |