From ee82daaac26e6f32d505c54db0fc4e89759e479e Mon Sep 17 00:00:00 2001 From: Byung-Woo Jun Date: Tue, 12 Dec 2017 14:28:48 -0500 Subject: Fix the super keyword misuse Remove the super keyword misuse, and create a static method for the correct assignment Change-Id: I7048d45c709520788eca53c8275af508d0c4a9a8 Issue-ID: SO-292 Signed-off-by: byungwoojun --- .../scripts/CreateVcpeResCustServiceTest.groovy | 75 +++++++++--------- .../scripts/DeleteVcpeResCustServiceTest.groovy | 71 +++++++++-------- .../DoCreateAllottedResourceBRGRollbackTest.groovy | 76 +++++++++---------- .../scripts/DoCreateAllottedResourceBRGTest.groovy | 76 +++++++++---------- .../DoCreateAllottedResourceTXCRollbackTest.groovy | 2 +- .../scripts/DoCreateAllottedResourceTXCTest.groovy | 82 ++++++++++---------- .../scripts/DoDeleteAllottedResourceBRGTest.groovy | 78 +++++++++---------- .../scripts/DoDeleteAllottedResourceTXCTest.groovy | 2 +- .../mso/bpmn/vcpe/scripts/GroovyTestBase.groovy | 88 +++++++++++----------- 9 files changed, 274 insertions(+), 276 deletions(-) (limited to 'bpmn/MSOInfrastructureBPMN/src/test/groovy') diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy index 70050422ee..3b97cad585 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.runtime.Execution + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule +import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore +import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -41,7 +41,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.patch import static com.github.tomakehurst.wiremock.client.WireMock.put import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; +import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition @@ -53,28 +53,27 @@ import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.vcpe.scripts.MapGetter import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter -import com.github.tomakehurst.wiremock.junit.WireMockRule - +import com.github.tomakehurst.wiremock.junit.WireMockRule + class CreateVcpeResCustServiceTest extends GroovyTestBase { - private static String request - - @Rule + private static String request + + @Rule public WireMockRule wireMockRule = new WireMockRule(PORT) - + String Prefix = "CVRCS_" - String RbType = "DCRENI_" + String RbType = "DCRENI_" @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() request = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/request.json") } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) } public CreateVcpeResCustServiceTest() { @@ -82,19 +81,19 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { } - // ***** preProcessRequest ***** - - @Test - // @Ignore - public void preProcessRequest() { + // ***** preProcessRequest ***** + + @Test + // @Ignore + public void preProcessRequest() { ExecutionEntity mex = setupMock() def map = setupMap(mex) initPreProcess(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.preProcessRequest(mex) - - verify(mex).getVariable(DBGFLAG) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) verify(mex).setVariable("prefix", Prefix) verify(mex).setVariable("aaiDistDelay", "aaidelay") verify(mex).setVariable("createVcpeServiceRequest", request) @@ -115,7 +114,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { def reqinfo = map.get(Prefix+"requestInfo") assertTrue(reqinfo.indexOf("mri= 0) - assertTrue(reqinfo.indexOf("VID= 0) + assertTrue(reqinfo.indexOf("VID= 0) } @Test @@ -1260,6 +1259,6 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { private initProcessJavaException(ExecutionEntity mex) { when(mex.getVariable(DBGFLAG)).thenReturn("true") - } - + } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy index 65c9e456e4..af56f34bce 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.runtime.Execution + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule +import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore +import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -41,7 +41,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.patch import static com.github.tomakehurst.wiremock.client.WireMock.put import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; +import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition @@ -53,28 +53,27 @@ import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.vcpe.scripts.MapGetter import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter -import com.github.tomakehurst.wiremock.junit.WireMockRule - +import com.github.tomakehurst.wiremock.junit.WireMockRule + class DeleteVcpeResCustServiceTest extends GroovyTestBase { - private static String request - - @Rule + private static String request + + @Rule public WireMockRule wireMockRule = new WireMockRule(PORT) - + String Prefix = "DVRCS_" - String RbType = "DCRENI_" + String RbType = "DCRENI_" @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() request = FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/request.json") } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) } public DeleteVcpeResCustServiceTest() { @@ -82,18 +81,18 @@ class DeleteVcpeResCustServiceTest extends GroovyTestBase { } - // ***** preProcessRequest ***** - - @Test -// @Ignore - public void preProcessRequest() { + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { ExecutionEntity mex = setupMock() def map = setupMap(mex) initPreProcess(mex) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.preProcessRequest(mex) - + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.preProcessRequest(mex) + verify(mex).getVariable(DBGFLAG) assertEquals(Prefix, map.get("prefix")) @@ -116,7 +115,7 @@ class DeleteVcpeResCustServiceTest extends GroovyTestBase { def reqinfo = map.get(Prefix+"requestInfo") assertTrue(reqinfo.indexOf("mri= 0) - assertTrue(reqinfo.indexOf("VID= 0) + assertTrue(reqinfo.indexOf("VID= 0) } @Test @@ -771,5 +770,5 @@ class DeleteVcpeResCustServiceTest extends GroovyTestBase { .withStatus(status) .withHeader("Content-Type", "text/xml") .withBodyFile("VCPE/DeleteVcpeResCustService/" + fileResp))); - } + } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy index af532e733c..bbe9d52225 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.runtime.Execution + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule +import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore +import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -39,7 +39,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse import static com.github.tomakehurst.wiremock.client.WireMock.get import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; +import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource @@ -47,25 +47,25 @@ import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResou import org.openecomp.mso.bpmn.core.RollbackData -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase { - - @Rule +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase { + + @Rule public WireMockRule wireMockRule = new WireMockRule(PORT) - + String Prefix = "DCARBRGRB_" - String RbType = "DCARBRG_" + String RbType = "DCARBRG_" @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() + // nothing for now } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) } public DoCreateAllottedResourceBRGRollbackTest() { @@ -73,18 +73,18 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase { } - // ***** preProcessRequest ***** - - @Test -// @Ignore - public void preProcessRequest() { + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { ExecutionEntity mex = setupMock() initPreProcess(mex) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) - - verify(mex).getVariable(DBGFLAG) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) verify(mex).setVariable("prefix", Prefix) verify(mex).setVariable("serviceInstanceId", "sii") verify(mex).setVariable("parentServiceInstanceId", "psii") @@ -99,7 +99,7 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase { verify(mex).setVariable("sdncDeleteRequest", "createreq") verify(mex).setVariable("sdncUnassignRequest", "assignreq") - verify(mex, never()).setVariable("skipRollback", true) + verify(mex, never()).setVariable("skipRollback", true) } @Test @@ -648,6 +648,6 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase { private initProcessRollbackJavaException(ExecutionEntity mex) { when(mex.getVariable(DBGFLAG)).thenReturn("true") - } - + } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy index 89c13f179c..acc6970dd1 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.runtime.Execution + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule +import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore +import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -39,7 +39,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse import static com.github.tomakehurst.wiremock.client.WireMock.put import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; +import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource @@ -49,24 +49,24 @@ import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutAllottedResourc import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter -import com.github.tomakehurst.wiremock.junit.WireMockRule - +import com.github.tomakehurst.wiremock.junit.WireMockRule + class DoCreateAllottedResourceBRGTest extends GroovyTestBase { - - @Rule + + @Rule public WireMockRule wireMockRule = new WireMockRule(PORT) - - String Prefix = "DCARBRG_" + + String Prefix = "DCARBRG_" @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() + // nothing for now } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) } public DoCreateAllottedResourceBRGTest() { @@ -74,19 +74,19 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase { } - // ***** preProcessRequest ***** - - @Test -// @Ignore - public void preProcessRequest() { + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { ExecutionEntity mex = setupMock() initPreProcess(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessRequest(mex) - - verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdncadapter_callback")) assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdnc_replication_delay")) @@ -97,7 +97,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase { assertTrue(checkMissingPreProcessRequest("vgmuxBearerIP")) assertTrue(checkMissingPreProcessRequest("brgWanMacAddress")) assertTrue(checkMissingPreProcessRequest("allottedResourceRole")) - assertTrue(checkMissingPreProcessRequest("allottedResourceType")) + assertTrue(checkMissingPreProcessRequest("allottedResourceType")) } @@ -992,6 +992,6 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase { private initUpdateAaiAROrchStatus(ExecutionEntity mex) { when(mex.getVariable(DBGFLAG)).thenReturn("true") when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - } - + } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy index e5635deba7..02352cf6af 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy @@ -59,7 +59,7 @@ class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase { @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() + // nothing for now } @Before diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy index b27e368316..2de6e44a2f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.runtime.Execution + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule +import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore +import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -39,7 +39,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse import static com.github.tomakehurst.wiremock.client.WireMock.put import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; +import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource @@ -51,28 +51,24 @@ import java.util.Map import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class DoCreateAllottedResourceTXCTest extends GroovyTestBase { - - @Rule +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoCreateAllottedResourceTXCTest extends GroovyTestBase { + + @Rule public WireMockRule wireMockRule = new WireMockRule(PORT) - - String Prefix = "DCARTXC_" + + String Prefix = "DCARTXC_" @BeforeClass public static void setUpBeforeClass() { - def fr = new FileReader("src/test/resources/mso.bpmn.urn.properties") - urnProps.load(fr) - fr.close() - - aaiUriPfx = urnProps.get("aai.endpoint") + // nothing for now } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) } public DoCreateAllottedResourceTXCTest() { @@ -80,19 +76,19 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase { } - // ***** preProcessRequest ***** - - @Test - // @Ignore - public void preProcessRequest() { + // ***** preProcessRequest ***** + + @Test + // @Ignore + public void preProcessRequest() { ExecutionEntity mex = setupMock() initPreProcess(mex) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.preProcessRequest(mex) - - verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdncadapter_callback")) assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdnc_replication_delay")) @@ -101,7 +97,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase { assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo")) assertTrue(checkMissingPreProcessRequest("brgWanMacAddress")) assertTrue(checkMissingPreProcessRequest("allottedResourceRole")) - assertTrue(checkMissingPreProcessRequest("allottedResourceType")) + assertTrue(checkMissingPreProcessRequest("allottedResourceType")) } @@ -950,6 +946,6 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase { private initUpdateAaiAROrchStatus(ExecutionEntity mex) { when(mex.getVariable(DBGFLAG)).thenReturn("true") when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - } - + } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy index ec65347f5e..4e62a566a7 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.runtime.Execution + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule +import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore +import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -42,7 +42,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.patch import static com.github.tomakehurst.wiremock.client.WireMock.put import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; +import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource @@ -54,24 +54,24 @@ import java.util.Map import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class DoDeleteAllottedResourceBRGTest extends GroovyTestBase { - - @Rule +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoDeleteAllottedResourceBRGTest extends GroovyTestBase { + + @Rule public WireMockRule wireMockRule = new WireMockRule(PORT) - - String Prefix = "DDARBRG_" + + String Prefix = "DDARBRG_" @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() + // nothing for now } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) } public DoDeleteAllottedResourceBRGTest() { @@ -79,24 +79,24 @@ class DoDeleteAllottedResourceBRGTest extends GroovyTestBase { } - // ***** preProcessRequest ***** - - @Test -// @Ignore - public void preProcessRequest() { + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { ExecutionEntity mex = setupMock() initPreProcess(mex) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - DoDeleteAllottedResourceBRG.preProcessRequest(mex) - - verify(mex).getVariable(DBGFLAG) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("sdncCallbackUrl", "sdncurn") + verify(mex).setVariable("sdncCallbackUrl", "sdncurn") assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdncadapter_callback")) assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) - assertTrue(checkMissingPreProcessRequest("allottedResourceId")) + assertTrue(checkMissingPreProcessRequest("allottedResourceId")) } @Test @@ -599,6 +599,6 @@ class DoDeleteAllottedResourceBRGTest extends GroovyTestBase { when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers") when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) - } - + } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy index adf6313a2a..33273c55a6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy @@ -65,7 +65,7 @@ class DoDeleteAllottedResourceTXCTest extends GroovyTestBase { @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() + // nothing for now } @Before diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/GroovyTestBase.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/GroovyTestBase.groovy index 121583ec10..01ca53ba97 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/GroovyTestBase.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/GroovyTestBase.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.runtime.Execution + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule +import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore +import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -41,14 +41,14 @@ import static com.github.tomakehurst.wiremock.client.WireMock.patch import static com.github.tomakehurst.wiremock.client.WireMock.put import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; +import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter -import com.github.tomakehurst.wiremock.junit.WireMockRule - +import com.github.tomakehurst.wiremock.junit.WireMockRule + class GroovyTestBase { static final int PORT = 28090 @@ -60,20 +60,24 @@ class GroovyTestBase { static final String ARID = "arId-1" static final String VERS = "myvers" - static final String DBGFLAG = "isDebugLogEnabled" + static final String DBGFLAG = "isDebugLogEnabled" static Properties urnProps = new Properties() static String aaiUriPfx - String processName + String processName - public static void setUpBeforeClass() { + static { def fr = new FileReader("src/test/resources/mso.bpmn.urn.properties") urnProps.load(fr) fr.close() - + aaiUriPfx = urnProps.get("aai.endpoint") } + + public static void setUpBeforeClass() { + // moved to the above static block to get the static aaiUriPfx assignment correctly. + } public GroovyTestBase(String processName) { this.processName = processName @@ -88,37 +92,37 @@ class GroovyTestBase { } catch(BpmnError e) { return true; } - } - - public ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn(processName) - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(processName) - when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") - ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) - - ExecutionEntity mex = mock(ExecutionEntity.class) - - when(mex.getId()).thenReturn("100") - when(mex.getProcessDefinitionId()).thenReturn(processName) - when(mex.getProcessInstanceId()).thenReturn(processName) - when(mex.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + } + + public ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn(processName) + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(processName) + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mex = mock(ExecutionEntity.class) + + when(mex.getId()).thenReturn("100") + when(mex.getProcessDefinitionId()).thenReturn(processName) + when(mex.getProcessInstanceId()).thenReturn(processName) + when(mex.getProcessEngineServices()).thenReturn(mockProcessEngineServices) when(mex.getProcessEngineServices().getRepositoryService().getProcessDefinition(mex.getProcessDefinitionId())).thenReturn(mockProcessDefinition) when(mex.getVariable("isAsyncProcess")).thenReturn("true") - when(mex.getVariable(processName+"WorkflowResponseSent")).thenReturn("false") - - return mex + when(mex.getVariable(processName+"WorkflowResponseSent")).thenReturn("false") + + return mex } public Map setupMap(ExecutionEntity mex) { MapSetter mapset = new MapSetter(); doAnswer(mapset).when(mex).setVariable(any(), any()) return mapset.getMap(); - } - + } + } -- cgit 1.2.3-korg