Implement builder 76/84076/1
authorArindam Mondal <arind.mondal@samsung.com>
Wed, 3 Apr 2019 09:59:37 +0000 (18:59 +0900)
committerarindamm <arind.mondal@samsung.com>
Wed, 3 Apr 2019 09:59:51 +0000 (18:59 +0900)
Issue-ID: SO-1577
Change-Id: I0bb4790ce179330cf7f942021725f2b72d1a0829
Signed-off-by: Arindam Mondal <arind.mondal@samsung.com>
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstance.java
bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstanceTest.java

index 67ba155..c5cd2c7 100644 (file)
@@ -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;
        }
index e17d3f8..b68b787 100644 (file)
@@ -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");
+       }
 
 }