summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-domain/src
diff options
context:
space:
mode:
authorArindam Mondal <arind.mondal@samsung.com>2019-02-25 18:08:57 +0900
committerarindamm <arind.mondal@samsung.com>2019-02-25 18:55:50 +0900
commit3911c26a7fda32b8f3332ceb7fa3adc34b4ece62 (patch)
treeb32411a7e841b78f464d63fdd94c730a4337c42e /ecomp-sdk/epsdk-domain/src
parent7b740b078f8fb593c2615e8b6689d30ea46a0c86 (diff)
Reduce method parameter by implementing builder
Issue-ID: PORTAL-529 Change-Id: I1f5adc677d43c2fdc4e18f893e11b708608b0b36 Signed-off-by: arindamm <arind.mondal@samsung.com>
Diffstat (limited to 'ecomp-sdk/epsdk-domain/src')
-rw-r--r--ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/ElementDetails.java96
-rw-r--r--ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ElementDetailsTest.java5
-rw-r--r--ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ElementTest.java3
3 files changed, 86 insertions, 18 deletions
diff --git a/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/ElementDetails.java b/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/ElementDetails.java
index 61fc6497..7d8de316 100644
--- a/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/ElementDetails.java
+++ b/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/ElementDetails.java
@@ -49,21 +49,91 @@ public class ElementDetails {
String vendor;
String vendor_shortname;
String enclosingContainer;
+
+
+ public static class ElementDetailsBuilder{
+ private String logical_group;
+ private String display_longname;
+ private String description;
+ private String primary_function;
+ private String network_function;
+ private String key_interfaces;
+ private String location;
+ private String vendor;
+ private String vendor_shortname;
+ private String enclosingContainer;
+
- public ElementDetails(String logical_group, String display_longname, String description, String primary_function,
- String network_function, String key_interfaces, String location, String vendor, String vendor_shortname,
- String enclosingContainer) {
+ public ElementDetailsBuilder setLogical_group(String logical_group) {
+ this.logical_group = logical_group;
+ return this;
+ }
- this.logical_group = logical_group;
- this.display_longname = display_longname;
- this.description = description;
- this.primary_function = primary_function;
- this.network_function = network_function;
- this.key_interfaces = key_interfaces;
- this.location = location;
- this.vendor = vendor;
- this.vendor_shortname = vendor_shortname;
- this.enclosingContainer = enclosingContainer;
+ public ElementDetailsBuilder setDisplay_longname(String display_longname) {
+ this.display_longname = display_longname;
+ return this;
+ }
+
+ public ElementDetailsBuilder setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public ElementDetailsBuilder setPrimary_function(String primary_function) {
+ this.primary_function = primary_function;
+ return this;
+ }
+
+ public ElementDetailsBuilder setNetwork_function(String network_function) {
+ this.network_function = network_function;
+ return this;
+ }
+
+ public ElementDetailsBuilder setKey_interfaces(String key_interfaces) {
+ this.key_interfaces = key_interfaces;
+ return this;
+ }
+
+ public ElementDetailsBuilder setLocation(String location) {
+ this.location = location;
+ return this;
+ }
+
+ public ElementDetailsBuilder setVendor(String vendor) {
+ this.vendor = vendor;
+ return this;
+ }
+
+ public ElementDetailsBuilder setVendor_shortname(String vendor_shortname) {
+ this.vendor_shortname = vendor_shortname;
+ return this;
+ }
+
+ public ElementDetailsBuilder setEnclosingContainer(String enclosingContainer) {
+ this.enclosingContainer = enclosingContainer;
+ return this;
+ }
+
+ public ElementDetails createElementDetails() {
+
+ return new ElementDetails(this);
+ }
+
+ }
+
+
+ private ElementDetails(ElementDetailsBuilder builder){
+
+ logical_group = builder.logical_group;
+ display_longname = builder.display_longname;
+ description = builder.description;
+ primary_function = builder.primary_function;
+ network_function = builder.network_function;
+ key_interfaces = builder.key_interfaces;
+ location = builder.location;
+ vendor = builder.vendor;
+ vendor_shortname = builder.vendor_shortname;
+ enclosingContainer = builder.enclosingContainer;
}
public String getLogical_group() {
diff --git a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ElementDetailsTest.java b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ElementDetailsTest.java
index d6b9c11b..62149054 100644
--- a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ElementDetailsTest.java
+++ b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ElementDetailsTest.java
@@ -40,12 +40,11 @@ package org.onap.portalsdk.core.domain.support;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
-import org.onap.portalsdk.core.domain.support.ElementDetails;
public class ElementDetailsTest {
public ElementDetails mockElementDetails(){
- ElementDetails elementDetails = new ElementDetails("test","test","test","test","test","test","test","test","test","test");
+ ElementDetails elementDetails = new ElementDetails.ElementDetailsBuilder().setLogical_group("test").setDisplay_longname("test").setDescription("test").setPrimary_function("test").setNetwork_function("test").setKey_interfaces("test").setLocation("test").setVendor("test").setVendor_shortname("test").setEnclosingContainer("test").createElementDetails();
elementDetails.setLogical_group("test");
@@ -56,7 +55,7 @@ public class ElementDetailsTest {
public void elementDetailsTest(){
ElementDetails elementDetails = mockElementDetails();
- ElementDetails elementDetails1 = new ElementDetails("test","test","test","test","test","test","test","test","test","test");
+ ElementDetails elementDetails1 = new ElementDetails.ElementDetailsBuilder().setLogical_group("test").setDisplay_longname("test").setDescription("test").setPrimary_function("test").setNetwork_function("test").setKey_interfaces("test").setLocation("test").setVendor("test").setVendor_shortname("test").setEnclosingContainer("test").createElementDetails();
elementDetails1.setLogical_group("test");
assertEquals(elementDetails.getLogical_group(), elementDetails1.getLogical_group());
diff --git a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ElementTest.java b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ElementTest.java
index bf58de1a..a3cfb4b1 100644
--- a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ElementTest.java
+++ b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/ElementTest.java
@@ -43,7 +43,6 @@ import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
-import org.onap.portalsdk.core.domain.support.Element;
public class ElementTest {
@@ -51,7 +50,7 @@ public class ElementTest {
@Before
public void setUp()
{
- details= new ElementDetails("logical_group", "display_longname", "description", "primary_function", "network_function", "key_interfaces", "location", "vendor", "vendor_shortname", "enclosingContainer");
+ details= new ElementDetails.ElementDetailsBuilder().setLogical_group("logical_group").setDisplay_longname("display_longname").setDescription("description").setPrimary_function("primary_function").setNetwork_function("network_function").setKey_interfaces("key_interfaces").setLocation("location").setVendor("vendor").setVendor_shortname("vendor_shortname").setEnclosingContainer("enclosingContainer").createElementDetails();
}
public Element mockElement(){