summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-domain
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2019-04-23 10:37:45 +0900
committerParshad Patel <pars.patel@samsung.com>2019-07-03 15:22:24 +0900
commitaad3703c8fe9929c71f9a9465a701f56dd1cbd5a (patch)
tree0d87f08a8484ced7a5bb2a6441aa2ce76fb43171 /ecomp-sdk/epsdk-domain
parentb3ced8c4eb98a152076b3f0a05ba601bce7f8d2a (diff)
Fix sonar issue in epsdk-domain
Fix Constructor has 10 parameters, which is greater than 7 authorized Issue-ID: PORTAL-562 Change-Id: I8eff61e2d829c86bd20c7052c181f90eed1a5926 Signed-off-by: Parshad Patel <pars.patel@samsung.com>
Diffstat (limited to 'ecomp-sdk/epsdk-domain')
-rw-r--r--ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Container.java88
-rw-r--r--ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ContainerTest.java57
-rw-r--r--ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/DomainTest.java24
-rw-r--r--ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/LayoutTest.java72
4 files changed, 192 insertions, 49 deletions
diff --git a/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Container.java b/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Container.java
index 3d9ee77a..1c122491 100644
--- a/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Container.java
+++ b/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Container.java
@@ -40,6 +40,7 @@ package org.onap.portalsdk.core.domain.support;
import java.util.List;
import java.util.Map;
+
public class Container {
String id;
@@ -90,22 +91,77 @@ public class Container {
}
- public Container(String id, String name, int numOfRows, int numOfCols, double interEleWd, double interEleH,
- double interEleToContainerWd, double interEleToContainerH, double interEleToInnerContainerWd,
- double interEleToInnerContainerH) {
-
- this.id = id;
- this.name = name;
- this.numOfRows = numOfRows;
- this.numOfCols = numOfCols;
- this.interEleWd = interEleWd;
- this.interEleH = interEleH;
- this.interEleToContainerWd = interEleToContainerWd;
- this.interEleToContainerH = interEleToContainerH;
- this.interEleToInnerContainerWd = interEleToInnerContainerWd;
- this.interEleToInnerContainerH = interEleToInnerContainerH;
-
- }
+ public Container(ContainerBuilder builder) {
+ this.id = builder.container.id;
+ this.name = builder.container.name;
+ this.numOfRows = builder.container.numOfRows;
+ this.numOfCols = builder.container.numOfCols;
+ this.interEleWd = builder.container.interEleWd;
+ this.interEleH = builder.container.interEleH;
+ this.interEleToContainerWd = builder.container.interEleToContainerWd;
+ this.interEleToContainerH = builder.container.interEleToContainerH;
+ this.interEleToInnerContainerWd = builder.container.interEleToInnerContainerWd;
+ this.interEleToInnerContainerH = builder.container.interEleToInnerContainerH;
+ }
+
+ public static class ContainerBuilder {
+
+ private final Container container = new Container();
+
+ public ContainerBuilder setId(String id) {
+ this.container.id = id;
+ return this;
+ }
+
+ public ContainerBuilder setName(String name) {
+ this.container.name = name;
+ return this;
+ }
+
+ public ContainerBuilder setNumOfRows(int numOfRows) {
+ this.container.numOfRows = numOfRows;
+ return this;
+ }
+
+ public ContainerBuilder setNumOfCols(int numOfCols) {
+ this.container.numOfCols = numOfCols;
+ return this;
+ }
+
+ public ContainerBuilder setInterEleWd(double interEleWd) {
+ this.container.interEleWd = interEleWd;
+ return this;
+ }
+
+ public ContainerBuilder setInterEleH(double interEleH) {
+ this.container.interEleH = interEleH;
+ return this;
+ }
+
+ public ContainerBuilder setInterEleToContainerWd(double interEleToContainerWd) {
+ this.container.interEleToContainerWd = interEleToContainerWd;
+ return this;
+ }
+
+ public ContainerBuilder setInterEleToContainerH(double interEleToContainerH) {
+ this.container.interEleToContainerH = interEleToContainerH;
+ return this;
+ }
+
+ public ContainerBuilder setInterEleToInnerContainerWd(double interEleToInnerContainerWd) {
+ this.container.interEleToInnerContainerWd = interEleToInnerContainerWd;
+ return this;
+ }
+
+ public ContainerBuilder setInterEleToInnerContainerH(double interEleToInnerContainerH) {
+ this.container.interEleToInnerContainerH = interEleToInnerContainerH;
+ return this;
+ }
+
+ public Container createContainer() {
+ return new Container(this);
+ }
+ }
public Map<String, Container> getContainerRowCol() {
return containerRowCol;
diff --git a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ContainerTest.java b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ContainerTest.java
index c468bec6..6f5b4777 100644
--- a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ContainerTest.java
+++ b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ContainerTest.java
@@ -49,15 +49,11 @@ import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.MockitoAnnotations;
import org.onap.portalsdk.core.domain.User;
-import org.onap.portalsdk.core.domain.support.Container;
-import org.onap.portalsdk.core.domain.support.Element;
-import org.onap.portalsdk.core.domain.support.Position;
-import org.onap.portalsdk.core.domain.support.Size;
public class ContainerTest {
@InjectMocks
- Container container = new Container();
+ Container container = new Container.ContainerBuilder().createContainer();
@Before
@@ -74,8 +70,12 @@ public class ContainerTest {
private static final double DELTA = 1e-15;
public Container mockContainer(){
- Container container = new Container("test","test",1,1,10,10,10,10,10,10);
-
+ Container container = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
+
Size size = new Size();
size.setHeight(10);
size.setWidth(10);
@@ -107,8 +107,12 @@ public class ContainerTest {
public void containerTest(){
Container container = mockContainer();
- Container container1 = new Container("test","test",1,1,10,10,10,10,10,10);
-
+ Container container1 = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
+
Size size1 = new Size();
size1.setHeight(10);
size1.setWidth(10);
@@ -139,14 +143,21 @@ public class ContainerTest {
public void computeSizeTest(){
Map<String, Container> containerRowCol = new HashMap<>();
- Container container = new Container("test","test",1,1,10,10,10,10,10,10);
+ Container container = new Container.ContainerBuilder().setId("test").setName("test").setNumOfRows(1)
+ .setNumOfCols(1).setInterEleWd(10).setInterEleH(10).setInterEleToContainerWd(10)
+ .setInterEleToContainerH(10).setInterEleToInnerContainerWd(10)
+ .setInterEleToInnerContainerH(10).createContainer();
containerRowCol.put("00", container);
Map<String, Element> elementRowCol = new HashMap<>();
Element element = new Element("1", "test");
elementRowCol.put("00", element);
-
- Container containerTest = new Container("test","Broadworks complex",1,1,10,10,10,10,10,10);
+
+ Container containerTest = new Container.ContainerBuilder().setId("test").setName("Broadworks complex")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
containerTest.setElements(elementRowCol);
containerTest.setInnerContainer(containerRowCol);
Size size = containerTest.computeSize();
@@ -158,18 +169,30 @@ public class ContainerTest {
public void computeElementPositionsTest(){
Map<String, Container> containerRowCol = new HashMap<>();
- Container container00 = new Container("test","test",1,1,10,10,10,10,10,10);
- Container container01 = new Container("test","test",1,1,10,10,10,10,10,10);
+ Container container00 = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
+ Container container01 = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
containerRowCol.put("00", container00);
containerRowCol.put("10", container01);
containerRowCol.put("11", container01);
-
+
Map<String, Element> elementRowCol = new HashMap<>();
Element element = new Element("1", "test");
elementRowCol.put("01", element);
elementRowCol.put("02", element);
-
- Container containerTest = new Container("test","Broadworks complex",2,3,10,10,10,10,10,10);
+
+ Container containerTest = new Container.ContainerBuilder().setId("test")
+ .setName("Broadworks complex").setNumOfRows(2).setNumOfCols(3).setInterEleWd(10)
+ .setInterEleH(10).setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
Position position = new Position();
position.setX(10);
position.setY(10);
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 016cd3f9..f7f32100 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
@@ -110,7 +110,11 @@ public class DomainTest {
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);
+ Container container = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
Map<String, Container> containerRowCol = new HashMap<>();
containerRowCol.put("00", container);
containerRowCol.put("10", container);
@@ -125,7 +129,11 @@ public class DomainTest {
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);
+ Container container = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
Map<String, Container> containerRowCol = new HashMap<>();
containerRowCol.put("00", container);
containerRowCol.put("10", container);
@@ -138,8 +146,16 @@ public class DomainTest {
@Test
public void computeConatinerPositionsTest(){
Map<String, Container> containerRowCol = new HashMap<>();
- Container container00 = new Container("test","test",1,1,10,10,10,10,10,10);
- Container container01 = new Container("test","test",1,1,10,10,10,10,10,10);
+ Container container00 = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
+ Container container01 = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
containerRowCol.put("00", container00);
containerRowCol.put("10", container01);
containerRowCol.put("11", container01);
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 1573da86..a5e1ea6d 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
@@ -104,7 +104,11 @@ public class LayoutTest {
.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);
+ Container container00 = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
Position position = new Position();
position.setX(10);
position.setY(10);
@@ -135,7 +139,11 @@ public class LayoutTest {
.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);
+ Container container00 = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
Position position = new Position();
position.setX(10);
position.setY(10);
@@ -166,7 +174,11 @@ public class LayoutTest {
.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);
+ Container container00 = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
Position position = new Position();
position.setX(10);
position.setY(10);
@@ -197,7 +209,11 @@ public class LayoutTest {
.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);
+ Container container00 = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
Position position = new Position();
position.setX(10);
position.setY(10);
@@ -236,11 +252,19 @@ public class LayoutTest {
domainRowCol.put("00", domain);
Map<String, Container> innerContainerRowCol = new HashMap<>();
- Container innerContainer = new Container("test","test",1,1,10,10,10,10,10,10);
+ Container innerContainer = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
innerContainerRowCol.put("00", innerContainer);
Map<String, Container> containerRowCol = new HashMap<>();
- Container container00 = new Container("test","test",1,1,10,10,10,10,10,10);
+ Container container00 = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
container00.setInnerContainer(innerContainerRowCol);
containerRowCol.put("00", container00);
@@ -274,11 +298,19 @@ public class LayoutTest {
domainRowCol.put("00", domain);
Map<String, Container> innerContainerRowCol = new HashMap<>();
- Container innerContainer = new Container("test","test",1,1,10,10,10,10,10,10);
+ Container innerContainer = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
innerContainerRowCol.put("00", innerContainer);
Map<String, Container> containerRowCol = new HashMap<>();
- Container container00 = new Container("test","test",1,1,10,10,10,10,10,10);
+ Container container00 = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
container00.setInnerContainer(innerContainerRowCol);
containerRowCol.put("00", container00);
@@ -310,11 +342,19 @@ public class LayoutTest {
domainRowCol.put("00", domain);
Map<String, Container> innerContainerRowCol = new HashMap<>();
- Container innerContainer = new Container("test","test",1,1,10,10,10,10,10,10);
+ Container innerContainer = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
innerContainerRowCol.put("00", innerContainer);
Map<String, Container> containerRowCol = new HashMap<>();
- Container container00 = new Container("test","test",1,1,10,10,10,10,10,10);
+ Container container00 = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
container00.setInnerContainer(innerContainerRowCol);
containerRowCol.put("00", container00);
@@ -345,11 +385,19 @@ public class LayoutTest {
domainRowCol.put("00", domain);
Map<String, Container> innerContainerRowCol = new HashMap<>();
- Container innerContainer = new Container("test","test",1,1,10,10,10,10,10,10);
+ Container innerContainer = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
innerContainerRowCol.put("00", innerContainer);
Map<String, Container> containerRowCol = new HashMap<>();
- Container container00 = new Container("test","test",1,1,10,10,10,10,10,10);
+ Container container00 = new Container.ContainerBuilder().setId("test").setName("test")
+ .setNumOfRows(1).setNumOfCols(1).setInterEleWd(10).setInterEleH(10)
+ .setInterEleToContainerWd(10).setInterEleToContainerH(10)
+ .setInterEleToInnerContainerWd(10).setInterEleToInnerContainerH(10)
+ .createContainer();
container00.setInnerContainer(innerContainerRowCol);
containerRowCol.put("00", container00);