summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArindam Mondal <arind.mondal@samsung.com>2019-04-18 19:05:58 +0900
committerarind.mondal <arind.mondal@samsung.com>2019-04-18 20:15:29 +0900
commitb3ced8c4eb98a152076b3f0a05ba601bce7f8d2a (patch)
treeb291f70c47c93cca6584665ee97161fb9452717d
parent383968fe6e903bc81c127e797b7c32cf99e0e246 (diff)
Fix sonar issue: implement builder
Sonar link: https://sonar.onap.org/issues?projectUuids=AV8LJxI3uDqGnRl2bdaB&resolved=false&rules=squid%3AS00107 Issue-ID: PORTAL-559 Change-Id: I28c202e69f4856131b91918c41343ae6a5df3bbe Signed-off-by: arind.mondal <arind.mondal@samsung.com>
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/ElementMapService.java8
-rw-r--r--ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/ElementMapServiceTest.java5
-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
5 files changed, 151 insertions, 42 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/ElementMapService.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/ElementMapService.java
index 210e494d..7fdc5609 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/ElementMapService.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/ElementMapService.java
@@ -655,10 +655,14 @@ public class ElementMapService {
Domain eachDomain = domainMap.get(domainsKey);
domainWidth += eachDomain.computeSize().getWidth();
}
- thisDomain = new Domain(id, name, 2, 2, domainWidth, 10, 3, rows, columns);
+ thisDomain = new Domain.DomainBuilder().setId(id).setName(name).setInterContWd(2).setInterContH(2)
+ .setDomainToLayoutWd(domainWidth).setDomainToLayoutH(10).setDomainToContH(3)
+ .setNumOfRowsofContainer(rows).setNumOfColsofContainer(columns).createDomain();
} else {
- thisDomain = new Domain(id, name, 2, 1, 11, 10, 3, rows, columns);
+ thisDomain = new Domain.DomainBuilder().setId(id).setName(name).setInterContWd(2).setInterContH(1)
+ .setDomainToLayoutWd(11).setDomainToLayoutH(10).setDomainToContH(3).setNumOfRowsofContainer(rows)
+ .setNumOfColsofContainer(columns).createDomain();
}
thisDomain.setContainers(domainContainersMap);
diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/ElementMapServiceTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/ElementMapServiceTest.java
index f0e4304c..e2655b59 100644
--- a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/ElementMapServiceTest.java
+++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/ElementMapServiceTest.java
@@ -130,8 +130,9 @@ public class ElementMapServiceTest {
Layout layout = new Layout(null, 0, 0, 2, 2);
Map<String, Domain> domainRowCol = new HashMap<>();
- 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();
Position position = new Position();
position.setX(10);
position.setY(10);
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);