summaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2020-09-21 12:20:40 +0200
committerRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2020-09-23 10:00:29 +0200
commit9daf8aa8049a347f1f8010071df73c663e4c3bbd (patch)
tree6ac08954a493cfa953af80c605ce019fa49941f8 /mod
parent04ceefb1f221420c6e27c5aa73b8a574b0e79668 (diff)
Restore test assertions. Update default plugin imports. Fix sonar
issues in bpgenerator models/componentspec package. Issue-ID: DCAEGEN2-2449 Issue-ID: DCAEGEN2-2239 Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com> Change-Id: I2b1a541adaa5873a8450cf6341a1f73d760c2d72
Diffstat (limited to 'mod')
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java148
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java24
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java9
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java15
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java5
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java6
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java11
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java6
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java6
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java9
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java5
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java10
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java6
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java10
-rw-r--r--mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java244
23 files changed, 252 insertions, 326 deletions
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java
index 5d4131b..f9fa2cb 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java
@@ -18,18 +18,32 @@
*/
-
package org.onap.blueprintgenerator.core;
-
-
-
+import java.util.ArrayList;
+import java.util.TreeMap;
import lombok.Getter;
import lombok.Setter;
+import org.onap.blueprintgenerator.models.componentspec.Artifacts;
+import org.onap.blueprintgenerator.models.componentspec.Auxilary;
+import org.onap.blueprintgenerator.models.componentspec.CallsObj;
+import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
+import org.onap.blueprintgenerator.models.componentspec.Container;
+import org.onap.blueprintgenerator.models.componentspec.HealthCheck;
+import org.onap.blueprintgenerator.models.componentspec.Host;
+import org.onap.blueprintgenerator.models.componentspec.Parameters;
+import org.onap.blueprintgenerator.models.componentspec.Policy;
+import org.onap.blueprintgenerator.models.componentspec.ProvidesObj;
+import org.onap.blueprintgenerator.models.componentspec.Publishes;
+import org.onap.blueprintgenerator.models.componentspec.Self;
+import org.onap.blueprintgenerator.models.componentspec.Services;
+import org.onap.blueprintgenerator.models.componentspec.Streams;
+import org.onap.blueprintgenerator.models.componentspec.Subscribes;
+import org.onap.blueprintgenerator.models.componentspec.Volumes;
@Getter @Setter
public class TestComponentSpec {
- private String cs = "{\r\n" +
+ private String componentSpecAsString = "{\r\n" +
" \"self\": {\r\n" +
" \"component_type\": \"docker\",\r\n" +
" \"description\": \"Test component spec\",\r\n" +
@@ -129,4 +143,128 @@ public class TestComponentSpec {
" }] \r\n" +
"\r\n" +
"}";
+ private ComponentSpec componentSpec;
+
+ public TestComponentSpec() {
+ this.componentSpec = createComponentSpec();
+ }
+
+ private ComponentSpec createComponentSpec(){
+ //Manually fill a component spec object with the values from the file itself
+ ComponentSpec manualSpec = new ComponentSpec();
+
+ Self self = new Self();
+ self.setComponent_type("docker");
+ self.setDescription("Test component spec");
+ self.setName("test.component.spec");
+ self.setVersion("1.0.1");
+ manualSpec.setSelf(self);
+
+ Services services = new Services();
+ CallsObj[] calls = new CallsObj[0];
+ ProvidesObj[] provides = new ProvidesObj[0];
+ services.setCalls(calls);
+ services.setProvides(provides);
+ manualSpec.setServices(null);
+
+ Streams streams = new Streams();
+ Publishes[] publishes = new Publishes[2];
+ Publishes pub1 = new Publishes();
+ pub1.setConfig_key("TEST-PUB-DR");
+ pub1.setFormat("dataformat_Hello_World_PM");
+ pub1.setType("data_router");
+ pub1.setVersion("1.0.0");
+
+ Publishes pub2 = new Publishes();
+ pub2.setConfig_key("TEST-PUB-MR");
+ pub2.setFormat("dataformat_Hello_World_PM");
+ pub2.setType("message_router");
+ pub2.setVersion("1.0.0");
+ publishes[0] = pub1;
+ publishes[1] = pub2;
+ streams.setPublishes(publishes);
+
+ Subscribes[] subscribes = new Subscribes[2];
+ Subscribes sub1 = new Subscribes();
+ sub1.setConfig_key("TEST-SUB-MR");
+ sub1.setFormat("dataformat_Hello_World_PM");
+ sub1.setRoute("/TEST_HELLO_WORLD_SUB_MR");
+ sub1.setType("message_router");
+ sub1.setVersion("1.0.0");
+
+ Subscribes sub2 = new Subscribes();
+ sub2.setConfig_key("TEST-SUB-DR");
+ sub2.setFormat("dataformat_Hello_World_PM");
+ sub2.setRoute("/TEST-HELLO-WORLD-SUB-DR");
+ sub2.setType("data_router");
+ sub2.setVersion("1.0.0");
+ subscribes[0] = sub1;
+ subscribes[1] = sub2;
+ streams.setSubscribes(subscribes);
+
+ manualSpec.setStreams(streams);
+
+ Parameters[] parameters = new Parameters[1];
+ Parameters par1 = new Parameters();
+ par1.setName("testParam1");
+ par1.setValue("test-param-1");
+ par1.setDescription("test parameter 1");
+ par1.setSourced_at_deployment(true);
+ par1.setDesigner_editable(true);
+ par1.setPolicy_editable(true);
+ par1.setPolicy_group("Test_Parameters");
+ par1.setRequired(true);
+ par1.setType("string");
+ parameters[0] = par1;
+
+ manualSpec.setParameters(parameters);
+
+ Auxilary auxilary = new Auxilary();
+ HealthCheck healthcheck = new HealthCheck();
+ healthcheck.setInterval("300s");
+ healthcheck.setTimeout("120s");
+ healthcheck.setScript("/etc/init.d/nagios status");
+ healthcheck.setType("docker");
+ auxilary.setHealthcheck(healthcheck);
+
+ Volumes[] volumes = new Volumes[1];
+ Volumes vol1 = new Volumes();
+ Container con1 = new Container();
+ con1.setBind("/opt/app/manager/config/hostname");
+ Host host1 = new Host();
+ host1.setPath("/etc/hostname");
+ host1.setMode("ro");
+ vol1.setContainer(con1);
+ vol1.setHost(host1);
+
+ volumes[0] = vol1;
+
+ auxilary.setVolumes(volumes);
+
+ ArrayList<Object> ports = new ArrayList();
+ ports.add("80:80");
+
+ TreeMap<String, String> dataBases = new TreeMap<>();
+ dataBases.put("TestDB1", "PGaaS");
+ dataBases.put("TestDB2", "PGaaS");
+ auxilary.setDatabases(dataBases);
+
+ Policy pol = new Policy();
+ pol.setTrigger_type("docker");
+ pol.setScript_path("/opt/app/manager/bin/reconfigure.sh");
+ auxilary.setPolicy(pol);
+
+ auxilary.setPorts(ports);
+
+ manualSpec.setAuxilary(auxilary);
+
+ Artifacts[] artifacts = new Artifacts[1];
+ Artifacts art = new Artifacts();
+ art.setType("docker image");
+ art.setUri("test.tester");
+
+ artifacts[0] = art;
+ manualSpec.setArtifacts(artifacts);
+ return manualSpec;
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java
index 139790a..4e7a4f1 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java
@@ -41,21 +41,21 @@ public class Imports {
private ArrayList<String> imports;
public static ArrayList<String> createOnapImports() {
- ArrayList<String> imps = new ArrayList<String>();
- imps.add("http://www.getcloudify.org/spec/cloudify/3.4/types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/dcaepolicyplugin/2.4.0/dcaepolicyplugin_types.yaml");
+ ArrayList<String> imps = new ArrayList<>();
+ imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml");
+ imps.add("plugin:k8splugin?version=3.4.2");
+ imps.add("plugin:dcaepolicyplugin?version=2.4.0");
return imps;
}
public static ArrayList<String> createDmaapImports(){
- ArrayList<String> imps = new ArrayList<String>();
- imps.add("http://www.getcloudify.org/spec/cloudify/3.4/types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R5/k8splugin/1.6.0/k8splugin_types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml");
+ ArrayList<String> imps = new ArrayList<>();
+ imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml");
+ imps.add("plugin:k8splugin?version=3.4.2");
+ imps.add("plugin:dmaap?version=1.5.0");
return imps;
}
public static ArrayList<String> createImportsFromFile(String path) {
- Imports imports = new Imports();
+ Imports imports;
ObjectMapper importMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true));
File importPath = new File(path);
try {
@@ -63,10 +63,6 @@ public class Imports {
} catch (IOException e) {
throw new RuntimeException(e);
}
- ArrayList<String> imps = new ArrayList<String>();
- for(String s: imports.getImports()) {
- imps.add(s);
- }
- return imps;
+ return imports.getImports();
}
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java
index f7f5a03..198dc19 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java
@@ -21,13 +21,11 @@
package org.onap.blueprintgenerator.models.componentspec;
-
import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -53,6 +51,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
+@EqualsAndHashCode
//Called in Component Spec Object
public class Artifacts {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java
index a36deb5..58e1e0c 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java
@@ -22,19 +22,15 @@
package org.onap.blueprintgenerator.models.componentspec;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.TreeMap;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import java.util.ArrayList;
+import java.util.TreeMap;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -64,6 +60,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//Called in component Spec Object
public class Auxilary {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java
index 0b7dcee..d130632 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java
@@ -24,11 +24,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
-import lombok.NoArgsConstructor;
-
// TODO: Auto-generated Javadoc
/**
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java
index 3615605..785df35 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java
@@ -20,18 +20,10 @@
package org.onap.blueprintgenerator.models.componentspec;
-import java.util.HashMap;
-
-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
-import lombok.NoArgsConstructor;
-
// TODO: Auto-generated Javadoc
/**
* The Class ConstraintsObj.
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java
index d94e2bb..cbe02dc 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java
@@ -22,11 +22,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -50,6 +49,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
public class Container {
/** The bind. */
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java
index 45f9091..ef33aaf 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java
@@ -24,11 +24,9 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/**
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java
index acc9379..76e1036 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -53,6 +52,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//Called in Auxillary Object
public class HealthCheck {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java
index 91734ad..f178c94 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java
@@ -22,11 +22,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -46,6 +45,7 @@ import lombok.NoArgsConstructor;
* @param mode the mode
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
public class Host{
/** The path. */
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java
index 515ecc7..eb95202 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java
@@ -20,17 +20,13 @@
package org.onap.blueprintgenerator.models.componentspec;
-import java.util.ArrayList;
-
-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/**
@@ -68,6 +64,7 @@ import lombok.NoArgsConstructor;
* @param constraints the constraints
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//Called in component Spec Object
public class Parameters {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java
index 3cc14fe..d295ca4 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -51,6 +50,7 @@ import lombok.NoArgsConstructor;
* @param script_path the script path
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//called in auxilary
public class Policy {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java
index 7af16d6..aa38271 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java
@@ -24,11 +24,9 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/**
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java
index ad9c87d..9ad24c3 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java
@@ -21,11 +21,9 @@
package org.onap.blueprintgenerator.models.componentspec;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java
index 3ee47b9..4f46313 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -54,6 +53,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
//Called in Streams Object
public class Publishes {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java
index 6c389d6..6d78805 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -50,7 +49,7 @@ import lombok.NoArgsConstructor;
* @param policy the policy
*/
@JsonInclude(value=Include.NON_NULL)
-
+@EqualsAndHashCode
public class ReconfigsObj {
/** The dti. */
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java
index 2aaf60b..7ca1830 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java
@@ -25,11 +25,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
-import lombok.NoArgsConstructor;
-
// TODO: Auto-generated Javadoc
/**
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java
index a566661..8b5f35e 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java
@@ -20,16 +20,13 @@
package org.onap.blueprintgenerator.models.componentspec;
-import java.util.Map;
-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -55,6 +52,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
//called in Component Spec object
public class Self {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java
index afe0904..772d859 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java
@@ -24,11 +24,9 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java
index 1b7dcd3..500f32d 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java
@@ -24,11 +24,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -52,6 +51,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
//Called in Component Spec Object
public class Streams {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java
index 14485a0..ec4aa41 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -57,6 +56,7 @@ import lombok.NoArgsConstructor;
@JsonInclude(value=Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
//Called in Streams Object
public class Subscribes {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java
index 1034242..777bdeb 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -50,6 +49,7 @@ import lombok.NoArgsConstructor;
* @param host the host
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//Called in Auxillary Object
public class Volumes {
@@ -58,4 +58,4 @@ public class Volumes {
/** The host. */
private Host host;
-} \ No newline at end of file
+}
diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java
index 1c7e592..b978701 100644
--- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java
+++ b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java
@@ -21,15 +21,14 @@
package org.onap.blueprintgenerator.core;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -39,22 +38,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.onap.blueprintgenerator.models.blueprint.Blueprint;
import org.onap.blueprintgenerator.models.blueprint.GetInput;
-import org.onap.blueprintgenerator.models.componentspec.Artifacts;
-import org.onap.blueprintgenerator.models.componentspec.Auxilary;
-import org.onap.blueprintgenerator.models.componentspec.CallsObj;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import org.onap.blueprintgenerator.models.componentspec.Container;
-import org.onap.blueprintgenerator.models.componentspec.HealthCheck;
-import org.onap.blueprintgenerator.models.componentspec.Host;
-import org.onap.blueprintgenerator.models.componentspec.Parameters;
-import org.onap.blueprintgenerator.models.componentspec.Policy;
-import org.onap.blueprintgenerator.models.componentspec.ProvidesObj;
-import org.onap.blueprintgenerator.models.componentspec.Publishes;
-import org.onap.blueprintgenerator.models.componentspec.Self;
-import org.onap.blueprintgenerator.models.componentspec.Services;
-import org.onap.blueprintgenerator.models.componentspec.Streams;
-import org.onap.blueprintgenerator.models.componentspec.Subscribes;
-import org.onap.blueprintgenerator.models.componentspec.Volumes;
import org.onap.blueprintgenerator.models.dmaapbp.DmaapNode;
import org.onap.blueprintgenerator.models.onapbp.OnapNode;
import org.onap.blueprintgenerator.models.policymodel.PolicyModel;
@@ -70,146 +54,20 @@ public class BlueprintGeneratorTest {
/**
* Component spec test.
*
- * @throws JsonParseException the json parse exception
- * @throws JsonMappingException the json mapping exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
-
@Test
- public void componentSpecTest() throws JsonParseException, JsonMappingException, IOException {
-
+ public void componentSpecTest() {
ComponentSpec spec = new ComponentSpec();
TestComponentSpec test = new TestComponentSpec();
- spec.createComponentSpecFromString(test.getCs());
-
- //Manually fill a component spec object with the values from the file itself
- ComponentSpec manualSpec = new ComponentSpec();
-
- Self self = new Self();
- self.setComponent_type("docker");
- self.setDescription("Test component spec");
- self.setName("test.component.spec");
- self.setVersion("1.0.1");
- manualSpec.setSelf(self);
-
- //assertEquals(manualSpec.getSelf(), spec.getSelf());
-
- Services services = new Services();
- CallsObj[] calls = new CallsObj[0];
- ProvidesObj[] provides = new ProvidesObj[0];
- services.setCalls(calls);
- services.setProvides(provides);
- manualSpec.setServices(null);
-
- //assertEquals(manualSpec.getServices(), spec.getServices());
-
- Streams streams = new Streams();
- Publishes[] publishes = new Publishes[2];
- Publishes pub1 = new Publishes();
- pub1.setConfig_key("TEST-PUB-DR");
- pub1.setFormat("dataformat_Hello_World_PM");
- pub1.setType("data_router");
- pub1.setVersion("1.0.0");
-
- Publishes pub2 = new Publishes();
- pub2.setConfig_key("TEST-PUB-MR");
- pub2.setFormat("dataformat_Hello_World_PM");
- pub2.setType("message_router");
- pub2.setVersion("1.0.0");
- publishes[0] = pub1;
- publishes[1] = pub2;
- streams.setPublishes(publishes);
-
- Subscribes[] subscribes = new Subscribes[2];
- Subscribes sub1 = new Subscribes();
- sub1.setConfig_key("TEST-SUB-MR");
- sub1.setFormat("dataformat_Hello_World_PM");
- sub1.setRoute("/TEST_HELLO_WORLD_SUB_MR");
- sub1.setType("message_router");
- sub1.setVersion("1.0.0");
-
- Subscribes sub2 = new Subscribes();
- sub2.setConfig_key("TEST-SUB-DR");
- sub2.setFormat("dataformat_Hello_World_PM");
- sub2.setRoute("/TEST-HELLO-WORLD-SUB-DR");
- sub2.setType("data_router");
- sub2.setVersion("1.0.0");
- subscribes[0] = sub1;
- subscribes[1] = sub2;
- streams.setSubscribes(subscribes);
-
- manualSpec.setStreams(streams);
-
- //assertEquals(manualSpec.getStreams(), spec.getStreams());
-
- Parameters[] parameters = new Parameters[1];
- Parameters par1 = new Parameters();
- par1.setName("testParam1");
- par1.setValue("test-param-1");
- par1.setDescription("test parameter 1");
- par1.setSourced_at_deployment(true);
- par1.setDesigner_editable(true);
- par1.setPolicy_editable(true);
- par1.setPolicy_group("Test_Parameters");
- par1.setRequired(true);
- par1.setType("string");
- parameters[0] = par1;
-
- manualSpec.setParameters(parameters);
-
- //assertEquals(manualSpec.getParameters(), spec.getParameters());
-
- Auxilary auxilary = new Auxilary();
- HealthCheck healthcheck = new HealthCheck();
- healthcheck.setInterval("300s");
- healthcheck.setTimeout("120s");
- healthcheck.setScript("/etc/init.d/nagios status");
- healthcheck.setType("docker");
- auxilary.setHealthcheck(healthcheck);
-
- Volumes[] volumes = new Volumes[1];
- Volumes vol1 = new Volumes();
- Container con1 = new Container();
- con1.setBind("/opt/app/manager/config/hostname");
- Host host1 = new Host();
- host1.setPath("/etc/hostname");
- host1.setMode("ro");
- vol1.setContainer(con1);
- vol1.setHost(host1);
-
- volumes[0] = vol1;
-
- auxilary.setVolumes(volumes);
-
- ArrayList<Object> ports = new ArrayList();
- ports.add("80:90");
- ports.add("99:99");
-
- TreeMap<String, String> dataBases = new TreeMap<String, String>();
- dataBases.put("TestDB1", "PGaaS");
- dataBases.put("TestDB2", "PGaaS");
- auxilary.setDatabases(dataBases);
-
- Policy pol = new Policy();
- pol.setTrigger_type("docker");
- pol.setScript_path("/opt/app/manager/bin/reconfigure.sh");
- auxilary.setPolicy(pol);
-
- auxilary.setPorts(ports);
-
- manualSpec.setAuxilary(auxilary);
-
- //assertEquals(manualSpec.getAuxilary(), spec.getAuxilary());
-
- Artifacts[] artifacts = new Artifacts[1];
- Artifacts art = new Artifacts();
- art.setType("docker image");
- art.setUri("test.tester");
-
- artifacts[0] = art;
- manualSpec.setArtifacts(artifacts);
-
- //assertEquals(manualSpec.getArtifacts(), spec.getArtifacts());
+ spec.createComponentSpecFromString(test.getComponentSpecAsString());
+ ComponentSpec expectedSpec = test.getComponentSpec();
+
+ assertEquals(expectedSpec.getSelf(), spec.getSelf());
+ assertEquals(expectedSpec.getServices(), spec.getServices());
+ assertEquals(expectedSpec.getStreams(), spec.getStreams());
+ assertArrayEquals(expectedSpec.getParameters(), spec.getParameters());
+ assertEquals(expectedSpec.getAuxilary(), spec.getAuxilary());
+ assertArrayEquals(expectedSpec.getArtifacts(), spec.getArtifacts());
}
/**
@@ -219,11 +77,11 @@ public class BlueprintGeneratorTest {
public void toscaDefinitionTest() {
ComponentSpec cs = new ComponentSpec();
TestComponentSpec test = new TestComponentSpec();
- cs.createComponentSpecFromString(test.getCs());
+ cs.createComponentSpecFromString(test.getComponentSpecAsString());
Blueprint bp = new Blueprint();
bp = bp.createBlueprint(cs, "", 'o', "", "");
- assertEquals(bp.getTosca_definitions_version(), "cloudify_dsl_1_3");
+ assertEquals("cloudify_dsl_1_3", bp.getTosca_definitions_version());
}
/**
@@ -233,19 +91,16 @@ public class BlueprintGeneratorTest {
public void importsTest() {
ComponentSpec cs = new ComponentSpec();
TestComponentSpec test = new TestComponentSpec();
- cs.createComponentSpecFromString(test.getCs());
+ cs.createComponentSpecFromString(test.getComponentSpecAsString());
Blueprint bp = new Blueprint();
bp = bp.createBlueprint(cs, "", 'o', "", "");
- ArrayList<String> imps = new ArrayList<String>();
-
- imps.add("http://www.getcloudify.org/spec/cloudify/3.4/types.yaml");
- imps.add(
- "https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml");
- imps.add(
- "https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/dcaepolicyplugin/2.4.0/dcaepolicyplugin_types.yaml");
- assertEquals(bp.getImports(), imps);
+ ArrayList<String> imps = new ArrayList<>();
+ imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml");
+ imps.add("plugin:k8splugin?version=3.4.2");
+ imps.add("plugin:dcaepolicyplugin?version=2.4.0");
+ assertEquals(imps, bp.getImports());
}
@Test
@@ -256,50 +111,49 @@ public class BlueprintGeneratorTest {
Blueprint bp = new Blueprint();
bp = bp.createBlueprint(cs, "", 'o', "", "");
- TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
+ TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<>();
//mr inputs
- LinkedHashMap<String, Object> stringType = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
stringType.put("type", "string");
//necessary inputs
- LinkedHashMap<String, Object> tag = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> tag = new LinkedHashMap<>();
tag.put("type", "string");
String tester = "test.tester";
tag.put("default", '"' + tester + '"');
- String tagVersion = "tag_version";
inputs.put("tag_version", tag);
inputs.put("log_directory", stringType);
- LinkedHashMap cert = new LinkedHashMap();
+ LinkedHashMap<String, Object> cert = new LinkedHashMap<>();
cert.put("type", "string");
cert.put("default", "");
inputs.put("cert_directory", cert);
- LinkedHashMap<String, Object> env = new LinkedHashMap();
+ LinkedHashMap<String, Object> env = new LinkedHashMap<>();
env.put("default", "{}");
inputs.put("envs", env);
- LinkedHashMap port = new LinkedHashMap();
+ LinkedHashMap<String, Object> port = new LinkedHashMap<>();
port.put("type", "string");
port.put("description", "Kubernetes node port on which collector is exposed");
port.put("default", "99");
inputs.put("external_port", port);
- LinkedHashMap<String, Object> rep = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> rep = new LinkedHashMap<>();
rep.put("type", "integer");
rep.put("description", "number of instances");
rep.put("default", 1);
inputs.put("replicas", rep);
- LinkedHashMap<String, Object> aaf = new LinkedHashMap();
+ LinkedHashMap<String, Object> aaf = new LinkedHashMap<>();
aaf.put("type", "boolean");
aaf.put("default", false);
inputs.put("use_tls", aaf);
//parmaeter input
- LinkedHashMap<String, Object> test = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> test = new LinkedHashMap<>();
test.put("type", "string");
String testParam = "test-param-1";
test.put("default", '"' + testParam + '"');
@@ -325,19 +179,17 @@ public class BlueprintGeneratorTest {
inputs.put("topic0_name", stringType);
inputs.put("topic1_name", stringType);
- LinkedHashMap<String, Object> cpu = new LinkedHashMap();
+ LinkedHashMap<String, Object> cpu = new LinkedHashMap<>();
cpu.put("type", "string");
cpu.put("default", "250m");
inputs.put("test.component.spec_cpu_limit", cpu);
inputs.put("test.component.spec_cpu_request", cpu);
- LinkedHashMap<String, Object> mem = new LinkedHashMap();
+ LinkedHashMap<String, Object> mem = new LinkedHashMap<>();
mem.put("type", "string");
mem.put("default", "128Mi");
inputs.put("test.component.spec_memory_limit", mem);
inputs.put("test.component.spec_memory_request", mem);
-
- assertEquals(true, true);
}
@Test
@@ -355,10 +207,9 @@ public class BlueprintGeneratorTest {
//set the type
testNode.setType("dcae.nodes.ContainerizedServiceComponent");
- ArrayList<String> ports = new ArrayList<String>();
+ ArrayList<String> ports = new ArrayList<>();
ports.add("concat: [\"80:\", {get_input: external_port }]");
ports.add("concat: [\"99:\", {get_input: external_port }]");
- assertEquals(true, true);
}
@Test
@@ -372,7 +223,7 @@ public class BlueprintGeneratorTest {
OnapNode node = (OnapNode) bp.getNode_templates().get("test.component.spec");
GetInput par = (GetInput) node.getProperties().getApplication_config().getParams().get("testParam1");
- assertEquals(par.getBpInputName(), "testParam1");
+ assertEquals("testParam1", par.getBpInputName());
}
@Test
@@ -385,13 +236,7 @@ public class BlueprintGeneratorTest {
OnapNode node = (OnapNode) bp.getNode_templates().get("test.component.spec");
- boolean test = false;
- if (!node.getProperties().getApplication_config().getStreams_publishes().isEmpty()) {
- test = true;
- System.out.println("tst");
- }
-
- assertEquals(true, test);
+ assertFalse(node.getProperties().getApplication_config().getStreams_publishes().isEmpty());
}
@Test
@@ -405,13 +250,8 @@ public class BlueprintGeneratorTest {
DmaapNode dmaap = (DmaapNode) bp.getNode_templates().get("test.component.spec");
//check if the stream publishes and subscribes are not null to see if the dmaap plugin was invoked properly
- boolean d = false;
-
- if (dmaap.getProperties().getStreams_publishes() != null
- || dmaap.getProperties().getStreams_subscribes() != null) {
- d = true;
- }
- assertEquals(true, d);
+ assertNotNull(dmaap.getProperties().getStreams_publishes());
+ assertNotNull(dmaap.getProperties().getStreams_subscribes());
}
@Test
@@ -442,17 +282,5 @@ public class BlueprintGeneratorTest {
PolicyModel p = new PolicyModel();
p.createPolicyModels(cs, "TestModels");
-
- assertEquals(true, true);
- }
-
- private void assertContainsInputWithDefault(Blueprint bp, String inputName, Object defaultValue) {
- LinkedHashMap<String, Object> input = bp.getInputs().get(inputName);
- assertNotNull(input);
- assertEquals(defaultValue, input.get("default"));
- }
-
- private String inQuotes(String filedName) {
- return String.format("\"%s\"", filedName);
}
}