From 53208e180ae8e7f7435bd1768f7c1631c34a0e7b Mon Sep 17 00:00:00 2001 From: Arindam Mondal Date: Wed, 3 Apr 2019 18:59:37 +0900 Subject: Implement builder Issue-ID: SO-1577 Change-Id: I0bb4790ce179330cf7f942021725f2b72d1a0829 Signed-off-by: Arindam Mondal --- .../infrastructure/aai/AAIServiceInstance.java | 77 ++++++++-- .../infrastructure/aai/AAIServiceInstanceTest.java | 167 +++++++++++---------- 2 files changed, 151 insertions(+), 93 deletions(-) (limited to 'bpmn/so-bpmn-infrastructure-common/src') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstance.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstance.java index 67ba155336..c5cd2c70da 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstance.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstance.java @@ -29,18 +29,73 @@ public class AAIServiceInstance { String modelVersionId; String environmentContext; String workloadContext; - public AAIServiceInstance(String serviceInstanceName, String serviceType, String serviceRole, - String orchestrationStatus, String modelInvariantUuid, String modelVersionId, String environmentContext, - String workloadContext) { - this.serviceInstanceName = serviceInstanceName; - this.serviceType = serviceType; - this.serviceRole = serviceRole; - this.orchestrationStatus = orchestrationStatus; - this.modelInvariantUuid = modelInvariantUuid; - this.modelVersionId = modelVersionId; - this.environmentContext = environmentContext; - this.workloadContext = workloadContext; + + public static class AAIServiceInstanceBuilder { + private String serviceInstanceName; + private String serviceType; + private String serviceRole; + private String orchestrationStatus; + private String modelInvariantUuid; + private String modelVersionId; + private String environmentContext; + private String workloadContext; + + public AAIServiceInstanceBuilder setServiceInstanceName(String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + return this; + } + + public AAIServiceInstanceBuilder setServiceType(String serviceType) { + this.serviceType = serviceType; + return this; + } + + public AAIServiceInstanceBuilder setServiceRole(String serviceRole) { + this.serviceRole = serviceRole; + return this; + } + + public AAIServiceInstanceBuilder setOrchestrationStatus(String orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + return this; + } + + public AAIServiceInstanceBuilder setModelInvariantUuid(String modelInvariantUuid) { + this.modelInvariantUuid = modelInvariantUuid; + return this; + } + + public AAIServiceInstanceBuilder setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + return this; + } + + public AAIServiceInstanceBuilder setEnvironmentContext(String environmentContext) { + this.environmentContext = environmentContext; + return this; + } + + public AAIServiceInstanceBuilder setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + return this; + } + + public AAIServiceInstance createAAIServiceInstance() { + return new AAIServiceInstance(this); + } } + + public AAIServiceInstance(AAIServiceInstanceBuilder aaiServiceInstanceBuilder) { + this.serviceInstanceName = aaiServiceInstanceBuilder.serviceInstanceName; + this.serviceType = aaiServiceInstanceBuilder.serviceType; + this.serviceRole = aaiServiceInstanceBuilder.serviceRole; + this.orchestrationStatus = aaiServiceInstanceBuilder.orchestrationStatus; + this.modelInvariantUuid = aaiServiceInstanceBuilder.modelInvariantUuid; + this.modelVersionId = aaiServiceInstanceBuilder.modelVersionId; + this.environmentContext = aaiServiceInstanceBuilder.environmentContext; + this.workloadContext = aaiServiceInstanceBuilder.workloadContext; + } + public String getServiceInstanceName() { return serviceInstanceName; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstanceTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstanceTest.java index e17d3f8fb5..b68b787904 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstanceTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstanceTest.java @@ -26,88 +26,91 @@ import org.junit.Test; public class AAIServiceInstanceTest { - AAIServiceInstance test = new AAIServiceInstance("serviceInstanceName","serviceType","serviceRole","orchestrationStatus","modelInvariantUuid","modelVersionId","environmentContext","workloadContext"); - - @Test - public void getServiceInstanceNameTest() throws Exception { - test.getServiceInstanceName(); - } - - @Test - public void setServiceInstanceNameTest() throws Exception { - test.setServiceInstanceName("serviceInstanceName"); - } - - @Test - public void getServiceTypeTest() throws Exception { - test.getServiceType(); - } - - @Test - public void setServiceTypeTest() throws Exception { - test.setServiceType("serviceType"); - } - - - @Test - public void getServiceRoleTest() throws Exception { - test.getServiceRole(); - } - - @Test - public void setServiceRoleTest() throws Exception { - test.setServiceRole("serviceRole"); - } - - @Test - public void getOrchestrationStatusTest() throws Exception { - test.getOrchestrationStatus(); - } - - @Test - public void setOrchestrationStatusTest() throws Exception { - test.setOrchestrationStatus("status"); - } - - @Test - public void getModelInvariantUuidTest() throws Exception { - test.getModelInvariantUuid(); - } - - @Test - public void setModelInvariantUuidTest() throws Exception { - test.setModelInvariantUuid("uuid"); - } - - @Test - public void getModelVersionIdTest() throws Exception { - test.getModelVersionId(); - } - - @Test - public void setModelVersionIdTest() throws Exception { - test.setModelVersionId("versionId"); - } - - @Test - public void getEnvironmentContextTest() throws Exception { - test.getEnvironmentContext(); - } - - @Test - public void setEnvironmentContextTest() throws Exception { - test.setEnvironmentContext("context"); - } - - @Test - public void getWorkloadContextTest() throws Exception { - test.getWorkloadContext(); - } - - @Test - public void setWorkloadContextTest() throws Exception { - test.setWorkloadContext("context"); - } + AAIServiceInstance test = new AAIServiceInstance.AAIServiceInstanceBuilder() + .setServiceInstanceName("serviceInstanceName").setServiceType("serviceType").setServiceRole("serviceRole") + .setOrchestrationStatus("orchestrationStatus").setModelInvariantUuid("modelInvariantUuid") + .setModelVersionId("modelVersionId").setEnvironmentContext("environmentContext") + .setWorkloadContext("workloadContext").createAAIServiceInstance(); + + @Test + public void getServiceInstanceNameTest() throws Exception { + test.getServiceInstanceName(); + } + + @Test + public void setServiceInstanceNameTest() throws Exception { + test.setServiceInstanceName("serviceInstanceName"); + } + + @Test + public void getServiceTypeTest() throws Exception { + test.getServiceType(); + } + + @Test + public void setServiceTypeTest() throws Exception { + test.setServiceType("serviceType"); + } + + @Test + public void getServiceRoleTest() throws Exception { + test.getServiceRole(); + } + + @Test + public void setServiceRoleTest() throws Exception { + test.setServiceRole("serviceRole"); + } + + @Test + public void getOrchestrationStatusTest() throws Exception { + test.getOrchestrationStatus(); + } + + @Test + public void setOrchestrationStatusTest() throws Exception { + test.setOrchestrationStatus("status"); + } + + @Test + public void getModelInvariantUuidTest() throws Exception { + test.getModelInvariantUuid(); + } + + @Test + public void setModelInvariantUuidTest() throws Exception { + test.setModelInvariantUuid("uuid"); + } + + @Test + public void getModelVersionIdTest() throws Exception { + test.getModelVersionId(); + } + + @Test + public void setModelVersionIdTest() throws Exception { + test.setModelVersionId("versionId"); + } + + @Test + public void getEnvironmentContextTest() throws Exception { + test.getEnvironmentContext(); + } + + @Test + public void setEnvironmentContextTest() throws Exception { + test.setEnvironmentContext("context"); + } + + @Test + public void getWorkloadContextTest() throws Exception { + test.getWorkloadContext(); + } + + @Test + public void setWorkloadContextTest() throws Exception { + test.setWorkloadContext("context"); + } } -- cgit 1.2.3-korg