diff options
author | eeginux <henry.xie@est.tech> | 2019-04-03 14:28:09 +0000 |
---|---|---|
committer | eeginux <henry.xie@est.tech> | 2019-04-04 11:41:31 +0100 |
commit | 88c47a23b9428188ff5dd0b46941f8856465376b (patch) | |
tree | 3f1e028033ad56f398e8154f0be2272012b666b2 /bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap | |
parent | b168125f237629b6dd7d73897548f2ee70139ed3 (diff) |
PNF WF post instantiation configuration
Add PNF ipv4/v6 address for config Deploy
Add Integration test for CreateVcpeResCustService_simplified.bpmn
Modify the PnfEventReadyDmaapClient to avoid one more running thread
Refactor the so-bpmn-infrastructure-flows test resources
Modify the CreateVcpeResCustService_simplified.bpmn
Add ConfigurePnfResource.bpmn
Add Delegates
Issue-ID: SO-1506
Change-Id: Iffb69d1441ef0b485ee8cd3fb5da5f1a35279a95
Signed-off-by: eeginux <henry.xie@est.tech>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap')
-rw-r--r-- | bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/AllBPMNTestSuites.java | 32 | ||||
-rw-r--r-- | bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/BaseBPMNTest.java | 69 | ||||
-rw-r--r-- | bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java (renamed from bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/InfraEmbeddedMariaDbConfig.java) | 63 | ||||
-rw-r--r-- | bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java | 110 | ||||
-rw-r--r-- | bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/TestApplication.java | 4 | ||||
-rw-r--r-- | bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/ValidBPMNTest.java | 43 | ||||
-rw-r--r-- | bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java | 261 |
7 files changed, 501 insertions, 81 deletions
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/AllBPMNTestSuites.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/AllBPMNTestSuites.java new file mode 100644 index 0000000000..4f98ee4f1b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/AllBPMNTestSuites.java @@ -0,0 +1,32 @@ +/* + * + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so; + +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; +import org.junit.runner.RunWith; + +@RunWith(WildcardPatternSuite.class) +@SuiteClasses({"**/service/*Test.class", "**/process/*Test.class", "**/subprocess/*Test.class"}) +public class AllBPMNTestSuites { + // the class remains empty, + // used only as a holder for the above annotations +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/BaseBPMNTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/BaseBPMNTest.java new file mode 100644 index 0000000000..648c9887c2 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/BaseBPMNTest.java @@ -0,0 +1,69 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so; + +import com.github.tomakehurst.wiremock.WireMockServer; +import java.util.HashMap; +import java.util.Map; +import org.camunda.bpm.engine.HistoryService; +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.RuntimeService; +import org.junit.After; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@ContextConfiguration +@AutoConfigureWireMock(port = 0) +public abstract class BaseBPMNTest { + + @Autowired + protected RuntimeService runtimeService; + + @Autowired + protected RepositoryService repositoryService; + + @Autowired + protected HistoryService historyService; + + protected Map<String, Object> variables = new HashMap<>(); + + @LocalServerPort + protected int port; + + @Autowired + protected WireMockServer wireMockServer; + + @Value("${wiremock.server.port}") + protected int wireMockPort; + + @After + public void shutDown(){ + wireMockServer.resetAll(); + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/InfraEmbeddedMariaDbConfig.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java index 3f0a2145df..963d989eb7 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/InfraEmbeddedMariaDbConfig.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java @@ -19,54 +19,47 @@ */ package org.onap.so; + import ch.vorburger.exec.ManagedProcessException; import ch.vorburger.mariadb4j.DBConfigurationBuilder; import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; -import org.springframework.beans.factory.annotation.Qualifier; +import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.jdbc.DataSourceBuilder; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Profile; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; @Configuration -@EnableTransactionManagement -@EnableJpaRepositories( - entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager", - basePackages = { "org.onap.so.db.request.data.repository"} -) @Profile({"test"}) -public class InfraEmbeddedMariaDbConfig { +public class EmbeddedMariaDbConfig { - @Primary - @Bean(name = "requestEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean - entityManagerFactory( - EntityManagerFactoryBuilder builder, - DataSource dataSource - ) { - return builder - .dataSource(dataSource) - .packages("org.onap.so.db.request.beans") - .persistenceUnit("requestDB") - .build(); + @Bean + MariaDB4jSpringService mariaDB4jSpringService() { + MariaDB4jSpringService service = new MariaDB4jSpringService(); + + + service.getConfiguration().addArg("--lower_case_table_names=1"); + return service; } - @Bean(name = "requestTransactionManager") - public PlatformTransactionManager transactionManager( - @Qualifier("requestEntityManagerFactory") EntityManagerFactory - entityManagerFactory - ) { - return new JpaTransactionManager(entityManagerFactory); + @Bean + DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + //Create our database with default root user and no password + mariaDB4jSpringService.getDB().createDB(databaseName); + + DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); + + return DataSourceBuilder + .create() + .username(datasourceUsername) + .password(datasourcePassword) + .url(config.getURL(databaseName)) + .driverClassName(datasourceDriver) + .build(); } } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java new file mode 100644 index 0000000000..a4de95e4fa --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java @@ -0,0 +1,110 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so; + +import io.grpc.ServerBuilder; +import io.grpc.stub.StreamObserver; +import io.grpc.testing.GrpcCleanupRule; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicReference; +import javax.annotation.PostConstruct; +import org.junit.Rule; +import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType; +import org.onap.ccsdk.cds.controllerblueprints.common.api.Status; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component +public class GrpcNettyServer extends BluePrintProcessingServiceImplBase { + + private static final Logger logger = LoggerFactory.getLogger(GrpcNettyServer.class); + + @Value("${cds.endpoint}") + private String host; + + @Value("${cds.port}") + private String port; + + @Rule + public final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule(); + + private final List<String> messagesDelivered = new ArrayList<>(); + private final CountDownLatch allRequestsDelivered = new CountDownLatch(1); + private final AtomicReference<StreamObserver<ExecutionServiceOutput>> responseObserverRef = new AtomicReference<>(); + + @PostConstruct + public void start() throws IOException { + + final BluePrintProcessingServiceImplBase blueprintPrcessorImpl = + new BluePrintProcessingServiceImplBase() { + @Override + public StreamObserver<ExecutionServiceInput> process( + StreamObserver<ExecutionServiceOutput> responseObserver) { + + responseObserverRef.set(responseObserver); + + StreamObserver<ExecutionServiceInput> requestObserver = new StreamObserver<ExecutionServiceInput>() { + @Override + public void onNext(ExecutionServiceInput message) { + messagesDelivered.add(message.getActionIdentifiers().getActionName()); + logger.info("Message received: {}", message); + ExecutionServiceOutput executionServiceOutput = ExecutionServiceOutput.newBuilder() + .setActionIdentifiers(message.getActionIdentifiers()) + .setStatus(Status.newBuilder().setEventType( + EventType.EVENT_COMPONENT_EXECUTED).build()).build(); + + responseObserverRef.get().onNext(executionServiceOutput); + logger.info("Message sent: {}", executionServiceOutput); + } + + @Override + public void onError(Throwable t) { + responseObserverRef.get().onError(t); + } + + @Override + public void onCompleted() { + allRequestsDelivered.countDown(); + responseObserverRef.get().onCompleted(); + } + }; + + return requestObserver; + } + }; + grpcCleanup.register( + ServerBuilder.forPort(Integer.valueOf(port)).directExecutor().addService(blueprintPrcessorImpl).build() + .start()); + + } + + public List<String> getMessagesDelivered() { + return this.messagesDelivered; + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/TestApplication.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/TestApplication.java index f1b69c653f..64311d85da 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/TestApplication.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/TestApplication.java @@ -31,13 +31,11 @@ import org.springframework.context.annotation.Profile; @SpringBootApplication @Profile("test") @ComponentScan(basePackages = {"org.onap.so"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = { - @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class) }) + @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) public class TestApplication { public static void main(String... args) { SpringApplication.run(TestApplication.class, args); System.getProperties().setProperty("mso.db", "MARIADB"); System.getProperties().setProperty("server.name", "Springboot"); - - } } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/ValidBPMNTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/ValidBPMNTest.java deleted file mode 100644 index 0521fa737d..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/ValidBPMNTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.so; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -@ContextConfiguration -@AutoConfigureWireMock(port = 0) -public class ValidBPMNTest { - - @Test - public void verifyApplicationStartup(){ - //Verifys Springboot app can start up and all BPMN's are in fact parsable - assert(true); - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java new file mode 100644 index 0000000000..897ab037f2 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java @@ -0,0 +1,261 @@ +/* + * + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.process; + +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; + +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import org.camunda.bpm.engine.runtime.Execution; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.so.BaseBPMNTest; +import org.onap.so.GrpcNettyServer; +import org.onap.so.bpmn.mock.FileUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + + +/** + * Basic Integration test for createVcpeResCustService_Simplified.bpmn workflow. + */ +public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private static final String TEST_PROCESSINSTANCE_KEY = "CreateVcpeResCustService_simplified"; + + private String testBusinessKey; + private String requestObject; + private String responseObject; + + @Autowired + private GrpcNettyServer grpcNettyServer; + + @Before + public void setUp() throws IOException { + + requestObject = FileUtil.readResourceFile("request/" + getClass().getSimpleName() + ".json"); + responseObject = FileUtil.readResourceFile("response/" + getClass().getSimpleName() + ".json"); + + variables.put("bpmnRequest", requestObject); + + /** + * This variable indicates that the flow was invoked asynchronously. + * It's injected by {@link WorkflowProcessor}. + */ + variables.put("isAsyncProcess", "true"); + + /** + * Temporary solution to add pnfCorrelationId to context. + * this value is getting from the request to SO api handler and then convert to CamudaInput + */ + variables.put("pnfCorrelationId", "PNFDemo"); + + /** + * Create mso-request-id. + */ + String msoRequestId = UUID.randomUUID().toString(); + + variables.put("mso-request-id", msoRequestId); + + /** + * Create Business key for the process instance + */ + testBusinessKey = UUID.randomUUID().toString(); + + logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); + + } + + @Test + public void workflow_validInput_expectedOuput() { + + mockCatalogDb(); + mockAai(); + mockDmaapForPnf(); + + ProcessInstance pi = runtimeService + .startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, variables); + assertThat(pi).isNotNull(); + + Execution execution = runtimeService.createExecutionQuery().processDefinitionKey("CreateAndActivatePnfResource") + .activityId("WaitForDmaapPnfReadyNotification").singleResult(); + + if (!execution.isSuspended() && !execution.isEnded()) { + try { + + runtimeService.signal(execution.getId()); + } catch (Exception e) { + logger.info(e.getMessage(), e); + } + } + + assertThat(pi).isStarted().hasPassedInOrder( + "createVCPE_startEvent", + "preProcessRequest_ScriptTask", + "sendSyncAckResponse_ScriptTask", + "ScriptTask_0cdtchu", + "DecomposeService", + "ScriptTask_0lpv2da", + "ScriptTask_1y241p8", + "CallActivity_1vc4jeh", + "ScriptTask_1y5lvl7", + "GeneratePnfUuid", + "Task_14l19kv", + "Pnf_Con", + "setPONR_ScriptTask", + "postProcessAndCompletionRequest_ScriptTask", + "callCompleteMsoProcess_CallActivity", + "ScriptTask_2", + "CreateVCPE_EndEvent" + ); + + assertThat(pi).isEnded(); + + List<String> messagesDelivered = grpcNettyServer.getMessagesDelivered(); + assertThat(messagesDelivered).containsSequence("config-assign", "config-deploy"); + } + + /** + * Mock the Dmaap Rest interface for Pnf topic. + */ + private void mockDmaapForPnf() { + + String pnfResponse = "[{\"correlationId\": \"PNFDemo\",\"key1\":\"value1\"}]"; + + /** + * Get the events from PNF topic + */ + wireMockServer + .stubFor(get(urlPathMatching("/events/pnfReady/consumerGroup.*")).willReturn(okJson(pnfResponse))); + } + + private void mockAai() { + + String aaiResponse = "{\n" + + " \"results\": [\n" + + " {\n" + + " \"resource-type\": \"service-instance\",\n" + + " \"resource-link\": \"https://localhost:8443/aai/v15/business/customers/customer/ADemoCustomerInCiti/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/key3\"\n" + + " }\n" + + " ]\n" + + "}"; + + String aaiPnfEntry = "{ \n" + + " \"pnf-name\":\"PNFDemo\",\n" + + " \"pnf-id\":\"testtest\",\n" + + " \"in-maint\":true,\n" + + " \"resource-version\":\"1541720264047\",\n" + + " \"pnf-ipv4-address\":\"1.1.1.1\",\n" + + " \"pnf-ipv6-address\":\"ipv6\"\n" + + "}"; + + /** + * Get the AAI entry for globalCustomerId as specified in the request file. + */ + wireMockServer.stubFor( + get(urlPathMatching("/aai/v15/business/customers/customer/ADemoCustomerInCiti.*")).willReturn(ok())); + + /** + * PUT the service to AAI with globalCustomerId, service type as specified in the request file. + * Service instance id is generated during runtime, REGEX is used to represent the information. + */ + wireMockServer.stubFor(put(urlPathMatching( + "/aai/v15/business/customers/customer/ADemoCustomerInCiti/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/.*"))); + + wireMockServer.stubFor(get(urlPathMatching( + "/aai/v15/business/customers/customer/ADemoCustomerInCiti/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/.*")) + .willReturn(okJson(aaiResponse))); + + /** + * Get the service from AAI + */ + wireMockServer.stubFor(get(urlPathMatching("/aai/v15/nodes/service-instances/service-instance/.*")) + .willReturn(okJson(aaiResponse))); + + /** + * Put the project as specified in the request file to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/v15/business/projects/project/Project-Demonstration"))); + + /** + * GET the project as specified in the request file to AAI. + */ + wireMockServer + .stubFor(get(urlPathMatching("/aai/v15/business/projects/project/Project-Demonstration")).willReturn(ok())); + + /** + * PUT the PNF correlation ID to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/v15/network/pnfs/pnf/PNFDemo"))); + + /** + * Get the PNF entry from AAI. + */ + wireMockServer.stubFor(get(urlEqualTo("/aai/v15/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); + + /** + * Put the PNF relationship + */ + wireMockServer.stubFor( + put(urlEqualTo("/aai/v15/business/projects/project/Project-Demonstration/relationship-list/relationship"))); + } + + /** + * Mock the catalobdb rest interface. + */ + private void mockCatalogDb() { + + String catalogdbClientResponse = FileUtil + .readResourceFile("response/" + getClass().getSimpleName() + "_catalogdb.json"); + + /** + * Return valid json for the model UUID in the request file. + */ + wireMockServer + .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=f2daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(responseObject))); + + /** + * Return valid json for the service model InvariantUUID as specified in the request file. + */ + wireMockServer.stubFor( + get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=539b7a2f-9524-4dbf-9eee-f2e05521df3f")) + .willReturn(okJson(responseObject))); + + /** + * Return valid spring data rest json for the service model UUID as specified in the request file. + */ + wireMockServer.stubFor(get(urlEqualTo( + "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=f2daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(catalogdbClientResponse))); + } +} |