From f2dc71a2443c29c00da7750230015d6555e86b1f Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Fri, 19 Apr 2019 15:46:20 +0900 Subject: Fix sonar issue in vid-app-common Fix Constructor has 8 parameters, which is greater than 7 authorized issue Issue-ID: VID-464 Change-Id: If3311351746f4a4890ab73e844decd34486a324f Signed-off-by: Parshad Patel --- .../org/onap/vid/aai/OperationalEnvironment.java | 80 +++++++++++++++++++--- .../onap/vid/aai/OperationalEnvironmentTest.java | 13 ++-- 2 files changed, 79 insertions(+), 14 deletions(-) diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java b/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java index fd4f6c7f5..be6c6e51f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java @@ -20,9 +20,9 @@ package org.onap.vid.aai; +import org.onap.vid.aai.model.RelationshipList; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import org.onap.vid.aai.model.RelationshipList; @JsonIgnoreProperties(ignoreUnknown = true) public class OperationalEnvironment { @@ -39,15 +39,75 @@ public class OperationalEnvironment { public OperationalEnvironment() { } - public OperationalEnvironment(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType, String operationalEnvironmentStatus, String tenantContext, String workloadContext, String resourceVersion, RelationshipList relationshipList) { - this.operationalEnvironmentId = operationalEnvironmentId; - this.operationalEnvironmentName = operationalEnvironmentName; - this.operationalEnvironmentType = operationalEnvironmentType; - this.operationalEnvironmentStatus = operationalEnvironmentStatus; - this.tenantContext = tenantContext; - this.workloadContext = workloadContext; - this.resourceVersion = resourceVersion; - this.relationshipList = relationshipList; + public OperationalEnvironment(OperationalEnvironmentBuilder builder) { + this.operationalEnvironmentId = builder.operationalEnvironmentId; + this.operationalEnvironmentName = builder.operationalEnvironmentName; + this.operationalEnvironmentType = builder.operationalEnvironmentType; + this.operationalEnvironmentStatus = builder.operationalEnvironmentStatus; + this.tenantContext = builder.tenantContext; + this.workloadContext = builder.workloadContext; + this.resourceVersion = builder.resourceVersion; + this.relationshipList = builder.relationshipList; + } + + public static class OperationalEnvironmentBuilder { + private String operationalEnvironmentId; + private String operationalEnvironmentName; + private String operationalEnvironmentType; + private String operationalEnvironmentStatus; + private String tenantContext; + private String workloadContext; + private String resourceVersion; + private RelationshipList relationshipList; + + public OperationalEnvironmentBuilder setOperationalEnvironmentId( + String operationalEnvironmentId) { + this.operationalEnvironmentId = operationalEnvironmentId; + return this; + } + + public OperationalEnvironmentBuilder setOperationalEnvironmentName( + String operationalEnvironmentName) { + this.operationalEnvironmentName = operationalEnvironmentName; + return this; + } + + public OperationalEnvironmentBuilder setOperationalEnvironmentType( + String operationalEnvironmentType) { + this.operationalEnvironmentType = operationalEnvironmentType; + return this; + } + + public OperationalEnvironmentBuilder setOperationalEnvironmentStatus( + String operationalEnvironmentStatus) { + this.operationalEnvironmentStatus = operationalEnvironmentStatus; + return this; + } + + public OperationalEnvironmentBuilder setTenantContext(String tenantContext) { + this.tenantContext = tenantContext; + return this; + } + + public OperationalEnvironmentBuilder setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + return this; + } + + public OperationalEnvironmentBuilder setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + return this; + } + + public OperationalEnvironmentBuilder setRelationshipList( + RelationshipList relationshipList) { + this.relationshipList = relationshipList; + return this; + } + + public OperationalEnvironment createOperationalEnvironment() { + return new OperationalEnvironment(this); + } } public String getOperationalEnvironmentId() { diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java index c331b3252..076c46284 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java @@ -56,10 +56,15 @@ public class OperationalEnvironmentTest { RelationshipList relationshipList = new RelationshipList(); relationshipList.relationship = new ArrayList<>(); - OperationalEnvironment operationalEnvironment = new OperationalEnvironment("testId", - "testEnvName", "testEnvType", - "testEnvStatus", "testTenant", "testWorkload", - "testResource", relationshipList); + OperationalEnvironment operationalEnvironment = + new OperationalEnvironment.OperationalEnvironmentBuilder() + .setOperationalEnvironmentId("testId") + .setOperationalEnvironmentName("testEnvName") + .setOperationalEnvironmentType("testEnvType") + .setOperationalEnvironmentStatus("testEnvStatus") + .setTenantContext("testTenant").setWorkloadContext("testWorkload") + .setResourceVersion("testResource").setRelationshipList(relationshipList) + .createOperationalEnvironment(); assertThat(operationalEnvironment.getOperationalEnvironmentId()).isEqualTo("testId"); assertThat(operationalEnvironment.getWorkloadContext()).isEqualTo("testWorkload"); -- cgit 1.2.3-korg