summaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-07-27 14:27:11 +0000
committerGerrit Code Review <gerrit@onap.org>2020-07-27 14:27:11 +0000
commit9a5cb7c2ba9ed9c2f8e4589e552b412a6c90bf2b (patch)
tree3d8fe76388aef41f736c8198beccbbc28e3b105e /adapters
parent9356a2e4a92d902e81a961e5327c9611bbd190ac (diff)
parent3bd46f56c2ef44f8197929707434ad7795feb312 (diff)
Merge "Implement getAllProcessingFlags rest query to"
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java32
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java31
2 files changed, 63 insertions, 0 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
index f283af1ba6..aa039c6ac4 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
@@ -655,4 +655,36 @@ public class CatalogDbAdapterRest {
return Response.status(HttpStatus.SC_NOT_FOUND).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.build();
}
+
+ @GET
+ @Path("processingFlags")
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ @Transactional(readOnly = true)
+ public Response getAllProcessingFlags() {
+ return getAllProcessingFlagsImpl();
+ }
+
+ public Response getAllProcessingFlagsImpl() {
+ List<ProcessingFlags> processingFlags = null;
+
+ int respStatus = HttpStatus.SC_OK;
+ try {
+ processingFlags = processingFlagsRepo.findAll();
+ if (processingFlags == null) {
+ logger.debug("ProcessingFlags not found");
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ } else {
+
+ logger.debug("ProcessingFlags processingFlags = {}", processingFlags.toString());
+ }
+ return Response.status(respStatus).entity(processingFlags)
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
+ } catch (Exception e) {
+ logger.error("Exception - queryProcesssingFlags", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
+ CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {}).build();
+ }
+ }
}
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;
@@ -831,6 +834,34 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
}
@Test
+ public void testGetAllProcessingFlags() 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));
+
+ ResponseEntity<String> response =
+ restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+ ObjectMapper mapper = new ObjectMapper();
+
+ List<ProcessingFlags> processingFlagsResponse =
+ mapper.readValue(response.getBody(), new TypeReference<List<ProcessingFlags>>() {});
+
+ 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();
updatedProcessingFlag.setFlag("TESTFLAG");