aboutsummaryrefslogtreecommitdiffstats
path: root/common-be/src
diff options
context:
space:
mode:
Diffstat (limited to 'common-be/src')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinition.java173
-rw-r--r--common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinitionTest.java42
2 files changed, 13 insertions, 202 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinition.java
index f8402b7a3a..4b7b6aa413 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinition.java
@@ -21,6 +21,10 @@
package org.openecomp.sdc.be.datatypes.elements;
import com.google.common.collect.Lists;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
@@ -30,11 +34,17 @@ import java.util.List;
/**
* Represents the requirement of the component or component instance
*/
+@EqualsAndHashCode
+@ToString
public class RequirementDataDefinition extends ToscaDataDefinition {
public static final String MIN_OCCURRENCES = "0";
public static final String MAX_OCCURRENCES = "UNBOUNDED";
public static final String MAX_DEFAULT_OCCURRENCES = "1";
+
+ @Getter
+ @Setter
+ public boolean external = false;
/**
* The default constructor initializing limits of the occurrences
@@ -69,6 +79,7 @@ public class RequirementDataDefinition extends ToscaDataDefinition {
this.setPath(Lists.newArrayList(other.getPath()));
}
this.setSource(other.getSource());
+ this.setExternal(other.isExternal());
}
/**
@@ -218,166 +229,4 @@ public class RequirementDataDefinition extends ToscaDataDefinition {
setPath(path);
}
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- String name = getName();
- String uniqueId = getUniqueId();
- String capability = getCapability();
- String node = getNode();
- String relationship = getRelationship();
- String ownerId = getOwnerId();
- String ownerName = getOwnerName();
- String minOccurrences = getMinOccurrences();
- String maxOccurrences = getMaxOccurrences();
- String leftOccurrences = getLeftOccurrences();
-
- List<String> path = this.getPath();
- String source = getSource();
-
- result = prime * result + ((capability == null) ? 0 : capability.hashCode());
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((node == null) ? 0 : node.hashCode());
- result = prime * result + ((ownerId == null) ? 0 : ownerId.hashCode());
- result = prime * result + ((ownerName == null) ? 0 : ownerName.hashCode());
- result = prime * result + ((relationship == null) ? 0 : relationship.hashCode());
- result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
- result = prime * result + ((minOccurrences == null) ? 0 : minOccurrences.hashCode());
- result = prime * result + ((maxOccurrences == null) ? 0 : maxOccurrences.hashCode());
- result = prime * result + ((leftOccurrences == null) ? 0 : leftOccurrences.hashCode());
- result = prime * result + ((path == null) ? 0 : path.hashCode());
- result = prime * result + ((source == null) ? 0 : source.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- RequirementDataDefinition other = (RequirementDataDefinition) obj;
-
- String name = getName();
- String uniqueId = getUniqueId();
- String capability = getCapability();
- String node = getNode();
- String relationship = getRelationship();
- String ownerId = getOwnerId();
- String ownerName = getOwnerName();
- String minOccurrences = getMinOccurrences();
- String maxOccurrences = getMaxOccurrences();
- String leftOccurrences = getLeftOccurrences();
- List<String> path = this.getPath();
- String source = getSource();
-
- if (capability == null) {
- if (other.getCapability() != null) {
- return false;
- }
- } else if (!capability.equals(other.getCapability())) {
- return false;
- }
- if (name == null) {
- if (other.getName() != null) {
- return false;
- }
- } else if (!name.equals(other.getName())) {
- return false;
- }
- if (node == null) {
- if (other.getNode() != null) {
- return false;
- }
- } else if (!node.equals(other.getNode())) {
- return false;
- }
- if (ownerId == null) {
- if (other.getOwnerId() != null) {
- return false;
- }
- } else if (!ownerId.equals(other.getOwnerId())) {
- return false;
- }
- if (ownerName == null) {
- if (other.getOwnerName() != null) {
- return false;
- }
- } else if (!ownerName.equals(other.getOwnerName())) {
- return false;
- }
- if (relationship == null) {
- if (other.getRelationship() != null) {
- return false;
- }
- } else if (!relationship.equals(other.getRelationship())) {
- return false;
- }
- if (uniqueId == null) {
- if (other.getUniqueId() != null) {
- return false;
- }
- } else if (!uniqueId.equals(other.getUniqueId())) {
- return false;
- }
- if (minOccurrences == null) {
- if (other.getMinOccurrences() != null) {
- return false;
- }
- } else if (!minOccurrences.equals(other.getMinOccurrences())) {
- return false;
- }
- if (maxOccurrences == null) {
- if (other.getMaxOccurrences() != null) {
- return false;
- }
- } else if (!maxOccurrences.equals(other.getMaxOccurrences())) {
- return false;
- }
- if (leftOccurrences == null) {
- if (other.getLeftOccurrences() != null) {
- return false;
- }
- } else if (!leftOccurrences.equals(other.getLeftOccurrences())) {
- return false;
- }
- if (path == null) {
- if (other.getPath() != null) {
- return false;
- }
- } else if (!path.equals(other.getPath())) {
- return false;
- }
- if (source == null) {
- return other.getSource() == null;
- } else {
- return source.equals(other.getSource());
- }
- }
-
- @Override
- public String toString() {
- String name = getName();
- String uniqueId = getUniqueId();
- String capability = getCapability();
- String node = getNode();
- String relationship = getRelationship();
- String ownerId = getOwnerId();
- String ownerName = getOwnerName();
- String minOccurrences = getMinOccurrences();
- String maxOccurrences = getMaxOccurrences();
- String leftOccurrences = getLeftOccurrences();
- List<String> path = this.getPath();
- String source = getSource();
-
- return "RequirementDefinition [uniqueId=" + uniqueId + ", name=" + name + ", capability=" + capability + ", node=" + node + ", relationship=" + relationship + ", ownerId=" + ownerId + ", ownerName=" + ownerName + ", minOccurrences="
- + minOccurrences + ", maxOccurrences=" + maxOccurrences + ",leftOccurrences=" + leftOccurrences + ", path=" + path + ", source=" + source + "]";
- }
-
}
diff --git a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinitionTest.java b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinitionTest.java
index 6e13054201..1fbe448959 100644
--- a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinitionTest.java
+++ b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinitionTest.java
@@ -22,7 +22,8 @@ package org.openecomp.sdc.be.datatypes.elements;
import org.junit.Assert;
import org.junit.Test;
-
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.util.List;
@@ -338,43 +339,4 @@ public class RequirementDataDefinitionTest {
testSubject.addToPath(elementInPath);
}
-
- @Test
- public void testHashCode() throws Exception {
- RequirementDataDefinition testSubject;
- int result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.hashCode();
- }
-
-
- @Test
- public void testEquals() throws Exception {
- RequirementDataDefinition testSubject;
- Object obj = null;
- boolean result;
-
- // test 1
- testSubject = createTestSubject();
- obj = null;
- result = testSubject.equals(obj);
- Assert.assertEquals(false, result);
- result = testSubject.equals(testSubject);
- Assert.assertEquals(true, result);
- result = testSubject.equals(createTestSubject());
- Assert.assertEquals(true, result);
- }
-
-
- @Test
- public void testToString() throws Exception {
- RequirementDataDefinition testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
}