summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ConfigSourceLocationTest.java8
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/DynamicConfigurationTest.java10
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NodeSpecificCLITest.java12
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationForNodeConfigTest.java18
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationOnPropValTest.java12
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/UnregisterNotificationTest.java10
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ValidateNodeConfigTest.java8
-rw-r--r--common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/test/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java198
-rw-r--r--common/openecomp-tosca-datatype/src/main/resources/globalTypes/openecomp-heat/data.yml6
9 files changed, 113 insertions, 169 deletions
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ConfigSourceLocationTest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ConfigSourceLocationTest.java
index 7eb591c6d2..731826b53c 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ConfigSourceLocationTest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ConfigSourceLocationTest.java
@@ -33,10 +33,10 @@ public class ConfigSourceLocationTest {
Properties props = new Properties();
props.setProperty("maxCachedBufferSize", "1024");
props.setProperty("artifact.maxsize", "1024");
- File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Config Property at Conventional Resource");
- out.close();
+ File f = new File(TestUtil.jsonSchemaLoc + "config.properties");
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Config Property at Conventional Resource");
+ }
}
@Test
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/DynamicConfigurationTest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/DynamicConfigurationTest.java
index 1ca41f8a81..2140e84873 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/DynamicConfigurationTest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/DynamicConfigurationTest.java
@@ -39,10 +39,10 @@ public class DynamicConfigurationTest {
props.setProperty(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, "20");
props.setProperty("_config.namespace",NAMESPACE);
props.setProperty("_config.mergeStrategy","override");
- File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Override Config Property at Conventional Resource");
- out.close();
+ File f = new File(TestUtil.jsonSchemaLoc + "config.properties");
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Override Config Property at Conventional Resource");
+ }
//Verify configuration with Configuration without wait. This should fetch cached value
Assert.assertEquals("14" , config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH));
@@ -60,7 +60,7 @@ public class DynamicConfigurationTest {
TestUtil.cleanUp();
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
}
}
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NodeSpecificCLITest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NodeSpecificCLITest.java
index 795780b83b..43729cbaf2 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NodeSpecificCLITest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NodeSpecificCLITest.java
@@ -51,10 +51,10 @@ public class NodeSpecificCLITest {
Properties props = new Properties();
props.setProperty(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, "50");
props.setProperty("_config.namespace",NAMESPACE);
- File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Node Config Property");
- out.close();
+ File f = new File(TestUtil.jsonSchemaLoc + "config.properties");
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Node Config Property");
+ }
Thread.sleep(35000);
@@ -86,7 +86,7 @@ public class NodeSpecificCLITest {
//Verify maxlength on other nodes by deleting node specific configuration
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
Thread.sleep(35000);
@@ -103,7 +103,7 @@ public class NodeSpecificCLITest {
TestUtil.cleanUp();
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
}
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationForNodeConfigTest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationForNodeConfigTest.java
index 3d1579e25e..9d719103df 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationForNodeConfigTest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationForNodeConfigTest.java
@@ -25,7 +25,7 @@ import java.util.Properties;
public class NotificationForNodeConfigTest {
public final static String NAMESPACE = "NotificationForNodeConfig";
- public String updatedValue = null;
+ private String updatedValue = null;
@Before
public void setUp() throws IOException {
@@ -42,10 +42,10 @@ public class NotificationForNodeConfigTest {
Properties props = new Properties();
props.setProperty(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, "30");
props.setProperty("_config.namespace",NAMESPACE);
- File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Node Config Property");
- out.close();
+ File f = new File(TestUtil.jsonSchemaLoc + "config.properties");
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Node Config Property");
+ }
Thread.sleep(35000);
@@ -55,9 +55,9 @@ public class NotificationForNodeConfigTest {
config.addConfigurationChangeListener(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, new NodePropValListener());
props.setProperty(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, "80");
- out = new FileOutputStream( f );
- props.store(out, "Updated Node Config Property");
- out.close();
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Updated Node Config Property");
+ }
Thread.sleep(35000);
@@ -79,7 +79,7 @@ public class NotificationForNodeConfigTest {
TestUtil.cleanUp();
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
}
}
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationOnPropValTest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationOnPropValTest.java
index 8a461503ae..7354cd19f7 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationOnPropValTest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationOnPropValTest.java
@@ -25,7 +25,7 @@ public class NotificationOnPropValTest {
public final static String NAMESPACE = "NotificationOnPropVal";
- public String updatedValue = null;
+ private String updatedValue = null;
@Before
public void setUp() throws IOException {
@@ -45,10 +45,10 @@ public class NotificationOnPropValTest {
props.setProperty(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, "20");
props.setProperty("_config.namespace",NAMESPACE);
props.setProperty("_config.mergeStrategy","override");
- File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Override Config Property at Conventional Resource");
- out.close();
+ File f = new File(TestUtil.jsonSchemaLoc + "config.properties");
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Override Config Property at Conventional Resource");
+ }
Thread.sleep(35000);
@@ -70,7 +70,7 @@ public class NotificationOnPropValTest {
TestUtil.cleanUp();
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
}
}
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/UnregisterNotificationTest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/UnregisterNotificationTest.java
index a53f3c2d40..e387f13e93 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/UnregisterNotificationTest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/UnregisterNotificationTest.java
@@ -25,7 +25,7 @@ import java.util.Properties;
public class UnregisterNotificationTest {
public final static String NAMESPACE = "UnregisterNotification";
- public String updatedValue = null;
+ private String updatedValue = null;
@Before
public void setUp() throws IOException {
@@ -70,9 +70,9 @@ public class UnregisterNotificationTest {
props.setProperty("_config.namespace",NAMESPACE);
props.setProperty("_config.mergeStrategy","override");
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Override Config Property at Conventional Resource");
- out.close();
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Override Config Property at Conventional Resource");
+ }
}
private class PropertyListener implements ConfigurationChangeListener {
@@ -88,7 +88,7 @@ public class UnregisterNotificationTest {
TestUtil.cleanUp();
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
}
}
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ValidateNodeConfigTest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ValidateNodeConfigTest.java
index 03a6786275..8f7d703468 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ValidateNodeConfigTest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ValidateNodeConfigTest.java
@@ -40,9 +40,9 @@ public class ValidateNodeConfigTest {
props.setProperty(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, "56");
props.setProperty("_config.namespace","ValidateNodeConfig");
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Node Config Property");
- out.close();
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Node Config Property");
+ }
System.out.println(System.getProperty("node.config.location"));
@@ -73,7 +73,7 @@ public class ValidateNodeConfigTest {
TestUtil.cleanUp();
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
}
diff --git a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/test/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/test/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java
index 01029e8adc..2de7535a8b 100644
--- a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/test/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java
+++ b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-core/src/test/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java
@@ -73,9 +73,9 @@ public class ArtifactGenerationServiceTest {
private static final String aaiArtifactType = ArtifactType.AAI.name();
private static final String aaiArtifactGroupType = GroupType.DEPLOYMENT.name();
private static final String generatorConfig = "{\"artifactTypes\": [\"OTHER\",\"AAI\"]}";
- Properties properties = new Properties();
- Map<String, String> additionalParams = new HashMap();
- Map<String, String> resourcesVersion = new HashMap<>();
+ private final Properties properties = new Properties();
+ private final Map<String, String> additionalParams = new HashMap<>();
+ private final Map<String, String> resourcesVersion = new HashMap<>();
@BeforeSuite
public void loadProperties() throws Exception{
@@ -87,7 +87,7 @@ public class ArtifactGenerationServiceTest {
public void testArtifactGeneration() {
// Sunny day scenario service with VF anf vfmodule
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
+
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "aai/";
@@ -112,7 +112,7 @@ public class ArtifactGenerationServiceTest {
Assert.assertEquals(resultData.size(),5); // 1-service,1-VF-resource,1-vfmodule and 2
// others
- outputArtifactMap = populateAAIGeneratedModelStore(resultData);
+ Map<String, Model> outputArtifactMap = populateAAIGeneratedModelStore(resultData);
testServiceTosca(toscas, outputArtifactMap);
testResourceTosca(toscas.iterator(), outputArtifactMap);
} else {
@@ -129,7 +129,6 @@ public class ArtifactGenerationServiceTest {
// Sunny day scenario service with VF and extra widget like CP anf vf has vfmodule without
// member
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "testWidgetinServiceTosca/";
@@ -142,7 +141,7 @@ public class ArtifactGenerationServiceTest {
List<Artifact> resultData = data.getResultData();
Assert.assertEquals(resultData.size(),5); // 1-service,1-VF-resource,1-vfmodule and 2
// others
- outputArtifactMap = populateAAIGeneratedModelStore(resultData);
+ Map<String, Model> outputArtifactMap = populateAAIGeneratedModelStore(resultData);
testServiceTosca(toscas, outputArtifactMap);
testResourceTosca(toscas.iterator(), outputArtifactMap);
} else {
@@ -159,7 +158,6 @@ public class ArtifactGenerationServiceTest {
// Sunny day scenario service with VF and extra widget like CP anf vf has vfmodule without
// member
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "testSameVLdifferentVersion/";
@@ -172,7 +170,7 @@ public class ArtifactGenerationServiceTest {
List<Artifact> resultData = data.getResultData();
Assert.assertEquals(resultData.size(),8);
// others
- outputArtifactMap = populateAAIGeneratedModelStore(resultData);
+ Map<String, Model> outputArtifactMap = populateAAIGeneratedModelStore(resultData);
testServiceTosca(toscas, outputArtifactMap);
testResourceTosca(toscas.iterator(), outputArtifactMap);
} else {
@@ -188,7 +186,6 @@ public class ArtifactGenerationServiceTest {
public void testArtifactGenerationAllottedResourceAndL3Network() {
// Sunny day scenario service with allotted resource and L3-network
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "aai2/";
@@ -203,7 +200,7 @@ public class ArtifactGenerationServiceTest {
Assert.assertEquals(resultData.size(),5);
// and 2
// others
- outputArtifactMap = populateAAIGeneratedModelStore(resultData);
+ Map<String, Model> outputArtifactMap = populateAAIGeneratedModelStore(resultData);
testServiceTosca(toscas, outputArtifactMap);
testResourceTosca(toscas.iterator(), outputArtifactMap);
} else {
@@ -248,7 +245,6 @@ public class ArtifactGenerationServiceTest {
public void testWhenOnlyServToscaNoResTosca() {
try {
//Testing only service tosca no resource Tosca
- Map<String, Model> outputArtifactMap = new HashMap<>();
String aaiResourceBasePaths = "testArtifactGeneration4/";
List<Artifact> inputArtifacts = init(aaiResourceBasePaths);
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
@@ -261,7 +257,7 @@ public class ArtifactGenerationServiceTest {
}
}
Assert.assertEquals(resultData.size(),3); // 1-service and 2-Others
- outputArtifactMap = populateAAIGeneratedModelStore(resultData);
+ Map<String, Model> outputArtifactMap = populateAAIGeneratedModelStore(resultData);
testServiceTosca(toscas, outputArtifactMap);
} catch (Exception e) {
Assert.fail(e.getMessage());
@@ -286,7 +282,6 @@ public class ArtifactGenerationServiceTest {
public void testWhenExtraResToscaNotPartOfServ() {
try {
// Valid scenario with extra resource tosca which is not part of Service
- Map<String, Model> outputArtifactMap = new HashMap<>();
String aaiResourceBasePaths = "testArtifactGeneration6/";
List<Artifact> inputArtifacts = init(aaiResourceBasePaths);
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
@@ -299,7 +294,7 @@ public class ArtifactGenerationServiceTest {
}
}
Assert.assertEquals(resultData.size(),3); // 1-service and 2 Others
- outputArtifactMap = populateAAIGeneratedModelStore(resultData);
+ Map<String, Model> outputArtifactMap = populateAAIGeneratedModelStore(resultData);
testServiceTosca(toscas, outputArtifactMap);
} catch (Exception e) {
Assert.fail(e.getMessage());
@@ -397,13 +392,8 @@ public class ArtifactGenerationServiceTest {
try {
//mandatory attribute <vfModuleModelInvariantUUID> missing
List<Artifact> inputArtifacts = new ArrayList<>();
- InputStream fis1 = ArtifactGenerationServiceTest.class.getResourceAsStream("/service_vmme_template_ModInvUUID.yml");
- readPayload(inputArtifacts,fis1, "service_vmme_template_ModInvUUID.yml");
- fis1.close();
-
- InputStream fis2 = ArtifactGenerationServiceTest.class.getResourceAsStream("/vf_vmme_template_ModInvUUID.yml");
- readPayload(inputArtifacts,fis2, "vf_vmme_template_ModInvUUID.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_ModInvUUID.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_ModInvUUID.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
Assert.assertEquals(
@@ -415,7 +405,7 @@ public class ArtifactGenerationServiceTest {
}
}
- public static void readPayload(List<Artifact> inputArtifacts,InputStream fis, String fileName) throws
+ public static void readPayload(List<Artifact> inputArtifacts, InputStream fis, String fileName) throws
IOException {
byte[] payload = new byte[fis.available()];
fis.read(payload);
@@ -435,13 +425,9 @@ public class ArtifactGenerationServiceTest {
try {
//invalid id since not of length 36 for <vfModuleModelInvariantUUID>
List<Artifact> inputArtifacts = new ArrayList<>();
- InputStream fis1 = ArtifactGenerationServiceTest.class.getResourceAsStream("/service_vmme_template_InvalidVfModInvUuIdAttr.yml");
- readPayload(inputArtifacts,fis1, "service_vmme_template_InvalidVfModInvUuIdAttr.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_InvalidVfModInvUuIdAttr.yml");
- InputStream fis2 = ArtifactGenerationServiceTest.class.getResourceAsStream("/vf_vmme_template_InvalidVfModInvUuIdAttr.yml");
- readPayload(inputArtifacts,fis2, "vf_vmme_template_InvalidVfModInvUuIdAttr.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_InvalidVfModInvUuIdAttr.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
Assert.assertEquals(
@@ -458,13 +444,9 @@ public class ArtifactGenerationServiceTest {
try {
//mandatory attribute <vfModuleModelName> missing
List<Artifact> inputArtifacts = new ArrayList<>();
- InputStream fis1 = ArtifactGenerationServiceTest.class.getResourceAsStream("/service_vmme_template_ModelName.yml");
- readPayload(inputArtifacts,fis1, "service_vmme_template_ModelName.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_ModelName.yml");
- InputStream fis2 = ArtifactGenerationServiceTest.class.getResourceAsStream("/vf_vmme_template_ModelName.yml");
- readPayload(inputArtifacts,fis2, "vf_vmme_template_ModelName.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_ModelName.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
Assert.assertEquals(
@@ -497,13 +479,9 @@ public class ArtifactGenerationServiceTest {
try {
//mandatory attribute <vfModuleModelUUID> missing in Artifact
List<Artifact> inputArtifacts = new ArrayList<>();
- InputStream fis1 = ArtifactGenerationServiceTest.class.getResourceAsStream("/service_vmme_template_ModelUUID.yml");
- readPayload(inputArtifacts,fis1, "service_vmme_template_ModelUUID.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_ModelUUID.yml");
- InputStream fis2 = ArtifactGenerationServiceTest.class.getResourceAsStream("/vf_vmme_template_ModelUUID.yml");
- readPayload(inputArtifacts,fis2, "vf_vmme_template_ModelUUID.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_ModelUUID.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
Assert.assertEquals(
@@ -521,13 +499,9 @@ public class ArtifactGenerationServiceTest {
try {
//invalid id since not of length 36 for <vfModuleModelUUID>
List<Artifact> inputArtifacts = new ArrayList<>();
- InputStream fis1 = ArtifactGenerationServiceTest.class.getResourceAsStream("/service_vmme_template_InvalidVfModUuIdAttr.yml");
- readPayload(inputArtifacts,fis1, "service_vmme_template_InvalidVfModUuIdAttr.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_InvalidVfModUuIdAttr.yml");
- InputStream fis2 = ArtifactGenerationServiceTest.class.getResourceAsStream("/vf_vmme_template_InvalidVfModUuIdAttr.yml");
- readPayload(inputArtifacts,fis2, "vf_vmme_template_InvalidVfModUuIdAttr.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_InvalidVfModUuIdAttr.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
Assert.assertEquals(
@@ -544,13 +518,9 @@ public class ArtifactGenerationServiceTest {
try {
//mandatory attribute <vfModuleModelVersion> missing
List<Artifact> inputArtifacts = new ArrayList<>();
- InputStream fis1 = ArtifactGenerationServiceTest.class.getResourceAsStream("/service_vmme_template_ModelVersion.yml");
- readPayload(inputArtifacts,fis1, "service_vmme_template_ModelVersion.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_ModelVersion.yml");
- InputStream fis2 = ArtifactGenerationServiceTest.class.getResourceAsStream("/vf_vmme_template_ModelVersion.yml");
- readPayload(inputArtifacts,fis2, "vf_vmme_template_ModelVersion.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_ModelVersion.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
Assert.assertEquals(
@@ -567,9 +537,7 @@ public class ArtifactGenerationServiceTest {
String configLoc = System.getProperty("artifactgenerator.config");
try {
System.clearProperty("artifactgenerator.config");
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "aai/";
List<Artifact> inputArtifacts = init(aaiResourceBasePaths);
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
@@ -599,17 +567,14 @@ public class ArtifactGenerationServiceTest {
.getName();
String assertMsg = ArtifactType.AAI.name() + ".model-version-id." +Widget.getWidget
(Widget.Type.SERVICE).getName();
- OutputStream fos = new FileOutputStream(new File(configLoc));
- String serviceWidgetId = properties.getProperty(serviceWidgetName);
//Remove property from Artifact-Generator.properties
properties.remove(serviceWidgetName);
- properties.store(fos,null);
- fos.close();
+ try (OutputStream fos = new FileOutputStream(new File(configLoc))) {
+ properties.store(fos,null);
+ }
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "aai/";
List<Artifact> inputArtifacts = init(aaiResourceBasePaths);
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
@@ -634,9 +599,7 @@ public class ArtifactGenerationServiceTest {
String configLoc = System.getProperty("artifactgenerator.config");
try {
System.setProperty("artifactgenerator.config",configLoc + File.separator + "testErrorWhenNoFileAtConfigLocation");
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "aai/";
List<Artifact> inputArtifacts = init(aaiResourceBasePaths);
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
@@ -656,9 +619,7 @@ public class ArtifactGenerationServiceTest {
// scenario service with VF anf vfmodule but no service version in additional parameter
try {
additionalParams.clear();
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "aai/";
List<Artifact> inputArtifacts = init(aaiResourceBasePaths);
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
@@ -678,7 +639,6 @@ public class ArtifactGenerationServiceTest {
// Sunny day scenario service with VF anf vfmodule and service version as adiitional parameter
try {
additionalParams.put(AdditionalParams.ServiceVersion.getName(),"9.0");
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "aai/";
@@ -703,7 +663,7 @@ public class ArtifactGenerationServiceTest {
Assert.assertEquals(resultData.size(),5); // 1-service,1-VF-resource,1-vfmodule and 2
// others
- outputArtifactMap = populateAAIGeneratedModelStore(resultData);
+ Map<String, Model> outputArtifactMap = populateAAIGeneratedModelStore(resultData);
testServiceTosca(toscas, outputArtifactMap);
testResourceTosca(toscas.iterator(), outputArtifactMap);
} else {
@@ -722,9 +682,7 @@ public class ArtifactGenerationServiceTest {
public void testErrorWhenInvalidServiceVersion() {
// scenario service with VF anf vfmodule but invalid service version in additional parameter
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "aai/";
List<Artifact> inputArtifacts = init(aaiResourceBasePaths);
@@ -785,9 +743,7 @@ public class ArtifactGenerationServiceTest {
public void testErrorWhenNoResourceVersion() {
// scenario service with VF but missing resource version in service tosca
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "testErrorWhenNoResourceVersion/";
List<Artifact> inputArtifacts = init(aaiResourceBasePaths);
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
@@ -803,9 +759,7 @@ public class ArtifactGenerationServiceTest {
public void testErrorWhenInvalidResourceVersion1() {
// scenario service with VF but invalid resource version 0.0 in service tosca
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "testErrorWhenInvalidResourceVersion1/";
List<Artifact> inputArtifacts = init(aaiResourceBasePaths);
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
@@ -821,9 +775,7 @@ public class ArtifactGenerationServiceTest {
public void testErrorWhenInvalidResourceVersion2() {
// scenario service with VF but invalid resource version 1 in service tosca
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "testErrorWhenInvalidResourceVersion2/";
List<Artifact> inputArtifacts = init(aaiResourceBasePaths);
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
@@ -838,7 +790,6 @@ public class ArtifactGenerationServiceTest {
@Test
public void testArtifactGenerationAllottedResourceWithIpMuxAndTunnelXConn() {
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "testArtifactGeneration15/";
@@ -851,7 +802,7 @@ public class ArtifactGenerationServiceTest {
List<Artifact> resultData = data.getResultData();
Assert.assertEquals(resultData.size(),5);
- outputArtifactMap = populateAAIGeneratedModelStore(resultData);
+ Map<String, Model> outputArtifactMap = populateAAIGeneratedModelStore(resultData);
testServiceTosca(toscas, outputArtifactMap);
testResourceTosca(toscas.iterator(), outputArtifactMap);
} else {
@@ -866,9 +817,7 @@ public class ArtifactGenerationServiceTest {
// @Test
public void testErrorWhenAllottedResourceWithOutProvidingServiceId() {
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "testErrorWhenAllottedResourceWithOutDependingServiceId/";
List<Artifact> inputArtifacts = init(aaiResourceBasePaths);
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
@@ -883,9 +832,7 @@ public class ArtifactGenerationServiceTest {
@Test
public void testArtifactGenerationWithoutAllottedResource() {
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "testArtifactGeneration16/";
List<Artifact> inputArtifacts = init(aaiResourceBasePaths);
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
@@ -900,7 +847,6 @@ public class ArtifactGenerationServiceTest {
@Test
public void testArtifactGenerationAllottedResourceIpmuxSameInvariantDiffVersion() {
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "testArtifactGeneration17/";
@@ -913,7 +859,7 @@ public class ArtifactGenerationServiceTest {
List<Artifact> resultData = data.getResultData();
Assert.assertEquals(resultData.size(),5);
- outputArtifactMap = populateAAIGeneratedModelStore(resultData);
+ Map<String, Model> outputArtifactMap = populateAAIGeneratedModelStore(resultData);
testServiceTosca(toscas, outputArtifactMap);
testResourceTosca(toscas.iterator(), outputArtifactMap);
} else {
@@ -928,7 +874,6 @@ public class ArtifactGenerationServiceTest {
@Test
public void testArtifactGenerationAllottedResourceIpmuxSameInvariantSameVersion() {
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "testArtifactGeneration18/";
@@ -942,7 +887,7 @@ public class ArtifactGenerationServiceTest {
Assert.assertEquals(resultData.size(),4);
- outputArtifactMap = populateAAIGeneratedModelStore(resultData);
+ Map<String, Model> outputArtifactMap = populateAAIGeneratedModelStore(resultData);
testServiceTosca(toscas, outputArtifactMap);
testResourceTosca(toscas.iterator(), outputArtifactMap);
} else {
@@ -957,7 +902,6 @@ public class ArtifactGenerationServiceTest {
@Test
public void testArtifactGenerationAllottedResourceIpmuxWithGroups() {
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "testAllotedResourceWithDependingSerWithGroups/";
@@ -970,7 +914,7 @@ public class ArtifactGenerationServiceTest {
List<Artifact> resultData = data.getResultData();
Assert.assertEquals(resultData.size(),5);
- outputArtifactMap = populateAAIGeneratedModelStore(resultData);
+ Map<String, Model> outputArtifactMap = populateAAIGeneratedModelStore(resultData);
testServiceTosca(toscas, outputArtifactMap);
testResourceTosca(toscas.iterator(), outputArtifactMap);
} else {
@@ -985,7 +929,6 @@ public class ArtifactGenerationServiceTest {
@Test
public void testArtifactGenerationAllottedResourceWithVF() {
try {
- Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList<>();
String aaiResourceBasePaths = "testArtifactGenerationAllottedResourceWithVF/";
@@ -998,7 +941,7 @@ public class ArtifactGenerationServiceTest {
List<Artifact> resultData = data.getResultData();
Assert.assertEquals(resultData.size(),7);
- outputArtifactMap = populateAAIGeneratedModelStore(resultData);
+ Map<String, Model> outputArtifactMap = populateAAIGeneratedModelStore(resultData);
testServiceTosca(toscas, outputArtifactMap);
testResourceTosca(toscas.iterator(), outputArtifactMap);
} else {
@@ -1500,7 +1443,7 @@ nodeProperties = node.getProperties();
return matchedModelElements;
}
- private Map<String, Model> populateAAIGeneratedModelStore(List<Artifact> resultData) {
+ private Map<String, Model> populateAAIGeneratedModelStore(List<Artifact> resultData) throws IOException {
Map<String, Model> outputArtifactMap = new HashMap<>();
for (Artifact outputArtifact : resultData) {
if (outputArtifact.getType().equals(ArtifactType.MODEL_INVENTORY_PROFILE.name())) {
@@ -1513,16 +1456,21 @@ nodeProperties = node.getProperties();
return outputArtifactMap;
}
- private Model getUnmarshalledArtifactModel(String aaiModel) {
- JAXBContext jaxbContext;
+ private Model getUnmarshalledArtifactModel(String aaiModel) throws IOException {
+
try {
- jaxbContext = JAXBContext.newInstance(Model.class);
+
+ JAXBContext jaxbContext = JAXBContext.newInstance(Model.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- InputStream aaiModelStream = new ByteArrayInputStream(aaiModel.getBytes());
- return (Model) unmarshaller.unmarshal(aaiModelStream);
+
+ try (InputStream aaiModelStream = new ByteArrayInputStream(aaiModel.getBytes())) {
+ return (Model) unmarshaller.unmarshal(aaiModelStream);
+ }
+
} catch (JAXBException e) {
e.printStackTrace();
}
+
return null;
}
@@ -1567,20 +1515,6 @@ nodeProperties = node.getProperties();
return null;
}
-
- private ToscaTemplate getResourceTosca(List<ToscaTemplate> input) {
- Iterator<ToscaTemplate> iter = input.iterator();
- while (iter.hasNext()) {
- ToscaTemplate tosca = iter.next();
- if (!tosca.isService()) {
- iter.remove();
- return tosca;
- }
- }
- return null;
- }
-
-
private Map<String, String> getVFModuleMetadataTosca(ToscaTemplate toscaTemplate,
String vfModuleModelUUID) {
Map<String, GroupDefinition> groupDefinitionMap =
@@ -1589,7 +1523,7 @@ nodeProperties = node.getProperties();
for (Map.Entry<String, GroupDefinition> e : groupDefinitionMap.entrySet()) {
if (e.getValue().getType().contains("org.openecomp.groups.VfModule")) {
String uuid = e.getValue().getMetadata().get("vfModuleModelUUID");
- if (uuid == vfModuleModelUUID) {
+ if (Objects.equals(uuid, vfModuleModelUUID)) {
vfModuleModelMetadata = e.getValue().getMetadata();
vfModuleModelMetadata.put("vf_module_description",
(String) e.getValue().getProperties().get("vf_module_description"));
@@ -1606,17 +1540,15 @@ nodeProperties = node.getProperties();
Map<String, NodeTemplate> nodeTemplateMaps =
toscaTemplate.getTopology_template().getNode_templates();
Map<String, Object> vfModuleMembers = new LinkedHashMap<>();
- List<String> vfModuleModelMetadata = new ArrayList<>();
+ List<String> vfModuleModelMetadata;
for (Map.Entry<String, GroupDefinition> e : groupDefinitionMap.entrySet()) {
if (e.getValue().getType().contains("org.openecomp.groups.VfModule")) {
String uuid = e.getValue().getMetadata().get("vfModuleModelUUID");
- if (uuid == vfModuleModelUUID) {
+ if (Objects.equals(uuid, vfModuleModelUUID)) {
vfModuleModelMetadata = e.getValue().getMembers();
if (vfModuleModelMetadata !=null) {
- Iterator itr = vfModuleModelMetadata.iterator();
- while (itr.hasNext()) {
- Object obj = itr.next();
- NodeTemplate nodeTemplate = nodeTemplateMaps.get(obj);
+ for (Object key : vfModuleModelMetadata) {
+ NodeTemplate nodeTemplate = nodeTemplateMaps.get(key);
String nodetype = null;
if (nodeTemplate != null) {
nodetype = nodeTemplate.getType();
@@ -1624,7 +1556,7 @@ nodeProperties = node.getProperties();
if (nodetype != null) {
String widgetType = membersType(nodetype);
if (widgetType != null) {
- vfModuleMembers.put(widgetType, obj);
+ vfModuleMembers.put(widgetType, key);
}
}
}
@@ -1686,24 +1618,24 @@ nodeProperties = node.getProperties();
Assert.fail("Invalid resource directory");
}
- for (int i = 0; i < resourceFileList.length; i++) {
- byte[] payload = null;
+ for (String aResourceFileList : resourceFileList) {
File resourceFile = new File(
- this.getClass().getClassLoader().getResource(aaiResourceBasePaths + resourceFileList[i])
- .getPath());
- FileInputStream fileInputStream;
+ this.getClass().getClassLoader().getResource(aaiResourceBasePaths + aResourceFileList)
+ .getPath());
+
//convert service tosca file into array of bytes
- payload = new byte[(int) resourceFile.length()];
- fileInputStream = new FileInputStream(resourceFile);
- fileInputStream.read(payload);
- fileInputStream.close();
+ byte[] payload = new byte[(int) resourceFile.length()];
+ try (FileInputStream fileInputStream = new FileInputStream(resourceFile)) {
+ fileInputStream.read(payload);
+ }
+
String checksum = GeneratorUtil.checkSum(payload);
byte[] encodedPayload = GeneratorUtil.encode(payload);
Artifact artifact =
- new Artifact(aaiArtifactType, aaiArtifactGroupType, checksum, encodedPayload);
- artifact.setName(resourceFileList[i]);
- artifact.setLabel(resourceFileList[i]);
- artifact.setDescription(resourceFileList[i]);
+ new Artifact(aaiArtifactType, aaiArtifactGroupType, checksum, encodedPayload);
+ artifact.setName(aResourceFileList);
+ artifact.setLabel(aResourceFileList);
+ artifact.setDescription(aResourceFileList);
artifact.setVersion("1.0");
inputArtifacts1.add(artifact);
@@ -1742,4 +1674,10 @@ nodeProperties = node.getProperties();
}
}
}
+
+ private void readPayloadFromResource(List<Artifact> inputArtifacts, String file) throws IOException {
+ try (InputStream stream = ArtifactGenerationServiceTest.class.getResourceAsStream("/" + file)) {
+ readPayload(inputArtifacts, stream, file);
+ }
+ }
}
diff --git a/common/openecomp-tosca-datatype/src/main/resources/globalTypes/openecomp-heat/data.yml b/common/openecomp-tosca-datatype/src/main/resources/globalTypes/openecomp-heat/data.yml
index f320a9879b..c9dda19d5c 100644
--- a/common/openecomp-tosca-datatype/src/main/resources/globalTypes/openecomp-heat/data.yml
+++ b/common/openecomp-tosca-datatype/src/main/resources/globalTypes/openecomp-heat/data.yml
@@ -562,6 +562,12 @@ data_types:
type: string
status: SUPPORTED
required: false
+ subnet_id:
+ type: string
+ description: Subnet in which to allocate the IP address for this port
+ required: false
+ status: SUPPORTED
+
org.openecomp.datatypes.heat.contrailV2.virtual.machine.interface.Properties:
derived_from: tosca.datatypes.Root