From 3bd46f56c2ef44f8197929707434ad7795feb312 Mon Sep 17 00:00:00 2001 From: "Kuleshov, Elena" Date: Fri, 24 Jul 2020 13:52:22 -0400 Subject: Implement getAllProcessingFlags rest query to Implement getAllProcessingFlags rest query to catalog DB. Remove debug printout from the JUnit test. Issue-ID: SO-3097 Signed-off-by: Benjamin, Max (mb388a) Change-Id: Icc2f7de1600a39d0c2d2a964e9df84ec9237a157 --- .../catalogdb/catalogrest/CatalogDBRestTest.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'adapters/mso-catalog-db-adapter/src/test/java/org') 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 04161e9df9..3906229c2c 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 @@ -21,7 +21,9 @@ package org.onap.so.adapters.catalogdb.catalogrest; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.util.List; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.json.JSONException; @@ -37,6 +39,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.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -830,6 +833,34 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { assertEquals(processingFlagsResponse.getDescription(), "TEST FLAG"); } + @Test + public void testGetAllProcessingFlags() throws Exception { + HttpEntity entity = new HttpEntity(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = + UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)); + + ResponseEntity response = + restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + ObjectMapper mapper = new ObjectMapper(); + + List processingFlagsResponse = + mapper.readValue(response.getBody(), new TypeReference>() {}); + + boolean testFlagFound = false; + for (int i = 0; i < processingFlagsResponse.size(); i++) { + if (processingFlagsResponse.get(i).getFlag().equals("TESTFLAG")) { + assertEquals(processingFlagsResponse.get(i).getEndpoint(), "TESTENDPOINT"); + assertEquals(processingFlagsResponse.get(i).getDescription(), "TEST FLAG"); + testFlagFound = true; + } + } + assertTrue(testFlagFound); + } + @Test public void testSetProcessingFlagsFlagValue() throws JSONException { ProcessingFlags updatedProcessingFlag = new ProcessingFlags(); -- cgit 1.2.3-korg