diff options
author | 2019-07-09 15:16:05 +0000 | |
---|---|---|
committer | 2019-07-09 15:16:05 +0000 | |
commit | 992fffffb3ef620466160c989c874dc8f5227536 (patch) | |
tree | cb1c0f83db3e8ad33698803a4ae709b956cd00e4 /ecomp-sdk/epsdk-domain | |
parent | db8a8f92e922e98b77a152af0f03fde57dd1fb44 (diff) | |
parent | aad3703c8fe9929c71f9a9465a701f56dd1cbd5a (diff) |
Merge "Fix sonar issue in epsdk-domain"
Diffstat (limited to 'ecomp-sdk/epsdk-domain')
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); |