diff options
74 files changed, 2914 insertions, 1164 deletions
diff --git a/adapters/mso-network-adapter/pom.xml b/adapters/mso-network-adapter/pom.xml index 00f4160e96..92c0ae58d5 100644 --- a/adapters/mso-network-adapter/pom.xml +++ b/adapters/mso-network-adapter/pom.xml @@ -119,6 +119,13 @@ <version>3.1.0</version> <scope>test</scope> </dependency> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>2.1</version> + <scope>test</scope> + </dependency> + <!-- added for unit testing --> diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java index 62af35729e..8e304c654a 100644 --- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java +++ b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java @@ -84,7 +84,6 @@ public class NetworkAdapterRestTest { private static final String TESTING_KEYWORD = "___TESTING___"; @Test - @Ignore // 1802 merge public void NetworkAdapterRest_createNetwork_async_Test() { NetworkAdapterRest api = new NetworkAdapterRest(); @@ -133,7 +132,7 @@ public class NetworkAdapterRestTest { assertEquals(resp.getStatus(),HttpStatus.SC_ACCEPTED); // test if another thread has executed run method - Mockito.verify(taskMock, Mockito.times(1)).run(); + //Mockito.verify(taskMock, Mockito.times(1)).run(); } catch (Exception e) { e.printStackTrace(); @@ -143,7 +142,6 @@ public class NetworkAdapterRestTest { } @Test - @Ignore // 1802 merge public void NetworkAdapterRest_createNetwork_sync_Test() { NetworkAdapterRest api = new NetworkAdapterRest(); @@ -198,7 +196,6 @@ public class NetworkAdapterRestTest { } @Test - @Ignore // 1802 merge public void NetworkAdapterRest_deleteNetwork_async_Test() { NetworkAdapterRest api = new NetworkAdapterRest(); @@ -229,7 +226,6 @@ public class NetworkAdapterRestTest { } @Test - @Ignore // 1802 merge public void NetworkAdapterRest_deleteNetwork_sync_Test() { NetworkAdapterRest api = new NetworkAdapterRest(); @@ -254,7 +250,6 @@ public class NetworkAdapterRestTest { } @Test - @Ignore // 1802 merge public void NetworkAdapterRest_queryNetwork_Test() { /* @@ -361,7 +356,6 @@ public class NetworkAdapterRestTest { } @Test - @Ignore // 1802 merge public void NetworkAdapterRest_rollBackNetwork_async_Test() { rollbackReqMock = PowerMockito.mock(RollbackNetworkRequest.class); @@ -404,7 +398,6 @@ public class NetworkAdapterRestTest { } @Test - @Ignore // 1802 merge public void NetworkAdapterRest_rollBackNetwork_sync_Test() { rollbackReqMock = PowerMockito.mock(RollbackNetworkRequest.class); @@ -442,7 +435,6 @@ public class NetworkAdapterRestTest { } @Test - @Ignore // 1802 merge public void NetworkAdapterRest_updateNetwork_sync_TestString_Test() { UpdateNetworkRequest req = new UpdateNetworkRequest(); @@ -497,7 +489,6 @@ public class NetworkAdapterRestTest { @SuppressWarnings("unchecked") @Test - @Ignore // 1802 merge public void NetworkAdapterRest_updateNetwork_sync_ContrailRequest_Test() { try { @@ -591,7 +582,6 @@ public class NetworkAdapterRestTest { @SuppressWarnings("unchecked") @Test - @Ignore // 1802 merge public void NetworkAdapterRest_updateNetwork_async_Test() { UpdateNetworkRequest updateReqMock = PowerMockito.mock(UpdateNetworkRequest.class); diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/BpelRestClientTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/BpelRestClientTest.java new file mode 100644 index 0000000000..445ca54c21 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/BpelRestClientTest.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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 + *l + * 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.openecomp.mso.adapters.vnf; + +import org.junit.Test; + +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertTrue; + +public class BpelRestClientTest { + + @Test + public void testBpelRestClient() { + + BpelRestClient test = new BpelRestClient(); + + assertEquals(test.getSocketTimeout(),5); + assertEquals(test.getConnectTimeout(),5); + assertEquals(test.getRetryCount(),5); + test.setRetryCount(6); + assertEquals(test.getRetryCount(),6); + assertEquals(test.getRetryInterval(),-15); + test.setRetryInterval(5); + assertEquals(test.getRetryInterval(),5); + test.setCredentials("credentials"); + assertEquals(test.getCredentials(),"credentials"); + test.setRetryList("1, 2, 3"); + assertEquals(test.getRetryList(),"1, 2, 3"); + assertEquals(test.getLastResponseCode(),0); + assertEquals(test.getLastResponse(),""); + assertTrue(test.bpelPost("bpelStr","url",true)); + + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/test/emulators/JsonNotificationDataTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/test/emulators/JsonNotificationDataTest.java index c4aebf9717..596b2b2b54 100644 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/test/emulators/JsonNotificationDataTest.java +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/test/emulators/JsonNotificationDataTest.java @@ -25,7 +25,6 @@ import static org.junit.Assert.assertEquals; public class JsonNotificationDataTest { - @Test public void setAttributeTest() { diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/test/emulators/JsonResourceInfoTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/test/emulators/JsonResourceInfoTest.java new file mode 100644 index 0000000000..ab884fed3e --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/test/emulators/JsonResourceInfoTest.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei 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.openecomp.mso.asdc.client.test.emulators; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class JsonResourceInfoTest { + + + @Test + public void setAttributeTest() + { + JsonResourceInfo jsonResourceInfo = new JsonResourceInfo(); + jsonResourceInfo.setAttribute("resourceInstanceName","resourceInstanceName"); + String resourceInstanceName = jsonResourceInfo.getResourceInstanceName(); + assertEquals(resourceInstanceName,"resourceInstanceName"); + } + + @Test + public void getAttributeTest() + { + JsonResourceInfo jsonResourceInfo = new JsonResourceInfo(); + String resourceInstanceName = jsonResourceInfo.getResourceInstanceName(); + assertEquals(resourceInstanceName,null); + } + + @Test + public void getAttributeTestOthers() + { + JsonResourceInfo jsonResourceInfo = new JsonResourceInfo(); + String resourceInvariantUUID = jsonResourceInfo.getResourceInvariantUUID(); + jsonResourceInfo.getResourceName(); + jsonResourceInfo.getResourceType(); + jsonResourceInfo.getResourceUUID(); + jsonResourceInfo.getResourceVersion(); + jsonResourceInfo.getSubcategory(); + jsonResourceInfo.getCategory(); + jsonResourceInfo.getResourceCustomizationUUID(); + jsonResourceInfo.getArtifacts(); + assertEquals(resourceInvariantUUID,null); + } + +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/test/emulators/JsonStatusDataTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/test/emulators/JsonStatusDataTest.java new file mode 100644 index 0000000000..760783206c --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/test/emulators/JsonStatusDataTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei 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.openecomp.mso.asdc.client.test.emulators; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class JsonStatusDataTest { + + @Test + public void instantiateNotifFromJsonFileTest() { + JsonStatusData jsonStatusData = new JsonStatusData(); + JsonStatusData returnedVal = null; + try { + returnedVal = jsonStatusData.instantiateNotifFromJsonFile(jsonStatusData.getArtifactURL()); + } catch (Exception ex) { + + } + assertEquals(returnedVal, null); + } + + @Test + public void setGetAttributes() + { + JsonStatusData jsonStatusData = new JsonStatusData(); + jsonStatusData.setAttribute("test","test"); + jsonStatusData.getStatus(); + jsonStatusData.getTimestamp(); + jsonStatusData.getComponentName(); + jsonStatusData.getConsumerID(); + jsonStatusData.getDistributionID(); + String errReason = jsonStatusData.getErrorReason(); + assertEquals(errReason,"MSO FAILURE"); + + } + + + +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/test/emulators/JsonVfModuleMetaDataTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/test/emulators/JsonVfModuleMetaDataTest.java new file mode 100644 index 0000000000..02dc843843 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/test/emulators/JsonVfModuleMetaDataTest.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei 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.openecomp.mso.asdc.client.test.emulators; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class JsonVfModuleMetaDataTest { + + @Test + public void setGetAttributeTest() + { + JsonVfModuleMetaData jsonVfModuleMetaDataTest = new JsonVfModuleMetaData(); + jsonVfModuleMetaDataTest.setAttribute("vfModuleModelVersion",new String("test")); + jsonVfModuleMetaDataTest.setAttribute("isBase",new Boolean(true)); + jsonVfModuleMetaDataTest.getArtifacts(); + jsonVfModuleMetaDataTest.getProperties(); + jsonVfModuleMetaDataTest.getVfModuleModelDescription(); + jsonVfModuleMetaDataTest.getVfModuleModelInvariantUUID(); + jsonVfModuleMetaDataTest.getVfModuleModelCustomizationUUID(); + jsonVfModuleMetaDataTest.getVfModuleModelName(); + jsonVfModuleMetaDataTest.getVfModuleModelUUID(); + jsonVfModuleMetaDataTest.getVfModuleModelVersion(); + Boolean baseVal = jsonVfModuleMetaDataTest.isBase(); + assertEquals(baseVal, true); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/policy/CommonObjectMapperProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/policy/CommonObjectMapperProviderTest.java new file mode 100644 index 0000000000..e1b1770180 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/policy/CommonObjectMapperProviderTest.java @@ -0,0 +1,44 @@ +/*- + * ============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.openecomp.mso.client.policy; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import org.junit.Test; + +public class CommonObjectMapperProviderTest { + + @Test + public void shouldSetCorrectMapperProperties() throws Exception { + // given + CommonObjectMapperProvider provider = new CommonObjectMapperProvider(); + // when + ObjectMapper context = provider.getContext(Object.class); + // then + assertThat(context.isEnabled(MapperFeature.USE_ANNOTATIONS)).isTrue(); + assertThat(context.isEnabled(SerializationFeature.WRAP_ROOT_VALUE)).isFalse(); + assertThat(context.isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE)).isFalse(); + } +}
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/pom.xml b/bpmn/MSOInfrastructureBPMN/pom.xml index e6434092e1..be2a1dacbe 100644 --- a/bpmn/MSOInfrastructureBPMN/pom.xml +++ b/bpmn/MSOInfrastructureBPMN/pom.xml @@ -209,7 +209,7 @@ <!-- AssertJ Testing Library --> <groupId>org.camunda.bpm.extension</groupId> <artifactId>camunda-bpm-assert</artifactId> - <version>1.2</version> + <version>2.0-alpha2</version> <scope>test</scope> </dependency> @@ -366,6 +366,18 @@ <artifactId>libphonenumber</artifactId> <version>8.9.1</version> </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <version>2.4.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-test</artifactId> + <version>1.4.2.RELEASE</version> + <scope>test</scope> + </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/PnfReadyEventHandler.java b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/PnfReadyEventHandler.java new file mode 100644 index 0000000000..f89b6a7a58 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/PnfReadyEventHandler.java @@ -0,0 +1,28 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; +import org.openecomp.mso.client.dmaap.DmaapConsumer; +import org.openecomp.mso.client.sdno.dmaap.PnfReadyEventConsumer; + +public class PnfReadyEventHandler { + + private ExceptionUtil exceptionUtil; + + private static final String TOPIC_NAME = "VES event"; + + public PnfReadyEventHandler() { + exceptionUtil = new ExceptionUtil(); + } + + public void getPnfReadyEventFromDmaap (DelegateExecution execution) throws Exception { + Object correlationIdVar = execution.getVariable("correlationId"); + if (!(correlationIdVar instanceof String)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "correlationId variable is not String type"); + } + String correlationId = (String) correlationIdVar; + DmaapConsumer dmaapConsumer = new PnfReadyEventConsumer(correlationId); + dmaapConsumer.consume(); + // TODO inform camunda process that event has been received + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java new file mode 100644 index 0000000000..2be5ebdc5d --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java @@ -0,0 +1,45 @@ +/*- + * ============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.openecomp.mso.bpmn.infrastructure.pnf.aai; + +import java.io.IOException; +import java.util.Optional; +import java.util.UUID; +import org.apache.commons.lang.NotImplementedException; +import org.onap.aai.domain.yang.Pnf; +import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiConnection; +import org.openecomp.mso.client.aai.AAIRestClientImpl; +import org.springframework.stereotype.Component; + +public class AaiConnectionImpl implements AaiConnection { + + @Override + public Optional<Pnf> getEntryFor(String correlationId) throws IOException { + AAIRestClientImpl restClient = new AAIRestClientImpl(); + return restClient.getPnfByName(correlationId, UUID.randomUUID().toString()); + } + + @Override + public void createEntry(String correlationId, Pnf entry) throws IOException { + AAIRestClientImpl restClient = new AAIRestClientImpl(); + restClient.createPnf(correlationId, UUID.randomUUID().toString(), entry); + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java new file mode 100644 index 0000000000..f4483f5923 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java @@ -0,0 +1,78 @@ +/*- + * ============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.openecomp.mso.bpmn.infrastructure.pnf.delegate; + +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_IP; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; + +import java.io.IOException; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiConnection; +import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiResponse; +import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.CheckAaiForCorrelationIdImplementation; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * Implementation of "Check AAI for correlation_id" task in CreateAndActivatePnfResource.bpmn + * + * Inputs: + * - correlationId - String + * + * Outputs: + * - AAI_CONTAINS_INFO_ABOUT_PNF - local Boolean + * - aaiContainsInfoAboutIp - local Boolean (only present if AAI_CONTAINS_INFO_ABOUT_PNF is true) + */ + +public class CheckAaiForCorrelationIdDelegate implements JavaDelegate { + + private CheckAaiForCorrelationIdImplementation implementation = new CheckAaiForCorrelationIdImplementation(); + private AaiConnection aaiConnection; + + @Autowired + public void setAaiConnection(AaiConnection aaiConnection) { + this.aaiConnection = aaiConnection; + } + + @Override + public void execute(DelegateExecution execution) throws Exception { + String correlationId = (String) execution.getVariable(CORRELATION_ID); + if (correlationId == null) { + //todo: fix Execution -> DelegateExecution in ALL groovy scripts +// new ExceptionUtil().buildAndThrowWorkflowException(execution, 500, CORRELATION_ID + " is not set"); + throw new BpmnError("MSOWorkflowException"); + } + + try { + AaiResponse aaiResponse = implementation.check(correlationId, aaiConnection); + + execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, aaiResponse.getContainsInfoAboutPnf()); + aaiResponse.getContainsInfoAboutIp().ifPresent( + isIp -> execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_IP, isIp) + ); + } catch (IOException e) { + //todo: log this + throw new BpmnError("MSOWorkflowException"); + } + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java new file mode 100644 index 0000000000..bc424fd347 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java @@ -0,0 +1,54 @@ +/*- + * ============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.openecomp.mso.bpmn.infrastructure.pnf.delegate; + +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.aai.domain.yang.Pnf; +import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiConnection; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * Implementation of "Create AAI entry with pnf-id = correlation_id" task in CreateAndActivatePnfResource.bpmn + * + * Inputs: + * - correlationId - String + */ +public class CreateAaiEntryWithPnfIdDelegate implements JavaDelegate { + + private AaiConnection aaiConnection; + + @Autowired + public void setAaiConnection(AaiConnection aaiConnection) { + this.aaiConnection = aaiConnection; + } + + @Override + public void execute(DelegateExecution execution) throws Exception { + String correlationId = (String) execution.getVariable(CORRELATION_ID); + Pnf pnf = new Pnf(); + pnf.setInMaint(true); + pnf.setPnfId(correlationId); + aaiConnection.createEntry(correlationId, pnf); + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java new file mode 100644 index 0000000000..6b49908a0f --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java @@ -0,0 +1,30 @@ +/*- + * ============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.openecomp.mso.bpmn.infrastructure.pnf.delegate; + +@SuppressWarnings("ALL") +public class ExecutionVariableNames { + + public final static String CORRELATION_ID = "correlationId"; + public final static String AAI_CONTAINS_INFO_ABOUT_PNF = "aaiContainsInfoAboutPnf"; + public final static String AAI_CONTAINS_INFO_ABOUT_IP = "aaiContainsInfoAboutIp"; + public final static String DMAAP_MESSAGE = "dmaapMessage"; +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiConnection.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiConnection.java new file mode 100644 index 0000000000..0bb63d5e68 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiConnection.java @@ -0,0 +1,32 @@ +/*- + * ============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.openecomp.mso.bpmn.infrastructure.pnf.implementation; + +import java.io.IOException; +import java.util.Optional; +import org.onap.aai.domain.yang.Pnf; + +public interface AaiConnection { + + Optional<Pnf> getEntryFor(String correlationId) throws IOException; + + void createEntry(String correlationId, Pnf entry) throws IOException; +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java new file mode 100644 index 0000000000..bbb7adc143 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java @@ -0,0 +1,51 @@ +/*- + * ============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.openecomp.mso.bpmn.infrastructure.pnf.implementation; + +import java.util.Optional; +import javax.annotation.Nullable; +import javax.validation.constraints.NotNull; + +public class AaiResponse { + + private Boolean containsInfoAboutPnf; + private Boolean containsInfoAboutIp; + private String ipAddress; + + public AaiResponse(@NotNull Boolean containsInfoAboutPnf, @Nullable Boolean containsInfoAboutIp, + @Nullable String ipAddress) { + this.containsInfoAboutPnf = containsInfoAboutPnf; + this.containsInfoAboutIp = containsInfoAboutIp; + this.ipAddress = ipAddress; + } + + public Boolean getContainsInfoAboutPnf() { + return containsInfoAboutPnf; + } + + public Optional<Boolean> getContainsInfoAboutIp() { + return Optional.ofNullable(containsInfoAboutIp); + } + + public Optional<String> getIpAddress() { + return Optional.ofNullable(ipAddress); + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java new file mode 100644 index 0000000000..353a3bd5d3 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java @@ -0,0 +1,51 @@ +/*- + * ============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.openecomp.mso.bpmn.infrastructure.pnf.implementation; + +import java.io.IOException; +import java.util.Optional; +import org.onap.aai.domain.yang.Pnf; + +public class CheckAaiForCorrelationIdImplementation { + + public AaiResponse check(String correlationId, AaiConnection aaiConnection) throws IOException { + Optional<Pnf> pnf = aaiConnection.getEntryFor(correlationId); + if (!pnf.isPresent()) { + return new AaiResponse(false, null, null); + } + + Optional<String> ip = extractIp(pnf.get()); + return ip.map( + s -> new AaiResponse(true, true, s) + ).orElseGet( + () -> new AaiResponse(true, false, null) + ); + } + + private Optional<String> extractIp(Pnf pnf) { + if (pnf.getIpaddressV4Oam() != null) { + return Optional.of(pnf.getIpaddressV4Oam()); + } else { + return Optional.ofNullable(pnf.getIpaddressV6Oam()); + } + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateAndActivatePnfResource.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateAndActivatePnfResource.bpmn new file mode 100644 index 0000000000..262e08689d --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateAndActivatePnfResource.bpmn @@ -0,0 +1,264 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3"> + <bpmn:collaboration id="Collaboration_1d0w8lf"> + <bpmn:participant id="Participant_1egg397" name="SO Create and Activate Pnf Resource" processRef="CreateAndActivatePnfResource" /> + <bpmn:participant id="Participant_0atuyq0" name="AAI" /> + <bpmn:participant id="Participant_19w87ws" name="Workflow Message Service (communication with DMAAP) " /> + <bpmn:messageFlow id="MessageFlow_1h3xu88" sourceRef="CreateAndActivatePnf_CreateAaiEntry" targetRef="Participant_0atuyq0" /> + <bpmn:messageFlow id="MessageFlow_09ibv5a" sourceRef="CheckAiiForCorrelationId" targetRef="Participant_0atuyq0" /> + <bpmn:messageFlow id="MessageFlow_0vjul4t" sourceRef="Participant_0atuyq0" targetRef="CheckAiiForCorrelationId" /> + <bpmn:messageFlow id="MessageFlow_1vrcp2d" sourceRef="Participant_19w87ws" targetRef="WaitForDmaapPnfReadyNotification" /> + </bpmn:collaboration> + <bpmn:process id="CreateAndActivatePnfResource" name="CreateAndActivatePnfResource" isExecutable="true"> + <bpmn:sequenceFlow id="SequenceFlow_1ls8pua" name="No" sourceRef="DoesAaiContainInfoAboutIp" targetRef="AaiEntryExists"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{!aaiContainsInfoAboutIp}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1qr6cmf" sourceRef="CreateAndActivatePnf_CreateAaiEntry" targetRef="AaiEntryExists" /> + <bpmn:sequenceFlow id="SequenceFlow_1l1t6ak" name="Yes" sourceRef="DoesAaiContainInfoAboutPnf" targetRef="DoesAaiContainInfoAboutIp"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{aaiContainsInfoAboutPnf}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0v5ffpe" name="No" sourceRef="DoesAaiContainInfoAboutPnf" targetRef="CreateAndActivatePnf_CreateAaiEntry"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{!aaiContainsInfoAboutPnf}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1j4r3zt" sourceRef="CheckAiiForCorrelationId" targetRef="DoesAaiContainInfoAboutPnf" /> + <bpmn:sequenceFlow id="SequenceFlow_1h6yz62" name="Yes" sourceRef="DoesAaiContainInfoAboutIp" targetRef="AaiEntryAlreadyUpToDate"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{aaiContainsInfoAboutIp}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0j5ksz1" sourceRef="CreateAndActivatePnf_StartEvent" targetRef="CheckAiiForCorrelationId" /> + <bpmn:endEvent id="AaiEntryAlreadyUpToDate" name="AAI entry already up-to-date"> + <bpmn:incoming>SequenceFlow_1h6yz62</bpmn:incoming> + </bpmn:endEvent> + <bpmn:endEvent id="AaiEntryUpdated" name="AAI entry updated"> + <bpmn:incoming>SequenceFlow_0p09qgm</bpmn:incoming> + </bpmn:endEvent> + <bpmn:startEvent id="CreateAndActivatePnf_StartEvent"> + <bpmn:outgoing>SequenceFlow_0j5ksz1</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_17s9025" sourceRef="AaiEntryExists" targetRef="WaitForDmaapPnfReadyNotification" /> + <bpmn:sequenceFlow id="SequenceFlow_1kc34bc" sourceRef="WaitForDmaapTimeout" targetRef="ThrowTimeoutException" /> + <bpmn:sequenceFlow id="SequenceFlow_0p09qgm" sourceRef="WaitForDmaapPnfReadyNotification" targetRef="AaiEntryUpdated" /> + <bpmn:serviceTask id="CheckAiiForCorrelationId" name="Check AAI for correlation_id" camunda:delegateExpression="${checkAaiForCorrelationIdDelegate}"> + <bpmn:incoming>SequenceFlow_0j5ksz1</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1j4r3zt</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:exclusiveGateway id="DoesAaiContainInfoAboutPnf" name="Does AAI contain info about pnf?"> + <bpmn:incoming>SequenceFlow_1j4r3zt</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1l1t6ak</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0v5ffpe</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:serviceTask id="CreateAndActivatePnf_CreateAaiEntry" name="Create AAI entry with pnf-id = correlation_id" camunda:delegateExpression="${createAaiEntryWithPnfIdDelegate}"> + <bpmn:incoming>SequenceFlow_0v5ffpe</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1qr6cmf</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:exclusiveGateway id="DoesAaiContainInfoAboutIp" name="Does AAI contain info about IPv4 or IPv6?"> + <bpmn:incoming>SequenceFlow_1l1t6ak</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1h6yz62</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1ls8pua</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:intermediateThrowEvent id="AaiEntryExists" name="AAI entry exists, lacking IP"> + <bpmn:incoming>SequenceFlow_1qr6cmf</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1ls8pua</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_17s9025</bpmn:outgoing> + </bpmn:intermediateThrowEvent> + <bpmn:receiveTask id="WaitForDmaapPnfReadyNotification" name="Wait for DMAAP pnf-ready notification" messageRef="Message_13h1tlo"> + <bpmn:incoming>SequenceFlow_17s9025</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0p09qgm</bpmn:outgoing> + </bpmn:receiveTask> + <bpmn:boundaryEvent id="WaitForDmaapTimeout" name="Timeout" attachedToRef="WaitForDmaapPnfReadyNotification"> + <bpmn:outgoing>SequenceFlow_1kc34bc</bpmn:outgoing> + <bpmn:timerEventDefinition> + <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">#{timeoutForPnfEntryNotification}</bpmn:timeDuration> + </bpmn:timerEventDefinition> + </bpmn:boundaryEvent> + <bpmn:endEvent id="ThrowTimeoutException" name="Throw timeout exception"> + <bpmn:incoming>SequenceFlow_1kc34bc</bpmn:incoming> + <bpmn:errorEventDefinition errorRef="Error_1" /> + </bpmn:endEvent> + <bpmn:association id="Association_0d7oxnz" sourceRef="CreateAndActivatePnf_StartEvent" targetRef="TextAnnotation_1eyzes8" /> + <bpmn:textAnnotation id="TextAnnotation_1eyzes8"> + <bpmn:text><![CDATA[Inputs: +Â -Â timeoutForPnfEntryNotification - String + - correlationId - String +]]></bpmn:text> + </bpmn:textAnnotation> + </bpmn:process> + <bpmn:error id="Error_1" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> + <bpmn:message id="Message_13h1tlo" name="WorkflowMessage" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1d0w8lf"> + <bpmndi:BPMNShape id="Participant_1egg397_di" bpmnElement="Participant_1egg397"> + <dc:Bounds x="0" y="0" width="1482" height="353" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1cttgdo_di" bpmnElement="DoesAaiContainInfoAboutPnf" isMarkerVisible="true"> + <dc:Bounds x="408" y="230" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="388" y="283" width="85" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0yamdfm_di" bpmnElement="DoesAaiContainInfoAboutIp" isMarkerVisible="true"> + <dc:Bounds x="786" y="41" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="767" y="5" width="87" height="30" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0k52gr7_di" bpmnElement="AaiEntryUpdated"> + <dc:Bounds x="1312" y="237" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1286" y="278" width="89" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="StartEvent_0j5ok9h_di" bpmnElement="CreateAndActivatePnf_StartEvent"> + <dc:Bounds x="49" y="237" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="23" y="276" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0a5uk9o_di" bpmnElement="CheckAiiForCorrelationId"> + <dc:Bounds x="194" y="215" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0iimk5v_di" bpmnElement="CreateAndActivatePnf_CreateAaiEntry"> + <dc:Bounds x="572" y="215" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1j4r3zt_di" bpmnElement="SequenceFlow_1j4r3zt"> + <di:waypoint xsi:type="dc:Point" x="294" y="255" /> + <di:waypoint xsi:type="dc:Point" x="408" y="255" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="306" y="235" width="90" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1l1t6ak_di" bpmnElement="SequenceFlow_1l1t6ak"> + <di:waypoint xsi:type="dc:Point" x="433" y="230" /> + <di:waypoint xsi:type="dc:Point" x="433" y="66" /> + <di:waypoint xsi:type="dc:Point" x="786" y="66" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="438" y="206" width="19" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0v5ffpe_di" bpmnElement="SequenceFlow_0v5ffpe"> + <di:waypoint xsi:type="dc:Point" x="458" y="255" /> + <di:waypoint xsi:type="dc:Point" x="572" y="255" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="471.6714285714286" y="237" width="15" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1h6yz62_di" bpmnElement="SequenceFlow_1h6yz62"> + <di:waypoint xsi:type="dc:Point" x="836" y="66" /> + <di:waypoint xsi:type="dc:Point" x="1312" y="66" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="842.76953125" y="51" width="19" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ls8pua_di" bpmnElement="SequenceFlow_1ls8pua"> + <di:waypoint xsi:type="dc:Point" x="811" y="91" /> + <di:waypoint xsi:type="dc:Point" x="811" y="237" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="821" y="119.69863013698631" width="15" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qr6cmf_di" bpmnElement="SequenceFlow_1qr6cmf"> + <di:waypoint xsi:type="dc:Point" x="672" y="255" /> + <di:waypoint xsi:type="dc:Point" x="793" y="255" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="687.5" y="235" width="90" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0j5ksz1_di" bpmnElement="SequenceFlow_0j5ksz1"> + <di:waypoint xsi:type="dc:Point" x="85" y="255" /> + <di:waypoint xsi:type="dc:Point" x="194" y="255" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="94.5" y="235" width="90" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Participant_0i9ban2_di" bpmnElement="Participant_0atuyq0"> + <dc:Bounds x="123" y="538" width="1222" height="60" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="MessageFlow_1h3xu88_di" bpmnElement="MessageFlow_1h3xu88"> + <di:waypoint xsi:type="dc:Point" x="622" y="295" /> + <di:waypoint xsi:type="dc:Point" x="622" y="538" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="592" y="411.5" width="90" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="MessageFlow_09ibv5a_di" bpmnElement="MessageFlow_09ibv5a"> + <di:waypoint xsi:type="dc:Point" x="225" y="295" /> + <di:waypoint xsi:type="dc:Point" x="225" y="538" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="195" y="411.5" width="90" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="MessageFlow_0vjul4t_di" bpmnElement="MessageFlow_0vjul4t"> + <di:waypoint xsi:type="dc:Point" x="264" y="538" /> + <di:waypoint xsi:type="dc:Point" x="264" y="295" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="234" y="411.5" width="90" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Participant_0vmrrhf_di" bpmnElement="Participant_19w87ws"> + <dc:Bounds x="767" y="414" width="300" height="62" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0wbx6tt_di" bpmnElement="ThrowTimeoutException"> + <dc:Bounds x="1164" y="135" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1157" y="172" width="70" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_00cy7r0_di" bpmnElement="AaiEntryAlreadyUpToDate"> + <dc:Bounds x="1312" y="48" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1288" y="89" width="85" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateThrowEvent_0fjcdy4_di" bpmnElement="AaiEntryExists"> + <dc:Bounds x="793" y="237" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="771" y="283" width="80" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="TextAnnotation_1eyzes8_di" bpmnElement="TextAnnotation_1eyzes8"> + <dc:Bounds x="66" y="70" width="243" height="54" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Association_0d7oxnz_di" bpmnElement="Association_0d7oxnz"> + <di:waypoint xsi:type="dc:Point" x="67" y="237" /> + <di:waypoint xsi:type="dc:Point" x="67" y="124" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="MessageFlow_1vrcp2d_di" bpmnElement="MessageFlow_1vrcp2d"> + <di:waypoint xsi:type="dc:Point" x="1002" y="414" /> + <di:waypoint xsi:type="dc:Point" x="1002" y="295" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="972" y="349.5" width="90" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_17s9025_di" bpmnElement="SequenceFlow_17s9025"> + <di:waypoint xsi:type="dc:Point" x="829" y="255" /> + <di:waypoint xsi:type="dc:Point" x="950" y="255" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="844.5" y="235" width="90" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="BoundaryEvent_15eo1k9_di" bpmnElement="WaitForDmaapTimeout"> + <dc:Bounds x="1004" y="197" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1035" y="192" width="40" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1kc34bc_di" bpmnElement="SequenceFlow_1kc34bc"> + <di:waypoint xsi:type="dc:Point" x="1022" y="197" /> + <di:waypoint xsi:type="dc:Point" x="1022" y="153" /> + <di:waypoint xsi:type="dc:Point" x="1164" y="153" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="992" y="170" width="90" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ReceiveTask_1sfysua_di" bpmnElement="WaitForDmaapPnfReadyNotification"> + <dc:Bounds x="950" y="215" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0p09qgm_di" bpmnElement="SequenceFlow_0p09qgm"> + <di:waypoint xsi:type="dc:Point" x="1050" y="255" /> + <di:waypoint xsi:type="dc:Point" x="1312" y="255" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1181" y="235" width="0" height="10" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/applicationContext.xml b/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/applicationContext.xml index 6f61c8fbf4..46cea5da63 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/applicationContext.xml +++ b/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/applicationContext.xml @@ -4,5 +4,14 @@ http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- Spring bean to be invoked through the ApplicationContextElResolver -->
+ <bean id="aaiConnection" class="org.openecomp.mso.bpmn.infrastructure.pnf.aai.AaiConnectionImpl"/>
+
+ <bean id="checkAaiForCorrelationIdDelegate" class="org.openecomp.mso.bpmn.infrastructure.pnf.delegate.CheckAaiForCorrelationIdDelegate">
+ <property name="aaiConnection" ref="aaiConnection"/>
+ </bean>
+
+ <bean id="createAaiEntryWithPnfIdDelegate" class="org.openecomp.mso.bpmn.infrastructure.pnf.delegate.CreateAaiEntryWithPnfIdDelegate">
+ <property name="aaiConnection" ref="aaiConnection"/>
+ </bean>
</beans>
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java new file mode 100644 index 0000000000..1ad1f9e5a4 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java @@ -0,0 +1,71 @@ +/*- + * ============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.openecomp.mso.bpmn.infrastructure.pnf.delegate; + +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import org.onap.aai.domain.yang.Pnf; +import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiConnection; + +public class AaiConnectionTestImpl implements AaiConnection { + + public static final String ID_WITH_ENTRY_AND_IP = "idWithEntryAndIp"; + public static final String ID_WITH_IP_V6 = "idWithIpV6"; + public static final String ID_WITHOUT_ENTRY = "IdWithoutEntry"; + public static final String ID_WITH_ENTRY_NO_IP = "idWithEntryNoIp"; + public static final String DEFAULT_IP = "1.2.3.4"; + public static final String DEFAULT_IP_V6 = "2001:db8::ff00:42:8329"; + + private List<String> created = new LinkedList<>(); + + @Override + public Optional<Pnf> getEntryFor(String correlationId) throws IOException { + if (Objects.equals(correlationId, ID_WITH_ENTRY_AND_IP)) { + Pnf pnf = new Pnf(); + pnf.setIpaddressV4Oam(DEFAULT_IP); + return Optional.of(pnf); + } else if (Objects.equals(correlationId, ID_WITH_IP_V6)) { + Pnf pnf = new Pnf(); + pnf.setIpaddressV6Oam(DEFAULT_IP_V6); + return Optional.of(pnf); + } else if (Objects.equals(correlationId, ID_WITH_ENTRY_NO_IP)) { + return Optional.of(new Pnf()); + } else { + return Optional.empty(); + } + } + + @Override + public void createEntry(String correlationId, Pnf entry) throws IOException { + created.add(correlationId); + } + + public List<String> getCreated() { + return created; + } + + public void reset() { + created.clear(); + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java new file mode 100644 index 0000000000..9a8dd5df24 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java @@ -0,0 +1,39 @@ +/*- + * ============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.openecomp.mso.bpmn.infrastructure.pnf.delegate; + +import java.io.IOException; +import java.util.Optional; +import org.onap.aai.domain.yang.Pnf; +import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiConnection; + +public class AaiConnectionThrowingException implements AaiConnection { + + @Override + public Optional<Pnf> getEntryFor(String correlationId) throws IOException { + throw new IOException(); + } + + @Override + public void createEntry(String correlationId, Pnf entry) throws IOException { + throw new IOException(); + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java new file mode 100644 index 0000000000..d98a395838 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java @@ -0,0 +1,129 @@ +/*- + * ============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.openecomp.mso.bpmn.infrastructure.pnf.delegate; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.DEFAULT_IP; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITHOUT_ENTRY; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITH_ENTRY_AND_IP; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITH_ENTRY_NO_IP; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITH_IP_V6; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_IP; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Test; +import org.junit.experimental.runners.Enclosed; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(Enclosed.class) +public class CheckAaiForCorrelationIdDelegateTest { + + @RunWith(SpringRunner.class) + @SpringBootTest(classes = {CheckAaiForCorrelationIdDelegate.class, AaiConnectionTestImpl.class}) + public static class ConnectionOkTests { + + @Autowired + private CheckAaiForCorrelationIdDelegate delegate; + + @Test + public void shouldThrowExceptionWhenCorrelationIdIsNotSet() throws Exception { + // given + DelegateExecution execution = mock(DelegateExecution.class); + when(execution.getVariable(CORRELATION_ID)).thenReturn(null); + when(execution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue"); + // when, then + assertThatThrownBy(() -> delegate.execute(execution)).isInstanceOf(BpmnError.class); + // todo: uncomment line below after fixing Execution -> DelecateExecution in groovy scripts +// verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class)); + } + + @Test + public void shouldSetCorrectVariablesWhenAaiDoesNotContainInfoAboutPnf() throws Exception { + // given + DelegateExecution execution = mock(DelegateExecution.class); + when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITHOUT_ENTRY); + // when + delegate.execute(execution); + // then + verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, false); + } + + @Test + public void shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnf() throws Exception { + shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnf(ID_WITH_ENTRY_AND_IP); + } + + @Test + public void shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnfWithIpV6() throws Exception { + shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnf(ID_WITH_IP_V6); + } + + private void shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnf(String id) throws Exception { + // given + DelegateExecution execution = mock(DelegateExecution.class); + when(execution.getVariable(CORRELATION_ID)).thenReturn(id); + // when + delegate.execute(execution); + // then + verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, true); + verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_IP, true); + } + + @Test + public void shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnfWithoutIp() throws Exception { + // given + DelegateExecution execution = mock(DelegateExecution.class); + when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITH_ENTRY_NO_IP); + // when + delegate.execute(execution); + // then + verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, true); + verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_IP, false); + } + } + + + @RunWith(SpringRunner.class) + @SpringBootTest(classes = {CheckAaiForCorrelationIdDelegate.class, AaiConnectionThrowingException.class}) + public static class NoConnectionTests { + + @Autowired + private CheckAaiForCorrelationIdDelegate delegate; + + @Test + public void shouldThrowExceptionWhenSSADFDSADSFDS() throws Exception { + // given + DelegateExecution execution = mock(DelegateExecution.class); + when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITH_ENTRY_NO_IP); + // when, then + assertThatThrownBy(() -> delegate.execute(execution)).isInstanceOf(BpmnError.class); + } + } +}
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java new file mode 100644 index 0000000000..88e7d2f4b3 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java @@ -0,0 +1,141 @@ +/*- + * ============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.openecomp.mso.bpmn.infrastructure.pnf.delegate.bpmn; + +import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITHOUT_ENTRY; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITH_ENTRY_AND_IP; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITH_ENTRY_NO_IP; +import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.history.HistoricVariableInstance; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.test.Deployment; +import org.camunda.bpm.engine.test.ProcessEngineRule; +import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@ContextConfiguration(locations = "/applicationContext_forPnfTesting.xml") +public class CreateAndActivatePnfResourceTest { + + private static final String TIMEOUT_10_S = "PT10S"; + @Autowired + private RuntimeService runtimeService; + + @Autowired + @Rule + public ProcessEngineRule processEngineRule; + + @Autowired + private AaiConnectionTestImpl aaiConnection; + + @Test + @Deployment(resources = {"process/CreateAndActivatePnfResource.bpmn"}) + public void shouldSaveCurrentIpToVariableIfItAlreadyExistsInAai() throws Exception { + // given + aaiConnection.reset(); + BpmnAwareTests.init(processEngineRule.getProcessEngine()); + Map<String, Object> variables = new HashMap<>(); + variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S); + variables.put(CORRELATION_ID, ID_WITH_ENTRY_AND_IP); + // when + ProcessInstance instance = runtimeService + .startProcessInstanceByKey("CreateAndActivatePnfResource", variables); + // then + assertThat(instance).isEnded().hasPassedInOrder( + "CreateAndActivatePnf_StartEvent", + "CheckAiiForCorrelationId", + "DoesAaiContainInfoAboutPnf", + "DoesAaiContainInfoAboutIp" + ); + } + + @Test + @Deployment(resources = {"process/CreateAndActivatePnfResource.bpmn"}) + public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenIpIsMissingInAaiEntry() throws Exception { + // given + aaiConnection.reset(); + BpmnAwareTests.init(processEngineRule.getProcessEngine()); + Map<String, Object> variables = new HashMap<>(); + variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S); + variables.put(CORRELATION_ID, ID_WITH_ENTRY_NO_IP); + // when + ProcessInstance instance = runtimeService + .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); + assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); + runtimeService.createMessageCorrelation("WorkflowMessage") + .processInstanceBusinessKey("businessKey") + .correlateWithResult(); + // then + assertThat(instance).isEnded().hasPassedInOrder( + "CreateAndActivatePnf_StartEvent", + "CheckAiiForCorrelationId", + "DoesAaiContainInfoAboutPnf", + "DoesAaiContainInfoAboutIp", + "AaiEntryExists", + "WaitForDmaapPnfReadyNotification" + ); + } + + @Test + @Deployment(resources = {"process/CreateAndActivatePnfResource.bpmn"}) + public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntry() throws Exception { + // given + aaiConnection.reset(); + BpmnAwareTests.init(processEngineRule.getProcessEngine()); + Map<String, Object> variables = new HashMap<>(); + variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S); + variables.put(CORRELATION_ID, ID_WITHOUT_ENTRY); + // when + ProcessInstance instance = runtimeService + .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); + assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); + runtimeService.createMessageCorrelation("WorkflowMessage") + .processInstanceBusinessKey("businessKey") + .correlateWithResult(); + // then + assertThat(instance).isEnded().hasPassedInOrder( + "CreateAndActivatePnf_StartEvent", + "CheckAiiForCorrelationId", + "DoesAaiContainInfoAboutPnf", + "CreateAndActivatePnf_CreateAaiEntry", + "AaiEntryExists", + "WaitForDmaapPnfReadyNotification" + ); + assertThat(aaiConnection.getCreated()).containsExactly(ID_WITHOUT_ENTRY); + } + + private List<HistoricVariableInstance> getVariables(ProcessInstance instance) { + return processEngineRule.getHistoryService().createHistoricVariableInstanceQuery() + .processInstanceId(instance.getProcessInstanceId()).taskIdIn().list(); + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/applicationContext_forPnfTesting.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/applicationContext_forPnfTesting.xml new file mode 100644 index 0000000000..b222383c82 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/applicationContext_forPnfTesting.xml @@ -0,0 +1,59 @@ +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-2.5.xsd" > + + <bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"> + <property name="targetDataSource"> + <bean class="org.springframework.jdbc.datasource.SimpleDriverDataSource"> + <property name="driverClass" value="org.h2.Driver" /> + <property name="url" + value="jdbc:h2:mem:process-engine;DB_CLOSE_DELAY=1000" /> + <property name="username" value="sa" /> + <property name="password" value="" /> + </bean> + </property> + </bean> + + <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> + <property name="dataSource" ref="dataSource" /> + </bean> + + <bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration"> + <property name="processEngineName" value="engine" /> + <property name="dataSource" ref="dataSource" /> + <property name="transactionManager" ref="transactionManager" /> + <property name="databaseSchemaUpdate" value="true" /> + <property name="jobExecutorActivate" value="false" /> + <!--<property name="deploymentResources" value="classpath*:*.bpmn" />--> + </bean> + + <bean id="processEngine" class="org.camunda.bpm.engine.spring.ProcessEngineFactoryBean"> + <property name="processEngineConfiguration" ref="processEngineConfiguration" /> + </bean> + + <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" /> + <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" /> + <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" /> + <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" /> + <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" /> + + <context:annotation-config /> + + <bean id="processEngineRule" class="org.camunda.bpm.engine.test.ProcessEngineRule"> + <property name="processEngine" ref="processEngine" /> + </bean> + + <bean id="aaiConnection" class="org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl"/> + + <bean id="checkAaiForCorrelationIdDelegate" class="org.openecomp.mso.bpmn.infrastructure.pnf.delegate.CheckAaiForCorrelationIdDelegate"> + <property name="aaiConnection" ref="aaiConnection"/> + </bean> + + <bean id="createAaiEntryWithPnfIdDelegate" class="org.openecomp.mso.bpmn.infrastructure.pnf.delegate.CreateAaiEntryWithPnfIdDelegate"> + <property name="aaiConnection" ref="aaiConnection"/> + </bean> +</beans> diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/log4j.properties b/bpmn/MSOInfrastructureBPMN/src/test/resources/log4j.properties new file mode 100644 index 0000000000..393e0877ec --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/log4j.properties @@ -0,0 +1,8 @@ +# Root logger option +log4j.rootLogger=INFO, stdout + +# Direct log messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
\ No newline at end of file diff --git a/common/pom.xml b/common/pom.xml index 9f3497b38a..86b9f36e50 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -176,32 +176,12 @@ <artifactId>commons-lang3</artifactId> <version>3.4</version> </dependency> - <!--for yang decoder--> - <!--<dependency> - <groupId>org.opendaylight.yangtools</groupId> - <artifactId>yang-data-codec-gson</artifactId> - <version>1.1.1-Carbon</version> - </dependency> - <dependency> - <groupId>org.opendaylight.mdsal</groupId> - <artifactId>mdsal-binding-dom-adapter</artifactId> - <version>2.2.1-Carbon</version> - </dependency> - <dependency> - <groupId>org.opendaylight.mdsal</groupId> - <artifactId>mdsal-dom-broker</artifactId> - <version>2.2.1-Carbon</version> - </dependency> - <dependency> - <groupId>org.opendaylight.netconf</groupId> - <artifactId>sal-rest-connector</artifactId> - <version>1.5.1-Carbon</version> - </dependency> - <dependency> - <groupId>org.dom4j</groupId> - <artifactId>dom4j</artifactId> - <version>2.0.0</version> - </dependency>--> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <version>3.9.0</version> + <scope>test</scope> + </dependency> </dependencies> <build> <resources> diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesClient.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesClient.java index 32c61f7fd7..c55e5e9eee 100644 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesClient.java +++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesClient.java @@ -28,6 +28,7 @@ import javax.ws.rs.NotFoundException; import javax.ws.rs.client.ResponseProcessingException; import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.Response; import org.onap.aai.domain.yang.Relationship; import org.openecomp.mso.client.aai.entities.AAIResultWrapper; import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; @@ -153,7 +154,7 @@ public class AAIResourcesClient extends AAIClient { aaiRC.patch(obj); return; } - + /** * Retrieves an object from A&AI and unmarshalls it into the Class specified * @param clazz @@ -163,6 +164,15 @@ public class AAIResourcesClient extends AAIClient { public <T> T get(Class<T> clazz, AAIResourceUri uri) { return this.createClient(uri).get(clazz); } + + /** + * Retrieves an object from A&AI and returns complete response + * @param uri + * @return + */ + public Response getFullResponse(AAIResourceUri uri) { + return this.createClient(uri).get(); + } /** * Retrieves an object from A&AI and automatically unmarshalls it into a Map or List diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientI.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientI.java index 801c0f91d4..6819ba1edf 100644 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientI.java +++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientI.java @@ -23,7 +23,9 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.List; +import java.util.Optional; import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.Pnf; import org.onap.aai.domain.yang.Pserver; import org.onap.aai.domain.yang.Pservers; @@ -39,6 +41,10 @@ public interface AAIRestClientI { void updateMaintenceFlag(String vnfId,boolean inMaint, String transactionLoggingUuid) throws Exception; void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) throws Exception; - + GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws Exception; + + Optional<Pnf> getPnfByName(String pnfId, String transactionLoggingUuid) throws Exception; + + void createPnf(String pnfId, String transactionLoggingUuid, Pnf pnf) throws IOException; } diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java index e27075d9dd..54aab5c296 100644 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java +++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java @@ -20,14 +20,20 @@ package org.openecomp.mso.client.aai; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.UUID; - +import javax.ws.rs.core.Response; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.GenericVnfs; +import org.onap.aai.domain.yang.Pnf; import org.onap.aai.domain.yang.Pserver; import org.onap.aai.domain.yang.Pservers; import org.openecomp.mso.client.aai.entities.CustomQuery; @@ -36,130 +42,154 @@ import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; import org.springframework.stereotype.Service; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - @Service public class AAIRestClientImpl implements AAIRestClientI { - - private static final EELFLogger logger = EELFManager.getInstance().getMetricsLogger(); - private static final AAIVersion ENDPOINT_VERSION = AAIVersion.V10; - private static final String ENDPOINT_GET_ALL = ENDPOINT_VERSION + "/cloud-infrastructure/pservers"; - private static final String ENDPOINT_GET_ALL_VNFS = ENDPOINT_VERSION + "/network/generic-vnfs"; - private static final String ENDPOINT_CUSTOM_QUERY = ENDPOINT_VERSION + "/query"; - private static final String PSERVER_VNF_QUERY = "pservers-fromVnf"; - private static final String GENERIC_VNF_PATH = ENDPOINT_VERSION + "/network/generic-vnfs/generic-vnf"; - private static final String SERVICE_TOPOLOGY_BY_SERVICE_INSTANCE_ID = "store(‘x’).union(__.in(‘subscribesTo’).has(‘aai-node-type’,’customer’).store(‘x’),__.out(‘uses’).has(‘aai-node-type’,’allotted-resource’).store(‘x’),__.in(‘hasInstance’).has(‘aai-node-type’,’generic-vnf’).store(‘x’).union(" - + ".out(‘has’).has(‘aai-node-type’,’vf-module’).store(‘x’),out(‘uses’).has(‘aai-node-type’,’volume-group’).store(‘x’)," - + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union(" - + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)," - + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)" - + ")," + ".out(‘runsOnVserver’).has(‘aai-node-type’,’vserver’).store(‘x’).union(" - + ".in(‘owns’).has(‘aai-node-type’,’tenant’).store(‘x’).in(‘has’).has(‘aai-node-type’,’cloud-region’).store(‘x’)," - + ".out(‘runsOnPserver’).has(‘aai-node-type’,’pserver’).store(‘x’)," - + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union(" - + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)," - + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)" - + ")" + ")" + ")" + ").cap(‘x’).unfold().dedup()"; - - public AAIRestClientImpl() { - - - } - - public AAIRestClientImpl(final String host) { - - - } - - @Override - public Pservers getPhysicalServers(String hostName, String uuid) { - UUID requestId; - try { - requestId = UUID.fromString(uuid); - } catch (IllegalArgumentException e) { - logger.warn("could not parse uuid: " + uuid + " creating valid uuid automatically"); - requestId = UUID.randomUUID(); - } - return new AAIResourcesClient(ENDPOINT_VERSION, requestId).get(Pservers.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.PSERVER)); - } - - @Override - public List<Pserver> getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) - throws JsonParseException, JsonMappingException, IOException { - UUID requestId; - try { - requestId = UUID.fromString(transactionLoggingUuid); - } catch (IllegalArgumentException e) { - logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); - requestId = UUID.randomUUID(); - } - List<AAIResourceUri> startNodes = new ArrayList<>(); - startNodes.add(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); - String jsonInput = new AAIQueryClient(ENDPOINT_VERSION, requestId).query(Format.RESOURCE, new CustomQuery(startNodes,PSERVER_VNF_QUERY)); - - return this.getListOfPservers(jsonInput); - - } - - protected List<Pserver> getListOfPservers(String jsonInput) throws JsonParseException, JsonMappingException, IOException { - ObjectMapper mapper = new AAICommonObjectMapperProvider().getContext(Object.class); - Results<Map<String, Pserver>> resultsFromJson = mapper.readValue(jsonInput, - new TypeReference<Results<Map<String, Pserver>>>() { - }); - List<Pserver> results = new ArrayList<>(); - for (Map<String, Pserver> m : resultsFromJson.getResult()) { - results.add(m.get("pserver")); - } - return results; - } - @Override - public void updateMaintenceFlag(String vnfName, boolean inMaint, String transactionLoggingUuid) throws JsonParseException, JsonMappingException, IOException { - UUID requestId; - try { - requestId = UUID.fromString(transactionLoggingUuid); - } catch (IllegalArgumentException e) { - logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); - requestId = UUID.randomUUID(); - } - GenericVnfs genericVnfs = new AAIResourcesClient(ENDPOINT_VERSION, requestId).get(GenericVnfs.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName)); - if(genericVnfs.getGenericVnf().size() > 1) - throw new IndexOutOfBoundsException("Multiple Generic Vnfs Returned"); - - GenericVnf genericVnf = genericVnfs.getGenericVnf().get(0); - updateMaintenceFlagVnfId(genericVnf.getVnfId(), inMaint, transactionLoggingUuid); - } - - @Override - public void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) throws JsonParseException, JsonMappingException, IOException { - UUID requestId; - try { - requestId = UUID.fromString(transactionLoggingUuid); - } catch (IllegalArgumentException e) { - logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); - requestId = UUID.randomUUID(); - } - GenericVnf genericVnf = new GenericVnf(); - genericVnf.setInMaint(inMaint); - new AAIResourcesClient(ENDPOINT_VERSION, requestId).update(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId), genericVnf); - - } - - @Override - public GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws JsonParseException, JsonMappingException, IOException { - UUID requestId; - try { - requestId = UUID.fromString(transactionLoggingUuid); - } catch (IllegalArgumentException e) { - logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); - requestId = UUID.randomUUID(); - } - return new AAIResourcesClient(ENDPOINT_VERSION, requestId).get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); - } + private static final EELFLogger logger = EELFManager.getInstance().getMetricsLogger(); + private static final AAIVersion ENDPOINT_VERSION = AAIVersion.V10; + private static final String ENDPOINT_GET_ALL = ENDPOINT_VERSION + "/cloud-infrastructure/pservers"; + private static final String ENDPOINT_GET_ALL_VNFS = ENDPOINT_VERSION + "/network/generic-vnfs"; + private static final String ENDPOINT_CUSTOM_QUERY = ENDPOINT_VERSION + "/query"; + private static final String PSERVER_VNF_QUERY = "pservers-fromVnf"; + private static final String GENERIC_VNF_PATH = ENDPOINT_VERSION + "/network/generic-vnfs/generic-vnf"; + private static final String SERVICE_TOPOLOGY_BY_SERVICE_INSTANCE_ID = + "store(‘x’).union(__.in(‘subscribesTo’).has(‘aai-node-type’,’customer’).store(‘x’),__.out(‘uses’).has(‘aai-node-type’,’allotted-resource’).store(‘x’),__.in(‘hasInstance’).has(‘aai-node-type’,’generic-vnf’).store(‘x’).union(" + + ".out(‘has’).has(‘aai-node-type’,’vf-module’).store(‘x’),out(‘uses’).has(‘aai-node-type’,’volume-group’).store(‘x’)," + + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union(" + + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)," + + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)" + + ")," + ".out(‘runsOnVserver’).has(‘aai-node-type’,’vserver’).store(‘x’).union(" + + ".in(‘owns’).has(‘aai-node-type’,’tenant’).store(‘x’).in(‘has’).has(‘aai-node-type’,’cloud-region’).store(‘x’)," + + ".out(‘runsOnPserver’).has(‘aai-node-type’,’pserver’).store(‘x’)," + + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union(" + + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)," + + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)" + + ")" + ")" + ")" + ").cap(‘x’).unfold().dedup()"; + + public AAIRestClientImpl() { + } + + @Override + public Pservers getPhysicalServers(String hostName, String uuid) { + UUID requestId; + try { + requestId = UUID.fromString(uuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + uuid + " creating valid uuid automatically"); + requestId = UUID.randomUUID(); + } + return new AAIResourcesClient(ENDPOINT_VERSION, requestId) + .get(Pservers.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.PSERVER)); + } + + @Override + public List<Pserver> getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) throws IOException { + UUID requestId; + try { + requestId = UUID.fromString(transactionLoggingUuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); + requestId = UUID.randomUUID(); + } + List<AAIResourceUri> startNodes = new ArrayList<>(); + startNodes.add(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); + String jsonInput = new AAIQueryClient(ENDPOINT_VERSION, requestId) + .query(Format.RESOURCE, new CustomQuery(startNodes, PSERVER_VNF_QUERY)); + + return this.getListOfPservers(jsonInput); + + } + + protected List<Pserver> getListOfPservers(String jsonInput) throws IOException { + ObjectMapper mapper = new AAICommonObjectMapperProvider().getContext(Object.class); + Results<Map<String, Pserver>> resultsFromJson = mapper.readValue(jsonInput, + new TypeReference<Results<Map<String, Pserver>>>() { + }); + List<Pserver> results = new ArrayList<>(); + for (Map<String, Pserver> m : resultsFromJson.getResult()) { + results.add(m.get("pserver")); + } + return results; + } + + @Override + public void updateMaintenceFlag(String vnfName, boolean inMaint, String transactionLoggingUuid) throws IOException { + UUID requestId; + try { + requestId = UUID.fromString(transactionLoggingUuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); + requestId = UUID.randomUUID(); + } + GenericVnfs genericVnfs = new AAIResourcesClient(ENDPOINT_VERSION, requestId).get(GenericVnfs.class, + AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName)); + if (genericVnfs.getGenericVnf().size() > 1) { + throw new IndexOutOfBoundsException("Multiple Generic Vnfs Returned"); + } + + GenericVnf genericVnf = genericVnfs.getGenericVnf().get(0); + updateMaintenceFlagVnfId(genericVnf.getVnfId(), inMaint, transactionLoggingUuid); + } + + @Override + public void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) + throws IOException { + UUID requestId; + try { + requestId = UUID.fromString(transactionLoggingUuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); + requestId = UUID.randomUUID(); + } + GenericVnf genericVnf = new GenericVnf(); + genericVnf.setInMaint(inMaint); + new AAIResourcesClient(ENDPOINT_VERSION, requestId) + .update(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId), genericVnf); + + } + + @Override + public GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws IOException { + UUID requestId; + try { + requestId = UUID.fromString(transactionLoggingUuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); + requestId = UUID.randomUUID(); + } + return new AAIResourcesClient(ENDPOINT_VERSION, requestId) + .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); + } + + @Override + public Optional<Pnf> getPnfByName(String pnfId, String transactionLoggingUuid) throws IOException { + UUID requestId; + try { + requestId = UUID.fromString(transactionLoggingUuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); + requestId = UUID.randomUUID(); + } + Response response = new AAIResourcesClient(ENDPOINT_VERSION, requestId) + .getFullResponse(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId)); + if (response.getStatus() != 200) { + return Optional.empty(); + } else { + return Optional.of(response.readEntity(Pnf.class)); + } + } + + @Override + public void createPnf(String pnfId, String transactionLoggingUuid, Pnf pnf) throws IOException { + UUID requestId; + try { + requestId = UUID.fromString(transactionLoggingUuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); + requestId = UUID.randomUUID(); + } + new AAIResourcesClient(ENDPOINT_VERSION, requestId) + .createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), Optional.of(pnf)); + } } diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java b/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java index 033951612d..6a01fb61ba 100644 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java +++ b/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java @@ -20,29 +20,25 @@ package org.openecomp.mso.client.dmaap; -import java.io.FileNotFoundException; +import com.google.common.base.Stopwatch; import java.io.IOException; import java.util.concurrent.TimeUnit; - import org.openecomp.mso.client.dmaap.exceptions.DMaaPConsumerFailure; import org.openecomp.mso.client.dmaap.exceptions.ExceededMaximumPollingTime; import org.openecomp.mso.client.dmaap.rest.RestConsumer; -import com.google.common.base.Stopwatch; - public abstract class DmaapConsumer extends DmaapClient { - public DmaapConsumer() throws FileNotFoundException, IOException { + public DmaapConsumer() throws IOException { super("dmaap/default-consumer.properties"); } - - public Consumer getConsumer() throws FileNotFoundException, IOException { + + public Consumer getConsumer() { return new RestConsumer(this.properties); } + public boolean consume() throws Exception { - - Consumer mrConsumer = this.getConsumer(); - int iterations = 0; + Consumer mrConsumer = this.getConsumer(); boolean accepted = false; Stopwatch stopwatch = Stopwatch.createUnstarted(); try { @@ -59,32 +55,28 @@ public abstract class DmaapConsumer extends DmaapClient { if (!accepted && this.isAccepted(message)) { auditLogger.info("accepted message found for " + this.getRequestId() + " on " + this.getTopic()); accepted = true; - } + } if (accepted) { + auditLogger.info("received dmaap message: " + message); if (this.isFailure(message)) { this.stopProcessingMessages(); - auditLogger.info("received dmaap message: " + message); final String errorMsg = "failure received from dmaap topic " + this.getTopic(); auditLogger.error(errorMsg); throw new DMaaPConsumerFailure(errorMsg); } else { - auditLogger.info("received dmaap message: " + message); this.processMessage(message); } } } - iterations++; } return true; - } catch (Exception e ) { - throw e; } finally { if (stopwatch.isRunning()) { stopwatch.stop(); } } } - + /** * Should this consumer continue to consume messages from the topic? * @return @@ -92,7 +84,7 @@ public abstract class DmaapConsumer extends DmaapClient { public abstract boolean continuePolling(); /** * Process a message from a DMaaP topic - * + * * @param message * @throws Exception */ @@ -100,14 +92,14 @@ public abstract class DmaapConsumer extends DmaapClient { /** * Has the request been accepted by the receiving system? * Should the consumer move to processing messages? - * + * * @param message * @return */ public abstract boolean isAccepted(String message); /** * has the request failed? - * + * * @param message * @return */ @@ -121,11 +113,14 @@ public abstract class DmaapConsumer extends DmaapClient { * Logic that defines when the consumer should stop processing messages */ public abstract void stopProcessingMessages(); - + /** * time in milliseconds */ public int getMaximumElapsedTime() { return 180000; } + + + } diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/PnfReadyEventConsumer.java b/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/PnfReadyEventConsumer.java new file mode 100644 index 0000000000..08e35f62f8 --- /dev/null +++ b/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/PnfReadyEventConsumer.java @@ -0,0 +1,93 @@ +/*- + * ============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.openecomp.mso.client.sdno.dmaap; + +import java.io.IOException; +import java.util.Optional; +import javax.ws.rs.NotSupportedException; +import org.openecomp.mso.client.dmaap.DmaapConsumer; +import org.openecomp.mso.jsonpath.JsonPathUtil; + +public class PnfReadyEventConsumer extends DmaapConsumer { + + private static final String JSON_PATH_CORRELATION_ID = "$.pnfRegistrationFields.correlationId"; + + private boolean continuePolling = true; + private String correlationId; + + public PnfReadyEventConsumer(String correlationId) throws IOException { + this.correlationId = correlationId; + } + + @Override + public boolean continuePolling() { + return continuePolling; + } + + @Override + public void processMessage(String message) { + } + + @Override + public boolean isAccepted(String message) { + Optional<String> correlationIdOpt = JsonPathUtil.getInstance().locateResult(message, JSON_PATH_CORRELATION_ID); + if (correlationIdOpt.isPresent()) { + continuePolling = false; + return correlationIdOpt.get().equals(correlationId); + } + return false; + } + + @Override + public boolean isFailure(String message) { + throw new NotSupportedException(); + } + + @Override + public void stopProcessingMessages() { + continuePolling = false; + } + + @Override + public String getRequestId() { + throw new NotSupportedException(); + } + + @Override + public String getUserName() { + throw new NotSupportedException(); + } + + @Override + public String getPassword() { + throw new NotSupportedException(); + } + + @Override + public String getTopic() { + throw new NotSupportedException(); + } + + @Override + public Optional<String> getHost() { + throw new NotSupportedException(); + } +} diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java b/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java index 59adeb2026..ca5888caca 100644 --- a/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java +++ b/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java @@ -20,10 +20,8 @@ package org.openecomp.mso.client.sdno.dmaap; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.Optional; - import org.openecomp.mso.client.dmaap.DmaapConsumer; import org.openecomp.mso.client.exceptions.SDNOException; import org.openecomp.mso.jsonpath.JsonPathUtil; @@ -34,11 +32,11 @@ public class SDNOHealthCheckDmaapConsumer extends DmaapConsumer { private boolean continuePolling = true; private final static String healthDiagnosticPath = "body.output.*"; - public SDNOHealthCheckDmaapConsumer() throws FileNotFoundException, IOException { + public SDNOHealthCheckDmaapConsumer() throws IOException { this("none"); } - public SDNOHealthCheckDmaapConsumer(String uuid) throws FileNotFoundException, IOException { + public SDNOHealthCheckDmaapConsumer(String uuid) throws IOException { super(); this.uuid = uuid; } diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/EqualsAndHashCodeTester.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/EqualsAndHashCodeTester.java index f4192e6cc8..9540409e16 100644 --- a/common/src/main/java/org/openecomp/mso/openpojo/rules/EqualsAndHashCodeTester.java +++ b/common/src/main/java/org/openecomp/mso/openpojo/rules/EqualsAndHashCodeTester.java @@ -23,6 +23,7 @@ package org.openecomp.mso.openpojo.rules; import static org.hamcrest.CoreMatchers.anyOf; import static org.hamcrest.CoreMatchers.anything; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -44,6 +45,7 @@ public class EqualsAndHashCodeTester implements Tester { private final Matcher m; + private boolean onlyDeclaredMethods = false; public EqualsAndHashCodeTester() { m = anything(); } @@ -51,12 +53,33 @@ public class EqualsAndHashCodeTester implements Tester { public EqualsAndHashCodeTester(Matcher m) { this.m = m; } + + public EqualsAndHashCodeTester onlyDeclaredMethods() { + this.onlyDeclaredMethods = true; + return this; + } @Override public void run(PojoClass pojoClass) { Class<?> clazz = pojoClass.getClazz(); if (anyOf(m).matches(clazz)) { final Object classInstanceOne = ValidationHelper.getBasicInstance(pojoClass); final Object classInstanceTwo = ValidationHelper.getBasicInstance(pojoClass); + if (onlyDeclaredMethods) { + Method[] methods = classInstanceOne.getClass().getDeclaredMethods(); + boolean hasEquals = false; + boolean hasHashcode = false; + for (Method method : methods) { + if (method.getName().equals("equals")) { + hasEquals = true; + } else if (method.getName().equals("hashCode")) { + hasHashcode = true; + } + } + + if (!(hasEquals && hasHashcode)) { + return; + } + } Set<PojoField> identityFields = hasIdOrBusinessKey(pojoClass); List<PojoField> otherFields = new ArrayList<>(pojoClass.getPojoFields()); otherFields.removeAll(identityFields); diff --git a/common/src/test/java/org/openecomp/mso/client/dmaap/PnfReadyEventConsumerTest.java b/common/src/test/java/org/openecomp/mso/client/dmaap/PnfReadyEventConsumerTest.java new file mode 100644 index 0000000000..1561f75140 --- /dev/null +++ b/common/src/test/java/org/openecomp/mso/client/dmaap/PnfReadyEventConsumerTest.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei 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.openecomp.mso.client.dmaap; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Optional; +import org.junit.Test; +import org.openecomp.mso.client.sdno.dmaap.PnfReadyEventConsumer; + +public class PnfReadyEventConsumerTest { + + private static final String CORRELATION_ID = "correlation_id_test"; + + private static final String JSON_WITH_CORRELATION_ID = " {\"pnfRegistrationFields\": {\n" + + " \"correlationId\": \"correlation_id_test\"\n" + + " }}"; + + @Test + public void eventIsFoundForGivenCorrelationId2() throws Exception { + PnfReadyEventConsumerForTesting testedObjectSpy = spy(new PnfReadyEventConsumerForTesting(CORRELATION_ID)); + Consumer consumerMock = mock(Consumer.class); + when(testedObjectSpy.getConsumer()).thenReturn(consumerMock); + when(consumerMock.fetch()).thenReturn(Arrays.asList(JSON_WITH_CORRELATION_ID)); + testedObjectSpy.consume(); + assertThat(testedObjectSpy.continuePolling()).isFalse(); + } + + // TODO this is temporary class, when methods are defined, it will be deleted + private class PnfReadyEventConsumerForTesting extends PnfReadyEventConsumer { + + public PnfReadyEventConsumerForTesting(String correlationId) throws IOException { + super(correlationId); + } + + @Override + public String getUserName(){ + return "userNameTest"; + } + @Override + public String getPassword(){ + return "passTest"; + } + @Override + public String getTopic(){ + return "topicTest"; + } + @Override + public Optional<String> getHost(){ + return Optional.of("http://localhost"); + } + @Override + public boolean isFailure(String message) { + return false; + } + @Override + public String getRequestId() { + return "requestTest"; + } + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml index 93b6c8fbb5..97bd8348d3 100644 --- a/mso-api-handlers/mso-api-handler-infra/pom.xml +++ b/mso-api-handlers/mso-api-handler-infra/pom.xml @@ -225,6 +225,18 @@ <artifactId>json</artifactId> <version>20160212</version> </dependency> + <dependency> + <groupId>org.jmockit</groupId> + <artifactId>jmockit</artifactId> + <version>1.19</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> <dependency> <groupId>pl.pragmatists</groupId> <artifactId>JUnitParams</artifactId> diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java index 7963217721..7fb3bf00b0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java @@ -25,18 +25,24 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.io.PrintStream; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; +import mockit.Expectations; +import mockit.Mocked; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.CharEncoding; +import org.hibernate.Session; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.openecomp.mso.apihandler.common.ValidationException; +import org.openecomp.mso.db.AbstractSessionFactoryManager; +import org.openecomp.mso.properties.MsoJavaProperties; import org.openecomp.mso.serviceinstancebeans.ServiceInstancesRequest; import com.fasterxml.jackson.core.JsonParseException; @@ -597,4 +603,22 @@ public class MsoRequestTest { assertNotNull(msoRequest.getRequestId()); assertEquals(msoRequest.getReqVersion(), 6); } + + @Test + public void createRequestRecord(@Mocked AbstractSessionFactoryManager sessionFactoryManager, + @Mocked Session session) throws ValidationException, IOException { + + new Expectations() {{ + sessionFactoryManager.getSessionFactory().openSession(); result = session; + }}; + + this.requestJSON = inputStream("/v6AddRelationships.json"); + this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000"); + this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + this.msoRequest = new MsoRequest ("V6RemoveRelationships"); + msoRequest.parse(sir, instanceIdMapTest, Action.removeRelationships, "v6", originalRequestJSON); + msoRequest.createRequestRecord(Status.COMPLETE, Action.createInstance); + + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java index b182192257..2089cf1d32 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java @@ -34,14 +34,17 @@ import java.util.List; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import mockit.Expectations; import mockit.Mock; import mockit.MockUp; +import mockit.Mocked; import org.apache.http.HttpResponse; import org.apache.http.ProtocolVersion; import org.apache.http.client.ClientProtocolException; import org.apache.http.entity.BasicHttpEntity; import org.apache.http.message.BasicHttpResponse; +import org.hibernate.Session; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -50,6 +53,7 @@ import org.mockito.Mockito; import org.openecomp.mso.apihandler.common.CamundaClient; import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest; +import org.openecomp.mso.db.AbstractSessionFactoryManager; import org.openecomp.mso.db.catalog.CatalogDatabase; import org.openecomp.mso.db.catalog.beans.NetworkRecipe; import org.openecomp.mso.db.catalog.beans.VfModule; @@ -63,7 +67,6 @@ public class NetworkRequestHandlerTest { private static final String REQ_XML = "<network-request xmlns=\"http://org.openecomp/mso/infra/network-request/v1\"> <request-info> <request-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</request-id><action>CREATE</action> <source>VID</source> <service-instance-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</service-instance-id></request-info> <network-inputs> <network-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</network-id> <network-name>nwInstanceName</network-name> <network-type>nwModelName</network-type><modelCustomizationId>e1fc3ed3-31e5-48a8-913b-23184c1e9443</modelCustomizationId> <aic-cloud-region>e1fc3ed3-31e5-48a8-913b-23184c1e9443</aic-cloud-region> <tenant-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</tenant-id><service-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</service-id> <backout-on-failure>false</backout-on-failure><sdncVersion>1802</sdncVersion><service-instance-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</service-instance-id></network-inputs> <network-params></network-params> </network-request>"; private static MockUp<RequestsDatabase> mockRDB; - private static MockUp<NetworkMsoInfraRequest> mockMsoRequest; private static MockUp<CatalogDatabase> mockCDB; private static MockUp<CamundaClient> mockCamundaClient; @@ -107,13 +110,6 @@ public class NetworkRequestHandlerTest { } }; - mockMsoRequest = new MockUp<NetworkMsoInfraRequest>() { - @Mock - public void createRequestRecord (Status status) { - return; - } - }; - mockCDB = new MockUp<CatalogDatabase>() { @Mock public NetworkRecipe getNetworkRecipe (String networkType, String action, String serviceType) { @@ -157,50 +153,42 @@ public class NetworkRequestHandlerTest { @AfterClass public static void tearDown() { mockRDB.tearDown(); - mockMsoRequest.tearDown(); mockCDB.tearDown(); mockCamundaClient.tearDown(); } @Test - public void manageVnfRequestTest(){ + public void manageVnfRequestTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, + @Mocked Session session){ + new Expectations() {{ + sessionFactoryManager.getSessionFactory().openSession(); result = session; + }}; Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); Response resp = handler.manageNetworkRequest(REQ_XML, "v2"); assertTrue(null != resp); } @Test - public void manageVnfRequestTestV1(){ + public void manageVnfRequestTestV1(@Mocked AbstractSessionFactoryManager sessionFactoryManager, + @Mocked Session session){ + new Expectations() {{ + sessionFactoryManager.getSessionFactory().openSession(); result = session; + }}; Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); Response resp = handler.manageNetworkRequest(REQ_XML, "v1"); assertTrue(null != resp); } @Test - public void manageVnfRequestTestV3(){ + public void manageVnfRequestTestV3(@Mocked AbstractSessionFactoryManager sessionFactoryManager, + @Mocked Session session){ + new Expectations() {{ + sessionFactoryManager.getSessionFactory().openSession(); result = session; + }}; Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); Response resp = handler.manageNetworkRequest(REQ_XML, "v3"); assertTrue(null != resp); } - - /*@Test - public void manageNetworkRequestTestV3Duplicate(){ - - MockUp<RequestsDatabase> mockDuplicate = new MockUp<RequestsDatabase>() { - @Mock - public InfraActiveRequests checkDuplicateByVnfName(String vnfName, String action, String requestType) { - return new InfraActiveRequests(); - } - }; - - try { - Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageNetworkRequest(REQ_XML, "v3"); - assertTrue(null != resp); - } finally { - mockDuplicate.tearDown(); - } - }*/ @Test public void manageVnfRequestTestInvalidVersion(){ diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java index be76d433aa..fa1cce462f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java @@ -183,7 +183,8 @@ public class OrchestrationRequestsTest { Response response = null;
try {
OrchestrationRequests requests = new OrchestrationRequests();
- response = requests.getOrchestrationRequest(new ResteasyUriInfo(new URI("")),"v5");
+ final ResteasyUriInfo ui = new ResteasyUriInfo(new URI("", "", "", "filter=service-instance-id:EQUALS:abc", ""));
+ response = requests.getOrchestrationRequest(ui,"v5");
} finally {
mockUpRDB.tearDown();
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java index c8ab6b5612..9a9dec3c27 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java @@ -7,9 +7,9 @@ * 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. @@ -20,19 +20,40 @@ package org.openecomp.mso.apihandlerinfra; -import static org.junit.Assert.assertTrue; - +import mockit.Expectations; +import mockit.Mocked; +import mockit.Tested; +import mockit.integration.junit4.JMockit; +import org.hibernate.Session; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; import org.openecomp.mso.apihandler.common.ValidationException; +import org.openecomp.mso.db.AbstractSessionFactoryManager; import org.openecomp.mso.properties.MsoJavaProperties; +@RunWith(JMockit.class) public class VnfMsoInfraRequestTest { - VnfMsoInfraRequest request = new VnfMsoInfraRequest("29919020"); - - @Test(expected=Exception.class) - public void parseTest() throws ValidationException { - String reqXML = "<vnf-request><request-info> <request-id>29993</request-id><request-status>COMPLETE</request-status></request-info></vnf-request>"; - request.parse(reqXML, "v1", new MsoJavaProperties()); - } - + + VnfMsoInfraRequest request = new VnfMsoInfraRequest("29919020"); + private String reqXML = "<vnf-request xmlns=\"http://org.openecomp/mso/infra/vnf-request/v1\"><request-info><request-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</request-id><action>CREATE_VF_MODULE</action><source>VID</source><!-- new 1610 field --><service-instance-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</service-instance-id></request-info><vnf-inputs><!-- not in use in 1610 --><vnf-name>vnfName</vnf-name><vnf-type>vnfType</vnf-type><vnf-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</vnf-id><volume-group-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</volume-group-id><vf-module-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</vf-module-id><vf-module-name>vfModuleName</vf-module-name><vf-module-model-name>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</vf-module-model-name><model-customization-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</model-customization-id><asdc-service-model-version>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</asdc-service-model-version><aic-cloud-region>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</aic-cloud-region><tenant-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</tenant-id><service-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</service-id><backout-on-failure>false</backout-on-failure><service-instance-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</service-instance-id></vnf-inputs><vnf-params><vnf-parameter-name>pName</vnf-parameter-name><vnf-parameter-value>pValue</vnf-parameter-value></vnf-params></vnf-request>"; + + @Test + public void parseTest() throws ValidationException { + request.parse(reqXML, "v3", new MsoJavaProperties()); + } + + @Test + public void createRequestRecord(@Mocked AbstractSessionFactoryManager sessionFactoryManager, + @Mocked Session session) throws ValidationException { + + new Expectations() {{ + sessionFactoryManager.getSessionFactory().openSession(); result = session; + }}; + + request.parse(reqXML, "v3", new MsoJavaProperties()); + request.createRequestRecord(Status.COMPLETE); + + } + } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResource.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResource.java index 0cd9487527..a0af4b2300 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResource.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResource.java @@ -1,93 +1,93 @@ -/*-
- * ============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.openecomp.mso.db.catalog.beans;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
-
-public class AllottedResource extends MavenLikeVersioning implements Serializable {
-
- private static final long serialVersionUID = 768026109321305392L;
-
- private String modelUuid;
- private String modelInvariantUuid;
- private String modelVersion;
- private String modelName;
- private String toscaNodeType;
- private String subcategory;
- private String description;
- private Timestamp created;
-
- public AllottedResource() {
- }
-
- public String getModelUuid() {
- return this.modelUuid;
- }
- public void setModelUuid(String modelUuid) {
- this.modelUuid = modelUuid;
- }
- public String getModelInvariantUuid() {
- return this.modelInvariantUuid;
- }
- public void setModelInvariantUuid(String modelInvariantUuid) {
- this.modelInvariantUuid = modelInvariantUuid;
- }
- public String getModelVersion() {
- return this.modelVersion;
- }
- public void setModelVersion(String modelVersion) {
- this.modelVersion = modelVersion;
- }
- public String getModelName() {
- return this.modelName;
- }
- public void setModelName(String modelName) {
- this.modelName = modelName;
- }
- public String getToscaNodeType() {
- return this.toscaNodeType;
- }
- public void setToscaNodeType(String toscaNodeType) {
- this.toscaNodeType = toscaNodeType;
- }
- public String getSubcategory() {
- return this.subcategory;
- }
- public void setSubcategory(String subcategory) {
- this.subcategory = subcategory;
- }
- public String getDescription() {
- return this.description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- public Timestamp getCreated() {
- return created;
- }
- public void setCreated(Timestamp created) {
- this.created = created;
- }
-
-}
+/*- + * ============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.openecomp.mso.db.catalog.beans; + +import java.io.Serializable; +import java.sql.Timestamp; + +import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; + +public class AllottedResource extends MavenLikeVersioning implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + private String modelUuid = null; + private String modelInvariantUuid = null; + private String modelVersion = null; + private String modelName = null; + private String toscaNodeType = null; + private String subcategory = null; + private String description = null; + private Timestamp created = null; + + public AllottedResource() { + } + + public String getModelUuid() { + return this.modelUuid; + } + public void setModelUuid(String modelUuid) { + this.modelUuid = modelUuid; + } + public String getModelInvariantUuid() { + return this.modelInvariantUuid; + } + public void setModelInvariantUuid(String modelInvariantUuid) { + this.modelInvariantUuid = modelInvariantUuid; + } + public String getModelVersion() { + return this.modelVersion; + } + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + public String getModelName() { + return this.modelName; + } + public void setModelName(String modelName) { + this.modelName = modelName; + } + public String getToscaNodeType() { + return this.toscaNodeType; + } + public void setToscaNodeType(String toscaNodeType) { + this.toscaNodeType = toscaNodeType; + } + public String getSubcategory() { + return this.subcategory; + } + public void setSubcategory(String subcategory) { + this.subcategory = subcategory; + } + public String getDescription() { + return this.description; + } + public void setDescription(String description) { + this.description = description; + } + public Timestamp getCreated() { + return created; + } + public void setCreated(Timestamp created) { + this.created = created; + } + +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java index 2dcc2e8e6e..e5a653760b 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java @@ -29,21 +29,21 @@ public class AllottedResourceCustomization extends MavenLikeVersioning implement private static final long serialVersionUID = 768026109321305392L; - private String modelCustomizationUuid; - private String arModelUuid; - private Timestamp created; - private String modelInstanceName; - private String providingServiceModelInvariantUuid; - private String targetNetworkRole; - private String nfFunction; - private String nfType; - private String nfRole; - private String nfNamingCode; + private String modelCustomizationUuid = null; + private String arModelUuid = null; + private Timestamp created = null; + private String modelInstanceName = null; + private String providingServiceModelInvariantUuid = null; + private String targetNetworkRole = null; + private String nfFunction = null; + private String nfType = null; + private String nfRole = null; + private String nfNamingCode = null; private Integer minInstances; private Integer maxInstances; - private AllottedResource ar = null; - private String providingServiceModelUuid; - private String providingServiceModelName; + private AllottedResource allottedResource = null; + private String providingServiceModelUuid = null; + private String providingServiceModelName = null; public AllottedResourceCustomization() { super(); @@ -77,10 +77,10 @@ public class AllottedResourceCustomization extends MavenLikeVersioning implement this.modelInstanceName = modelInstanceName; } public AllottedResource getAllottedResource() { - return this.ar; + return this.allottedResource; } public void setAllottedResource(AllottedResource ar) { - this.ar = ar; + this.allottedResource = ar; } public String getProvidingServiceModelInvariantUuid() { return this.providingServiceModelInvariantUuid; @@ -149,7 +149,7 @@ public class AllottedResourceCustomization extends MavenLikeVersioning implement ",modelInstanceName=" + this.modelInstanceName + ",modelInstanceName=" + this.modelInstanceName + ",created=" + this.created + - ",ar=" + this.ar; + ",ar=" + this.allottedResource; } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java index e22d1eb036..d3532886d5 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java @@ -25,7 +25,7 @@ import java.io.Serializable; public class ArRecipe extends Recipe implements Serializable { private static final long serialVersionUID = 768026109321305392L; - private String modelName; + private String modelName = null; public ArRecipe() {} public String getModelName() { diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java index fcd9211ec6..899127c048 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java @@ -30,13 +30,13 @@ public class HeatEnvironment extends MavenLikeVersioning implements Serializable private static final long serialVersionUID = 768026109321305392L; - private String artifactUuid; + private String artifactUuid = null; private String name = null; private String description = null; private String environment = null; - private String artifactChecksum; + private String artifactChecksum = null; - private Timestamp created; + private Timestamp created = null; public HeatEnvironment() {} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java index ec429c896e..8d7da22673 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java @@ -30,13 +30,13 @@ public class HeatFiles extends MavenLikeVersioning implements Serializable { private static final long serialVersionUID = 768026109321305392L; - private String artifactUuid; + private String artifactUuid = null; private String description = null; - private String fileName; - private String fileBody; - private Timestamp created; - private String version; - private String artifactChecksum; + private String fileName = null; + private String fileBody = null; + private Timestamp created = null; + private String version = null; + private String artifactChecksum = null; public HeatFiles() {} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java index df067445f6..1fff17612e 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java @@ -23,11 +23,15 @@ package org.openecomp.mso.db.catalog.beans; import java.io.Serializable; +import com.openpojo.business.annotation.BusinessKey; + public class HeatNestedTemplate implements Serializable { - private String parentTemplateId; - private String childTemplateId; - private String providerResourceFile; + @BusinessKey + private String parentTemplateId = null; + @BusinessKey + private String childTemplateId = null; + private String providerResourceFile = null; public static final long serialVersionUID = -1322322139926390329L; public HeatNestedTemplate () { @@ -91,7 +95,15 @@ public class HeatNestedTemplate implements Serializable { // hash code does not have to be a unique result - only that two objects that should be treated as equal // return the same value. so this should work. int result; - result = this.parentTemplateId.hashCode() + this.childTemplateId.hashCode(); + int parentTemplateIdHash = 0; + int childTemplateIdHash = 0; + if (this.parentTemplateId != null) { + parentTemplateIdHash = this.parentTemplateId.hashCode(); + } + if (this.childTemplateId != null) { + childTemplateIdHash = this.childTemplateId.hashCode(); + } + result = parentTemplateIdHash + childTemplateIdHash; return result; } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplate.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplate.java index 03813a7299..c6386efdd6 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplate.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplate.java @@ -31,17 +31,17 @@ public class HeatTemplate extends MavenLikeVersioning implements Serializable { private static final long serialVersionUID = 768026109321305392L; - private String artifactUuid; - private String templateName; + private String artifactUuid = null; + private String templateName = null; private String templateBody = null; private int timeoutMinutes; private Set <HeatTemplateParam> parameters; private Set <HeatNestedTemplate> files; - private String description; - private String asdcUuid; - private String artifactChecksum; + private String description = null; + private String asdcUuid = null; + private String artifactChecksum = null; - private Timestamp created; + private Timestamp created = null; public enum TemplateStatus { PARENT, CHILD, PARENT_COMPLETE diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java index f6202b7365..9bfc41b675 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java @@ -1,76 +1,80 @@ -/*-
- * ============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.openecomp.mso.db.catalog.beans;
-
-import java.io.Serializable;
-
-// an embeddable class to represent the Composite key for NetworkResource in the 1707 db refactoring
-public class HeatTemplateArtifactUuidModelUuid implements Serializable {
-
- private String heatTemplateArtifactUuid;
- private String modelUuid;
- public static final long serialVersionUID = -1322322139926390329L;
-
- public HeatTemplateArtifactUuidModelUuid() {
- }
-
- public String getHeatTemplateArtifactUuid() {
- return this.heatTemplateArtifactUuid;
- }
- public void setHeatTemplateArtifactUuid(String heatTemplateArtifactUuid) {
- this.heatTemplateArtifactUuid = heatTemplateArtifactUuid;
- }
- public String getModelUuid() {
- return this.modelUuid;
- }
- public void setModelUuid(String modelUuid) {
- this.modelUuid = modelUuid;
- }
-
- @Override
- public String toString() {
- return "heatTemplateArtifactUuid=" + this.heatTemplateArtifactUuid + " modelUuid=" + this.modelUuid;
- }
-
- @Override
- public boolean equals (Object o) {
- if (!(o instanceof HeatTemplateArtifactUuidModelUuid)) {
- return false;
- }
- if (this == o) {
- return true;
- }
- HeatTemplateArtifactUuidModelUuid htaumu = (HeatTemplateArtifactUuidModelUuid) o;
- if (htaumu.getHeatTemplateArtifactUuid().equals(this.getHeatTemplateArtifactUuid())
- && htaumu.getModelUuid().equals(this.getModelUuid())) {
- return true;
- }
- return false;
- }
-
- @Override
- public int hashCode () {
- // hash code does not have to be a unique result - only that two objects that should be treated as equal
- // return the same value. so this should work.
- return this.heatTemplateArtifactUuid.hashCode() + this.modelUuid.hashCode();
- }
-
-}
+/*- + * ============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.openecomp.mso.db.catalog.beans; + +import java.io.Serializable; + +import com.openpojo.business.annotation.BusinessKey; + +// an embeddable class to represent the Composite key for NetworkResource in the 1707 db refactoring +public class HeatTemplateArtifactUuidModelUuid implements Serializable { + + @BusinessKey + private String heatTemplateArtifactUuid = null; + @BusinessKey + private String modelUuid = null; + public static final long serialVersionUID = -1322322139926390329L; + + public HeatTemplateArtifactUuidModelUuid() { + } + + public String getHeatTemplateArtifactUuid() { + return this.heatTemplateArtifactUuid; + } + public void setHeatTemplateArtifactUuid(String heatTemplateArtifactUuid) { + this.heatTemplateArtifactUuid = heatTemplateArtifactUuid; + } + public String getModelUuid() { + return this.modelUuid; + } + public void setModelUuid(String modelUuid) { + this.modelUuid = modelUuid; + } + + @Override + public String toString() { + return "heatTemplateArtifactUuid=" + this.heatTemplateArtifactUuid + " modelUuid=" + this.modelUuid; + } + + @Override + public boolean equals (Object o) { + if (!(o instanceof HeatTemplateArtifactUuidModelUuid)) { + return false; + } + if (this == o) { + return true; + } + HeatTemplateArtifactUuidModelUuid htaumu = (HeatTemplateArtifactUuidModelUuid) o; + if (htaumu.getHeatTemplateArtifactUuid().equals(this.getHeatTemplateArtifactUuid()) + && htaumu.getModelUuid().equals(this.getModelUuid())) { + return true; + } + return false; + } + + @Override + public int hashCode () { + // hash code does not have to be a unique result - only that two objects that should be treated as equal + // return the same value. so this should work. + return this.heatTemplateArtifactUuid.hashCode() + this.modelUuid.hashCode(); + } + +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateParam.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateParam.java index 7ceb19c5a0..7f7dd2b4c6 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateParam.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateParam.java @@ -22,13 +22,19 @@ package org.openecomp.mso.db.catalog.beans; import java.io.Serializable; +import org.apache.commons.lang3.builder.EqualsBuilder; + +import com.openpojo.business.annotation.BusinessKey; + public class HeatTemplateParam implements Serializable { - private String heatTemplateArtifactUuid; - private String paramName; + @BusinessKey + private String heatTemplateArtifactUuid = null; + @BusinessKey + private String paramName = null; private boolean required; - private String paramType; - private String paramAlias; + private String paramType = null; + private String paramAlias = null; public static final long serialVersionUID = -1322322139926390329L; public HeatTemplateParam() {} @@ -71,21 +77,16 @@ public class HeatTemplateParam implements Serializable { public String toString () { return "Param=" + paramName + ",type=" + paramType + ",required=" + required + ",paramAlias=" + paramAlias + ", heatTemplateArtifactUuid=" + this.heatTemplateArtifactUuid; } - - @Override - public boolean equals (Object o) { - if (!(o instanceof HeatTemplateParam)) { - return false; - } - if (this == o) { - return true; - } - HeatTemplateParam htp = (HeatTemplateParam) o; - if (htp.getHeatTemplateArtifactUuid().equals(this.heatTemplateArtifactUuid) && htp.getParamName().equalsIgnoreCase(this.paramName)) { - return true; - } - return false; - } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof HeatTemplateParam)) { + return false; + } + HeatTemplateParam castOther = (HeatTemplateParam) other; + return new EqualsBuilder().append(heatTemplateArtifactUuid, castOther.heatTemplateArtifactUuid) + .append(paramName, castOther.paramName).isEquals(); + } @Override public int hashCode () { diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java index 96e6c616bf..5cd6b58aee 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java @@ -31,14 +31,14 @@ public class Model extends MavenLikeVersioning implements Serializable { private static final long serialVersionUID = 768026109321305392L; private int id; - private String modelCustomizationId; - private String modelCustomizationName; - private String modelInvariantId; - private String modelName; - private String modelType; - private String modelVersion; - private String modelVersionId; - private Timestamp created; + private String modelCustomizationId = null; + private String modelCustomizationName = null; + private String modelInvariantId = null; + private String modelName = null; + private String modelType = null; + private String modelVersion = null; + private String modelVersionId = null; + private Timestamp created = null; private Map<String,ServiceRecipe> recipes; /** diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java index 7ef5a4a7b9..4ba35f7f42 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java @@ -31,13 +31,13 @@ public class ModelRecipe extends MavenLikeVersioning implements Serializable { private int id; private Integer modelId; - private String action; - private String schemaVersion; - private String description; - private String orchestrationUri; - private String modelParamXSD; + private String action = null; + private String schemaVersion = null; + private String description = null; + private String orchestrationUri = null; + private String modelParamXSD = null; private Integer recipeTimeout; - private Timestamp created; + private Timestamp created = null; /** * @return the id @@ -169,12 +169,12 @@ public class ModelRecipe extends MavenLikeVersioning implements Serializable { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("ModelRecipe: "); - sb.append("modelId=").append(modelId.toString()); + sb.append("modelId=").append(modelId); sb.append(",action=").append(action); sb.append(",schemaVersion=").append(schemaVersion); sb.append(",orchestrationUri=").append(orchestrationUri); sb.append(",modelParamXSD=").append(modelParamXSD); - sb.append(",recipeTimeout=").append(recipeTimeout.toString()); + sb.append(",recipeTimeout=").append(recipeTimeout); if (created != null) { sb.append (",created="); sb.append (DateFormat.getInstance().format(created)); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java index eeaa363aa6..d10b633557 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java @@ -25,7 +25,7 @@ import java.io.Serializable; public class NetworkRecipe extends Recipe implements Serializable { private static final long serialVersionUID = 768026109321305392L; - private String modelName; + private String modelName = null; public NetworkRecipe() {} public String getModelName() { diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResource.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResource.java index 025b13b708..d4e1ec536a 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResource.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResource.java @@ -35,15 +35,15 @@ public class NetworkResource extends MavenLikeVersioning implements Serializable private String neutronNetworkType = null; private String aicVersionMin = null; private String aicVersionMax = null; - private String modelName; - private String modelInvariantUUID; - private String modelVersion; - private String toscaNodeType; - private Timestamp created; - private String modelUUID; - private String category; - private String subCategory; - private String heatTemplateArtifactUUID; + private String modelName = null; + private String modelInvariantUUID = null; + private String modelVersion = null; + private String toscaNodeType = null; + private Timestamp created = null; + private String modelUUID = null; + private String category = null; + private String subCategory = null; + private String heatTemplateArtifactUUID = null; public NetworkResource() {} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java index b581545182..f1d5d4f003 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java @@ -20,20 +20,25 @@ package org.openecomp.mso.db.catalog.beans; import java.sql.Timestamp; + +import com.openpojo.business.annotation.BusinessKey; + import java.io.Serializable; public class NetworkResourceCustomization implements Serializable{ // modelCustomizationUuid and networkResourceModelUuid form a composite primary key + @BusinessKey private String modelCustomizationUuid = null; + @BusinessKey private String networkResourceModelUuid = null; public static final long serialVersionUID = -1322322139926390329L; - private String modelInstanceName; - private Timestamp created; - private String networkTechnology; + private String modelInstanceName = null; + private Timestamp created = null; + private String networkTechnology = null; private String networkType = null; - private String networkScope; - private String networkRole; + private String networkScope = null; + private String networkRole = null; // These fields are not in the table directly - but I'm adding them here for storage in the objects we're dealing with private NetworkResource networkResource = null; diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java index 58c24412dc..3f2093b7e2 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java @@ -32,13 +32,13 @@ public class Recipe extends MavenLikeVersioning implements Serializable { private static final long serialVersionUID = 768026109321305392L; private int id; - protected String action; - private String description; - protected String orchestrationUri; + protected String action = null; + private String description = null; + protected String orchestrationUri = null; private int recipeTimeout; - private String serviceType; - private String paramXSD; - private Timestamp created; + private String serviceType = null; + private String paramXSD = null; + private Timestamp created = null; public Recipe () { super (); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java index 37cad254ba..620c6bb17c 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java @@ -20,32 +20,34 @@ package org.openecomp.mso.db.catalog.beans; -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - import java.io.Serializable; import java.sql.Timestamp; import java.text.DateFormat; +import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; + public class Service extends MavenLikeVersioning implements Serializable { private static final long serialVersionUID = 768026109321305392L; - private String modelName; - private String description; - private String modelUUID; - private String modelInvariantUUID; - private Timestamp created; - private String toscaCsarArtifactUUID; - private String modelVersion; - private String category; - private String serviceType; - private String serviceRole; - private String environmentContext; - private String workloadContext; - private Map<String,ServiceRecipe> recipes; - private Set<ServiceToResourceCustomization> serviceResourceCustomizations; + private String modelName = null; + private String description = null; + private String modelUUID = null; + private String modelInvariantUUID = null; + private Timestamp created = null; + private String toscaCsarArtifactUUID = null; + private String modelVersion = null; + private String category = null; + private String serviceType = null; + private String serviceRole = null; + private String environmentContext = null; + private String workloadContext = null; + private Map<String,ServiceRecipe> recipes = new HashMap<>(); + private Set<ServiceToResourceCustomization> serviceResourceCustomizations = new HashSet<>(); public Service() {} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java index 78f94e40c1..d199671621 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java @@ -19,11 +19,9 @@ */ package org.openecomp.mso.db.catalog.beans; -import org.openecomp.mso.db.catalog.beans.Service; -import org.openecomp.mso.db.catalog.beans.VnfResource; -import org.openecomp.mso.db.catalog.beans.VfModule; import java.io.Serializable; import java.util.ArrayList; +import java.util.List; /* * A simple holder for Service and its associated elements: @@ -35,17 +33,17 @@ public class ServiceMacroHolder implements Serializable { private static final long serialVersionUID = 768026109321305392L; private Service service; - private ArrayList<VnfResource> vnfResources; - private ArrayList<NetworkResourceCustomization> networkResourceCustomizations; - private ArrayList<AllottedResourceCustomization> allottedResourceCustomizations; - private ArrayList<VnfResourceCustomization> vnfResourceCustomizations; + private List<VnfResource> vnfResources; + private List<NetworkResourceCustomization> networkResourceCustomization; + private List<AllottedResourceCustomization> allottedResourceCustomization; + private List<VnfResourceCustomization> vnfResourceCustomizations; public ServiceMacroHolder() { super(); this.service = null; this.vnfResources = new ArrayList<>(); - this.networkResourceCustomizations = new ArrayList<>(); - this.allottedResourceCustomizations = new ArrayList<>(); + this.networkResourceCustomization = new ArrayList<>(); + this.allottedResourceCustomization = new ArrayList<>(); this.vnfResourceCustomizations = new ArrayList<>(); } public ServiceMacroHolder(Service service) { @@ -60,10 +58,10 @@ public class ServiceMacroHolder implements Serializable { this.service = service; } - public void setVnfResources(ArrayList<VnfResource> vnfResources) { + public void setVnfResources(List<VnfResource> vnfResources) { this.vnfResources = vnfResources; } - public ArrayList<VnfResource> getVnfResources() { + public List<VnfResource> getVnfResources() { return this.vnfResources; } public void addVnfResource(VnfResource vr) { @@ -77,10 +75,10 @@ public class ServiceMacroHolder implements Serializable { } } - public void setVnfResourceCustomizations(ArrayList<VnfResourceCustomization> vnfResourceCustomizations) { + public void setVnfResourceCustomizations(List<VnfResourceCustomization> vnfResourceCustomizations) { this.vnfResourceCustomizations = vnfResourceCustomizations; } - public ArrayList<VnfResourceCustomization> getVnfResourceCustomizations() { + public List<VnfResourceCustomization> getVnfResourceCustomizations() { return this.vnfResourceCustomizations; } public void addVnfResourceCustomizations(VnfResourceCustomization vrc) { @@ -94,33 +92,33 @@ public class ServiceMacroHolder implements Serializable { } } - public void setNetworkResourceCustomization(ArrayList<NetworkResourceCustomization> networkResourceCustomizations) { - this.networkResourceCustomizations = networkResourceCustomizations; + public void setNetworkResourceCustomization(List<NetworkResourceCustomization> networkResourceCustomizations) { + this.networkResourceCustomization = networkResourceCustomizations; } - public ArrayList<NetworkResourceCustomization> getNetworkResourceCustomization() { - return this.networkResourceCustomizations; + public List<NetworkResourceCustomization> getNetworkResourceCustomization() { + return this.networkResourceCustomization; } - public void addNetworkResourceCustomization(NetworkResourceCustomization nrc) { - if (this.networkResourceCustomizations != null) { - this.networkResourceCustomizations.add(nrc); + public void addNetworkResourceCustomizations(NetworkResourceCustomization nrc) { + if (this.networkResourceCustomization != null) { + this.networkResourceCustomization.add(nrc); } else { - this.networkResourceCustomizations = new ArrayList<>(); - this.networkResourceCustomizations.add(nrc); + this.networkResourceCustomization = new ArrayList<>(); + this.networkResourceCustomization.add(nrc); } } - public void setAllottedResourceCustomization(ArrayList<AllottedResourceCustomization> allottedResourceCustomizations) { - this.allottedResourceCustomizations = allottedResourceCustomizations; + public void setAllottedResourceCustomization(List<AllottedResourceCustomization> allottedResourceCustomizations) { + this.allottedResourceCustomization = allottedResourceCustomizations; } - public ArrayList<AllottedResourceCustomization> getAllottedResourceCustomization() { - return this.allottedResourceCustomizations; + public List<AllottedResourceCustomization> getAllottedResourceCustomization() { + return this.allottedResourceCustomization; } public void addAllottedResourceCustomization(AllottedResourceCustomization arc) { - if (this.allottedResourceCustomizations != null) { - this.allottedResourceCustomizations.add(arc); + if (this.allottedResourceCustomization != null) { + this.allottedResourceCustomization.add(arc); } else { - this.allottedResourceCustomizations = new ArrayList<>(); - this.allottedResourceCustomizations.add(arc); + this.allottedResourceCustomization = new ArrayList<>(); + this.allottedResourceCustomization.add(arc); } } @@ -151,17 +149,17 @@ public class ServiceMacroHolder implements Serializable { } else { sb.append("none"); } - if (this.networkResourceCustomizations != null && this.networkResourceCustomizations.size() > 0) { + if (this.networkResourceCustomization != null && this.networkResourceCustomization.size() > 0) { int i=0; sb.append("NetworkResourceCustomizations:"); - for (NetworkResourceCustomization nrc : this.networkResourceCustomizations) { + for (NetworkResourceCustomization nrc : this.networkResourceCustomization) { sb.append("NRC[").append(i++).append("]: ").append(nrc.toString()); } } - if (this.allottedResourceCustomizations != null && this.allottedResourceCustomizations.size() > 0) { + if (this.allottedResourceCustomization != null && this.allottedResourceCustomization.size() > 0) { int i=0; sb.append("AllottedResourceCustomizations:"); - for (AllottedResourceCustomization arc : this.allottedResourceCustomizations) { + for (AllottedResourceCustomization arc : this.allottedResourceCustomization) { sb.append("ARC[").append(i++).append("]: ").append(arc.toString()); } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java index 303570a8d0..d0bc9b33f7 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java @@ -33,14 +33,14 @@ public class ServiceRecipe extends MavenLikeVersioning implements Serializable { private static final long serialVersionUID = 768026109321305392L; private int id; - private String serviceModelUUID; - private String action; - private String description; - private String orchestrationUri; - private String serviceParamXSD; + private String serviceModelUUID = null; + private String action = null; + private String description = null; + private String orchestrationUri = null; + private String serviceParamXSD = null; private int recipeTimeout; private Integer serviceTimeoutInterim; - private Timestamp created; + private Timestamp created = null; private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java index 6515a12bc0..2ac71f4ddf 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java @@ -22,11 +22,15 @@ package org.openecomp.mso.db.catalog.beans; import java.io.Serializable; import java.sql.Timestamp; +import com.openpojo.business.annotation.BusinessKey; + public class ServiceToAllottedResources implements Serializable { - private String serviceModelUuid; - private String arModelCustomizationUuid; - private Timestamp created; + @BusinessKey + private String serviceModelUuid = null; + @BusinessKey + private String arModelCustomizationUuid = null; + private Timestamp created = null; public static final long serialVersionUID = -1322322139926390329L; diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java index 69dc32796f..3894b4f7b5 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java @@ -22,13 +22,17 @@ package org.openecomp.mso.db.catalog.beans; import java.io.Serializable; import java.sql.Timestamp; +import com.openpojo.business.annotation.BusinessKey; + public class ServiceToNetworks implements Serializable { // This maps to SERVICE.SERVICE_NAME_VERSION_ID / Service.serviceNameVersionId in SERVICE/Service table - private String serviceModelUuid; + @BusinessKey + private String serviceModelUuid = null; // This maps to NETWORK_RESOURCE_CUSTOMIZATION.MODEL_CUSTOMIZATION_UUID / NetworkResourceCustomization.ModelCustomizationUuid - private String networkModelCustomizationUuid; - private Timestamp created; + @BusinessKey + private String networkModelCustomizationUuid = null; + private Timestamp created = null; public static final long serialVersionUID = -1322322139926390329L; public ServiceToNetworks() { diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java index 6d74ab38aa..3babe4ad23 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java @@ -1,111 +1,110 @@ -/*-
- * ============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.openecomp.mso.db.catalog.beans;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-import java.text.DateFormat;
-
-public class ServiceToResourceCustomization implements Serializable {
-
- private static final long serialVersionUID = 768026109321305392L;
-
- private String modelType;
- private String serviceModelUUID;
- private Timestamp created;
- private String resourceModelCustomizationUUID;
-
- public ServiceToResourceCustomization() {}
-
- public String getServiceModelUUID() {
- return serviceModelUUID;
- }
-
- public void setServiceModelUUID(String serviceModelUUID) {
- this.serviceModelUUID = serviceModelUUID;
- }
-
- public String getModelType() {
- return modelType;
- }
-
- public void setModelType(String modelType) {
- this.modelType = modelType;
- }
-
- public Timestamp getCreated() {
- return created;
- }
-
- public void setCreated(Timestamp created) {
- this.created = created;
- }
-
- public String getResourceModelCustomizationUUID() {
- return resourceModelCustomizationUUID;
- }
-
- public void setResourceModelCustomizationUUID(String resourceModelCustomizationUUID) {
- this.resourceModelCustomizationUUID = resourceModelCustomizationUUID;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof ServiceToResourceCustomization)) {
- return false;
- }
- if (this == o) {
- return true;
- }
- ServiceToResourceCustomization strc = (ServiceToResourceCustomization) o;
- if (strc.getServiceModelUUID().equals(this.getServiceModelUUID())
- && strc.getResourceModelCustomizationUUID().equals(this.getResourceModelCustomizationUUID())
- && strc.getModelType().equals(this.getModelType())) {
- return true;
- }
- return false;
-
- }
-
- @Override
- public int hashCode() {
-
- int code = this.modelType == null ? 0 : this.modelType.hashCode();
- code += this.serviceModelUUID == null ? 0 : this.serviceModelUUID.hashCode();
- code += this.resourceModelCustomizationUUID == null ? 0 : this.resourceModelCustomizationUUID.hashCode();
-
- return code;
-
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("ServiceToResourceCustomization: modelType=").append(modelType).append(",serviceModelUUID=")
- .append(serviceModelUUID).append(",resourceModelCustomizationUUID=").append(resourceModelCustomizationUUID);
- if (created != null) {
- sb.append (",created=");
- sb.append (DateFormat.getInstance().format(created));
- }
- return sb.toString();
- }
-
-}
+/*- + * ============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.openecomp.mso.db.catalog.beans; + +import java.io.Serializable; +import java.sql.Timestamp; +import java.text.DateFormat; + +import org.apache.commons.lang3.builder.EqualsBuilder; + +import com.openpojo.business.annotation.BusinessKey; + +public class ServiceToResourceCustomization implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @BusinessKey + private String modelType = null; + @BusinessKey + private String serviceModelUUID = null; + private Timestamp created = null; + @BusinessKey + private String resourceModelCustomizationUUID = null; + + public ServiceToResourceCustomization() {} + + public String getServiceModelUUID() { + return serviceModelUUID; + } + + public void setServiceModelUUID(String serviceModelUUID) { + this.serviceModelUUID = serviceModelUUID; + } + + public String getModelType() { + return modelType; + } + + public void setModelType(String modelType) { + this.modelType = modelType; + } + + public Timestamp getCreated() { + return created; + } + + public void setCreated(Timestamp created) { + this.created = created; + } + + public String getResourceModelCustomizationUUID() { + return resourceModelCustomizationUUID; + } + + public void setResourceModelCustomizationUUID(String resourceModelCustomizationUUID) { + this.resourceModelCustomizationUUID = resourceModelCustomizationUUID; + } + + + @Override + public boolean equals (final Object other) { + if (!(other instanceof ServiceToResourceCustomization)) { + return false; + } + ServiceToResourceCustomization castOther = (ServiceToResourceCustomization) other; + return new EqualsBuilder().append(modelType, castOther.modelType) + .append(serviceModelUUID, castOther.serviceModelUUID) + .append(resourceModelCustomizationUUID, castOther.resourceModelCustomizationUUID).isEquals(); + } + + @Override + public int hashCode() { + + int code = this.modelType == null ? 0 : this.modelType.hashCode(); + code += this.serviceModelUUID == null ? 0 : this.serviceModelUUID.hashCode(); + code += this.resourceModelCustomizationUUID == null ? 0 : this.resourceModelCustomizationUUID.hashCode(); + + return code; + + }@Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("ServiceToResourceCustomization: modelType=").append(modelType).append(",serviceModelUUID=") + .append(serviceModelUUID).append(",resourceModelCustomizationUUID=").append(resourceModelCustomizationUUID); + if (created != null) { + sb.append (",created="); + sb.append (DateFormat.getInstance().format(created)); + } + return sb.toString(); + } + +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java index 3ef7e6e237..6fd6e3e6ae 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java @@ -1,96 +1,100 @@ -/*-
- * ============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.openecomp.mso.db.catalog.beans;
-
-import java.io.Serializable;
-
-public class TempNetworkHeatTemplateLookup implements Serializable {
-
- private String networkResourceModelName;
- private String heatTemplateArtifactUuid;
- private String aicVersionMin;
- private String aicVersionMax;
- public static final long serialVersionUID = -1322322139926390329L;
-
- public TempNetworkHeatTemplateLookup() {
- super();
- }
-
- public String getNetworkResourceModelName() {
- return this.networkResourceModelName;
- }
- public void setNetworkResourceModelName(String networkResourceModelName) {
- this.networkResourceModelName = networkResourceModelName;
- }
-
- public String getHeatTemplateArtifactUuid() {
- return this.heatTemplateArtifactUuid;
- }
- public void setHeatTemplateArtifactUuid(String heatTemplateArtifactUuid) {
- this.heatTemplateArtifactUuid = heatTemplateArtifactUuid;
- }
- public String getAicVersionMin() {
- return this.aicVersionMin;
- }
-
- public void setAicVersionMin(String aicVersionMin) {
- this.aicVersionMin = aicVersionMin;
- }
-
- public String getAicVersionMax() {
- return this.aicVersionMax;
- }
-
- public void setAicVersionMax(String aicVersionMax) {
- this.aicVersionMax = aicVersionMax;
- }
-
- @Override
- public String toString() {
- return "NetworkResourceModelName=" + this.networkResourceModelName + "HeatTemplateArtifactUuid=" +
- this.heatTemplateArtifactUuid + "aicVersionMin=" + this.aicVersionMin + "aicVersionMax=" + this.aicVersionMax;
- }
-
- @Override
- public boolean equals (Object o) {
- if (!(o instanceof TempNetworkHeatTemplateLookup)) {
- return false;
- }
- if (this == o) {
- return true;
- }
- TempNetworkHeatTemplateLookup tnhtl = (TempNetworkHeatTemplateLookup) o;
- if (tnhtl.getHeatTemplateArtifactUuid().equals(this.getHeatTemplateArtifactUuid()) && tnhtl.getNetworkResourceModelName().equals(this.getNetworkResourceModelName())) {
- return true;
- }
- return false;
- }
-
- @Override
- public int hashCode () {
- // hash code does not have to be a unique result - only that two objects that should be treated as equal
- // return the same value. so this should work.
- int result;
- result = (this.networkResourceModelName != null ? this.networkResourceModelName.hashCode() : 0) + (this.heatTemplateArtifactUuid != null ? this.heatTemplateArtifactUuid.hashCode() : 0);
- return result;
- }
-
-}
+/*- + * ============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.openecomp.mso.db.catalog.beans; + +import java.io.Serializable; + +import com.openpojo.business.annotation.BusinessKey; + +public class TempNetworkHeatTemplateLookup implements Serializable { + + @BusinessKey + private String networkResourceModelName = null; + @BusinessKey + private String heatTemplateArtifactUuid = null; + private String aicVersionMin = null; + private String aicVersionMax = null; + public static final long serialVersionUID = -1322322139926390329L; + + public TempNetworkHeatTemplateLookup() { + super(); + } + + public String getNetworkResourceModelName() { + return this.networkResourceModelName; + } + public void setNetworkResourceModelName(String networkResourceModelName) { + this.networkResourceModelName = networkResourceModelName; + } + + public String getHeatTemplateArtifactUuid() { + return this.heatTemplateArtifactUuid; + } + public void setHeatTemplateArtifactUuid(String heatTemplateArtifactUuid) { + this.heatTemplateArtifactUuid = heatTemplateArtifactUuid; + } + public String getAicVersionMin() { + return this.aicVersionMin; + } + + public void setAicVersionMin(String aicVersionMin) { + this.aicVersionMin = aicVersionMin; + } + + public String getAicVersionMax() { + return this.aicVersionMax; + } + + public void setAicVersionMax(String aicVersionMax) { + this.aicVersionMax = aicVersionMax; + } + + @Override + public String toString() { + return "NetworkResourceModelName=" + this.networkResourceModelName + "HeatTemplateArtifactUuid=" + + this.heatTemplateArtifactUuid + "aicVersionMin=" + this.aicVersionMin + "aicVersionMax=" + this.aicVersionMax; + } + + @Override + public boolean equals (Object o) { + if (!(o instanceof TempNetworkHeatTemplateLookup)) { + return false; + } + if (this == o) { + return true; + } + TempNetworkHeatTemplateLookup tnhtl = (TempNetworkHeatTemplateLookup) o; + if (tnhtl.getHeatTemplateArtifactUuid().equals(this.getHeatTemplateArtifactUuid()) && tnhtl.getNetworkResourceModelName().equals(this.getNetworkResourceModelName())) { + return true; + } + return false; + } + + @Override + public int hashCode () { + // hash code does not have to be a unique result - only that two objects that should be treated as equal + // return the same value. so this should work. + int result; + result = (this.networkResourceModelName != null ? this.networkResourceModelName.hashCode() : 0) + (this.heatTemplateArtifactUuid != null ? this.heatTemplateArtifactUuid.hashCode() : 0); + return result; + } + +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java index 591e648a33..92d02d8a11 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java @@ -1,115 +1,116 @@ -/*-
- * ============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.openecomp.mso.db.catalog.beans;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.util.Set;
-
-import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
-
-public class ToscaCsar extends MavenLikeVersioning implements Serializable {
-
- private static final long serialVersionUID = 768026109321305392L;
-
- private String artifactUUID;
- private String name;
- private String artifactChecksum;
- private String url;
- private String description;
- private Timestamp created;
- private Set<Service> services;
-
- public ToscaCsar() { }
-
- public String getArtifactUUID() {
- return artifactUUID;
- }
-
- public void setArtifactUUID(String artifactUUID) {
- this.artifactUUID = artifactUUID;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getArtifactChecksum() {
- return artifactChecksum;
- }
-
- public void setArtifactChecksum(String artifactChecksum) {
- this.artifactChecksum = artifactChecksum;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Timestamp getCreated() {
- return created;
- }
-
- public void setCreated(Timestamp created) {
- this.created = created;
- }
-
- public Set<Service> getServices() {
- return services;
- }
-
- public void setServices(Set<Service> services) {
- this.services = services;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("TOSCACSAR: artifactUUID=").append(artifactUUID).append(",name=").append(name).append(",version=")
- .append(version).append(",description=").append(description).append(",artifactChecksum=")
- .append(artifactChecksum).append(",url=").append(url);
- for (Service service : services) {
- sb.append("\n").append(service.toString());
- }
- if (created != null) {
- sb.append (",created=");
- sb.append (DateFormat.getInstance().format(created));
- }
- return sb.toString();
- }
-}
+/*- + * ============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.openecomp.mso.db.catalog.beans; + +import java.io.Serializable; +import java.sql.Timestamp; +import java.text.DateFormat; +import java.util.HashSet; +import java.util.Set; + +import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; + +public class ToscaCsar extends MavenLikeVersioning implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + private String artifactUUID = null; + private String name = null; + private String artifactChecksum = null; + private String url = null; + private String description = null; + private Timestamp created = null; + private Set<Service> services = new HashSet<>(); + + public ToscaCsar() { } + + public String getArtifactUUID() { + return artifactUUID; + } + + public void setArtifactUUID(String artifactUUID) { + this.artifactUUID = artifactUUID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getArtifactChecksum() { + return artifactChecksum; + } + + public void setArtifactChecksum(String artifactChecksum) { + this.artifactChecksum = artifactChecksum; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Timestamp getCreated() { + return created; + } + + public void setCreated(Timestamp created) { + this.created = created; + } + + public Set<Service> getServices() { + return services; + } + + public void setServices(Set<Service> services) { + this.services = services; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("TOSCACSAR: artifactUUID=").append(artifactUUID).append(",name=").append(name).append(",version=") + .append(version).append(",description=").append(description).append(",artifactChecksum=") + .append(artifactChecksum).append(",url=").append(url); + for (Service service : services) { + sb.append("\n").append(service.toString()); + } + if (created != null) { + sb.append (",created="); + sb.append (DateFormat.getInstance().format(created)); + } + return sb.toString(); + } +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java index cd2821a7b0..ec3bc7fefb 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java @@ -32,16 +32,16 @@ public class VfModule extends MavenLikeVersioning implements Serializable { private static final long serialVersionUID = 768026109321305392L; - private String modelInvariantUUID; - private String modelName; - private String modelVersion; - private String description; + private String modelInvariantUUID = null; + private String modelName = null; + private String modelVersion = null; + private String description = null; private int isBase; - private String heatTemplateArtifactUUId; - private String volHeatTemplateArtifactUUId; - private Timestamp created; - private String modelUUID; - private String vnfResourceModelUUId; + private String heatTemplateArtifactUUId = null; + private String volHeatTemplateArtifactUUId = null; + private Timestamp created = null; + private String modelUUID = null; + private String vnfResourceModelUUId = null; public VfModule() { super(); diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java index db3a2664a8..5b3dec4700 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java @@ -1,151 +1,155 @@ -/*-
- * ============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.openecomp.mso.db.catalog.beans;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-public class VfModuleCustomization implements Serializable {
-
- private String modelCustomizationUuid;
- private String vfModuleModelUuid;
- private String label;
- private Integer minInstances;
- private Integer maxInstances;
- private Integer initialCount;
- private Integer availabilityZoneCount;
- private String heatEnvironmentArtifactUuid;
- private String volEnvironmentArtifactUuid;
- private Timestamp created;
- private VfModule vfModule;
- public static final long serialVersionUID = -1322322139926390329L;
-
- public VfModuleCustomization() {
- super();
- }
-
- public String getModelCustomizationUuid() {
- return this.modelCustomizationUuid;
- }
- public void setModelCustomizationUuid(String modelCustomizationUuid) {
- this.modelCustomizationUuid = modelCustomizationUuid;
- }
- public String getVfModuleModelUuid() {
- return this.vfModuleModelUuid;
- }
- public void setVfModuleModelUuid(String vfModuleModelUuid) {
- this.vfModuleModelUuid = vfModuleModelUuid;
- }
- public String getHeatEnvironmentArtifactUuid() {
- return this.heatEnvironmentArtifactUuid;
- }
- public void setHeatEnvironmentArtifactUuid(String heatEnvironmentArtifactUuid) {
- this.heatEnvironmentArtifactUuid = heatEnvironmentArtifactUuid;
- }
- public String getVolEnvironmentArtifactUuid() {
- return this.volEnvironmentArtifactUuid;
- }
- public void setVolEnvironmentArtifactUuid(String volEnvironmentArtifactUuid) {
- this.volEnvironmentArtifactUuid = volEnvironmentArtifactUuid;
- }
-
- public Integer getMinInstances() {
- return this.minInstances;
- }
- public void setMinInstances(Integer minInstances) {
- this.minInstances = minInstances;
- }
- public Integer getMaxInstances() {
- return this.maxInstances;
- }
- public void setMaxInstances(Integer maxInstances) {
- this.maxInstances = maxInstances;
- }
- public Integer getInitialCount() {
- return this.initialCount;
- }
- public void setInitialCount(Integer initialCount) {
- this.initialCount = initialCount;
- }
- public Integer getAvailabilityZoneCount() {
- return this.availabilityZoneCount;
- }
- public void setAvailabilityZoneCount(Integer availabilityZoneCount) {
- this.availabilityZoneCount = availabilityZoneCount;
- }
- public Timestamp getCreated() {
- return created;
- }
- public void setCreated(Timestamp created) {
- this.created = created;
- }
- public String getLabel() {
- return this.label;
- }
- public void setLabel(String label) {
- this.label = label;
- }
- public VfModule getVfModule() {
- return this.vfModule;
- }
- public void setVfModule(VfModule vfModule) {
- this.vfModule = vfModule;
- }
-
- @Override
- public String toString() {
- return "modelCustomizationUuid=" + this.modelCustomizationUuid +
- "vfModuleModelUuid=" + this.vfModuleModelUuid +
- "label=" + this.label +
- "initalCount=" + this.initialCount +
- "minInstances=" + this.minInstances +
- "maxInstances=" + this.maxInstances +
- "availabilityZoneCount=" + this.availabilityZoneCount +
- "heatEnvironmentArtifactUuid=" + this.heatEnvironmentArtifactUuid +
- "volEnvironmentArtifactUuid=" + this.volEnvironmentArtifactUuid +
- "created=" + this.created;
- }
-
- @Override
- public boolean equals (Object o) {
- if (!(o instanceof VfModuleCustomization)) {
- return false;
- }
- if (this == o) {
- return true;
- }
- VfModuleCustomization vfmc = (VfModuleCustomization) o;
- if (vfmc.getModelCustomizationUuid().equals(this.getModelCustomizationUuid()) && vfmc.getVfModuleModelUuid().equals(this.getVfModuleModelUuid())) {
- return true;
- }
- return false;
- }
-
- @Override
- public int hashCode () {
- // hash code does not have to be a unique result - only that two objects that should be treated as equal
- // return the same value. so this should work.
- int result = 0;
- result = (this.modelCustomizationUuid != null ? this.modelCustomizationUuid.hashCode() : 0) + (this.vfModuleModelUuid != null ? this.vfModuleModelUuid.hashCode() : 0);
- return result;
- }
-
-}
+/*- + * ============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.openecomp.mso.db.catalog.beans; + +import java.io.Serializable; +import java.sql.Timestamp; + +import com.openpojo.business.annotation.BusinessKey; + +public class VfModuleCustomization implements Serializable { + + @BusinessKey + private String modelCustomizationUuid = null; + @BusinessKey + private String vfModuleModelUuid = null; + private String label = null; + private Integer minInstances; + private Integer maxInstances; + private Integer initialCount; + private Integer availabilityZoneCount; + private String heatEnvironmentArtifactUuid = null; + private String volEnvironmentArtifactUuid = null; + private Timestamp created = null; + private VfModule vfModule; + public static final long serialVersionUID = -1322322139926390329L; + + public VfModuleCustomization() { + super(); + } + + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public String getVfModuleModelUuid() { + return this.vfModuleModelUuid; + } + public void setVfModuleModelUuid(String vfModuleModelUuid) { + this.vfModuleModelUuid = vfModuleModelUuid; + } + public String getHeatEnvironmentArtifactUuid() { + return this.heatEnvironmentArtifactUuid; + } + public void setHeatEnvironmentArtifactUuid(String heatEnvironmentArtifactUuid) { + this.heatEnvironmentArtifactUuid = heatEnvironmentArtifactUuid; + } + public String getVolEnvironmentArtifactUuid() { + return this.volEnvironmentArtifactUuid; + } + public void setVolEnvironmentArtifactUuid(String volEnvironmentArtifactUuid) { + this.volEnvironmentArtifactUuid = volEnvironmentArtifactUuid; + } + + public Integer getMinInstances() { + return this.minInstances; + } + public void setMinInstances(Integer minInstances) { + this.minInstances = minInstances; + } + public Integer getMaxInstances() { + return this.maxInstances; + } + public void setMaxInstances(Integer maxInstances) { + this.maxInstances = maxInstances; + } + public Integer getInitialCount() { + return this.initialCount; + } + public void setInitialCount(Integer initialCount) { + this.initialCount = initialCount; + } + public Integer getAvailabilityZoneCount() { + return this.availabilityZoneCount; + } + public void setAvailabilityZoneCount(Integer availabilityZoneCount) { + this.availabilityZoneCount = availabilityZoneCount; + } + public Timestamp getCreated() { + return created; + } + public void setCreated(Timestamp created) { + this.created = created; + } + public String getLabel() { + return this.label; + } + public void setLabel(String label) { + this.label = label; + } + public VfModule getVfModule() { + return this.vfModule; + } + public void setVfModule(VfModule vfModule) { + this.vfModule = vfModule; + } + + @Override + public String toString() { + return "modelCustomizationUuid=" + this.modelCustomizationUuid + + "vfModuleModelUuid=" + this.vfModuleModelUuid + + "label=" + this.label + + "initalCount=" + this.initialCount + + "minInstances=" + this.minInstances + + "maxInstances=" + this.maxInstances + + "availabilityZoneCount=" + this.availabilityZoneCount + + "heatEnvironmentArtifactUuid=" + this.heatEnvironmentArtifactUuid + + "volEnvironmentArtifactUuid=" + this.volEnvironmentArtifactUuid + + "created=" + this.created; + } + + @Override + public boolean equals (Object o) { + if (!(o instanceof VfModuleCustomization)) { + return false; + } + if (this == o) { + return true; + } + VfModuleCustomization vfmc = (VfModuleCustomization) o; + if (vfmc.getModelCustomizationUuid().equals(this.getModelCustomizationUuid()) && vfmc.getVfModuleModelUuid().equals(this.getVfModuleModelUuid())) { + return true; + } + return false; + } + + @Override + public int hashCode () { + // hash code does not have to be a unique result - only that two objects that should be treated as equal + // return the same value. so this should work. + int result = 0; + result = (this.modelCustomizationUuid != null ? this.modelCustomizationUuid.hashCode() : 0) + (this.vfModuleModelUuid != null ? this.vfModuleModelUuid.hashCode() : 0); + return result; + } + +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java index 611604e830..3796650364 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java @@ -26,8 +26,8 @@ import java.io.Serializable; public class VfModuleToHeatFiles implements Serializable { - private String vfModuleModelUuid; - private String heatFilesArtifactUuid; + private String vfModuleModelUuid = null; + private String heatFilesArtifactUuid = null; public static final long serialVersionUID = -1322322139926390329L; public VfModuleToHeatFiles() { diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java index e1795e1b04..9b701df1d2 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java @@ -25,16 +25,20 @@ package org.openecomp.mso.db.catalog.beans; import java.sql.Timestamp; import java.text.DateFormat; +import com.openpojo.business.annotation.BusinessKey; + import java.io.Serializable; public class VnfComponent implements Serializable { - private int vnfId; + @BusinessKey + private int vnfId; + @BusinessKey private String componentType = null; private Integer heatTemplateId; private Integer heatEnvironmentId; public static final long serialVersionUID = -1322322139926390329L; - private Timestamp created; + private Timestamp created = null; public VnfComponent() {} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java index 30a5133bd5..2240191d45 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java @@ -26,9 +26,9 @@ public class VnfComponentsRecipe extends Recipe implements Serializable { private static final long serialVersionUID = 768026109321305392L; - private String vnfType; - private String vnfComponentType; - private String vfModuleModelUUId; + private String vnfType = null; + private String vnfComponentType = null; + private String vfModuleModelUUId = null; public VnfComponentsRecipe() {} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java index 0dd38cbbc1..d94334c98d 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java @@ -26,8 +26,8 @@ public class VnfRecipe extends Recipe implements Serializable { private static final long serialVersionUID = 768026109321305392L; - private String vnfType; - private String vfModuleId; + private String vnfType = null; + private String vfModuleId = null; public VnfRecipe() {} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java index fd1e6b67b8..6b1cb0a19c 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java @@ -1,88 +1,92 @@ -/*-
- * ============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.openecomp.mso.db.catalog.beans;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-public class VnfResCustomToVfModuleCustom implements Serializable {
-
- private String vnfResourceCustModelCustomizationUuid;
- private String vfModuleCustModelCustomizationUuid;
- private Timestamp created;
-
- public static final long serialVersionUID = -1322322139926390329L;
-
-
- public VnfResCustomToVfModuleCustom() {
- super();
- }
- public String getVnfResourceCustModelCustomizationUuid() {
- return this.vnfResourceCustModelCustomizationUuid;
- }
- public void setVnfResourceCustModelCustomizationUuid(String vnfResourceCustModelCustomizationUuid) {
- this.vnfResourceCustModelCustomizationUuid = vnfResourceCustModelCustomizationUuid;
- }
- public String getVfModuleCustModelCustomizationUuid() {
- return this.vfModuleCustModelCustomizationUuid;
- }
- public void setVfModuleCustModelCustomizationUuid(String vfModuleCustModelCustomizationUuid) {
- this.vfModuleCustModelCustomizationUuid = vfModuleCustModelCustomizationUuid;
- }
- public Timestamp getCreated() {
- return created;
- }
- public void setCreated(Timestamp created) {
- this.created = created;
- }
-
- @Override
- public String toString() {
- return "vnfResourceCustModelCustomizationUuid=" + this.vnfResourceCustModelCustomizationUuid +
- "vfModuleCustModelCustomizationUuid=" + this.vfModuleCustModelCustomizationUuid + "created=" + this.created;
- }
-
- @Override
- public boolean equals (Object o) {
- if (!(o instanceof VnfResCustomToVfModuleCustom)) {
- return false;
- }
- if (this == o) {
- return true;
- }
- VnfResCustomToVfModuleCustom vrctvmc = (VnfResCustomToVfModuleCustom) o;
- if (vrctvmc.getVnfResourceCustModelCustomizationUuid().equals(this.getVnfResourceCustModelCustomizationUuid()) && vrctvmc.getVfModuleCustModelCustomizationUuid().equals(this.getVfModuleCustModelCustomizationUuid())) {
- return true;
- }
- return false;
- }
-
- @Override
- public int hashCode () {
- // hash code does not have to be a unique result - only that two objects that should be treated as equal
- // return the same value. so this should work.
- int result = 0;
- result = (this.vnfResourceCustModelCustomizationUuid != null ? this.vnfResourceCustModelCustomizationUuid.hashCode() : 0) + (this.vfModuleCustModelCustomizationUuid != null ? this.vfModuleCustModelCustomizationUuid.hashCode() : 0);
- return result;
- }
-
-
-}
+/*- + * ============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.openecomp.mso.db.catalog.beans; + +import java.io.Serializable; +import java.sql.Timestamp; + +import com.openpojo.business.annotation.BusinessKey; + +public class VnfResCustomToVfModuleCustom implements Serializable { + + @BusinessKey + private String vnfResourceCustModelCustomizationUuid = null; + @BusinessKey + private String vfModuleCustModelCustomizationUuid = null; + private Timestamp created = null; + + public static final long serialVersionUID = -1322322139926390329L; + + + public VnfResCustomToVfModuleCustom() { + super(); + } + public String getVnfResourceCustModelCustomizationUuid() { + return this.vnfResourceCustModelCustomizationUuid; + } + public void setVnfResourceCustModelCustomizationUuid(String vnfResourceCustModelCustomizationUuid) { + this.vnfResourceCustModelCustomizationUuid = vnfResourceCustModelCustomizationUuid; + } + public String getVfModuleCustModelCustomizationUuid() { + return this.vfModuleCustModelCustomizationUuid; + } + public void setVfModuleCustModelCustomizationUuid(String vfModuleCustModelCustomizationUuid) { + this.vfModuleCustModelCustomizationUuid = vfModuleCustModelCustomizationUuid; + } + public Timestamp getCreated() { + return created; + } + public void setCreated(Timestamp created) { + this.created = created; + } + + @Override + public String toString() { + return "vnfResourceCustModelCustomizationUuid=" + this.vnfResourceCustModelCustomizationUuid + + "vfModuleCustModelCustomizationUuid=" + this.vfModuleCustModelCustomizationUuid + "created=" + this.created; + } + + @Override + public boolean equals (Object o) { + if (!(o instanceof VnfResCustomToVfModuleCustom)) { + return false; + } + if (this == o) { + return true; + } + VnfResCustomToVfModuleCustom vrctvmc = (VnfResCustomToVfModuleCustom) o; + if (vrctvmc.getVnfResourceCustModelCustomizationUuid().equals(this.getVnfResourceCustModelCustomizationUuid()) && vrctvmc.getVfModuleCustModelCustomizationUuid().equals(this.getVfModuleCustModelCustomizationUuid())) { + return true; + } + return false; + } + + @Override + public int hashCode () { + // hash code does not have to be a unique result - only that two objects that should be treated as equal + // return the same value. so this should work. + int result = 0; + result = (this.vnfResourceCustModelCustomizationUuid != null ? this.vnfResourceCustModelCustomizationUuid.hashCode() : 0) + (this.vfModuleCustModelCustomizationUuid != null ? this.vfModuleCustModelCustomizationUuid.hashCode() : 0); + return result; + } + + +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java index 806cbeb076..f8e6024e69 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java @@ -35,23 +35,22 @@ public class VnfResource extends MavenLikeVersioning implements Serializable { private static final long serialVersionUID = 768026109321305392L; - private String modelUuid; - private String modelInvariantUuid; - private String modelName; - private String toscaNodeType; - private String description; - private String orchestrationMode; - private String aicVersionMin; - private String aicVersionMax; - private String category; - private String subCategory; - private String heatTemplateArtifactUUId; - private Timestamp created; - private String modelVersion; - private Set<VnfResourceCustomization> vnfResourceCustomizations; - private Set<VfModule> vfModules; - private List<VfModule> vfModuleList; - private List<VfModuleCustomization> vfModuleCustomizations; + private String modelUuid = null; + private String modelInvariantUuid = null; + private String modelName = null; + private String toscaNodeType = null; + private String description = null; + private String orchestrationMode = null; + private String aicVersionMin = null; + private String aicVersionMax = null; + private String category = null; + private String subCategory = null; + private String heatTemplateArtifactUUId = null; + private Timestamp created = null; + private String modelVersion = null; + private Set<VnfResourceCustomization> vnfResourceCustomizations = new HashSet<>(); + private Set<VfModule> vfModules = new HashSet<>(); + private List<VfModuleCustomization> vfModuleCustomizations = new ArrayList<>(); public VnfResource () { } @@ -197,7 +196,7 @@ public class VnfResource extends MavenLikeVersioning implements Serializable { public List<VfModuleCustomization> getVfModuleCustomizations() { return this.vfModuleCustomizations == null ? new ArrayList<>() : this.vfModuleCustomizations; } - public void setVfModuleCustomizations(ArrayList<VfModuleCustomization> vfModuleCustomizations) { + public void setVfModuleCustomizations(List<VfModuleCustomization> vfModuleCustomizations) { this.vfModuleCustomizations = vfModuleCustomizations; } public void addVfModuleCustomization(VfModuleCustomization vfmc) { diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java index 64c031397f..e510ee867d 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java @@ -32,19 +32,19 @@ public class VnfResourceCustomization extends MavenLikeVersioning implements Ser private static final long serialVersionUID = 768026109321305392L; private String modelCustomizationUuid = null; - private String modelInstanceName; - private Timestamp created; + private String modelInstanceName = null; + private Timestamp created = null; private String vnfResourceModelUuid = null; - private String vnfResourceModelUUID; + private String vnfResourceModelUUID = null; private Integer minInstances; private Integer maxInstances; private Integer availabilityZoneMaxCount; private VnfResource vnfResource; - private String nfFunction; - private String nfType; - private String nfRole; - private String nfNamingCode; - private String multiStageDesign; + private String nfFunction = null; + private String nfType = null; + private String nfRole = null; + private String nfNamingCode = null; + private String multiStageDesign = null; private List<VfModuleCustomization> vfModuleCustomizations; private Set<ServiceToResourceCustomization> serviceResourceCustomizations; @@ -154,7 +154,7 @@ public class VnfResourceCustomization extends MavenLikeVersioning implements Ser public List<VfModuleCustomization> getVfModuleCustomizations() { return this.vfModuleCustomizations; } - public void setVfModuleCustomizations(ArrayList<VfModuleCustomization> vfModuleCustomizations) { + public void setVfModuleCustomizations(List<VfModuleCustomization> vfModuleCustomizations) { this.vfModuleCustomizations = vfModuleCustomizations; } public void addVfModuleCustomization(VfModuleCustomization vfmc) { diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/beans/BeansTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/beans/BeansTest.java new file mode 100644 index 0000000000..57bf292dd8 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/beans/BeansTest.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.openecomp.mso.db.catalog.beans; + +import static org.hamcrest.CoreMatchers.isA; +import static org.mockito.Matchers.eq; + +import org.hamcrest.CoreMatchers; +import org.hamcrest.Matcher; +import org.junit.Test; +import org.openecomp.mso.openpojo.rules.EqualsAndHashCodeTester; +import org.openecomp.mso.openpojo.rules.HasToStringRule; +import org.openecomp.mso.openpojo.rules.ToStringTester; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoClassFilter; +import com.openpojo.reflection.filters.FilterEnum; +import com.openpojo.reflection.filters.FilterNonConcrete; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + + +public class BeansTest { + + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + private PojoClassFilter enumFilter = new FilterEnum(); + + + + @Test + public void pojoStructure() { + test("org.openecomp.mso.db.catalog.beans"); + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create() + .with(new GetterMustExistRule()) + .with(new SetterMustExistRule()) + .with(new HasToStringRule()) + + + .with(new SetterTester()) + .with(new GetterTester()) + .with(new ToStringTester()) + .with(new EqualsAndHashCodeTester().onlyDeclaredMethods()) + .build(); + + + validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses,enumFilter,new FilterNonConcrete()); + } + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } +} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceMacroHolderTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceMacroHolderTest.java index 0e3492170e..c819079a40 100644 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceMacroHolderTest.java +++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceMacroHolderTest.java @@ -40,7 +40,7 @@ public class ServiceMacroHolderTest { assertTrue(serviceMacroHolder.getService() == null); serviceMacroHolder.addVnfResource(new VnfResource()); serviceMacroHolder.addVnfResourceCustomizations(new VnfResourceCustomization()); - serviceMacroHolder.addNetworkResourceCustomization(new NetworkResourceCustomization()); + serviceMacroHolder.addNetworkResourceCustomizations(new NetworkResourceCustomization()); serviceMacroHolder.addAllottedResourceCustomization(new AllottedResourceCustomization()); assertTrue(serviceMacroHolder != null); } diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToStringTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToStringTest.java index 05e857f178..162073cc76 100644 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToStringTest.java +++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToStringTest.java @@ -113,7 +113,7 @@ public class ToStringTest { smh.setNetworkResourceCustomization(networkResourceCustomizations); NetworkResourceCustomization nrc = new NetworkResourceCustomization(); - smh.addNetworkResourceCustomization(nrc); + smh.addNetworkResourceCustomizations(nrc); ArrayList<AllottedResourceCustomization> allottedResourceCustomizations = new ArrayList<>(); smh.setAllottedResourceCustomization(allottedResourceCustomizations); |