From: Determe, Sebastien (sd378r) Date: Thu, 14 Sep 2017 14:11:00 +0000 (+0200) Subject: Add new tests for DAO X-Git-Tag: v1.1.0~74^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=fbe35388ec1841b8a75fb054d2fc809b901c11aa;hp=-c;p=clamp.git Add new tests for DAO New test to validate some methods of the DAO and attempt to disable Camunda in IT when it was not required to have it Change-Id: I231230a7a4818f4bfd7887319a321625f66ffcae Issue-ID: CLAMP-54 Signed-off-by: Determe, Sebastien (sd378r) --- fbe35388ec1841b8a75fb054d2fc809b901c11aa diff --git a/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java b/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java index 87f9c0c4..e6e7325a 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java @@ -49,7 +49,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.xml.transform.TransformerException; -import org.camunda.bpm.engine.RuntimeService; import org.onap.clamp.clds.dao.CldsDao; import org.onap.clamp.clds.model.CldsTemplate; import org.onap.clamp.clds.model.ValueItem; @@ -90,8 +89,7 @@ public class CldsTemplateService extends SecureServiceBase { @Autowired private CldsDao cldsDao; - @Autowired - private RuntimeService runtimeService; + @Autowired private XslTransformer cldsBpmnTransformer; diff --git a/src/test/java/org/onap/clamp/clds/it/CldsDaoIT.java b/src/test/java/org/onap/clamp/clds/it/CldsDaoIT.java new file mode 100644 index 00000000..bd419647 --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/it/CldsDaoIT.java @@ -0,0 +1,149 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.it; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import javax.ws.rs.NotFoundException; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.clamp.clds.AbstractIT; +import org.onap.clamp.clds.dao.CldsDao; +import org.onap.clamp.clds.model.CldsEvent; +import org.onap.clamp.clds.model.CldsModel; +import org.onap.clamp.clds.model.CldsTemplate; +import org.onap.clamp.clds.util.ResourceFileUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * Test CldsDAO calls through CldsModel and CldsEvent. This really test the DB + * and stored procedures. + */ +@RunWith(SpringRunner.class) +@SpringBootTest +@TestPropertySource(locations = "classpath:application-no-camunda.properties") +public class CldsDaoIT extends AbstractIT { + + @Autowired + public CldsDao cldsDao; + + private String bpmnText; + private String imageText; + private String bpmnPropText; + + @Before + public void setupBefore() throws IOException { + bpmnText = ResourceFileUtil.getResourceAsString("example/dao/bpmn-template.xml"); + imageText = ResourceFileUtil.getResourceAsString("example/dao/image-template.xml"); + bpmnPropText = ResourceFileUtil.getResourceAsString("example/dao/bpmn-prop.json"); + } + + @Test + public void testModelSave() throws IOException { + // Add the template first + CldsTemplate newTemplate = new CldsTemplate(); + newTemplate.setName("test-template"); + + newTemplate.setBpmnText(bpmnText); + newTemplate.setImageText(imageText); + + // Save the template in DB + cldsDao.setTemplate(newTemplate, "user"); + // Test if it's well there + CldsTemplate newTemplateRead = cldsDao.getTemplate("test-template"); + assertEquals(bpmnText, newTemplateRead.getBpmnText()); + assertEquals(imageText, newTemplateRead.getImageText()); + + // Save the model + CldsModel newModel = new CldsModel(); + newModel.setName("test-model"); + + newModel.setBpmnText(bpmnText); + newModel.setImageText(imageText); + newModel.setPropText(bpmnPropText); + newModel.setControlNamePrefix("ClosedLoop-"); + newModel.setTemplateName("test-template"); + newModel.setTemplateId(newTemplate.getId()); + newModel.setDocText(newTemplate.getPropText()); + newModel.setDocId(newTemplate.getPropId()); + // Save the model in DB + cldsDao.setModel(newModel, "user"); + // Test if the model can be retrieved + CldsModel newCldsModel = cldsDao.getModelTemplate("test-model"); + assertEquals(bpmnText, newCldsModel.getBpmnText()); + assertEquals(imageText, newCldsModel.getImageText()); + assertEquals(bpmnPropText, newCldsModel.getPropText()); + + } + + @Test(expected = NotFoundException.class) + public void testGetModelNotFound() { + CldsModel.retrieve(cldsDao, "test-model-not-found", false); + } + + @Test(expected = NotFoundException.class) + public void testGetTemplateNotFound() { + CldsTemplate.retrieve(cldsDao, "test-template-not-found", false); + } + + @Test + public void testInsEvent() { + // Add the template first + CldsTemplate newTemplate = new CldsTemplate(); + newTemplate.setName("test-template-for-event"); + + newTemplate.setBpmnText(bpmnText); + newTemplate.setImageText(imageText); + + newTemplate.save(cldsDao, "user"); + + // Test if it's well there + CldsTemplate newTemplateRead = CldsTemplate.retrieve(cldsDao, "test-template-for-event", false); + assertEquals(bpmnText, newTemplateRead.getBpmnText()); + assertEquals(imageText, newTemplateRead.getImageText()); + + // Save the model + CldsModel newModel = new CldsModel(); + newModel.setName("test-model-for-event"); + + newModel.setBpmnText(bpmnText); + newModel.setImageText(imageText); + newModel.setPropText(bpmnPropText); + newModel.setControlNamePrefix("ClosedLoop-"); + newModel.setTemplateName("test-template-for-event"); + newModel.setTemplateId(newTemplate.getId()); + newModel.setDocText(newTemplate.getPropText()); + newModel.setDocId(newTemplate.getPropId()); + + CldsEvent.insEvent(cldsDao, newModel, "user", CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_COMPLETED, + "process-instance-id"); + } +} diff --git a/src/test/java/org/onap/clamp/clds/it/DcaeIT.java b/src/test/java/org/onap/clamp/clds/it/DcaeIT.java index fc13270c..4f0ebb4e 100644 --- a/src/test/java/org/onap/clamp/clds/it/DcaeIT.java +++ b/src/test/java/org/onap/clamp/clds/it/DcaeIT.java @@ -25,7 +25,6 @@ package org.onap.clamp.clds.it; import org.junit.Test; import org.junit.runner.RunWith; - import org.onap.clamp.clds.AbstractIT; import org.onap.clamp.clds.client.req.DcaeReq; import org.onap.clamp.clds.model.CldsEvent; @@ -33,13 +32,16 @@ import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.util.ResourceFileUtil; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; /** - * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE Delegates in test. + * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE + * Delegates in test. */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = "classpath:application-no-camunda.properties") public class DcaeIT extends AbstractIT { @Test @@ -49,8 +51,8 @@ public class DcaeIT extends AbstractIT { String modelName = "example-model"; String controlName = "ClosedLoop-FRWL-SIG-1582f840-2881-11e6-b4ec-005056a9d756"; - ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, - true, modelBpmnProp, modelProp); + ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, + modelProp); String dcaeReq = DcaeReq.format(refProp, prop); System.out.println("dcaeReq=" + dcaeReq); diff --git a/src/test/java/org/onap/clamp/clds/it/HttpsIT.java b/src/test/java/org/onap/clamp/clds/it/HttpsIT.java index ff630330..98319b41 100644 --- a/src/test/java/org/onap/clamp/clds/it/HttpsIT.java +++ b/src/test/java/org/onap/clamp/clds/it/HttpsIT.java @@ -50,8 +50,7 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.client.RestTemplate; /** - * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE - * Delegates in test. + * Test HTTP and HTTPS settings + redirection of HTTP to HTTPS. */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java index 69df9721..09f1efef 100644 --- a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java +++ b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java @@ -48,6 +48,7 @@ import org.onap.policy.api.AttributeType; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; /** @@ -56,6 +57,7 @@ import org.springframework.test.context.junit4.SpringRunner; */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = "classpath:application-no-camunda.properties") public class PolicyClientIT extends AbstractIT { String modelProp; String modelBpmnProp; diff --git a/src/test/java/org/onap/clamp/clds/it/PropJsonBuilderIT.java b/src/test/java/org/onap/clamp/clds/it/PropJsonBuilderIT.java index c3b35eec..525f9cb3 100644 --- a/src/test/java/org/onap/clamp/clds/it/PropJsonBuilderIT.java +++ b/src/test/java/org/onap/clamp/clds/it/PropJsonBuilderIT.java @@ -39,6 +39,7 @@ import org.onap.clamp.clds.client.req.SdcReq; import org.onap.clamp.clds.model.CldsSdcServiceDetail; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; /** @@ -49,9 +50,10 @@ import org.springframework.test.context.junit4.SpringRunner; */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = "classpath:application-no-camunda.properties") public class PropJsonBuilderIT extends AbstractIT { - private String globalPropsPartial; + private String globalPropsPartial; private ObjectMapper mapper; /** @@ -86,8 +88,8 @@ public class PropJsonBuilderIT extends AbstractIT { private void sampleJsonObject() throws JsonProcessingException { /** - * Create three JSON Objects objectNode1, objectNode2, objectNode3. - * Add all these three objects in the array + * Create three JSON Objects objectNode1, objectNode2, objectNode3. Add + * all these three objects in the array */ ObjectNode objectNode1 = mapper.createObjectNode(); objectNode1.put("bookName", "Java"); @@ -124,9 +126,8 @@ public class PropJsonBuilderIT extends AbstractIT { private String createEmptySharedObject() throws JsonProcessingException { /** - * Empty Object initialization. - * "": { "vf": { "": "" }, "location": { "": "" }, "alarmCondition": { - * "": "" } } + * Empty Object initialization. "": { "vf": { "": "" }, "location": { + * "": "" }, "alarmCondition": { "": "" } } */ ObjectNode emptyObjectNode = mapper.createObjectNode(); emptyObjectNode.put("", ""); @@ -144,8 +145,8 @@ public class PropJsonBuilderIT extends AbstractIT { emptyServiceObjectNode.putPOJO("", samArrayNode); /** - * Object initialization. - * "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": "DCAE_CLAMP_DEMO3" } + * Object initialization. "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": + * "DCAE_CLAMP_DEMO3" } * */ ObjectNode dcaeClampDemo3Node = mapper.createObjectNode(); @@ -157,9 +158,8 @@ public class PropJsonBuilderIT extends AbstractIT { vfObjectNode2.putPOJO("vf", vfArrayNode); /** - * Object initialization. - * "location": { "SNDGCA64": "San Diego SAN3", "ALPRGAED": - * "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" }, + * Object initialization. "location": { "SNDGCA64": "San Diego SAN3", + * "ALPRGAED": "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" }, */ ObjectNode sandiegoLocationNode = mapper.createObjectNode(); sandiegoLocationNode.put("SNDGCA64", "San Diego SAN3"); @@ -173,10 +173,10 @@ public class PropJsonBuilderIT extends AbstractIT { locationObjectNode2.putPOJO("location", locationArrayNode); /** - * Object initialization. - * "alarmCondition": { "A+Fallback+Operation+will+soon+be+started": - * "A Fallback Operation will soon be started", - * "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto Export Backup Failed", + * Object initialization. "alarmCondition": { + * "A+Fallback+Operation+will+soon+be+started": "A Fallback Operation + * will soon be started", "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto + * Export Backup Failed", */ ObjectNode alamrCondition1 = mapper.createObjectNode(); alamrCondition1.put("A+Fallback+Operation+will+soon+be+started", "A Fallback Operation will soon be started"); @@ -206,8 +206,7 @@ public class PropJsonBuilderIT extends AbstractIT { byServiceBasicObjetNode.putPOJO("byService", byServiceBasicArrayNode); /** - * Object initialization. - * "byVf": { "": { "vfc": { "": "" }, + * Object initialization. "byVf": { "": { "vfc": { "": "" }, * "03596c12-c7e3-44b7-8994-5cdfeda8afdd": { "vfc": { " ": " " } } } } */ ObjectNode vfCObjectNode = mapper.createObjectNode(); @@ -240,9 +239,8 @@ public class PropJsonBuilderIT extends AbstractIT { private String createTestEmptySharedObject() throws IOException { /** - * Object initialization. - * "": { "vf": { "": "" }, "location": { "": "" }, "alarmCondition": { - * "": "" } } + * Object initialization. "": { "vf": { "": "" }, "location": { "": "" + * }, "alarmCondition": { "": "" } } */ ObjectNode emptyObjectNode = mapper.createObjectNode(); emptyObjectNode.put("", ""); @@ -254,8 +252,8 @@ public class PropJsonBuilderIT extends AbstractIT { emptyServiceObjectNode.putPOJO("", vfObjectNode); /** - * Object initialization. - * "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": "DCAE_CLAMP_DEMO3" } + * Object initialization. "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": + * "DCAE_CLAMP_DEMO3" } * */ ObjectNode vfObjectNode2 = mapper.createObjectNode(); @@ -265,9 +263,8 @@ public class PropJsonBuilderIT extends AbstractIT { vfObjectNode2.putPOJO("vf", dcaeClampDemo3Node); /** - * Object initialization. - * "location": { "SNDGCA64": "San Diego SAN3", "ALPRGAED": - * "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" }, + * Object initialization. "location": { "SNDGCA64": "San Diego SAN3", + * "ALPRGAED": "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" }, */ // ObjectNode sandiegoLocationNode = mapper.createObjectNode(); // sandiegoLocationNode.put("SNDGCA64","San Diego SAN3"); @@ -277,10 +274,10 @@ public class PropJsonBuilderIT extends AbstractIT { vfObjectNode2.putPOJO("location", locationJsonNode); /** - * Object initialization. - * "alarmCondition": { "A+Fallback+Operation+will+soon+be+started": - * "A Fallback Operation will soon be started", - * "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto Export Backup Failed", + * Object initialization. "alarmCondition": { + * "A+Fallback+Operation+will+soon+be+started": "A Fallback Operation + * will soon be started", "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto + * Export Backup Failed", */ // ObjectNode alamrCondition1 = mapper.createObjectNode(); // alamrCondition1.put("A+Fallback+Operation+will+soon+be+started","A @@ -295,8 +292,7 @@ public class PropJsonBuilderIT extends AbstractIT { byServiceBasicObjetNode.putPOJO("byService", emptyServiceObjectNode); /** - * Object initialization. - * "byVf": { "": { "vfc": { "": "" }, + * Object initialization. "byVf": { "": { "vfc": { "": "" }, * "03596c12-c7e3-44b7-8994-5cdfeda8afdd": { "vfc": { " ": " " } } } } */ ObjectNode vfCObjectNode = mapper.createObjectNode(); @@ -316,9 +312,8 @@ public class PropJsonBuilderIT extends AbstractIT { private String createCldsSharedObject(CldsSdcServiceDetail CldsSdcServiceDetail) throws IOException { /** - * Object initialization. - * "": { "vf": { "": "" }, "location": { "": "" }, "alarmCondition": { - * "": "" } } + * Object initialization. "": { "vf": { "": "" }, "location": { "": "" + * }, "alarmCondition": { "": "" } } */ ObjectNode emptyObjectNode = mapper.createObjectNode(); emptyObjectNode.put("", ""); @@ -330,8 +325,8 @@ public class PropJsonBuilderIT extends AbstractIT { emptyServiceObjectNode.putPOJO("", vfObjectNode); /** - * Object initialization. - * "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": "DCAE_CLAMP_DEMO3" } + * Object initialization. "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": + * "DCAE_CLAMP_DEMO3" } * */ ObjectNode vfObjectNode2 = mapper.createObjectNode(); @@ -341,9 +336,8 @@ public class PropJsonBuilderIT extends AbstractIT { vfObjectNode2.putPOJO("vf", dcaeClampDemo3Node); /** - * Object initialization. - * "location": { "SNDGCA64": "San Diego SAN3", "ALPRGAED": - * "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" }, + * Object initialization. "location": { "SNDGCA64": "San Diego SAN3", + * "ALPRGAED": "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" }, */ ObjectNode sandiegoLocationNode = mapper.createObjectNode(); sandiegoLocationNode.put("SNDGCA64", "San Diego SAN3"); @@ -351,10 +345,10 @@ public class PropJsonBuilderIT extends AbstractIT { vfObjectNode2.putPOJO("location", sandiegoLocationNode); /** - * Object initialization. - * "alarmCondition": { "A+Fallback+Operation+will+soon+be+started": - * "A Fallback Operation will soon be started", - * "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto Export Backup Failed", + * Object initialization. "alarmCondition": { + * "A+Fallback+Operation+will+soon+be+started": "A Fallback Operation + * will soon be started", "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto + * Export Backup Failed", */ ObjectNode alamrCondition1 = mapper.createObjectNode(); alamrCondition1.put("A+Fallback+Operation+will+soon+be+started", "A Fallback Operation will soon be started"); @@ -365,8 +359,7 @@ public class PropJsonBuilderIT extends AbstractIT { byServiceBasicObjetNode.putPOJO("byService", emptyServiceObjectNode); /** - * Object initialization. - * "byVf": { "": { "vfc": { "": "" }, + * Object initialization. "byVf": { "": { "vfc": { "": "" }, * "03596c12-c7e3-44b7-8994-5cdfeda8afdd": { "vfc": { " ": " " } } } } */ diff --git a/src/test/java/org/onap/clamp/clds/it/RefPropIT.java b/src/test/java/org/onap/clamp/clds/it/RefPropIT.java index c6a5de29..473ce4a2 100644 --- a/src/test/java/org/onap/clamp/clds/it/RefPropIT.java +++ b/src/test/java/org/onap/clamp/clds/it/RefPropIT.java @@ -32,6 +32,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.AbstractIT; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; /** @@ -39,12 +40,14 @@ import org.springframework.test.context.junit4.SpringRunner; */ @RunWith(SpringRunner.class) @SpringBootTest +@TestPropertySource(locations = "classpath:application-no-camunda.properties") public class RefPropIT extends AbstractIT { /** * Test getting prop value as a JSON Node / template. * - * @throws IOException when JSON parsing fails + * @throws IOException + * when JSON parsing fails */ @Test public void testJsonTemplate() throws IOException { diff --git a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java index 2995b6c8..dce6c901 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java @@ -41,14 +41,15 @@ import org.onap.clamp.clds.model.CldsSdcServiceInfo; import org.onap.clamp.clds.model.CldsServiceData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; /** - * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE - * Delegates in test. + * Test SDC Catalog Service class by mocking the SDC answers. */ @RunWith(SpringRunner.class) @SpringBootTest +@TestPropertySource(locations = "classpath:application-no-camunda.properties") public class SdcCatalogServicesIT extends AbstractIT { @Autowired private SdcCatalogServices sdcCatalogWired = new SdcCatalogServices(); diff --git a/src/test/java/org/onap/clamp/clds/it/SdcIT.java b/src/test/java/org/onap/clamp/clds/it/SdcIT.java index da9e5af7..025420ff 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcIT.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcIT.java @@ -26,7 +26,6 @@ package org.onap.clamp.clds.it; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; - import org.onap.clamp.clds.AbstractIT; import org.onap.clamp.clds.client.SdcCatalogServices; import org.onap.clamp.clds.client.req.SdcReq; @@ -36,16 +35,18 @@ import org.onap.clamp.clds.model.refprop.RefProp; import org.onap.clamp.clds.util.ResourceFileUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; /** - * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE Delegates in test. + * Test SDC Blueprint formater. */ @RunWith(SpringRunner.class) @SpringBootTest +@TestPropertySource(locations = "classpath:application-no-camunda.properties") public class SdcIT extends AbstractIT { @Autowired - private RefProp refProp; + private RefProp refProp; @Autowired private SdcCatalogServices sdcCatalogServices; @@ -62,14 +63,13 @@ public class SdcIT extends AbstractIT { String modelName = "example-model06"; String controlName = "ClosedLoop-FRWL-SIG04-1582f840-test-test-1234-005056a9d756"; String docText = ResourceFileUtil.getResourceAsString("example/templateProp.json"); - ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, - true, modelBpmnProp, modelProp); + ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, + modelProp); String blueprint = SdcReq.formatBlueprint(refProp, prop, docText); System.out.println("blueprint=" + blueprint); - //assertEquals(blueprint, ""); + // assertEquals(blueprint, ""); } - @Test public void testTcaBlueprint() throws Exception { String modelProp = ResourceFileUtil.getResourceAsString("example/modelPropForPolicy.json"); @@ -77,10 +77,10 @@ public class SdcIT extends AbstractIT { String modelName = "example-model06"; String controlName = "ClosedLoop-FRWL-SIG04-1582f840-test-test-1234-005056a9d756"; String docText = ResourceFileUtil.getResourceAsString("example/templatePropForTca.json"); - ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, - true, modelBpmnProp, modelProp); + ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, + modelProp); String blueprint = SdcReq.formatBlueprint(refProp, prop, docText); System.out.println("blueprint=" + blueprint); - //assertEquals(blueprint, ""); + // assertEquals(blueprint, ""); } } diff --git a/src/test/resources/application-no-camunda.properties b/src/test/resources/application-no-camunda.properties new file mode 100644 index 00000000..dbf0e5ba --- /dev/null +++ b/src/test/resources/application-no-camunda.properties @@ -0,0 +1,158 @@ +### +# ============LICENSE_START======================================================= +# ONAP CLAMP +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights +# reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END============================================ +# =================================================================== +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +### + +info.build.artifact=@project.artifactId@ +info.build.name=@project.name@ +info.build.description=@project.description@ +info.build.version=@project.version@ + +### Set the port for HTTP or HTTPS protocol (Controlled by Spring framework, only one at a time). +### (See below for the parameter 'server.http.port' if you want to have both enabled) +### To have only HTTP, keep the lines server.ssl.* commented +### To have only HTTPS enabled, uncomment the server.ssl.* lines and specify a right keystore location +server.port=10443 +### Settings for HTTPS (this automatically enables the HTTPS on the port 'server.port') +server.ssl.key-store=classpath:https/keystore-test.jks +server.ssl.key-store-password=testpass +server.ssl.key-password=testpass + +### In order to be user friendly when HTTPS is enabled, +### you can add another HTTP port that will be automatically redirected to HTTPS +### by enabling this parameter (server.http.port) and set it to another port (80 or 8080, 8090, etc ...) +#server.http-to-https-redirection.port=10080 + +### HTTP Example: +###-------------- +### server.port=8080 + +### HTTPS Example: +### -------------- +### server.port=8443 +### server.ssl.key-store=file:/tmp/mykey.jks +### server.ssl.key-store-password=mypass +### server.ssl.key-password=mypass + +### HTTP (Redirected to HTTPS) and HTTPS Example: +### -------------------------------------------- +### server.port=8443 <-- The HTTPS port +### server.ssl.key-store=file:/tmp/mykey.jks +### server.ssl.key-store-password=mypass +### server.ssl.key-password=mypass +### server.http-to-https-redirection.port=8090 <-- The HTTP port + +server.contextPath=/ +#Modified engine-rest applicationpath +spring.jersey.application-path=/engine-rest +spring.profiles.active=clamp-default,clamp-spring-authentication +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration + +#The max number of active threads in this pool +server.tomcat.max-threads=200 +#The minimum number of threads always kept alive +server.tomcat.min-Spare-Threads=25 +#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads +server.tomcat.max-idle-time=60000 + + +#Add this properties only if you want to change the URL, AJSC Framework interceptors will intercept +#com.att.ajsc.common.interceptors.PreInterceptor.url=/** +#com.att.ajsc.common.interceptors.PostInterceptor.url=/** + +#Servlet context parameters +server.context_parameters.p-name=value #context parameter with p-name as key and value as value. + +camel.springboot.consumer-template-cache-size=1000 +camel.springboot.producer-template-cache-size=1000 +camel.springboot.jmx-enabled=true +camel.defaultthreadpool.poolsize=10 +camel.defaultthreadpool.maxpoolsize=20 +camel.defaultthreadpool.maxqueuesize=1000 +camel.defaultthreadpool.keepaliveTime=60 +camel.defaultthreadpool.rejectpolicy=CallerRuns + +kubernetes.namespace=com-att-ajsc + +#server.port=0 + +#Camunda Process Engine DataSource connection Details +spring.datasource.camunda.url=jdbc:mariadb://localhost:${docker.mariadb.port.host}/camundabpm?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 +spring.datasource.camunda.username=camunda +spring.datasource.camunda.password=ndMSpw4CAM +spring.datasource.camunda.driverClassName=org.mariadb.jdbc.Driver +spring.datasource.camunda.validationQuery=SELECT 1 +spring.datasource.camunda.validationQueryTimeout=20000 +spring.datasource.camunda.validationInterval=60000 +spring.datasource.camunda.testWhileIdle = true +# Automatically test whether a connection provided is good or not +spring.datasource.camunda.testOnBorrow=true + +#Camunda application properties +#Camunda history level +camunda.bpm.history-level=auto +camunda.bpm.enabled=false +camunda.bpm.auto-deployment-enabled=false +camunda.bpm.job-execution.active=false +camunda.bpm.job-execution.enabled=false +camunda.bpm.management.health.camunda.enabled=false +camunda.bpm.metrics.enabled=false + +#clds datasource connection details +spring.datasource.cldsdb.driver-class-name=org.mariadb.jdbc.Driver +spring.datasource.cldsdb.url=jdbc:mariadb://localhost:${docker.mariadb.port.host}/cldsdb4?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 +spring.datasource.cldsdb.username=clds +spring.datasource.cldsdb.password=sidnnd83K +spring.datasource.cldsdb.driverClassName=com.mysql.jdbc.Driver +spring.datasource.cldsdb.validationQuery=SELECT 1 +spring.datasource.cldsdb.validationQueryTimeout=20000 +spring.datasource.cldsdb.validationInterval=60000 +spring.datasource.cldsdb.testWhileIdle = true +# Automatically test whether a connection provided is good or not +spring.datasource.cldsdb.testOnBorrow=true + +#Async Executor default Parameters +async.core.pool.size=10 +async.max.pool.size=20 +async.queue.capacity=500 + +org.onap.clamp.config.dcae.url=http://localhost:9000/closedloop-dcae-services + +#GRM Edge endpoint details +service.name=ajsc6camundademo +service.version=1.0.0.0 +routeoffer=TEST +#Update with your application name +application.name=AJSC6CAMUNDA + +org.onap.clamp.config.files.cldsReference=classpath:/clds/clds-reference.properties +org.onap.clamp.config.files.cldsPolicyConfig=classpath:/clds/clds-policy-config.properties +org.onap.clamp.config.files.cldsUsers=classpath:/clds/clds-users.json +org.onap.clamp.config.files.globalClds=classpath:/clds/globalClds.properties + +#Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case ! +CLDS_PERMISSION_TYPE_CL=permission-type-cl +CLDS_PERMISSION_TYPE_CL_MANAGE=permission-type-cl-manage +CLDS_PERMISSION_TYPE_CL_EVENT=permission-type-cl-event +CLDS_PERMISSION_TYPE_FILTER_VF=permission-type-filter-vf +CLDS_PERMISSION_TYPE_TEMPLATE=permission-type-template +#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties +CLDS_PERMISSION_INSTANCE=dev \ No newline at end of file diff --git a/src/test/resources/example/dao/bpmn-prop.json b/src/test/resources/example/dao/bpmn-prop.json new file mode 100644 index 00000000..f2bfc7de --- /dev/null +++ b/src/test/resources/example/dao/bpmn-prop.json @@ -0,0 +1,54 @@ +{ + "Holmes_1m8n1s9": [ + { + "name": "correlationalLogic", + "value": "uktukk" + } + ], + "Policy_19c1hms": { + "policy1": [ + { + "name": "pname", + "value": "policy1" + }, + { + "name": "pid", + "value": "0" + }, + { + "name": "timeout", + "value": "345" + }, + { + "policyConfigurations": [ + [ + { + "name": "maxRetries", + "value": [ + "3" + ] + }, + { + "name": "retryTimeLimit", + "value": [ + "180" + ] + }, + { + "name": "_id", + "value": [ + "JmAZRQx" + ] + }, + { + "name": "parentPolicy", + "value": [ + "" + ] + } + ] + ] + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/example/dao/bpmn-template.xml b/src/test/resources/example/dao/bpmn-template.xml new file mode 100644 index 00000000..5aa133ac --- /dev/null +++ b/src/test/resources/example/dao/bpmn-template.xml @@ -0,0 +1,126 @@ + + + + + SequenceFlow_0mshiwd + + + SequenceFlow_0mshiwd + SequenceFlow_0z37chw + + + SequenceFlow_0z37chw + SequenceFlow_1io8zzg + + + SequenceFlow_1io8zzg + SequenceFlow_0yenh9m + + + SequenceFlow_0yenh9m + SequenceFlow_1gq21be + + + SequenceFlow_1gq21be + SequenceFlow_14phr7v + + + SequenceFlow_14phr7v + SequenceFlow_1q2yngv + + + SequenceFlow_1q2yngv + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/example/dao/image-template.xml b/src/test/resources/example/dao/image-template.xml new file mode 100644 index 00000000..d7af2aa6 --- /dev/null +++ b/src/test/resources/example/dao/image-template.xml @@ -0,0 +1,448 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Collector + + + + + + + + + + + + + StringMatch + + + + + + + + + + + + + + V + + + E + + + S + + + VesCollector + + + + + + + + + + + + + H + + + Holmes + + + + + + + + + + + + + TCA + + + + + + + + + + + + + Policy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file