diff options
Diffstat (limited to 'src')
18 files changed, 425 insertions, 63 deletions
diff --git a/src/main/java/org/onap/pomba/common/datatypes/Attribute.java b/src/main/java/org/onap/pomba/common/datatypes/Attribute.java index d73435e..6a1f7b3 100644 --- a/src/main/java/org/onap/pomba/common/datatypes/Attribute.java +++ b/src/main/java/org/onap/pomba/common/datatypes/Attribute.java @@ -24,15 +24,15 @@ import com.google.gson.annotations.SerializedName; public class Attribute {
@Expose
@SerializedName("name")
- private String name;
+ private Name name;
@Expose
@SerializedName("value")
- private Value value;
+ private String value;
@Expose
@SerializedName("dataQuality")
private DataQuality dataQuality = new DataQuality();
- public enum Value {
+ public enum Name {
adminState,
ipAddress,
hostName,
@@ -45,16 +45,16 @@ public class Attribute { networkRole,
routerExternalBoolean
}
- public String getName() {
+ public Name getName() {
return name;
}
- public void setName(String name) {
+ public void setName(Name name) {
this.name = name;
}
- public Value getValue() {
+ public String getValue() {
return value;
}
- public void setValue(Value value) {
+ public void setValue(String value) {
this.value = value;
}
public DataQuality getDataQuality() {
diff --git a/src/main/java/org/onap/pomba/common/datatypes/DataQuality.java b/src/main/java/org/onap/pomba/common/datatypes/DataQuality.java index 111fd94..9c442e0 100644 --- a/src/main/java/org/onap/pomba/common/datatypes/DataQuality.java +++ b/src/main/java/org/onap/pomba/common/datatypes/DataQuality.java @@ -49,4 +49,25 @@ public class DataQuality { public void setErrorText(String errorText) {
this.errorText = errorText;
}
+
+ public static DataQuality ok() {
+ // as a non-mutable class, it is not safe to define a constant for this
+ DataQuality result = new DataQuality();
+ result.setStatus(Status.ok);
+ return result;
+ }
+
+ public static DataQuality error(String text) {
+ // as a non-mutable class, it is not safe to define a constant for this
+ DataQuality result = new DataQuality();
+ result.setStatus(Status.error);
+ result.setErrorText(text);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "DataQuality [status=" + this.status + ", errorText=" + this.errorText + "]";
+ }
+
}
diff --git a/src/main/java/org/onap/pomba/common/datatypes/ModelContext.java b/src/main/java/org/onap/pomba/common/datatypes/ModelContext.java index 523ed52..592d68a 100644 --- a/src/main/java/org/onap/pomba/common/datatypes/ModelContext.java +++ b/src/main/java/org/onap/pomba/common/datatypes/ModelContext.java @@ -50,19 +50,19 @@ public class ModelContext { public void setDataQuality(DataQuality dataQuality) {
this.dataQuality = dataQuality;
}
- public List<Attribute> getAttribute() {
+ public List<Attribute> getAttributes() {
return attributeList;
}
- public void setAttribute(List<Attribute> attributeList) {
+ public void setAttributes(List<Attribute> attributeList) {
this.attributeList = attributeList;
}
public void addAttribute(Attribute attribute) {
this.attributeList.add(attribute);
}
- public List<VF> getVf() {
+ public List<VF> getVfs() {
return vfList;
}
- public void setVf(List<VF> vfList) {
+ public void setVfs(List<VF> vfList) {
this.vfList = vfList;
}
public void addVf(VF vf) {
diff --git a/src/main/java/org/onap/pomba/common/datatypes/Network.java b/src/main/java/org/onap/pomba/common/datatypes/Network.java new file mode 100644 index 0000000..19c286c --- /dev/null +++ b/src/main/java/org/onap/pomba/common/datatypes/Network.java @@ -0,0 +1,86 @@ +/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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=====================================================
+ */
+
+package org.onap.pomba.common.datatypes;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Network {
+ @Expose
+ @SerializedName("name")
+ private String name;
+ @Expose
+ @SerializedName("invariantUUID")
+ private String invariantUuid;
+ @Expose
+ @SerializedName("uuid")
+ private String uuid;
+ @Expose
+ @SerializedName("nfNamingCode")
+ private String nfcNamingCode;
+ @Expose
+ @SerializedName("dataQuality")
+ private DataQuality dataQuality = new DataQuality();
+ @Expose
+ @SerializedName("attributeList")
+ private List<Attribute> attributeList = new ArrayList<>();
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getInvariantUuid() {
+ return invariantUuid;
+ }
+ public void setInvariantUuid(String invariantUuid) {
+ this.invariantUuid = invariantUuid;
+ }
+ public String getUuid() {
+ return uuid;
+ }
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+ public String getNfcNamingCode() {
+ return nfcNamingCode;
+ }
+ public void setNfcNamingCode(String nfcType) {
+ this.nfcNamingCode = nfcType;
+ }
+ public List<Attribute> getAttributes() {
+ return attributeList;
+ }
+ public void setAttributes(List<Attribute> attributeList) {
+ this.attributeList = attributeList;
+ }
+ public void addAttribute(Attribute attribute) {
+ this.attributeList.add(attribute);
+ }
+ public DataQuality getDataQuality() {
+ return dataQuality;
+ }
+ public void setDataQuality(DataQuality dataQuality) {
+ this.dataQuality = dataQuality;
+ }
+
+}
diff --git a/src/main/java/org/onap/pomba/common/datatypes/Service.java b/src/main/java/org/onap/pomba/common/datatypes/Service.java index 1fde805..b225b6a 100644 --- a/src/main/java/org/onap/pomba/common/datatypes/Service.java +++ b/src/main/java/org/onap/pomba/common/datatypes/Service.java @@ -65,10 +65,10 @@ public class Service { public void setDataQuality(DataQuality dataQuality) {
this.dataQuality = dataQuality;
}
- public List<Attribute> getAttribute() {
+ public List<Attribute> getAttributes() {
return attributeList;
}
- public void setAttribute(List<Attribute> attributeList) {
+ public void setAttributes(List<Attribute> attributeList) {
this.attributeList = attributeList;
}
public void addAttribute(Attribute attribute) {
diff --git a/src/main/java/org/onap/pomba/common/datatypes/VF.java b/src/main/java/org/onap/pomba/common/datatypes/VF.java index 05fb9ec..7bbb962 100644 --- a/src/main/java/org/onap/pomba/common/datatypes/VF.java +++ b/src/main/java/org/onap/pomba/common/datatypes/VF.java @@ -52,7 +52,7 @@ public class VF { private List<VFModule> vfModules = new ArrayList<>();
@Expose
@SerializedName("vnfcList")
- private List<VNFC> vnfc = new ArrayList<>();
+ private List<VNFC> vnfcs = new ArrayList<>();
public String getName() {
return name;
@@ -93,19 +93,19 @@ public class VF { public void addVfModule(VFModule vfModule) {
this.vfModules.add(vfModule);
}
- public List<VNFC> getVnfc() {
- return vnfc;
+ public List<VNFC> getVnfcs() {
+ return vnfcs;
}
- public void setVnfc(List<VNFC> vnfc) {
- this.vnfc = vnfc;
+ public void setVnfcs(List<VNFC> vnfc) {
+ this.vnfcs = vnfc;
}
public void addVnfc(VNFC vnfc) {
- this.vnfc.add(vnfc);
+ this.vnfcs.add(vnfc);
}
- public List<Attribute> getAttribute() {
+ public List<Attribute> getAttributes() {
return attributeList;
}
- public void setAttribute(List<Attribute> attributeList) {
+ public void setAttributes(List<Attribute> attributeList) {
this.attributeList = attributeList;
}
public void addAttribute(Attribute attribute) {
diff --git a/src/main/java/org/onap/pomba/common/datatypes/VFModule.java b/src/main/java/org/onap/pomba/common/datatypes/VFModule.java index 1c82801..876f6b2 100644 --- a/src/main/java/org/onap/pomba/common/datatypes/VFModule.java +++ b/src/main/java/org/onap/pomba/common/datatypes/VFModule.java @@ -49,6 +49,12 @@ public class VFModule { @Expose
@SerializedName("attributeList")
private List<Attribute> attributeList = new ArrayList<>();
+ @Expose
+ @SerializedName("vmList")
+ private List<VM> vms = new ArrayList<>();
+ @Expose
+ @SerializedName("networkList")
+ private List<Network> networks = new ArrayList<>();
public String getName() {
@@ -87,10 +93,28 @@ public class VFModule { public void setMinInstances(int minInstances) {
this.minInstances = minInstances;
}
- public List<Attribute> getAttribute() {
+ public List<VM> getVms() {
+ return vms;
+ }
+ public void setVms(List<VM> vms) {
+ this.vms = vms;
+ }
+ public void addVm(VM vm) {
+ this.vms.add(vm);
+ }
+ public List<Network> getNetworks() {
+ return networks;
+ }
+ public void setNetworks(List<Network> network) {
+ this.networks = network;
+ }
+ public void addNetwork(Network vnfc) {
+ this.networks.add(vnfc);
+ }
+ public List<Attribute> getAttributes() {
return attributeList;
}
- public void setAttribute(List<Attribute> attributeList) {
+ public void setAttributes(List<Attribute> attributeList) {
this.attributeList = attributeList;
}
public void addAttribute(Attribute attribute) {
diff --git a/src/main/java/org/onap/pomba/common/datatypes/VM.java b/src/main/java/org/onap/pomba/common/datatypes/VM.java new file mode 100644 index 0000000..29f4c29 --- /dev/null +++ b/src/main/java/org/onap/pomba/common/datatypes/VM.java @@ -0,0 +1,86 @@ +/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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=====================================================
+ */
+
+package org.onap.pomba.common.datatypes;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+import java.util.ArrayList;
+import java.util.List;
+
+public class VM {
+ @Expose
+ @SerializedName("name")
+ private String name;
+ @Expose
+ @SerializedName("invariantUUID")
+ private String invariantUuid;
+ @Expose
+ @SerializedName("uuid")
+ private String uuid;
+ @Expose
+ @SerializedName("nfNamingCode")
+ private String nfcNamingCode;
+ @Expose
+ @SerializedName("dataQuality")
+ private DataQuality dataQuality = new DataQuality();
+ @Expose
+ @SerializedName("attributeList")
+ private List<Attribute> attributeList = new ArrayList<>();
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getInvariantUuid() {
+ return invariantUuid;
+ }
+ public void setInvariantUuid(String invariantUuid) {
+ this.invariantUuid = invariantUuid;
+ }
+ public String getUuid() {
+ return uuid;
+ }
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+ public String getNfcNamingCode() {
+ return nfcNamingCode;
+ }
+ public void setNfcNamingCode(String nfcType) {
+ this.nfcNamingCode = nfcType;
+ }
+ public List<Attribute> getAttributes() {
+ return attributeList;
+ }
+ public void setAttributes(List<Attribute> attributeList) {
+ this.attributeList = attributeList;
+ }
+ public void addAttribute(Attribute attribute) {
+ this.attributeList.add(attribute);
+ }
+ public DataQuality getDataQuality() {
+ return dataQuality;
+ }
+ public void setDataQuality(DataQuality dataQuality) {
+ this.dataQuality = dataQuality;
+ }
+
+}
diff --git a/src/main/java/org/onap/pomba/common/datatypes/VNFC.java b/src/main/java/org/onap/pomba/common/datatypes/VNFC.java index 1302b6f..66c852a 100644 --- a/src/main/java/org/onap/pomba/common/datatypes/VNFC.java +++ b/src/main/java/org/onap/pomba/common/datatypes/VNFC.java @@ -68,10 +68,10 @@ public class VNFC { public void setNfcNamingCode(String nfcType) {
this.nfcNamingCode = nfcType;
}
- public List<Attribute> getAttribute() {
+ public List<Attribute> getAttributes() {
return attributeList;
}
- public void setAttribute(List<Attribute> attributeList) {
+ public void setAttributes(List<Attribute> attributeList) {
this.attributeList = attributeList;
}
public void addAttribute(Attribute attribute) {
diff --git a/src/test/java/org/onap/pomba/common/datatypes/AttributeTests.java b/src/test/java/org/onap/pomba/common/datatypes/AttributeTests.java index 2eb6a72..261b8a2 100644 --- a/src/test/java/org/onap/pomba/common/datatypes/AttributeTests.java +++ b/src/test/java/org/onap/pomba/common/datatypes/AttributeTests.java @@ -21,17 +21,17 @@ package org.onap.pomba.common.datatypes; import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.onap.pomba.common.datatypes.Attribute.Value;
+import org.onap.pomba.common.datatypes.Attribute.Name;
import org.onap.pomba.common.datatypes.DataQuality.Status;
public class AttributeTests {
@Test
public void testAttribute() {
Attribute attribute = new Attribute();
- attribute.setName("Attribute");
- attribute.setValue(Value.adminState);
- assertTrue("Attribute name doesn't match", attribute.getName().equals("Attribute"));
- assertTrue("Attribute value doesn't match", attribute.getValue().equals(Value.adminState));
+ attribute.setName(Name.hostName);
+ attribute.setValue("Attribute");
+ assertTrue("Attribute name doesn't match", attribute.getName().equals(Name.hostName));
+ assertTrue("Attribute value doesn't match", attribute.getValue().equals("Attribute"));
DataQuality dataQuality = new DataQuality();
dataQuality.setStatus(Status.error);
dataQuality.setErrorText("Test");
diff --git a/src/test/java/org/onap/pomba/common/datatypes/DataQualityTests.java b/src/test/java/org/onap/pomba/common/datatypes/DataQualityTests.java index 3a71cd8..df0e808 100644 --- a/src/test/java/org/onap/pomba/common/datatypes/DataQualityTests.java +++ b/src/test/java/org/onap/pomba/common/datatypes/DataQualityTests.java @@ -18,6 +18,8 @@ package org.onap.pomba.common.datatypes;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
@@ -34,4 +36,16 @@ public class DataQualityTests { assertTrue("DataQuality status doesn't match", dataQuality.getStatus().equals(Status.error));
assertTrue("DataQuality error text doesn't match", dataQuality.getErrorText().equals("Test"));
}
+
+ @Test
+ public void dataQualityHelpers() {
+ DataQuality dataQuality = DataQuality.ok();
+ assertEquals(DataQuality.Status.ok, dataQuality.getStatus());
+ assertNull(dataQuality.getErrorText());
+
+ dataQuality = DataQuality.error("test");
+ assertEquals(DataQuality.Status.error, dataQuality.getStatus());
+ assertEquals("test", dataQuality.getErrorText());
+ assertTrue(dataQuality.toString().contains("test"));
+ }
}
diff --git a/src/test/java/org/onap/pomba/common/datatypes/ModelContextTests.java b/src/test/java/org/onap/pomba/common/datatypes/ModelContextTests.java index 85dbfc7..ee04a08 100644 --- a/src/test/java/org/onap/pomba/common/datatypes/ModelContextTests.java +++ b/src/test/java/org/onap/pomba/common/datatypes/ModelContextTests.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List;
import org.junit.Test;
+import org.onap.pomba.common.datatypes.Attribute.Name;
import org.onap.pomba.common.datatypes.DataQuality.Status;
public class ModelContextTests {
@@ -38,12 +39,12 @@ public class ModelContextTests { assertTrue("ModelContext data quality status doesn't match", modelContext.getDataQuality().getStatus().equals(Status.error));
assertTrue("ModelContext data quality error text doesn't match", modelContext.getDataQuality().getErrorText().equals("Test"));
Attribute attribute = new Attribute();
- attribute.setName("Attribute");
+ attribute.setName(Name.hostName);
modelContext.addAttribute(attribute);
- assertTrue("ModelContext attribute name doesn't match", modelContext.getAttribute().get(0).getName().equals("Attribute"));
- List<Attribute> attributeList = modelContext.getAttribute();
- modelContext.setAttribute(attributeList);
- assertEquals(modelContext.getAttribute().size(), 1);
+ assertTrue("ModelContext attribute name doesn't match", modelContext.getAttributes().get(0).getName().equals(Name.hostName));
+ List<Attribute> attributeList = modelContext.getAttributes();
+ modelContext.setAttributes(attributeList);
+ assertEquals(modelContext.getAttributes().size(), 1);
}
@Test
@@ -63,8 +64,8 @@ public class ModelContextTests { VF aVF = new VF();
aVF.setName("VF name");
vfList.add(aVF);
- modelContext.setVf(vfList);
- assertEquals(modelContext.getVf().size(), 1);
+ modelContext.setVfs(vfList);
+ assertEquals(modelContext.getVfs().size(), 1);
}
@Test
@@ -73,8 +74,8 @@ public class ModelContextTests { VF aVF = new VF();
aVF.setName("VF name");
modelContext.addVf(aVF);
- assertEquals(modelContext.getVf().size(), 1);
- assertTrue("ModelContext VF name doesn't match", modelContext.getVf().get(0).getName().equals("VF name"));
+ assertEquals(modelContext.getVfs().size(), 1);
+ assertTrue("ModelContext VF name doesn't match", modelContext.getVfs().get(0).getName().equals("VF name"));
}
}
diff --git a/src/test/java/org/onap/pomba/common/datatypes/NetworkTests.java b/src/test/java/org/onap/pomba/common/datatypes/NetworkTests.java new file mode 100644 index 0000000..747bc7c --- /dev/null +++ b/src/test/java/org/onap/pomba/common/datatypes/NetworkTests.java @@ -0,0 +1,55 @@ +/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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=====================================================
+ */
+
+package org.onap.pomba.common.datatypes;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import java.util.List;
+import org.junit.Test;
+import org.onap.pomba.common.datatypes.Attribute.Name;
+import org.onap.pomba.common.datatypes.DataQuality.Status;
+
+public class NetworkTests {
+ @Test
+ public void testNetwork() {
+ Network aNetwork = new Network();
+ aNetwork.setName("Network name");
+ aNetwork.setInvariantUuid("Invariant Uuid");
+ aNetwork.setUuid("Uuid");
+ aNetwork.setNfcNamingCode("NFC Naming Code");
+ DataQuality dataQuality = new DataQuality();
+ dataQuality.setStatus(Status.error);
+ dataQuality.setErrorText("Test");
+ aNetwork.setDataQuality(dataQuality);
+ Attribute attribute = new Attribute();
+ attribute.setName(Name.hostName);
+ aNetwork.addAttribute(attribute);
+ assertTrue("Network name doesn't match", aNetwork.getName().equals("Network name"));
+ assertTrue("Network invariant uuid doesn't match", aNetwork.getInvariantUuid().equals("Invariant Uuid"));
+ assertTrue("Network NFC Naming Code doesn't match", aNetwork.getNfcNamingCode().equals("NFC Naming Code"));
+ assertTrue("Network uuid doesn't match", aNetwork.getUuid().equals("Uuid"));
+ assertTrue("Network data quality status doesn't match", aNetwork.getDataQuality().getStatus().equals(Status.error));
+ assertTrue("Network data quality error text doesn't match", aNetwork.getDataQuality().getErrorText().equals("Test"));
+ assertTrue("Network attribute name doesn't match", aNetwork.getAttributes().get(0).getName().equals(Name.hostName));
+ List<Attribute> attributeList = aNetwork.getAttributes();
+ aNetwork.setAttributes(attributeList);
+ assertEquals(aNetwork.getAttributes().size(), 1);
+ }
+
+}
diff --git a/src/test/java/org/onap/pomba/common/datatypes/ServiceTests.java b/src/test/java/org/onap/pomba/common/datatypes/ServiceTests.java index a4ebc74..10f9339 100644 --- a/src/test/java/org/onap/pomba/common/datatypes/ServiceTests.java +++ b/src/test/java/org/onap/pomba/common/datatypes/ServiceTests.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
+import org.onap.pomba.common.datatypes.Attribute.Name;
import org.onap.pomba.common.datatypes.DataQuality.Status;
public class ServiceTests {
@@ -36,16 +37,16 @@ public class ServiceTests { dataQuality.setErrorText("Test");
aService.setDataQuality(dataQuality);
Attribute attribute = new Attribute();
- attribute.setName("Attribute");
+ attribute.setName(Name.hostName);
aService.addAttribute(attribute);
assertTrue("Service Name doesn't match", aService.getName().equals("new service"));
assertTrue("Invariant Uuid doesn't match", aService.getInvariantUuid().equals("Invariant Uuid"));
assertTrue("Uuid doesn't match", aService.getUuid().equals("Uuid"));
assertTrue("Service data quality status doesn't match", aService.getDataQuality().getStatus().equals(Status.error));
assertTrue("Service data quality error text doesn't match", aService.getDataQuality().getErrorText().equals("Test"));
- assertTrue("Service attribute name doesn't match", aService.getAttribute().get(0).getName().equals("Attribute"));
- List<Attribute> attributeList = aService.getAttribute();
- aService.setAttribute(attributeList);
- assertEquals(aService.getAttribute().size(), 1);
+ assertTrue("Service attribute name doesn't match", aService.getAttributes().get(0).getName().equals(Name.hostName));
+ List<Attribute> attributeList = aService.getAttributes();
+ aService.setAttributes(attributeList);
+ assertEquals(aService.getAttributes().size(), 1);
}
}
diff --git a/src/test/java/org/onap/pomba/common/datatypes/VMTests.java b/src/test/java/org/onap/pomba/common/datatypes/VMTests.java new file mode 100644 index 0000000..0d74c00 --- /dev/null +++ b/src/test/java/org/onap/pomba/common/datatypes/VMTests.java @@ -0,0 +1,55 @@ +/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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=====================================================
+ */
+
+package org.onap.pomba.common.datatypes;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import java.util.List;
+import org.junit.Test;
+import org.onap.pomba.common.datatypes.Attribute.Name;
+import org.onap.pomba.common.datatypes.DataQuality.Status;
+
+public class VMTests {
+ @Test
+ public void testVM() {
+ VM aVM = new VM();
+ aVM.setName("VM name");
+ aVM.setInvariantUuid("Invariant Uuid");
+ aVM.setUuid("Uuid");
+ aVM.setNfcNamingCode("NFC Naming Code");
+ DataQuality dataQuality = new DataQuality();
+ dataQuality.setStatus(Status.error);
+ dataQuality.setErrorText("Test");
+ aVM.setDataQuality(dataQuality);
+ Attribute attribute = new Attribute();
+ attribute.setName(Name.hostName);
+ aVM.addAttribute(attribute);
+ assertTrue("VM name doesn't match", aVM.getName().equals("VM name"));
+ assertTrue("VM invariant uuid doesn't match", aVM.getInvariantUuid().equals("Invariant Uuid"));
+ assertTrue("VM NFC Naming Code doesn't match", aVM.getNfcNamingCode().equals("NFC Naming Code"));
+ assertTrue("VM uuid doesn't match", aVM.getUuid().equals("Uuid"));
+ assertTrue("VM data quality status doesn't match", aVM.getDataQuality().getStatus().equals(Status.error));
+ assertTrue("VM data quality error text doesn't match", aVM.getDataQuality().getErrorText().equals("Test"));
+ assertTrue("VM attribute name doesn't match", aVM.getAttributes().get(0).getName().equals(Name.hostName));
+ List<Attribute> attributeList = aVM.getAttributes();
+ aVM.setAttributes(attributeList);
+ assertEquals(aVM.getAttributes().size(), 1);
+ }
+
+}
diff --git a/src/test/java/org/onap/pomba/common/datatypes/VfModuleTests.java b/src/test/java/org/onap/pomba/common/datatypes/VfModuleTests.java index 3bb577c..3d46510 100644 --- a/src/test/java/org/onap/pomba/common/datatypes/VfModuleTests.java +++ b/src/test/java/org/onap/pomba/common/datatypes/VfModuleTests.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
+import org.onap.pomba.common.datatypes.Attribute.Name;
import org.onap.pomba.common.datatypes.DataQuality.Status;
public class VfModuleTests {
@@ -39,7 +40,7 @@ public class VfModuleTests { dataQuality.setErrorText("Test");
aVFModule.setDataQuality(dataQuality);
Attribute attribute = new Attribute();
- attribute.setName("Attribute");
+ attribute.setName(Name.hostName);
aVFModule.addAttribute(attribute);
assertTrue("VFModule Name doesn't match", aVFModule.getName().equals("Name"));
assertTrue("VFModule Invariant Uuid doesn't match", aVFModule.getInvariantUuid().equals("Invariant Uuid"));
@@ -49,9 +50,25 @@ public class VfModuleTests { assertEquals(aVFModule.getMinInstances(), 1);
assertTrue("VFModule data quality status doesn't match", aVFModule.getDataQuality().getStatus().equals(Status.error));
assertTrue("VFModule data quality error text doesn't match", aVFModule.getDataQuality().getErrorText().equals("Test"));
- assertTrue("VFModule attribute name doesn't match", aVFModule.getAttribute().get(0).getName().equals("Attribute"));
- List<Attribute> attributeList = aVFModule.getAttribute();
- aVFModule.setAttribute(attributeList);
- assertEquals(aVFModule.getAttribute().size(), 1);
+ assertTrue("VFModule attribute name doesn't match", aVFModule.getAttributes().get(0).getName().equals(Name.hostName));
+ List<Attribute> attributeList = aVFModule.getAttributes();
+ aVFModule.setAttributes(attributeList);
+ assertEquals(aVFModule.getAttributes().size(), 1);
+ VM vm = new VM();
+ vm.setName("VM");
+ aVFModule.addVm(vm);
+ assertTrue("VFModule vm name doesn't match", aVFModule.getVms().get(0).getName().equals("VM"));
+ List<VM> vmList = aVFModule.getVms();
+ aVFModule.setVms(vmList);
+ assertEquals(aVFModule.getVms().size(), 1);
+ Network network = new Network();
+ network.setName("Network");
+ aVFModule.addNetwork(network);
+ assertTrue("VFModule network name doesn't match", aVFModule.getNetworks().get(0).getName().equals("Network"));
+ List<Network> networkList = aVFModule.getNetworks();
+ aVFModule.setNetworks(networkList);
+ assertEquals(aVFModule.getNetworks().size(), 1);
+
+
}
}
diff --git a/src/test/java/org/onap/pomba/common/datatypes/VfTests.java b/src/test/java/org/onap/pomba/common/datatypes/VfTests.java index 9c17589..464758e 100644 --- a/src/test/java/org/onap/pomba/common/datatypes/VfTests.java +++ b/src/test/java/org/onap/pomba/common/datatypes/VfTests.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List;
import org.junit.Test;
+import org.onap.pomba.common.datatypes.Attribute.Name;
import org.onap.pomba.common.datatypes.DataQuality.Status;
public class VfTests {
@@ -41,7 +42,7 @@ public class VfTests { dataQuality.setErrorText("Test");
aVF.setDataQuality(dataQuality);
Attribute attribute = new Attribute();
- attribute.setName("Attribute");
+ attribute.setName(Name.hostName);
aVF.addAttribute(attribute);
assertTrue("VF name doesn't match", aVF.getName().equals("VF name"));
assertTrue("VF Type doesn't match", aVF.getType().equals("Type"));
@@ -50,10 +51,10 @@ public class VfTests { assertTrue("VF NF Naming Code doesn't match", aVF.getNfNamingCode().equals("NF Naming Code"));
assertTrue("VF data quality status doesn't match", aVF.getDataQuality().getStatus().equals(Status.error));
assertTrue("VF data quality error text doesn't match", aVF.getDataQuality().getErrorText().equals("Test"));
- assertTrue("VF attribute name doesn't match", aVF.getAttribute().get(0).getName().equals("Attribute"));
- List<Attribute> attributeList = aVF.getAttribute();
- aVF.setAttribute(attributeList);
- assertEquals(aVF.getAttribute().size(), 1);
+ assertTrue("VF attribute name doesn't match", aVF.getAttributes().get(0).getName().equals(Name.hostName));
+ List<Attribute> attributeList = aVF.getAttributes();
+ aVF.setAttributes(attributeList);
+ assertEquals(aVF.getAttributes().size(), 1);
}
@Test
@@ -111,17 +112,17 @@ public class VfTests { VNFC aVNFC = new VNFC();
aVNFC.setName("VNFC name");
vnfcList.add(aVNFC);
- aVF.setVnfc(vnfcList);
- assertTrue("VNFC list item doesn't match", aVF.getVnfc().get(0).getName().equals("VNFC name"));
+ aVF.setVnfcs(vnfcList);
+ assertTrue("VNFC list item doesn't match", aVF.getVnfcs().get(0).getName().equals("VNFC name"));
}
@Test
public void testAddVnfc() {
VF aVF = new VF();
- assertEquals(aVF.getVnfc().size(), 0);
+ assertEquals(aVF.getVnfcs().size(), 0);
VNFC aVNFC = new VNFC();
aVNFC.setName("VNFC name");
aVF.addVnfc(aVNFC);
- assertTrue("VNFC list item doesn't match", aVF.getVnfc().get(0).getName().equals("VNFC name"));
+ assertTrue("VNFC list item doesn't match", aVF.getVnfcs().get(0).getName().equals("VNFC name"));
}
}
diff --git a/src/test/java/org/onap/pomba/common/datatypes/VnfcTests.java b/src/test/java/org/onap/pomba/common/datatypes/VnfcTests.java index ea5ccc4..38d68fe 100644 --- a/src/test/java/org/onap/pomba/common/datatypes/VnfcTests.java +++ b/src/test/java/org/onap/pomba/common/datatypes/VnfcTests.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
+import org.onap.pomba.common.datatypes.Attribute.Name;
import org.onap.pomba.common.datatypes.DataQuality.Status;
public class VnfcTests {
@@ -37,7 +38,7 @@ public class VnfcTests { dataQuality.setErrorText("Test");
aVNFC.setDataQuality(dataQuality);
Attribute attribute = new Attribute();
- attribute.setName("Attribute");
+ attribute.setName(Name.hostName);
aVNFC.addAttribute(attribute);
assertTrue("VNFC name doesn't match", aVNFC.getName().equals("VNFC name"));
assertTrue("VNFC invariant uuid doesn't match", aVNFC.getInvariantUuid().equals("Invariant Uuid"));
@@ -45,9 +46,9 @@ public class VnfcTests { assertTrue("VNFC uuid doesn't match", aVNFC.getUuid().equals("Uuid"));
assertTrue("VNFC data quality status doesn't match", aVNFC.getDataQuality().getStatus().equals(Status.error));
assertTrue("VNFC data quality error text doesn't match", aVNFC.getDataQuality().getErrorText().equals("Test"));
- assertTrue("VNFC attribute name doesn't match", aVNFC.getAttribute().get(0).getName().equals("Attribute"));
- List<Attribute> attributeList = aVNFC.getAttribute();
- aVNFC.setAttribute(attributeList);
- assertEquals(aVNFC.getAttribute().size(), 1);
+ assertTrue("VNFC attribute name doesn't match", aVNFC.getAttributes().get(0).getName().equals(Name.hostName));
+ List<Attribute> attributeList = aVNFC.getAttributes();
+ aVNFC.setAttributes(attributeList);
+ assertEquals(aVNFC.getAttributes().size(), 1);
}
}
|