summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-domain
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-domain')
-rw-r--r--ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Domain.java88
-rw-r--r--ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/DomainTest.java28
-rw-r--r--ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/LayoutTest.java64
3 files changed, 142 insertions, 38 deletions
diff --git a/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Domain.java b/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Domain.java
index dcf4fd54..8dd51757 100644
--- a/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Domain.java
+++ b/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Domain.java
@@ -65,20 +65,80 @@ public class Domain {
double newXafterColl;
double YafterColl;
- public Domain(String id, String name, double interContWd, double interContH, double domainToLayoutWd,
- double domainToLayoutH, double domainToContH, int numOfRowsofContainer, int numOfColsofContainer) {
- this.id = id;
- this.name = name;
- this.interContWd = interContWd;
- this.interContH = interContH;
- this.domainToLayoutWd = domainToLayoutWd;
- this.domainToLayoutH = domainToLayoutH;
- this.domainToContH = domainToContH;
- this.numOfRowsofContainer = numOfRowsofContainer;
- this.numOfColsofContainer = numOfColsofContainer;
- }
-
- public Position getP() {
+ public static class DomainBuilder {
+ private String id;
+ private String name;
+ private double interContWd;
+ private double interContH;
+ private double domainToLayoutWd;
+ private double domainToLayoutH;
+ private double domainToContH;
+ private int numOfRowsofContainer;
+ private int numOfColsofContainer;
+
+ public DomainBuilder setId(String id) {
+ this.id = id;
+ return this;
+ }
+
+ public DomainBuilder setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public DomainBuilder setInterContWd(double interContWd) {
+ this.interContWd = interContWd;
+ return this;
+ }
+
+ public DomainBuilder setInterContH(double interContH) {
+ this.interContH = interContH;
+ return this;
+ }
+
+ public DomainBuilder setDomainToLayoutWd(double domainToLayoutWd) {
+ this.domainToLayoutWd = domainToLayoutWd;
+ return this;
+ }
+
+ public DomainBuilder setDomainToLayoutH(double domainToLayoutH) {
+ this.domainToLayoutH = domainToLayoutH;
+ return this;
+ }
+
+ public DomainBuilder setDomainToContH(double domainToContH) {
+ this.domainToContH = domainToContH;
+ return this;
+ }
+
+ public DomainBuilder setNumOfRowsofContainer(int numOfRowsofContainer) {
+ this.numOfRowsofContainer = numOfRowsofContainer;
+ return this;
+ }
+
+ public DomainBuilder setNumOfColsofContainer(int numOfColsofContainer) {
+ this.numOfColsofContainer = numOfColsofContainer;
+ return this;
+ }
+
+ public Domain createDomain() {
+ return new Domain(this);
+ }
+ }
+
+ public Domain(DomainBuilder domainBuilder) {
+ this.id = domainBuilder.id;
+ this.name = domainBuilder.name;
+ this.interContWd = domainBuilder.interContWd;
+ this.interContH = domainBuilder.interContH;
+ this.domainToLayoutWd = domainBuilder.domainToLayoutWd;
+ this.domainToLayoutH = domainBuilder.domainToLayoutH;
+ this.domainToContH = domainBuilder.domainToContH;
+ this.numOfRowsofContainer = domainBuilder.numOfRowsofContainer;
+ this.numOfColsofContainer = domainBuilder.numOfColsofContainer;
+ }
+
+ public Position getP() {
return p;
}
diff --git a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/DomainTest.java b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/DomainTest.java
index ec455b43..016cd3f9 100644
--- a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/DomainTest.java
+++ b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/DomainTest.java
@@ -43,9 +43,6 @@ import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
-import org.onap.portalsdk.core.domain.support.Container;
-import org.onap.portalsdk.core.domain.support.Domain;
-import org.onap.portalsdk.core.domain.support.Size;
public class DomainTest {
@@ -53,7 +50,10 @@ public class DomainTest {
public Domain mockDomain(){
- Domain domain = new Domain(null, null, 0, 0, 0, 0, 0, 0, 0);
+ Domain domain =
+ new Domain.DomainBuilder().setId(null).setName(null).setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(0).setNumOfColsofContainer(0)
+ .createDomain();
domain.setP(null);
domain.setNewXafterColl(0);
@@ -74,7 +74,10 @@ public class DomainTest {
public void domainTest(){
Domain domain = mockDomain();
- Domain domain1 = new Domain(null, null, 0, 0, 0, 0, 0, 0, 0);
+ Domain domain1 =
+ new Domain.DomainBuilder().setId(null).setName(null).setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(0).setNumOfColsofContainer(0)
+ .createDomain();
domain1.setP(null);
domain1.setNewXafterColl(0);
@@ -103,7 +106,10 @@ public class DomainTest {
@Test
public void computeSizeTest(){
- Domain domain = new Domain("test", "VNI", 0, 0, 0, 0, 0, 2, 2);
+ Domain domain =
+ new Domain.DomainBuilder().setId("test").setName("VNI").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
Container container = new Container("test","test",1,1,10,10,10,10,10,10);
Map<String, Container> containerRowCol = new HashMap<>();
containerRowCol.put("00", container);
@@ -115,7 +121,10 @@ public class DomainTest {
}
@Test
public void computeSizeWithoutNameTest(){
- Domain domain = new Domain("test", "XYZ", 0, 0, 0, 0, 0, 2, 2);
+ Domain domain =
+ new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
Container container = new Container("test","test",1,1,10,10,10,10,10,10);
Map<String, Container> containerRowCol = new HashMap<>();
containerRowCol.put("00", container);
@@ -135,7 +144,10 @@ public class DomainTest {
containerRowCol.put("10", container01);
containerRowCol.put("11", container01);
- Domain domain = new Domain("test", "XYZ", 0, 1, 1, 4, 4, 2, 2);
+ Domain domain =
+ new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(1).setDomainToLayoutWd(1)
+ .setDomainToLayoutH(4).setDomainToContH(4).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
domain.setContainers(containerRowCol);
domain.computeConatinerPositions();
assertEquals(21.0, domain.getContainerRowCol().get("10").getP().getX(), DELTA);
diff --git a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/LayoutTest.java b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/LayoutTest.java
index c7038144..1573da86 100644
--- a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/LayoutTest.java
+++ b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/LayoutTest.java
@@ -45,10 +45,6 @@ import java.util.List;
import java.util.Map;
import org.junit.Test;
-import org.onap.portalsdk.core.domain.support.Container;
-import org.onap.portalsdk.core.domain.support.Domain;
-import org.onap.portalsdk.core.domain.support.Layout;
-import org.onap.portalsdk.core.domain.support.Position;
public class LayoutTest {
@@ -84,7 +80,10 @@ public class LayoutTest {
@Test
public void computeDomainPositionsTest(){
Layout layout = new Layout(null, 0, 0, 2, 2);
- Domain domain = new Domain("test", "XYZ", 0, 0, 0, 0, 0, 2, 2);
+ Domain domain =
+ new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
Map<String, Domain> domainRowCol = new HashMap<>();
List<Domain> domainList = new ArrayList<>();
domainList.add(domain);
@@ -100,7 +99,10 @@ public class LayoutTest {
@Test
public void computeDomainPositionsModifiedTest(){
Layout layout = new Layout(null, 0, 0, 2, 2);
- Domain domain = new Domain("test", "XYZ", 0, 0, 0, 0, 0, 2, 2);
+ Domain domain =
+ new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
Map<String, Container> containerRowCol = new HashMap<>();
Container container00 = new Container("test","test",1,1,10,10,10,10,10,10);
Position position = new Position();
@@ -124,8 +126,14 @@ public class LayoutTest {
@Test
public void collapseDomainModifiedTest(){
Layout layout = new Layout(null, 0, 0, 2, 2);
- Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2);
- Domain domain2 = new Domain("test", "XYZ", 0, 0, 0, 0, 0, 2, 2);
+ Domain domain =
+ new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
+ Domain domain2 =
+ new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
Map<String, Container> containerRowCol = new HashMap<>();
Container container00 = new Container("test","test",1,1,10,10,10,10,10,10);
Position position = new Position();
@@ -149,8 +157,14 @@ public class LayoutTest {
@Test
public void collapseDomainNewTest(){
Layout layout = new Layout(null, 0, 0, 2, 2);
- Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2);
- Domain domain2 = new Domain("test", "XYZ", 0, 0, 0, 0, 0, 2, 2);
+ Domain domain =
+ new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
+ Domain domain2 =
+ new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
Map<String, Container> containerRowCol = new HashMap<>();
Container container00 = new Container("test","test",1,1,10,10,10,10,10,10);
Position position = new Position();
@@ -174,8 +188,14 @@ public class LayoutTest {
@Test
public void collapseDomainTest(){
Layout layout = new Layout(null, 0, 0, 2, 2);
- Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2);
- Domain domain2 = new Domain("test", "XYZ", 0, 0, 0, 0, 0, 2, 2);
+ Domain domain =
+ new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
+ Domain domain2 =
+ new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
Map<String, Container> containerRowCol = new HashMap<>();
Container container00 = new Container("test","test",1,1,10,10,10,10,10,10);
Position position = new Position();
@@ -204,7 +224,10 @@ public class LayoutTest {
Layout layout = new Layout(null, 0, 0, 2, 2);
- Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2);
+ Domain domain =
+ new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
Position position = new Position();
position.setX(10);
position.setY(10);
@@ -239,7 +262,10 @@ public class LayoutTest {
public void uncollapseDomainTest(){
Layout layout = new Layout(null, 0, 0, 2, 2);
- Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2);
+ Domain domain =
+ new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
Position position = new Position();
position.setX(10);
position.setY(10);
@@ -272,7 +298,10 @@ public class LayoutTest {
public void uncollapseDomainNewTest(){
Layout layout = new Layout(null, 0, 0, 2, 2);
- Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2);
+ Domain domain =
+ new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
Position position = new Position();
position.setX(10);
position.setY(10);
@@ -304,7 +333,10 @@ public class LayoutTest {
Layout layout = new Layout(null, 0, 0, 2, 2);
- Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2);
+ Domain domain =
+ new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0)
+ .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2)
+ .createDomain();
Position position = new Position();
position.setX(10);
position.setY(10);