diff options
author | Smokowski, Steven <steve.smokowski@att.com> | 2019-04-26 21:10:25 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-04-28 10:40:57 -0400 |
commit | a10606e383ce6c872cb7c95fe1d5e65565827813 (patch) | |
tree | 2c8baf9a0ea897ee884611a332ca61ef9f1bc5ad /adapters/mso-requests-db-adapter/src/test/java | |
parent | 0bb58cfbe91dd7b77178f775df16d873131eb1ef (diff) |
Store Cloud Request in Database
Store Cloud Request in Database, add to request service
Add query Param to Plural to include cloud data
Change-Id: If906d28d0dc9c0c804e550e2074af3d75ba46d32
Issue-ID: SO-1807
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-requests-db-adapter/src/test/java')
2 files changed, 13 insertions, 29 deletions
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java index 514e5ad923..9faba0df67 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java @@ -50,35 +50,10 @@ public class HealthCheckHandlerTest extends RequestsAdapterBase { @Test public void testHealthcheck() throws JSONException { - TestAppender.events.clear(); HttpEntity<String> entity = new HttpEntity<String>(null, headers); - ResponseEntity<String> response = restTemplate.exchange(createURLWithPort("/manage/health"), HttpMethod.GET, entity, String.class); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - for (ILoggingEvent logEvent : TestAppender.events) - if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") - && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) { - Map<String, String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals("INPROGRESS", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - } else if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") - && logEvent.getMarker() != null && logEvent.getMarker() != null - && logEvent.getMarker().getName().equals("EXIT")) { - Map<String, String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - assertEquals("200", mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE)); - assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals("COMPLETED", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - } - TestAppender.events.clear(); } private String createURLWithPort(String uri) { diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java index 3b737c6768..03df115574 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java @@ -25,6 +25,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.requestsdb.RequestsAdapterBase; import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication; +import org.onap.so.db.request.beans.CloudApiRequests; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.OperationStatus; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; @@ -41,9 +42,9 @@ import java.util.Map; import java.util.HashMap; import java.util.ArrayList; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertFalse; @@ -87,6 +88,14 @@ public class RequestsDbClientTest extends RequestsAdapterBase { infraActiveRequests.setRequestAction("someaction"); infraActiveRequests .setRequestUrl("http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances"); + List<CloudApiRequests> cloudApiRequests = new ArrayList<>(); + CloudApiRequests cloudRequest = new CloudApiRequests(); + cloudRequest.setCloudIdentifier("heatstackanme/id"); + cloudRequest.setId(1); + cloudRequest.setRequestBody("requestBody"); + cloudRequest.setRequestId(infraActiveRequests.getRequestId()); + cloudApiRequests.add(cloudRequest); + infraActiveRequests.setCloudApiRequests(cloudApiRequests); requestsDbClient.save(infraActiveRequests); } @@ -96,7 +105,8 @@ public class RequestsDbClientTest extends RequestsAdapterBase { private void verifyInfraActiveRequests(InfraActiveRequests infraActiveRequestsResponse) { - assertThat(infraActiveRequestsResponse, sameBeanAs(infraActiveRequests).ignoring("modifyTime").ignoring("log")); + assertThat(infraActiveRequestsResponse, sameBeanAs(infraActiveRequests).ignoring("modifyTime").ignoring("log") + .ignoring("cloudApiRequests.created").ignoring("cloudApiRequests.id")); } @Test @@ -113,7 +123,6 @@ public class RequestsDbClientTest extends RequestsAdapterBase { verifyInfraActiveRequests(infraActiveRequestsResponse); } - @Test public void checkVnfIdStatusTest() { InfraActiveRequests infraActiveRequestsResponse = @@ -182,7 +191,7 @@ public class RequestsDbClientTest extends RequestsAdapterBase { public void getInfraActiveRequestbyRequestIdWhereRequestUrlNullTest() { // requestUrl setup to null and save infraActiveRequests.setRequestUrl(null); - requestsDbClient.save(infraActiveRequests); + requestsDbClient.updateInfraActiveRequests(infraActiveRequests); InfraActiveRequests infraActiveRequestsResponse = requestsDbClient.getInfraActiveRequestbyRequestId(infraActiveRequests.getRequestId()); verifyInfraActiveRequests(infraActiveRequestsResponse); |