From 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Mon, 30 Jul 2018 15:56:09 -0400 Subject: Containerization feature of SO Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) --- .../bpmn/core/BadInjectedFiledExceptionTest.java | 46 +++ .../java/org/onap/so/bpmn/core/BaseTaskTest.java | 247 ++++++++++++++ .../test/java/org/onap/so/bpmn/core/BeansTest.java | 91 ++++++ .../core/MissingInjectedFiledExceptionTest.java | 39 +++ .../org/onap/so/bpmn/core/ResponseBuilderTest.java | 110 +++++++ .../org/onap/so/bpmn/core/RollbackDataTest.java | 92 ++++++ .../onap/so/bpmn/core/UrnPropertiesReaderTest.java | 63 ++++ .../onap/so/bpmn/core/WorkflowExceptionTest.java | 47 +++ .../so/bpmn/core/domain/AllottedResourceTest.java | 54 ++++ .../bpmn/core/domain/CompareModelsResultTest.java | 83 +++++ .../so/bpmn/core/domain/ConfigResourceTest.java | 39 +++ .../so/bpmn/core/domain/ConfigurationTest.java | 47 +++ .../org/onap/so/bpmn/core/domain/CustomerTest.java | 38 +++ .../onap/so/bpmn/core/domain/DomainPojoTest.java | 56 ++++ .../so/bpmn/core/domain/HomingSolutionTest.java | 58 ++++ .../org/onap/so/bpmn/core/domain/LicenseTest.java | 89 ++++++ .../onap/so/bpmn/core/domain/ModelInfoTest.java | 47 +++ .../so/bpmn/core/domain/ModuleResourceTest.java | 48 +++ .../so/bpmn/core/domain/NetworkResourceTest.java | 42 +++ .../onap/so/bpmn/core/domain/OwningEntityTest.java | 39 +++ .../org/onap/so/bpmn/core/domain/ProjectTest.java | 36 +++ .../org/onap/so/bpmn/core/domain/RequestTest.java | 44 +++ .../core/domain/ResourceDecompositionTest.java | 50 +++ .../org/onap/so/bpmn/core/domain/ResourceTest.java | 68 ++++ .../bpmn/core/domain/ServiceDecompositionTest.java | 125 ++++++++ .../so/bpmn/core/domain/ServiceInstanceTest.java | 61 ++++ .../onap/so/bpmn/core/domain/SubscriberTest.java | 41 +++ .../onap/so/bpmn/core/domain/VnfResourceTest.java | 55 ++++ .../core/internal/VariableNameExtractorTest.java | 89 ++++++ .../so/bpmn/core/json/DecomposeJsonUtilTest.java | 170 ++++++++++ .../core/json/JsonDecomposingExceptionTest.java | 38 +++ .../org/onap/so/bpmn/core/json/JsonUtils2Test.java | 329 +++++++++++++++++++ .../org/onap/so/bpmn/core/json/JsonUtilsTest.java | 233 ++++++++++++++ .../onap/so/bpmn/core/utils/CamundaDBSetup.java | 73 +++++ .../org/onap/so/bpmn/core/xml/XmlToolTest.java | 82 +++++ .../mso/bpmn/core/HealthCheckHandlerTest.java | 38 --- .../org/openecomp/mso/bpmn/core/JsonUtilsTest.java | 356 --------------------- .../mso/bpmn/core/PropertyConfigurationTest.java | 106 ------ .../openecomp/mso/bpmn/core/RollbackDataTest.java | 85 ----- .../org/openecomp/mso/bpmn/core/TestBaseTask.java | 271 ---------------- .../mso/bpmn/core/domain/AllottedResourceTest.java | 57 ---- .../bpmn/core/domain/CompareModelsResultTest.java | 83 ----- .../mso/bpmn/core/domain/ConfigResourceTest.java | 39 --- .../mso/bpmn/core/domain/ConfigurationTest.java | 47 --- .../mso/bpmn/core/domain/CustomerTest.java | 38 --- .../mso/bpmn/core/domain/HomingSolutionTest.java | 58 ---- .../mso/bpmn/core/domain/LicenseTest.java | 89 ------ .../mso/bpmn/core/domain/ModelInfoTest.java | 47 --- .../mso/bpmn/core/domain/ModuleResourceTest.java | 48 --- .../mso/bpmn/core/domain/NetworkResourceTest.java | 42 --- .../mso/bpmn/core/domain/OwningEntityTest.java | 39 --- .../mso/bpmn/core/domain/ProjectTest.java | 36 --- .../mso/bpmn/core/domain/RequestTest.java | 44 --- .../core/domain/ResourceDecompositionTest.java | 50 --- .../mso/bpmn/core/domain/ResourceTest.java | 68 ---- .../bpmn/core/domain/ServiceDecompositionTest.java | 83 ----- .../mso/bpmn/core/domain/ServiceInstanceTest.java | 61 ---- .../mso/bpmn/core/domain/SubscriberTest.java | 41 --- .../mso/bpmn/core/domain/TunnelConnectTest.java | 44 --- .../mso/bpmn/core/domain/VnfResourceTest.java | 55 ---- .../core/internal/VariableNameExtractorTest.java | 86 ----- .../mso/bpmn/core/json/JsonUtilsTest.java | 65 ---- .../mso/bpmn/core/utils/CamundaDBSetup.java | 114 ------- 63 files changed, 2869 insertions(+), 2190 deletions(-) create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BadInjectedFiledExceptionTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BaseTaskTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BeansTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/MissingInjectedFiledExceptionTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/ResponseBuilderTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/RollbackDataTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/UrnPropertiesReaderTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/WorkflowExceptionTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/AllottedResourceTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CompareModelsResultTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigResourceTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigurationTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CustomerTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/DomainPojoTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/HomingSolutionTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/LicenseTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModelInfoTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModuleResourceTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/NetworkResourceTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/OwningEntityTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ProjectTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/RequestTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceDecompositionTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceInstanceTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/SubscriberTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/internal/VariableNameExtractorTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/DecomposeJsonUtilTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonDecomposingExceptionTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtils2Test.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/utils/CamundaDBSetup.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/xml/XmlToolTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/HealthCheckHandlerTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/PropertyConfigurationTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/AllottedResourceTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResultTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigResourceTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigurationTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CustomerTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/HomingSolutionTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/LicenseTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModelInfoTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModuleResourceTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/NetworkResourceTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/OwningEntityTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ProjectTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/RequestTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceDecompositionTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceDecompositionTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceInstanceTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/SubscriberTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/TunnelConnectTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/VnfResourceTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsTest.java delete mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/utils/CamundaDBSetup.java (limited to 'bpmn/MSOCoreBPMN/src/test/java/org') diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BadInjectedFiledExceptionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BadInjectedFiledExceptionTest.java new file mode 100644 index 0000000000..b35e65485f --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BadInjectedFiledExceptionTest.java @@ -0,0 +1,46 @@ +/* +* ============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.onap.so.bpmn.core; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class BadInjectedFiledExceptionTest { + + private BadInjectedFieldException badInjectedFieldException; + + @Test + public void test() { + String fieldName = "anyFieldName"; + String taskName = "anyTask"; + Object info = new String("info"); + + String expectedMessage1 = taskName+" injected field '"+fieldName+"' is bad: "+(String)info; + badInjectedFieldException = new BadInjectedFieldException(fieldName, taskName, info); + assertEquals(expectedMessage1, badInjectedFieldException.getMessage()); + + String expectedMessage2 = "java.lang.Throwable: anyCause"; + Throwable cause = new Throwable("anyCause"); + badInjectedFieldException = new BadInjectedFieldException(fieldName, taskName, info, cause); + assertEquals(expectedMessage2, badInjectedFieldException.getCause().toString()); + + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BaseTaskTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BaseTaskTest.java new file mode 100644 index 0000000000..40fcb982c1 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BaseTaskTest.java @@ -0,0 +1,247 @@ +/* +* ============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.onap.so.bpmn.core; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.Expression; +import org.camunda.bpm.engine.repository.ProcessDefinition; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import org.junit.rules.ExpectedException; + +public class BaseTaskTest { + + private String prefix = "PRE_"; + private String processKey = "AnyProcessKey"; + private String definitionId = "100"; + private String anyVariable = "anyVariable"; + private String anyValueString = "anyValue"; + private String badValueString = "123abc"; + private int anyValueInt = 123; + private Integer anyValueInteger = new Integer(anyValueInt); + private long anyValuelong = 123L; + private Long anyValueLong = new Long(anyValuelong); + + private DelegateExecution mockExecution; + private Expression mockExpression; + private BaseTask baseTask; + private Object obj1; + private Object obj2; + private Object objectString; + private Object objectInteger; + private Object objectLong; + private Object objectBoolean; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void before() throws Exception { + baseTask = new BaseTask(); + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class); + when(mockProcessDefinition.getKey()).thenReturn(processKey); + RepositoryService mockRepositoryService = mock(RepositoryService.class); + when(mockRepositoryService.getProcessDefinition(definitionId)).thenReturn(mockProcessDefinition); + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class); + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService); + mockExecution = mock(DelegateExecution.class); + when(mockExecution.getId()).thenReturn(definitionId); + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices); + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition); + when(mockExecution.getVariable("prefix")).thenReturn(prefix); + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true"); + mockExpression = mock(Expression.class); + } + + @Test + public void testExecution() throws Exception{ + baseTask.execute(mockExecution); + assertEquals("BaseTask", baseTask.getTaskName()); + } + + @Test + public void testGetFieldAndMissingInjectedException() throws Exception{ + objectString = new String(anyValueString); + when(mockExpression.getValue(mockExecution)).thenReturn(objectString); + obj1 = baseTask.getField(mockExpression, mockExecution, anyVariable); + assertEquals(anyValueString, obj1.toString()); + + expectedException.expect(MissingInjectedFieldException.class); + obj2 = baseTask.getField(null, mockExecution, anyVariable); + } + + @Test + public void testGetFieldAndBadInjectedFieldException() throws Exception{ + expectedException.expect(BadInjectedFieldException.class); + obj1 = baseTask.getField(mockExpression, mockExecution, null); + } + + @Test + public void testGetOptionalField() throws Exception{ + objectString = new String(anyValueString); + when(mockExpression.getValue(mockExecution)).thenReturn(objectString); + obj1 = baseTask.getOptionalField(mockExpression, mockExecution, anyVariable); + assertEquals(anyValueString, obj1.toString()); + } + + @Test + public void testGetStringFieldAndMissingInjectedFieldException() throws Exception{ + objectString = new String(anyValueString); + when(mockExpression.getValue(mockExecution)).thenReturn(objectString); + obj1 = baseTask.getStringField(mockExpression, mockExecution, anyVariable); + assertEquals(anyValueString, obj1.toString()); + + expectedException.expect(MissingInjectedFieldException.class); + Object objectBoolean = new Boolean(true); // bad data + when(mockExpression.getValue(mockExecution)).thenReturn(objectBoolean); + obj2 = baseTask.getStringField(null, mockExecution, anyVariable); + } + + @Test + public void testGetStringFieldAndBadInjectedFieldException() throws Exception{ + expectedException.expect(BadInjectedFieldException.class); + obj1 = baseTask.getStringField(mockExpression, mockExecution, null); + } + + @Test + public void testGetOptionalStringField() throws Exception{ + objectString = new String(anyValueString); + when(mockExpression.getValue(mockExecution)).thenReturn(objectString); + obj1 = baseTask.getOptionalStringField(mockExpression, mockExecution, anyVariable); + assertEquals(anyValueString, obj1.toString()); + } + + @Test + public void testGetIntegerFieldAndMissingInjectedFieldException() throws Exception{ + objectInteger = new Integer(anyValueInt); + when(mockExpression.getValue(mockExecution)).thenReturn(objectInteger); + obj1 = baseTask.getIntegerField(mockExpression, mockExecution, anyVariable); + assertEquals(anyValueInteger, (Integer)obj1); + + expectedException.expect(MissingInjectedFieldException.class); + objectString = new String(badValueString); + when(mockExpression.getValue(mockExecution)).thenReturn(objectString); + obj2 = baseTask.getIntegerField(null, mockExecution, anyVariable); + } + + @Test + public void testGetIntegerFieldAndBadInjectedFieldException() throws Exception{ + expectedException.expect(BadInjectedFieldException.class); + obj1 = baseTask.getIntegerField(mockExpression, mockExecution, null); + } + + + @Test + public void testGetOptionalIntegerField() throws Exception{ + objectInteger = new Integer(anyValueInt); + when(mockExpression.getValue(mockExecution)).thenReturn(objectInteger); + obj1 = baseTask.getOptionalIntegerField(mockExpression, mockExecution, anyVariable); + assertEquals(anyValueInteger, (Integer)obj1); + } + + @Test + public void testGetOptionalIntegerFieldAndBadInjectedFieldException() throws Exception{ + expectedException.expect(BadInjectedFieldException.class); + objectBoolean = new Boolean(true); + when(mockExpression.getValue(mockExecution)).thenReturn(objectBoolean); + obj1 = baseTask.getOptionalIntegerField(mockExpression, mockExecution, anyVariable); + } + + @Test + public void testGetLongFieldAndMissingInjectedFieldException() throws Exception{ + objectLong = new Long(anyValuelong); + when(mockExpression.getValue(mockExecution)).thenReturn(objectLong); + obj1 = baseTask.getLongField(mockExpression, mockExecution, anyVariable); + assertEquals(anyValueLong, (Long)obj1); + + expectedException.expect(MissingInjectedFieldException.class); + objectString = new String(badValueString); + when(mockExpression.getValue(mockExecution)).thenReturn(objectString); + obj2 = baseTask.getLongField(null, mockExecution, anyVariable); + } + + @Test + public void testGetLongFieldAndBadInjectedFieldException() throws Exception{ + expectedException.expect(BadInjectedFieldException.class); + obj2 = baseTask.getLongField(mockExpression, mockExecution, null); + } + + @Test + public void testGetOptionalLongField() throws Exception{ + objectLong = new Long(anyValuelong); + when(mockExpression.getValue(mockExecution)).thenReturn(objectLong); + obj1 = baseTask.getOptionalLongField(mockExpression, mockExecution, anyVariable); + assertEquals(anyValueLong, (Long)obj1); + } + + @Test + public void testGetOptionalLongFieldAndBadInjectedFieldException() throws Exception{ + expectedException.expect(BadInjectedFieldException.class); + objectBoolean = new Boolean(true); + when(mockExpression.getValue(mockExecution)).thenReturn(objectBoolean); + obj1 = baseTask.getOptionalLongField(mockExpression, mockExecution, anyVariable); + } + + @Test + public void testGetOutputAndMissingInjectedFieldException() throws Exception{ + objectString = new String(anyValueString); + when(mockExpression.getValue(mockExecution)).thenReturn(objectString); + obj1 = baseTask.getOutputField(mockExpression, mockExecution, anyVariable); + assertEquals(anyValueString, obj1.toString()); + + expectedException.expect(MissingInjectedFieldException.class); + objectString = new String(anyValueString); + when(mockExpression.getValue(mockExecution)).thenReturn(objectString); + obj2 = baseTask.getOutputField(null, mockExecution, anyVariable); + } + + @Test + public void testGetOutputAndBadInjectedFieldException() throws Exception{ + expectedException.expect(BadInjectedFieldException.class); + obj2 = baseTask.getOutputField(null, mockExecution, anyVariable); + } + + @Test + public void testGetOptionalOutputField() throws Exception{ + objectString = new String(anyValueString); + when(mockExpression.getValue(mockExecution)).thenReturn(objectString); + obj1 = baseTask.getOptionalOutputField(mockExpression, mockExecution, anyVariable); + assertEquals(anyValueString, obj1.toString()); + } + + @Test + public void testGetOptionalOutputFieldAndBadInjectedFieldException() throws Exception{ + expectedException.expect(BadInjectedFieldException.class); + objectBoolean = new Boolean(true); + when(mockExpression.getValue(mockExecution)).thenReturn(objectBoolean); + obj1 = baseTask.getOptionalOutputField(mockExpression, mockExecution, anyVariable); + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BeansTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BeansTest.java new file mode 100644 index 0000000000..2415e619d7 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BeansTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.core; + +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.onap.so.openpojo.rules.HasAnnotationMatcher.hasAnnotation; +import static org.onap.so.openpojo.rules.HasAnnotationPropertyWithValueMatcher.hasAnnotationPropertyWithValue; + +import javax.persistence.Column; +import javax.persistence.Temporal; + +import org.junit.Test; +import org.onap.so.openpojo.rules.CustomSetterMustExistRule; +import org.onap.so.openpojo.rules.EqualsAndHashCodeTester; +import org.onap.so.openpojo.rules.HasEqualsAndHashCodeRule; +import org.onap.so.openpojo.rules.HasToStringRule; +import org.onap.so.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.BusinessKeyMustExistRule; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.NoNestedClassRule; +import com.openpojo.validation.rule.impl.NoPrimitivesRule; +import com.openpojo.validation.rule.impl.NoPublicFieldsExceptStaticFinalRule; +import com.openpojo.validation.rule.impl.NoStaticExceptFinalRule; +import com.openpojo.validation.rule.impl.SerializableMustHaveSerialVersionUIDRule; +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.onap.so.bpmn.core.domain"); + + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create() + .with(new GetterMustExistRule()) + .with(new NoNestedClassRule()) + .with(new SerializableMustHaveSerialVersionUIDRule()) + .with(new NoPublicFieldsExceptStaticFinalRule()) + .with(new SetterTester()) + .with(new GetterTester()) + + + + .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/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/MissingInjectedFiledExceptionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/MissingInjectedFiledExceptionTest.java new file mode 100644 index 0000000000..b0aa41b05d --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/MissingInjectedFiledExceptionTest.java @@ -0,0 +1,39 @@ +/* +* ============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.onap.so.bpmn.core; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class MissingInjectedFiledExceptionTest { + + private MissingInjectedFieldException missingInjectedFieldException; + + @Test + public void test() { + String fieldName = "anyFieldName"; + String taskName = "anyTask"; + String info = "missing required field"; + String expectedMessage1 = taskName+" injected field '"+fieldName+"' is bad: "+info; + missingInjectedFieldException = new MissingInjectedFieldException(fieldName, taskName); + assertEquals(expectedMessage1, missingInjectedFieldException.getMessage()); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/ResponseBuilderTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/ResponseBuilderTest.java new file mode 100644 index 0000000000..b605209739 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/ResponseBuilderTest.java @@ -0,0 +1,110 @@ +/* +* ============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.onap.so.bpmn.core; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.repository.ProcessDefinition; +import org.junit.Before; +import org.junit.Test; + +public class ResponseBuilderTest { + + private String prefix = "PRE_"; + private String processKey = "AnyProcessKey"; + private String definitionId = "100"; + private int errorCode_200 = 200; + private int errorCode_404 = 404; + private String errorMessage = "any error message!"; + private String errorMessageXML = "any error message!200"; + private String response = "bad"; + + private DelegateExecution mockExecution; + private ResponseBuilder responseBuilder; + private WorkflowException workflowException; + private Object obj; + + @Before + public void before() throws Exception { + responseBuilder = new ResponseBuilder(); + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class); + when(mockProcessDefinition.getKey()).thenReturn(processKey); + RepositoryService mockRepositoryService = mock(RepositoryService.class); + when(mockRepositoryService.getProcessDefinition(definitionId)).thenReturn(mockProcessDefinition); + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class); + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService); + mockExecution = mock(DelegateExecution.class); + when(mockExecution.getId()).thenReturn(definitionId); + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices); + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition); + when(mockExecution.getVariable("prefix")).thenReturn(prefix); + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true"); + } + + @Test + public void buildWorkflowException_WorkflowException_2000_Test() { + when(mockExecution.getVariable(prefix+"ErrorResponse")).thenReturn(errorMessage); + when(mockExecution.getVariable(prefix+"ResponseCode")).thenReturn(errorCode_200); + workflowException = responseBuilder.buildWorkflowException(mockExecution); + assertEquals(2000, workflowException.getErrorCode()); + assertEquals("any error message!", workflowException.getErrorMessage()); + } + + @Test + public void buildWorkflowException_WorkflowException_XML_2000_Test() { + when(mockExecution.getVariable(prefix+"ErrorResponse")).thenReturn(errorMessageXML); + when(mockExecution.getVariable(prefix+"ResponseCode")).thenReturn(errorCode_200); + workflowException = responseBuilder.buildWorkflowException(mockExecution); + assertEquals(2000, workflowException.getErrorCode()); + assertEquals("any error message!", workflowException.getErrorMessage()); + } + + @Test + public void buildWorkflowException_WorkflowException_NULL_Test() { + when(mockExecution.getVariable(prefix+"ErrorResponse")).thenReturn(null); + when(mockExecution.getVariable(prefix+"ResponseCode")).thenReturn(null); + workflowException = responseBuilder.buildWorkflowException(mockExecution); + assertEquals(null, workflowException); + } + + @Test + public void buildWorkflowException_Response_1002_Test() { + when(mockExecution.getVariable(processKey+"Response")).thenReturn(response); + when(mockExecution.getVariable(prefix+"ResponseCode")).thenReturn(errorCode_404); + workflowException = responseBuilder.buildWorkflowException(mockExecution); + assertEquals(response, workflowException.getErrorMessage()); + assertEquals(1002, workflowException.getErrorCode()); + } + + @Test + public void buildWorkflowResponse_Object_Test() { + String workflowResponse = "good"; + when(mockExecution.getVariable("WorkflowResponse")).thenReturn(workflowResponse); + obj = responseBuilder.buildWorkflowResponse(mockExecution); + assertEquals(workflowResponse, obj); + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/RollbackDataTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/RollbackDataTest.java new file mode 100644 index 0000000000..875df6cf94 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/RollbackDataTest.java @@ -0,0 +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.onap.so.bpmn.core; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.hamcrest.Matchers.isIn; +import java.util.Arrays; +import java.util.Collections; + +import org.junit.Test; + +public class RollbackDataTest { + + private final static String TYPE_A = "typeA"; + private final static String TYPE_B = "typeB"; + private static final String KEY_1 = "key1"; + private static final String VALUE_1 = "value1"; + private static final String VALUE_2 = "value2"; + + @Test + public void shouldReturnStringRepresentationOfDataInAnyPermutation() throws Exception { + // given + RollbackData data = new RollbackData(); + data.put(TYPE_A, KEY_1, VALUE_1); + data.put(TYPE_A, "key2", "value2"); + data.put(TYPE_B, "key3", "value3"); + // when, then + assertThat(data.toString(), isIn(Arrays.asList( + "[typeB{key3=value3},typeA{key1=value1, key2=value2}]", + "[typeB{key3=value3},typeA{key2=value2, key1=value1}]", + "[typeA{key1=value1, key2=value2},typeB{key3=value3}]", + "[typeA{key2=value2, key1=value1},typeB{key3=value3}]"))); + } + + @Test + public void shouldBeEmptyOnCreation() throws Exception { + // given + RollbackData data = new RollbackData(); + // then + assertFalse(data.hasType(TYPE_A)); + assertNull(data.get(TYPE_A, KEY_1)); + } + + @Test + public void shouldHaveTypeAfterPuttingDataOfThatType() throws Exception { + // given + RollbackData data = new RollbackData(); + // when + data.put(TYPE_A, KEY_1, VALUE_1); + // then + assertTrue(data.hasType(TYPE_A)); + assertFalse(data.hasType(TYPE_B)); + assertEquals(VALUE_1, data.get(TYPE_A, KEY_1)); + } + + @Test + public void shouldKeepTwoValuesWithSameKeysButDifferentTypes() throws Exception { + // given + RollbackData data = new RollbackData(); + // when + data.put(TYPE_A, KEY_1, VALUE_1); + data.put(TYPE_B, KEY_1, VALUE_2); + // then + assertEquals(VALUE_1, data.get(TYPE_A, KEY_1)); + assertThat(data.get(TYPE_A), is(Collections.singletonMap(KEY_1, VALUE_1))); + assertEquals(VALUE_2, data.get(TYPE_B, KEY_1)); + assertThat(data.get(TYPE_B), is(Collections.singletonMap(KEY_1, VALUE_2))); + } +} \ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/UrnPropertiesReaderTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/UrnPropertiesReaderTest.java new file mode 100644 index 0000000000..5d9a1d61f2 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/UrnPropertiesReaderTest.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.core; + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.core.env.Environment; + +import static org.mockito.Mockito.*; + +public class UrnPropertiesReaderTest { + + @Test + public void testGetVariableFromExecution() { + ExecutionEntity mockExecution = mock(ExecutionEntity.class); + when(mockExecution.getVariable("testKey")).thenReturn("testValue"); + String value = UrnPropertiesReader.getVariable("testKey",mockExecution); + Assert.assertEquals("testValue", value); + verify(mockExecution).getVariable("testKey"); + verify(mockExecution, never()).setVariable("testKey", value); + } + + @Test + public void testGetVariableFromEnvironment() { + ExecutionEntity mockExecution = mock(ExecutionEntity.class); + Environment mockEnvironment = mock(Environment.class); + when(mockEnvironment.getProperty("testKey")).thenReturn("testValue"); + UrnPropertiesReader urnPropertiesReader = new UrnPropertiesReader(); + urnPropertiesReader.setEnvironment(mockEnvironment); + String value = UrnPropertiesReader.getVariable("testKey",mockExecution); + Assert.assertEquals("testValue",value); + verify(mockExecution).getVariable("testKey"); + verify(mockExecution).setVariable("testKey", value); + } + + @Test + public void testGetVariableNotExist() { + ExecutionEntity mockExecution = mock(ExecutionEntity.class); + String value = UrnPropertiesReader.getVariable("notExist", mockExecution); + Assert.assertEquals(null, value); + verify(mockExecution).getVariable("notExist"); + verify(mockExecution, never()).setVariable("notExist", value); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/WorkflowExceptionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/WorkflowExceptionTest.java new file mode 100644 index 0000000000..c1e9b8776b --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/WorkflowExceptionTest.java @@ -0,0 +1,47 @@ +/* +* ============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.onap.so.bpmn.core; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import org.junit.Test; + +public class WorkflowExceptionTest { + + private WorkflowException workflowException; + + @Test + public void test() { + String processKey = "AnyProcessKey"; + int errorCode = 200; + String errorMessage = "any error message!"; + workflowException = new WorkflowException(processKey, errorCode, errorMessage); + assertEquals(errorCode, workflowException.getErrorCode()); + assertEquals(errorMessage, workflowException.getErrorMessage()); + assertEquals(processKey, workflowException.getProcessKey()); + assertEquals("*", workflowException.getWorkStep()); + String workStep = "one"; + workflowException = new WorkflowException(processKey, errorCode, errorMessage, workStep); + assertEquals(workStep, workflowException.getWorkStep()); + assertNotEquals(null, workflowException.toString()); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/AllottedResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/AllottedResourceTest.java new file mode 100644 index 0000000000..b1dd8659cd --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/AllottedResourceTest.java @@ -0,0 +1,54 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class AllottedResourceTest { + private AllottedResource ar = new AllottedResource(); + + @Test + public void testAllottedResource() { + ar.setAllottedResourceType("allottedResourceType"); + ar.setAllottedResourceRole("allottedResourceRole"); + ar.setProvidingServiceModelName("providingServiceModelName"); + ar.setProvidingServiceModelInvariantUuid("providingServiceModelInvariantUuid"); + ar.setProvidingServiceModelUuid("providingServiceModelUuid"); + ar.setNfFunction("nfFunction"); + ar.setNfType("nfType"); + ar.setNfRole("nfRole"); + ar.setNfNamingCode("nfNamingCode"); + ar.setOrchestrationStatus("orchestrationStatus"); + assertEquals(ar.getAllottedResourceType(), "allottedResourceType"); + assertEquals(ar.getAllottedResourceRole(), "allottedResourceRole"); + assertEquals(ar.getProvidingServiceModelName(), "providingServiceModelName"); + assertEquals(ar.getProvidingServiceModelInvariantUuid(), "providingServiceModelInvariantUuid"); + assertEquals(ar.getProvidingServiceModelUuid(), "providingServiceModelUuid"); + assertEquals(ar.getNfFunction(), "nfFunction"); + assertEquals(ar.getNfType(), "nfType"); + assertEquals(ar.getNfRole(), "nfRole"); + assertEquals(ar.getNfNamingCode(), "nfNamingCode"); + assertEquals(ar.getOrchestrationStatus(), "orchestrationStatus"); + + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CompareModelsResultTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CompareModelsResultTest.java new file mode 100644 index 0000000000..af9c7a7fa6 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CompareModelsResultTest.java @@ -0,0 +1,83 @@ +/* +* ============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.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; + +public class CompareModelsResultTest { + + private CompareModelsResult modelsResult; + private List addedResourceList; + private List deletedResourceList; + private ResourceModelInfo resourceModelInfo1; + private ResourceModelInfo resourceModelInfo2; + private List requestInputs; + + @Before + public void before() { + resourceModelInfo1 = new ResourceModelInfo(); + resourceModelInfo1.setResourceCustomizationUuid("f1d563e8-e714-4393-8f99-cc480144a05e"); + resourceModelInfo1.setResourceInvariantUuid("e1d563e8-e714-4393-8f99-cc480144a05f"); + resourceModelInfo1.setResourceName("resourceName1"); + resourceModelInfo1.setResourceUuid("f1d563e8-e714-4393-8f99-cc480144a05g"); + resourceModelInfo2 = new ResourceModelInfo(); + resourceModelInfo2.setResourceCustomizationUuid("a1d563e8-e714-4393-8f99-cc480144a05d"); + resourceModelInfo2.setResourceInvariantUuid("b1d563e8-e714-4393-8f99-cc480144a05e"); + resourceModelInfo2.setResourceName("resourceName2"); + resourceModelInfo2.setResourceUuid("c1d563e8-e714-4393-8f99-cc480144a05f"); + } + + @Test + public void testSetAddedResourceList() { + addedResourceList = new ArrayList(); + addedResourceList.add(resourceModelInfo1); + addedResourceList.add(resourceModelInfo2); + modelsResult = new CompareModelsResult(); + modelsResult.setAddedResourceList(addedResourceList); + assertEquals(addedResourceList, modelsResult.getAddedResourceList()); + } + + @Test + public void testSetDeletedResourceList() { + deletedResourceList = new ArrayList(); + deletedResourceList.add(resourceModelInfo1); + deletedResourceList.add(resourceModelInfo2); + modelsResult = new CompareModelsResult(); + modelsResult.setDeletedResourceList(deletedResourceList); + assertEquals(deletedResourceList, modelsResult.getDeletedResourceList()); + } + + @Test + public void testSetRequestInputs() { + requestInputs = new ArrayList(); + requestInputs.add("requestInput1"); + requestInputs.add("requestInput2"); + modelsResult = new CompareModelsResult(); + modelsResult.setRequestInputs(requestInputs); + assertEquals(requestInputs, modelsResult.getRequestInputs()); + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigResourceTest.java new file mode 100644 index 0000000000..13a30d26ee --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigResourceTest.java @@ -0,0 +1,39 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ConfigResourceTest { + private ConfigResource configresource = new ConfigResource();{ + configresource.resourceType = ResourceType.CONFIGURATION; + } + + @Test + public void testConfigResource() { + configresource.setToscaNodeType("toscaNodeType"); + assertEquals(configresource.getToscaNodeType(), "toscaNodeType"); + + + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigurationTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigurationTest.java new file mode 100644 index 0000000000..fe84a1b5a7 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigurationTest.java @@ -0,0 +1,47 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ConfigurationTest { + private Configuration configuration = new Configuration(); + + @Test + public void testConfigurationTest() { + configuration.setId("id"); + configuration.setName("name"); + configuration.setType("type"); + configuration.setOrchestrationStatus("orchestrationStatus"); + configuration.setTunnelBandwidth("tunnelBandwidth"); + configuration.setVendorAllowedMaxBandwidth("vendorAllowedMaxBandwidth"); + configuration.setResourceVersion("resourceVersion"); + assertEquals(configuration.getId(), "id"); + assertEquals(configuration.getName(), "name"); + assertEquals(configuration.getType(), "type"); + assertEquals(configuration.getOrchestrationStatus(), "orchestrationStatus"); + assertEquals(configuration.getTunnelBandwidth(), "tunnelBandwidth"); + assertEquals(configuration.getVendorAllowedMaxBandwidth(), "vendorAllowedMaxBandwidth"); + assertEquals(configuration.getResourceVersion(), "resourceVersion"); + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CustomerTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CustomerTest.java new file mode 100644 index 0000000000..86eb717664 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CustomerTest.java @@ -0,0 +1,38 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class CustomerTest { + private Customer customer = new Customer(); + + @Test + public void testCustomer() { + customer.setSubscriptionServiceType("subscriptionServiceType"); + customer.setGlobalSubscriberId("globalSubscriberId"); + assertEquals(customer.getSubscriptionServiceType(), "subscriptionServiceType"); + assertEquals(customer.getGlobalSubscriberId(), "globalSubscriberId"); + + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/DomainPojoTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/DomainPojoTest.java new file mode 100644 index 0000000000..b4860c6323 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/DomainPojoTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.core.domain; + +import org.junit.Test; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoClassFilter; +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.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + + +public class DomainPojoTest { + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + @Test + public void pojoStructure() { + test("org.onap.so.bpmn.core.domain"); + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create() + .with(new SetterTester()) + .with(new GetterTester()) + .build(); + validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses, new FilterNonConcrete()); + } + + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/HomingSolutionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/HomingSolutionTest.java new file mode 100644 index 0000000000..9750e03b4c --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/HomingSolutionTest.java @@ -0,0 +1,58 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class HomingSolutionTest { + + private HomingSolution homingsolution = new HomingSolution(); + InventoryType inventory = InventoryType.cloud; + VnfResource vnfresource = new VnfResource(); + License license = new License(); + + @Test + public void testHomingSolution() { + homingsolution.setInventoryType(inventory); + homingsolution.setRehome(true); + homingsolution.setServiceInstanceId("serviceInstanceId"); + homingsolution.setCloudOwner("cloudOwner"); + homingsolution.setCloudRegionId("cloudRegionId"); + homingsolution.setAicClli("aicClli"); + homingsolution.setAicVersion("aicVersion"); + homingsolution.setTenant("tenant"); + homingsolution.setVnf(vnfresource); + homingsolution.setLicense(license); + assertEquals(homingsolution.getInventoryType(), inventory); + assertEquals(homingsolution.isRehome(), true); + assertEquals(homingsolution.getServiceInstanceId(), "serviceInstanceId"); + assertEquals(homingsolution.getCloudOwner(), "cloudOwner"); + assertEquals(homingsolution.getCloudRegionId(), "cloudRegionId"); + assertEquals(homingsolution.getAicClli(), "aicClli"); + assertEquals(homingsolution.getAicVersion(), "aicVersion"); + assertEquals(homingsolution.getTenant(), "tenant"); + assertEquals(homingsolution.getVnf(), vnfresource); + assertEquals(homingsolution.getLicense(), license); + + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/LicenseTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/LicenseTest.java new file mode 100644 index 0000000000..e3133cb1c6 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/LicenseTest.java @@ -0,0 +1,89 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.BDDMockito.Then; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + + +//@RunWith(PowerMockRunner.class) +//@PrepareForTest({License.class}) +public class LicenseTest { + + //@Mock + private License license= new License(); + //@InjectMocks + //private LicenseTest licenceTest; + List entitlementPoolList = new ArrayList(); + private List licenseKeyGroupList = new ArrayList(); + //JSONArray array = new JSONArray(entitlementPoolList); + //JSONArray array1 = new JSONArray(licenseKeyGroupList); + //@PrepareForTest({License.class}) + Long serialVersionUID = 333L; + + @Test + public void testLicense() { + license.setEntitlementPoolList(entitlementPoolList); + license.setLicenseKeyGroupList(licenseKeyGroupList); + //license.addEntitlementPool("entitlementPoolUuid"); + license.addLicenseKeyGroup("licenseKeyGroupUuid"); + assertEquals(license.getEntitlementPoolList(), entitlementPoolList); + assertEquals(license.getLicenseKeyGroupList(), licenseKeyGroupList); + assert(license.getEntitlementPoolListAsString()!= null); + assert(license.getLicenseKeyGroupListAsString()!=null); + license.addEntitlementPool("entitlementPoolUuid"); + //assertEquals(license.getSerialversionuid(), serialVersionUID); + //assertArrayEquals(license.getSerialversionuid(), serialVersionUID); + //assert + + /*PowerMockito.mockStatic(License.class); + Mockito.when(License.getSerialversionuid()).thenReturn(getserial()); + assertEquals(License.getSerialversionuid(),"abc");*/ + + } + // @Before + // public void mocksetUp() { +// Long serialVersionUID = 333L; +// PowerMockito.mockStatic(License.class); +// expect (license.getSerialversionuid()).andReturn(serialVersionUID); +// //PowerMockito.when(license.getSerialversionuid(). +// //PowerMockito.when(MathUtil.addInteger(2, 2)).thenReturn(1); +// } + + /*private Long getserial() { + + return abc; + }*/ + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModelInfoTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModelInfoTest.java new file mode 100644 index 0000000000..3d07f85c04 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModelInfoTest.java @@ -0,0 +1,47 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ModelInfoTest { + private ModelInfo modelinfo = new ModelInfo(); + + @Test + public void testModelInfo() { + modelinfo.setModelName("modelName"); + modelinfo.setModelUuid("modelUuid"); + modelinfo.setModelInvariantUuid("modelInvariantUuid"); + modelinfo.setModelVersion("modelVersion"); + modelinfo.setModelCustomizationUuid("modelCustomizationUuid"); + modelinfo.setModelInstanceName("modelInstanceName"); + modelinfo.setModelType("modelType"); + assertEquals(modelinfo.getModelName(), "modelName"); + assertEquals(modelinfo.getModelUuid(), "modelUuid"); + assertEquals(modelinfo.getModelInvariantUuid(), "modelInvariantUuid"); + assertEquals(modelinfo.getModelVersion(), "modelVersion"); + assertEquals(modelinfo.getModelCustomizationUuid(), "modelCustomizationUuid"); + assertEquals(modelinfo.getModelInstanceName(), "modelInstanceName"); + assertEquals(modelinfo.getModelType(), "modelType"); + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModuleResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModuleResourceTest.java new file mode 100644 index 0000000000..dcb62cfc40 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModuleResourceTest.java @@ -0,0 +1,48 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ModuleResourceTest { + private ModuleResource moduleresource = new ModuleResource(); + + @Test + public void testModuleResource() { + + moduleresource.setVfModuleName("vfModuleName"); + moduleresource.setHeatStackId("heatStackId"); + moduleresource.setIsBase(true); + moduleresource.setVfModuleLabel("vfModuleLabel"); + moduleresource.setInitialCount(0); + moduleresource.setVfModuleType("vfModuleType"); + moduleresource.setHasVolumeGroup(true); + assertEquals(moduleresource.getVfModuleName(), "vfModuleName"); + assertEquals(moduleresource.getHeatStackId(), "heatStackId"); + assertEquals(moduleresource.getIsBase(), true); + assertEquals(moduleresource.getVfModuleLabel(), "vfModuleLabel"); + assertEquals(moduleresource.getInitialCount(), 0); + assertEquals(moduleresource.getVfModuleType(), "vfModuleType"); + assertEquals(moduleresource.isHasVolumeGroup(), true); + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/NetworkResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/NetworkResourceTest.java new file mode 100644 index 0000000000..6ca9cef8d2 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/NetworkResourceTest.java @@ -0,0 +1,42 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class NetworkResourceTest { + private NetworkResource nr = new NetworkResource(); + + @Test + public void testNetworkResource() { + nr.setNetworkType("networkType"); + nr.setNetworkRole("networkRole"); + nr.setNetworkTechnology("networkTechnology"); + nr.setNetworkScope("networkScope"); + assertEquals(nr.getNetworkType(), "networkType"); + assertEquals(nr.getNetworkRole(), "networkRole"); + assertEquals(nr.getNetworkTechnology(), "networkTechnology"); + assertEquals(nr.getNetworkScope(), "networkScope"); + + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/OwningEntityTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/OwningEntityTest.java new file mode 100644 index 0000000000..396d866446 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/OwningEntityTest.java @@ -0,0 +1,39 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ + +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class OwningEntityTest { + private OwningEntity oe = new OwningEntity(); + + @Test + public void testOwingEntity() { + oe.setOwningEntityId("owningEntityId"); + oe.setOwningEntityName("owningEntityName"); + assertEquals(oe.getOwningEntityId(), "owningEntityId"); + assertEquals(oe.getOwningEntityName(), "owningEntityName"); + + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ProjectTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ProjectTest.java new file mode 100644 index 0000000000..9081f9dd14 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ProjectTest.java @@ -0,0 +1,36 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ProjectTest { + + private Project project = new Project(); + + @Test + public void testProject() { + project.setProjectName("projectName"); + assertEquals(project.getProjectName(), "projectName"); + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/RequestTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/RequestTest.java new file mode 100644 index 0000000000..0c552ce19e --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/RequestTest.java @@ -0,0 +1,44 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class RequestTest { + + private Request request = new Request(); + ModelInfo model = new ModelInfo(); + + @Test + public void testRequest() { + request.setSdncRequestId("sdncRequestId"); + request.setRequestId("requestId"); + request.setModelInfo(model); + request.setProductFamilyId("productFamilyId"); + assertEquals(request.getSdncRequestId(), "sdncRequestId"); + assertEquals(request.getRequestId(), "requestId"); + assertEquals(request.getModelInfo(), model); + assertEquals(request.getProductFamilyId(), "productFamilyId"); + + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceDecompositionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceDecompositionTest.java new file mode 100644 index 0000000000..573ffab4aa --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceDecompositionTest.java @@ -0,0 +1,50 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ResourceDecompositionTest { + + private ResourceDecomposition rd = new ResourceDecomposition() { + private static final long serialVersionUID = 1L; + }; + ModelInfo model = new ModelInfo(); + ResourceInstance ri = new ResourceInstance(); + + + + @Test + public void testResourceDecomposition() { + rd.setModelInfo(model); + rd.setInstanceData(ri); + rd.setResourceType("resourceType"); + rd.setResourceInstanceId("newInstanceId"); + rd.setResourceInstanceName("newInstanceName"); + assertEquals(rd.getResourceModel(), model); + assertEquals(rd.getModelInfo(), model); + assertEquals(rd.getInstanceData(), ri); + assertEquals(rd.getResourceInstanceId(), "newInstanceId"); + assertEquals(rd.getResourceInstanceName(), "newInstanceName"); + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceTest.java new file mode 100644 index 0000000000..afdbcd9f98 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceTest.java @@ -0,0 +1,68 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ResourceTest { + private Resource resource = new Resource() { + private static final long serialVersionUID = 1L; + + + }; + ModelInfo model = new ModelInfo(); + ResourceInstance ri = new ResourceInstance(); + HomingSolution hs = new HomingSolution(); + ResourceType rt = ResourceType.VNF; + public long concurrencyCounter = 1L; + long initval = resource.getConcurrencyCounter(); + + @Test + public void testResource() { + resource.setResourceId("resourceId"); + resource.setModelInfo(model); + resource.setResourceInstance(ri); + resource.setHomingSolution(hs); + resource.setCurrentHomingSolution(hs); + resource.setResourceType(rt); + resource.setToscaNodeType("toscaNodeType"); + resource.setResourceInstanceId("newInstanceId"); + resource.setResourceInstanceName("newInstanceName"); + resource.incrementConcurrencyCounter(); + assertEquals(resource.getResourceId(), "resourceId"); + assertEquals(resource.getModelInfo(), model); + assertEquals(resource.getResourceInstance(), ri); + assertEquals(resource.getHomingSolution(), hs); + assertEquals(resource.getCurrentHomingSolution(), hs); + assertEquals(resource.getResourceType(), rt); + assertEquals(resource.getToscaNodeType(), "toscaNodeType"); + assertEquals(resource.getResourceInstanceId(), "newInstanceId"); + assertEquals(resource.getResourceInstanceName(), "newInstanceName"); + assertEquals(resource.getConcurrencyCounter(), initval+1); + + + + + + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java new file mode 100644 index 0000000000..82470f125b --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java @@ -0,0 +1,125 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; + +import org.junit.Before; +import org.junit.Test; + +import com.fasterxml.jackson.core.JsonProcessingException; + +public class ServiceDecompositionTest { + private static final String RESOURCE_PATH = "src/test/resources/json-examples/"; + + VnfResource vnfResource; + NetworkResource networkResource; + AllottedResource allottedResource; + ConfigResource configResource; + + @Before + public void before() { + vnfResource = new VnfResource(); + vnfResource.setResourceId("vnfResourceId"); + vnfResource.setModules(new ArrayList<>()); + + networkResource = new NetworkResource(); + networkResource.setResourceId("networkResourceId"); + + allottedResource = new AllottedResource(); + allottedResource.setResourceId("allottedResourceId"); + + configResource = new ConfigResource(); + configResource.setResourceId("configResourceId"); + } + + @Test + public void serviceDecompositionTest() throws JsonProcessingException, IOException { + // covering methods not covered by openpojo test + String catalogRestOutput = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "ServiceDecomposition.json"))); + + ServiceDecomposition serviceDecomp = new ServiceDecomposition(catalogRestOutput); + serviceDecomp.addVnfResource(vnfResource); + serviceDecomp.addNetworkResource(networkResource); + serviceDecomp.addAllottedResource(allottedResource); + serviceDecomp.addConfigResource(configResource); + + assertThat(serviceDecomp.getServiceResource(vnfResource.getResourceId()), sameBeanAs(vnfResource)); + assertThat(serviceDecomp.getServiceResource(networkResource.getResourceId()), sameBeanAs(networkResource)); + assertThat(serviceDecomp.getServiceResource(allottedResource.getResourceId()), sameBeanAs(allottedResource)); + assertThat(serviceDecomp.getServiceResource(configResource.getResourceId()), sameBeanAs(configResource)); + + VnfResource vnfResourceReplace = new VnfResource(); + vnfResourceReplace.setResourceId(vnfResource.getResourceId()); + vnfResourceReplace.setResourceInstanceName("vnfResourceReplaceInstanceName"); + + assertTrue(serviceDecomp.replaceResource(vnfResourceReplace)); + assertTrue(serviceDecomp.getVnfResources().contains(vnfResourceReplace)); + + assertTrue(serviceDecomp.deleteResource(vnfResourceReplace)); + assertFalse(serviceDecomp.deleteResource(vnfResourceReplace)); + assertFalse(serviceDecomp.deleteResource(new VnfResource())); + } + + @Test + public void serviceDecompositionJsonTest() throws IOException { + String catalogRestOutput = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "ServiceDecomposition.json"))); + String expectedCatalogRestOutput = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "ServiceDecompositionExpected.json"))); + String vnfResourceJson = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "VnfResource.json"))); + String networkResourceJson = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "NetworkResource.json"))); + String allottedResourceJson = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "AllottedResource.json"))); + String configResourceJson = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "ConfigResource.json"))); + + ServiceDecomposition serviceDecomp = new ServiceDecomposition(catalogRestOutput, "serviceInstanceId"); + serviceDecomp.addResource(vnfResource); + serviceDecomp.addResource(networkResource); + serviceDecomp.addResource(allottedResource); + serviceDecomp.addResource(configResource); + + assertThat(serviceDecomp.getServiceResource(vnfResource.getResourceId()), sameBeanAs(vnfResource)); + assertThat(serviceDecomp.getServiceResource(networkResource.getResourceId()), sameBeanAs(networkResource)); + assertThat(serviceDecomp.getServiceResource(allottedResource.getResourceId()), sameBeanAs(allottedResource)); + assertThat(serviceDecomp.getServiceResource(configResource.getResourceId()), sameBeanAs(configResource)); + + serviceDecomp = new ServiceDecomposition(catalogRestOutput, "serviceInstanceId"); + serviceDecomp.addVnfResource(vnfResourceJson); + serviceDecomp.addNetworkResource(networkResourceJson); + serviceDecomp.addAllottedResource(allottedResourceJson); + serviceDecomp.addConfigResource(configResourceJson); + + ServiceDecomposition expectedServiceDecomp = new ServiceDecomposition(expectedCatalogRestOutput, "serviceInstanceId"); + + assertThat(serviceDecomp, sameBeanAs(expectedServiceDecomp)); + assertEquals(serviceDecomp.listToJson(Arrays.asList(networkResource)) + serviceDecomp.listToJson(Arrays.asList(vnfResource)) + + serviceDecomp.listToJson(Arrays.asList(allottedResource)) + serviceDecomp.listToJson(Arrays.asList(configResource)), + serviceDecomp.getServiceResourcesJsonString()); + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceInstanceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceInstanceTest.java new file mode 100644 index 0000000000..7cacc9da88 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceInstanceTest.java @@ -0,0 +1,61 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import java.util.Map; + +import org.junit.Test; + +public class ServiceInstanceTest { + + private ServiceInstance si= new ServiceInstance(); + Map serviceParams; + Configuration config= new Configuration(); + ModelInfo model= new ModelInfo(); + + @Test + public void testServiceInstance() { + si.setServiceType("serviceType"); + si.setServiceId("serviceId"); + si.setServiceParams(serviceParams); + si.setInstanceId("instanceId"); + si.setInstanceName("instanceName"); + si.setOrchestrationStatus("orchestrationStatus"); + si.setConfiguration(config); + si.setModelInfo(model); + si.setEnvironmentContext("environmentContext"); + si.setWorkloadContext("workloadContext"); + assertEquals(si.getServiceType(), "serviceType"); + assertEquals(si.getServiceId(), "serviceId"); + assertEquals(si.getServiceParams(), serviceParams); + assertEquals(si.getInstanceId(), "instanceId"); + assertEquals(si.getInstanceName(), "instanceName"); + assertEquals(si.getOrchestrationStatus(), "orchestrationStatus"); + assertEquals(si.getConfiguration(), config); + assertEquals(si.getModelInfo(), model); + assertEquals(si.getEnvironmentContext(), "environmentContext"); + assertEquals(si.getWorkloadContext(), "workloadContext"); + + + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/SubscriberTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/SubscriberTest.java new file mode 100644 index 0000000000..b862c8704f --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/SubscriberTest.java @@ -0,0 +1,41 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class SubscriberTest { + Subscriber subscriber= new Subscriber("globalId", "name", "commonSiteId"); + + @Test + public void testSubscriber() { + subscriber.setGlobalId("globalId"); + subscriber.setName("name"); + subscriber.setCommonSiteId("commonSiteId"); + assertEquals(subscriber.getGlobalId(), "globalId"); + assertEquals(subscriber.getName(), "name"); + assertEquals(subscriber.getCommonSiteId(), "commonSiteId"); + + + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java new file mode 100644 index 0000000000..24947e9a8d --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java @@ -0,0 +1,55 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= +*/ +package org.onap.so.bpmn.core.domain; + +import static org.junit.Assert.*; + +import java.util.List; + +import org.junit.Test; + +public class VnfResourceTest { + + private VnfResource vnf= new VnfResource(); + List moduleResources; + + @Test + public void testVnfResource() { + vnf.setModules(moduleResources); + vnf.setVnfHostname("vnfHostname"); + vnf.setVnfType("vnfType"); + vnf.setNfFunction("nfFunction"); + vnf.setNfType("nfType"); + vnf.setNfRole("nfRole"); + vnf.setNfNamingCode("nfNamingCode"); + vnf.setMultiStageDesign("multiStageDesign"); + assertEquals(vnf.getVfModules(), moduleResources); + assertEquals(vnf.getVnfHostname(), "vnfHostname"); + assertEquals(vnf.getVnfType(), "vnfType"); + assertEquals(vnf.getNfFunction(), "nfFunction"); + assertEquals(vnf.getNfType(), "nfType"); + assertEquals(vnf.getNfRole(), "nfRole"); + assertEquals(vnf.getNfNamingCode(), "nfNamingCode"); + assertEquals(vnf.getMultiStageDesign(), "multiStageDesign"); + + + } + +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/internal/VariableNameExtractorTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/internal/VariableNameExtractorTest.java new file mode 100644 index 0000000000..e32bc88b7c --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/internal/VariableNameExtractorTest.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.core.internal; +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.*; +import static org.mockito.Matchers.contains; + +import java.util.Optional; +import org.junit.Test; + +public class VariableNameExtractorTest { + + @Test + public void shouldExtractVariableName() throws Exception { + // given + String name = "A_different_NAME123"; + String variable = "${A_different_NAME123}"; + VariableNameExtractor extractor = new VariableNameExtractor(variable); + // when + Optional extracted = extractor.extract(); + // then + assertTrue(extracted.isPresent()); + assertThat(extracted.get(), containsString(name)); + } + + @Test + public void shouldExtractVariableNameFromWhitespaces() throws Exception { + // given + String name = "name"; + String variable = " \n\t$ \n\t{ \n\tname \n\t} \n\t"; + VariableNameExtractor extractor = new VariableNameExtractor(variable); + // when + Optional extracted = extractor.extract(); + // then + assertTrue(extracted.isPresent()); + assertThat(extracted.get(), containsString(name)); + } + + @Test + public void shouldReturnEmptyIfThereIsMoreThanVariable() throws Exception { + // given + String variable = "a ${test}"; + VariableNameExtractor extractor = new VariableNameExtractor(variable); + // when + Optional extracted = extractor.extract(); + // then + assertFalse(extracted.isPresent()); + } + + @Test + public void shouldReturnEmptyIfVariableNameIsIncorrect() throws Exception { + // given + String variable = "${name with space}"; + VariableNameExtractor extractor = new VariableNameExtractor(variable); + // when + Optional extracted = extractor.extract(); + // then + assertFalse(extracted.isPresent()); + } + + @Test + public void shouldReturnEmptyIfTwoVariablesPresent() throws Exception { + // given + String variable = "${var1} ${var2}"; + VariableNameExtractor extractor = new VariableNameExtractor(variable); + // when + Optional extracted = extractor.extract(); + // then + assertFalse(extracted.isPresent()); + } +} \ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/DecomposeJsonUtilTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/DecomposeJsonUtilTest.java new file mode 100644 index 0000000000..c1f7cce30b --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/DecomposeJsonUtilTest.java @@ -0,0 +1,170 @@ +/* +* ============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.onap.so.bpmn.core.json; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.so.bpmn.core.domain.AllottedResource; +import org.onap.so.bpmn.core.domain.ConfigResource; +import org.onap.so.bpmn.core.domain.NetworkResource; +import org.onap.so.bpmn.core.domain.ServiceDecomposition; +import org.onap.so.bpmn.core.domain.VnfResource; + +public class DecomposeJsonUtilTest { + + private VnfResource vnfResource; + private NetworkResource networkResource; + private AllottedResource allottedResource; + private ConfigResource configResource; + private ServiceDecomposition serviceDecomposition; + + private String serviceInstanceId = "serviceInstanceId"; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void before() throws Exception { + + } + + @Test + public void testJsonToServiceDecomposition_twoParams() throws JsonDecomposingException { + serviceDecomposition = createServiceDecompositionData(); + ServiceDecomposition serviceDecompositionObj = DecomposeJsonUtil.jsonToServiceDecomposition(serviceDecomposition.toString(), "serviceInstanceId"); + assertEquals(serviceInstanceId, serviceDecompositionObj.getServiceInstance().getInstanceId()); + } + + @Test + public void testJsonToServiceDecomposition() throws JsonDecomposingException { + serviceDecomposition = createServiceDecompositionData(); + ServiceDecomposition serviceDecompositionObj = DecomposeJsonUtil.jsonToServiceDecomposition(serviceDecomposition.toString()); + assertEquals(serviceDecomposition.getServiceType(), serviceDecompositionObj.getServiceType()); + } + + @Test + public void testJsonToServiceDecomposition_JsonDecomposingException() throws JsonDecomposingException { + expectedException.expect(JsonDecomposingException.class); + vnfResource = createVnfResourceData(); // wrong object + ServiceDecomposition serviceDecompositionObj = DecomposeJsonUtil.jsonToServiceDecomposition(vnfResource.toString()); + } + + @Test + public void testJsonToVnfResource() throws JsonDecomposingException { + vnfResource = createVnfResourceData(); + VnfResource vnfResourceObj = DecomposeJsonUtil.jsonToVnfResource(vnfResource.toString()); + assertEquals(vnfResource.getResourceId(), vnfResourceObj.getResourceId()); + } + + @Test + public void testJsonToVnfResource_JsonDecomposingException() throws JsonDecomposingException { + expectedException.expect(JsonDecomposingException.class); + networkResource = createNetworkResourceData(); // wrong object + VnfResource vnfResourceObj = DecomposeJsonUtil.jsonToVnfResource(networkResource.toString()); + } + + @Test + public void testJsonToNetworkResource() throws JsonDecomposingException { + networkResource = createNetworkResourceData(); + NetworkResource networkResourceObj = DecomposeJsonUtil.jsonToNetworkResource(networkResource.toString()); + assertEquals(networkResource.getResourceId(), networkResourceObj.getResourceId()); + } + + @Test + public void testJsonToNetworkResource_JsonDecomposingException() throws JsonDecomposingException { + expectedException.expect(JsonDecomposingException.class); + vnfResource = createVnfResourceData(); // wrong object + NetworkResource networkResourceObj = DecomposeJsonUtil.jsonToNetworkResource(vnfResource.toString()); + } + + @Test + public void testJsonToAllottedResource() throws JsonDecomposingException { + allottedResource = createAllottedResourceData(); + AllottedResource allottedResourceObj = DecomposeJsonUtil.jsonToAllottedResource(allottedResource.toString()); + assertEquals(allottedResource.getResourceId(), allottedResourceObj.getResourceId()); + } + + @Test + public void testJsonToAllottedResource_JsonDecomposingException() throws JsonDecomposingException { + expectedException.expect(JsonDecomposingException.class); + configResource = createConfigResourceData(); // wrong object + AllottedResource allottedResourceObj = DecomposeJsonUtil.jsonToAllottedResource(configResource.toString()); + } + + @Test + public void testJsonToConfigResource() throws JsonDecomposingException { + configResource = createConfigResourceData(); + ConfigResource configResourceObj = DecomposeJsonUtil.jsonToConfigResource(configResource.toString()); + assertEquals(configResource.getResourceId(), configResourceObj.getResourceId()); + } + + @Test + public void testJsonToConfigResource_JsonDecomposingException() throws JsonDecomposingException { + expectedException.expect(JsonDecomposingException.class); + allottedResource = createAllottedResourceData(); // wrong object + ConfigResource configResourceObj = DecomposeJsonUtil.jsonToConfigResource(allottedResource.toString()); + } + + // data creation section + private VnfResource createVnfResourceData() { + vnfResource = new VnfResource(); + vnfResource.setResourceId("resourceId"); + vnfResource.setNfFunction("nfFunction"); + vnfResource.setNfNamingCode("nfNamingCode"); + vnfResource.setNfRole("nfRole"); + return vnfResource; + } + + private NetworkResource createNetworkResourceData() { + networkResource = new NetworkResource(); + networkResource.setNetworkRole("networkRole"); + networkResource.setResourceId("resourceId"); + return networkResource; + } + + private AllottedResource createAllottedResourceData() { + allottedResource = new AllottedResource(); + allottedResource.setResourceId("resourceId"); + allottedResource.setNfFunction("nfFunction"); + allottedResource.setNfNamingCode("nfNamingCode"); + allottedResource.setNfRole("nfRole"); + return allottedResource; + } + + private ConfigResource createConfigResourceData() { + configResource = new ConfigResource(); + configResource.setResourceId("resourceId"); + configResource.setToscaNodeType("toscaNodeType"); + return configResource; + } + + private ServiceDecomposition createServiceDecompositionData() { + serviceDecomposition = new ServiceDecomposition(); + serviceDecomposition.setSdncVersion("sdncVersion"); + serviceDecomposition.setServiceRole("serviceRole"); + serviceDecomposition.setServiceType("serviceType"); + return serviceDecomposition; + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonDecomposingExceptionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonDecomposingExceptionTest.java new file mode 100644 index 0000000000..6c8b7326e2 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonDecomposingExceptionTest.java @@ -0,0 +1,38 @@ +/* +* ============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.onap.so.bpmn.core.json; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class JsonDecomposingExceptionTest { + + private JsonDecomposingException jsonDecomposingException; + + @Test + public void test() { + String expectedMessage = "java.lang.Throwable: anyCause"; + String message = "java.lang.Throwable: anyCause"; + Throwable cause = new Throwable("anyCause"); + jsonDecomposingException = new JsonDecomposingException(message, cause); + assertEquals(expectedMessage, jsonDecomposingException.getMessage()); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtils2Test.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtils2Test.java new file mode 100644 index 0000000000..667027f8de --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtils2Test.java @@ -0,0 +1,329 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.core.json; + + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; + +import org.json.JSONObject; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.core.xml.XmlTool; +import org.onap.so.exceptions.ValidationException; +import org.xmlunit.builder.DiffBuilder; +import org.xmlunit.diff.DefaultNodeMatcher; +import org.xmlunit.diff.Diff; +import org.xmlunit.diff.ElementSelectors; + +/** + * @version 1.0 + */ +public class JsonUtils2Test { + + private static final String EOL = "\n"; + private static final String XML_REQ = + "" + EOL + + " " + EOL + + " DEV-VF-0021" + EOL + + " CREATE_VF_MODULE" + EOL + + " PORTAL" + EOL + + " " + EOL + + " " + EOL + + " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + + " STMTN5MMSC21" + EOL + + " asc_heat-int" + EOL + + " STMTN5MMSC21-MMSC::module-0-0" + EOL + + " STMTN5MMSC21-MMSC::model-1-0" + EOL + + " true" + EOL + + " 00000000-0000-0000-0000-000000000000" + EOL + + " 1.0" + EOL + + " 999999999-0000-0000-0000-000000000000" + EOL + + " 1.5" + EOL + + " 00000000-0000-0000-0000-000000000000" + EOL + + " SDN-ETHERNET-INTERNET" + EOL + + " fba1bd1e195a404cacb9ce17a9b2b421" + EOL + + " pending-delete" + EOL + + " RDM2WAGPLCP" + EOL + + " 1" + EOL + + " " + EOL + + " " + EOL + + " network1111" + EOL + + " server1111" + EOL + + " " + EOL + + "" + EOL; + + private static final String XML_REQ_NO_ATTRS = + "" + EOL + + " " + EOL + + " DELETE_VF_MODULE" + EOL + + " PORTAL" + EOL + + " " + EOL + + " " + EOL + + " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + + " STMTN5MMSC21" + EOL + + " asc_heat-int" + EOL + + " 973ed047-d251-4fb9-bf1a-65b8949e0a73" + EOL + + " STMTN5MMSC21-MMSC::module-0-0" + EOL + + " 00000000-0000-0000-0000-000000000000" + EOL + + " SDN-ETHERNET-INTERNET" + EOL + + " fba1bd1e195a404cacb9ce17a9b2b421" + EOL + + " pending-delete" + EOL + + " RDM2WAGPLCP" + EOL + + " " + EOL + + " " + EOL + + "" + EOL; + + private static final String XML_ARRAY_REQ = + "" + EOL + + " BROADBAND" + EOL + + " IVLAN" + EOL + + " SHELLUCPE31" + EOL + + " " + EOL + + " " + EOL + + " AVPN" + EOL + + " 1000BASE-T" + EOL + + " ATT" + EOL + + " BT/SLIR/70911" + EOL + + " Active" + EOL + + " WAN1" + EOL + + " ATT" + EOL + + " 100" + EOL + + " ELECTRICAL" + EOL + + " " + EOL + + " " + EOL + + " AVPN" + EOL + + " 10/100/1000BASE-T" + EOL + + " ATT" + EOL + + " AS/KRFN/34611" + EOL + + " Active" + EOL + + " WAN2" + EOL + + " ATT" + EOL + + " 10000" + EOL + + " MMF" + EOL + + " " + EOL + + " " + EOL + + " ASD-987-M31" + EOL + + " USOSTCDALTX0101UJZZ31" + EOL + + " FG-VM00*" + EOL + + ""; + + // JSON request w/ embedded XML will be read from a file + private static String jsonReq; + private static String jsonReqArray; + + @BeforeClass + public static void initialize() throws Exception { + jsonReq = readFileToString("src/test/resources/request.json"); + jsonReqArray = readFileToString("src/test/resources/requestArray.json"); + } + + private static String readFileToString(String path) throws IOException { + File file = new File(path); + return new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); + } + + @Test + public void shouldConvertXmlToJsonAndBackToSameXml() throws Exception { + // Note: the current version of the JsonUtils.json2xml() method + // does not support converting the JSONObject representation + // of XML attributes (JSONArray) back to XML. So this test will + // only succeed if the original XML does not contain attributes + + // given + String xmlIn = XmlTool.removeNamespaces(XML_REQ_NO_ATTRS); + // when + String json = JsonUtils.xml2json(XML_REQ_NO_ATTRS); + String xmlOut = JsonUtils.json2xml(json); + // then + Diff diffXml = DiffBuilder.compare(xmlIn).withTest(xmlOut).ignoreWhitespace() + .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)).checkForSimilar().build(); + + assertFalse(diffXml.hasDifferences()); + } + + @Test + public void shouldReadValuesForAbsoluteJsonPaths() throws Exception { + // given + String json = JsonUtils.xml2json(XML_REQ); + // when, then + assertEquals("STMTN5MMSC21", JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-name")); + assertEquals("CREATE_VF_MODULE", JsonUtils.getJsonValue(json, "vnf-request.request-info.action")); + assertEquals("1", JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.persona-model-version")); + assertEquals("1.5", JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-persona-model-version")); + assertEquals("true", JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.is-base-module")); + } + + @Test + public void shouldReturnValueForJsonKey() throws Exception { + // given + String json = JsonUtils.xml2json(XML_REQ); + // when, then + assertEquals("PORTAL", JsonUtils.getJsonValueForKey(json, "source")); + } + + @Test + public void shouldReturnNullForNonexistentJsonNode() throws Exception { + // given + String json = JsonUtils.xml2json(XML_REQ); + // when, then + assertNull(JsonUtils.getJsonValueForKey(json, "nonexistent-node")); + } + + @Test + public void shouldReturnNullForNonExistentParameter() throws Exception { + // given + String json = JsonUtils.xml2json(XML_REQ); + // when, then + assertNull(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.bad")); + } + + @Test + public void shouldGetJasonParametersFromArray() throws Exception { + // given + String json = JsonUtils.xml2json(XML_REQ); + // when, then + assertEquals("network", JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name")); + assertEquals("network1111", JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "content")); + assertEquals("server", JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name", 1)); + assertEquals("server1111", JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "content", 1)); + assertNull(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "badParam")); + assertNull(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name", 2)); + } + + @Test + public void shouldAddJsonValue() throws Exception { + // given + String json = JsonUtils.xml2json(XML_REQ); + String key = "vnf-request.request-info.comment"; + String value = "Some comment"; + // when + String jsonUpd = JsonUtils.addJsonValue(json, key, value); + // then + String extractedValue = JsonUtils.getJsonValue(jsonUpd, key); + assertEquals(value, extractedValue); + } + + @Test + public void shouldIgnoreAddIfFieldAlreadyExists() throws Exception { + // given + String json = JsonUtils.xml2json(XML_REQ); + String key = "vnf-request.vnf-inputs.vnf-name"; + String newValue = "STMTN5MMSC22"; + // when + String jsonUpd = JsonUtils.addJsonValue(json, key, newValue); + // then + String extractedValue = JsonUtils.getJsonValue(jsonUpd, key); + assertNotEquals(newValue, extractedValue); + } + + @Test + public void shouldUpdateValueInJson() throws Exception { + // given + String json = JsonUtils.xml2json(XML_REQ); + String key = "vnf-request.vnf-inputs.vnf-name"; + String newValue = "STMTN5MMSC22"; + String oldValue = JsonUtils.getJsonValue(json, key); + // when + String jsonUpd = JsonUtils.updJsonValue(json, key, newValue); + // then + String extractedValue = JsonUtils.getJsonValue(jsonUpd, key); + assertEquals(newValue, extractedValue); + } + + @Test + public void shouldDeleteValue() throws Exception { + // given + String json = JsonUtils.xml2json(XML_REQ); + String key = "vnf-request.vnf-inputs.vnf-name"; + // when + String jsonUpd = JsonUtils.delJsonValue(json, key); + // then + String extractedValue = JsonUtils.getJsonValue(jsonUpd, key); + assertNull(extractedValue); + JSONObject jsonObj = new JSONObject(json); + Integer intValue = JsonUtils.getJsonIntValueForKey(jsonObj, "persona-model-version"); + Assert.assertTrue(intValue == 1); + Boolean boolValue = JsonUtils.getJsonBooleanValueForKey(jsonObj, "is-base-module"); + Assert.assertTrue(boolValue); + } + + @Test + public void shouldReturnOriginalJsonWhenTryingToRemoveNonexistentField() throws Exception { + // given + String json = JsonUtils.xml2json(XML_REQ); + String key = "vnf-request.vnf-inputs.does-not-exist"; + // when + String jsonUpd = JsonUtils.delJsonValue(json, key); + // then + assertEquals(json, jsonUpd); + } + + @Test + public void shouldConvertXmlToJsonAndBackToSameXmlExtractedFromTheRequest() throws Exception { + // given + String value = JsonUtils.getJsonValue(jsonReq, "variables.bpmnRequest.value"); + String xmlReq = XmlTool.removeNamespaces(XmlTool.normalize(value)); + // when + String json = JsonUtils.xml2json(xmlReq); + String xmlOut = JsonUtils.json2xml(json); + // then + Diff diffXml = DiffBuilder.compare(xmlReq).withTest(xmlOut).ignoreWhitespace() + .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)).checkForSimilar().build(); + assertFalse(diffXml.hasDifferences()); + } + + @Test + public void shouldConvertJsonContainingArrayToXml() throws Exception { + // when + String jsonParm = JsonUtils.getJsonNodeValue(jsonReqArray, "requestDetails.requestParameters.ucpeInfo"); + String xmlOut = JsonUtils.json2xml(jsonParm); + // then + Diff diffXml = DiffBuilder.compare(XML_ARRAY_REQ).withTest(xmlOut).ignoreWhitespace() + .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)).checkForSimilar().build(); + assertFalse(diffXml.hasDifferences()); + } + + @Test + // Tests the jsonSchemaValidation() method + public void testJsonSchemaValidation() { + try { + String myReqArray = jsonReqArray; + String result = JsonUtils.jsonSchemaValidation(myReqArray, "src/test/resources/requestSchema.json"); + System.out.println("Schema Validation Result: " + result); + Assert.assertTrue(result.contains("success")); + // remove a required parameter from the JSON doc so that validation fails + myReqArray = JsonUtils.delJsonValue(myReqArray, "requestDetails.requestParameters.ucpeInfo.ucpeHostName"); + result = JsonUtils.jsonSchemaValidation(myReqArray, "src/test/resources/requestSchema.json"); + System.out.println("Schema Validation Result: " + result); + Assert.assertTrue(result.contains("failure")); + Assert.assertTrue(result.contains("error: object has missing required properties ([\"ucpeHostName\"])")); + } catch (ValidationException e) { + e.printStackTrace(); + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java new file mode 100644 index 0000000000..07523ca931 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java @@ -0,0 +1,233 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.core.json; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.runtime.Execution; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.onap.so.exceptions.ValidationException; + +public class JsonUtilsTest { + + @Mock public DelegateExecution execution; + @Mock public Execution mockEexecution; + private final String fileLocation = "src/test/resources/json-examples/"; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Test + public void jsonStringToMapTest() throws IOException { + + JsonUtils utils = new JsonUtils(); + String response = this.getJson("SDNCServiceResponseExample.json"); + String entry = JsonUtils.getJsonValue(response, "SDNCServiceResponse.params"); + Map map = utils.jsonStringToMap(execution, entry); + assertEquals(map.get("e2e-vpn-key"), "my-key"); + } + + @Test + public void entryArrayToMapTest() throws IOException { + JsonUtils utils = new JsonUtils(); + String response = this.getJson("SNIROExample.json"); + String entry = JsonUtils.getJsonValue(response, "solutionInfo.placementInfo"); + JSONArray arr = new JSONArray(entry); + JSONObject homingDataJson = arr.getJSONObject(0); + JSONArray assignmentInfo = homingDataJson.getJSONArray("assignmentInfo"); + Map map = utils.entryArrayToMap(execution, assignmentInfo.toString(), "variableName", "variableValue"); + assertEquals(map.get("cloudOwner"), "att-aic"); + } + @Test + public void entryArrayToMapStringTest() throws IOException { + JsonUtils utils = new JsonUtils(); + String response = this.getJson("SNIROExample.json"); + String entry = JsonUtils.getJsonValue(response, "solutionInfo.placementInfo"); + JSONArray arr = new JSONArray(entry); + JSONObject homingDataJson = arr.getJSONObject(0); + JSONArray assignmentInfo = homingDataJson.getJSONArray("assignmentInfo"); + Map map = utils.entryArrayToMap(assignmentInfo.toString(), "variableName", "variableValue"); + assertEquals(map.get("cloudOwner"), "att-aic"); + } + @Test + public void getJsonRootPropertyTest() throws IOException { + String response = this.getJson("SDNCServiceResponseExample.json"); + assertEquals("SDNCServiceResponse",JsonUtils.getJsonRootProperty(response)); + } + @Test + public void getJsonRootProperty_ExceptionTest() throws IOException { + expectedException.expect(JSONException.class); + String response = this.getJson("SNIROExample.json"); + String root = JsonUtils.getJsonRootProperty(response); + } + @Test + public void getJsonNodeValueTest() throws IOException { + String response = this.getJson("SDNCServiceResponseExample.json"); + String code = JsonUtils.getJsonNodeValue(response,"SDNCServiceResponse.responseCode"); + assertEquals("200", code); + } + @Test + public void stringArrayToList_jsonStringTest() throws IOException { + String response = this.getJson("SNIROExample.json"); + String licenseInfo = JsonUtils.getJsonNodeValue(response,"solutionInfo.licenseInfo"); + JsonUtils utils = new JsonUtils(); + List listString = utils.StringArrayToList(licenseInfo); + assertNotNull(listString.get(0)); + } + @Test + public void stringArrayToList_JSONArrayTest() throws IOException { + String response = this.getJson("SNIROExample.json"); + String licenseInfo = JsonUtils.getJsonNodeValue(response,"solutionInfo.licenseInfo"); + JSONArray jsonArray = new JSONArray(licenseInfo); + JsonUtils utils = new JsonUtils(); + List listString = utils.StringArrayToList(jsonArray); + assertNotNull(listString.get(0)); + } + @Test + public void stringArrayToList_withExecutionTest() throws IOException { + String response = this.getJson("SNIROExample.json"); + String licenseInfo = JsonUtils.getJsonNodeValue(response,"solutionInfo.licenseInfo"); + JsonUtils utils = new JsonUtils(); + List listString = utils.StringArrayToList(mockEexecution, licenseInfo); + assertNotNull(listString.get(0)); + } + @Test + public void jsonElementExist_trueTest() throws IOException { + String response = this.getJson("SDNCServiceResponseExample.json"); + boolean isExist = JsonUtils.jsonElementExist(response,"SDNCServiceResponse.responseCode"); + assertEquals(true, isExist); + } + @Test + public void jsonElementExist_falseTest() throws IOException { + String response = this.getJson("SDNCServiceResponseExample.json"); + boolean isExist = JsonUtils.jsonElementExist(response,"SDNCServiceResponse.responseX"); + assertEquals(false, isExist); + } + @Test + public void jsonElementExist_NullTest() throws IOException { + String response = this.getJson("SDNCServiceResponseExample.json"); + boolean isExist = JsonUtils.jsonElementExist(response, null); + assertEquals(true, isExist); + } + @Test + public void jsonSchemaValidation_ExceptionTest() throws IOException, ValidationException { + expectedException.expect(ValidationException.class); + String response = this.getJson("SDNCServiceResponseExample.json"); + String isExist = JsonUtils.jsonSchemaValidation(response, fileLocation); + } + @Test + public void getJsonIntValueTest() throws IOException { + String response = this.getJson("SDNCServiceResponseExample.json"); + int intValue = JsonUtils.getJsonIntValue(response,"SDNCServiceResponse.responseCode"); + assertEquals(0, intValue); + } + @Test + public void getJsonBooleanValueTest() throws IOException { + String response = this.getJson("SDNCServiceResponseExample.json"); + boolean isBoolean = JsonUtils.getJsonBooleanValue(response,"SDNCServiceResponse.responseCode"); + assertEquals(false, isBoolean); + } + @Test + public void prettyJsonTest() throws IOException { + String response = this.getJson("SNIROExample.json"); + assertNotNull(JsonUtils.prettyJson(response)); + String malformedJson = "{\"name\" \"myName\"}"; + assertNull(JsonUtils.prettyJson(malformedJson)); + } + @Test + public void xml2jsonTest() throws IOException { + String expectedJson = "{\"name\":\"myName\"}"; + String xml = "myName"; + assertEquals(expectedJson, JsonUtils.xml2json(xml,false)); + } + @Test + public void xml2jsonErrorTest() throws IOException { + String malformedXml = "myName"; + assertNull(JsonUtils.xml2json(malformedXml)); + } + @Test + public void json2xmlTest() throws IOException { + String expectedXml = "myName"; + String malformedJson = "{\"name\":\"myName\"}"; + assertEquals(expectedXml, JsonUtils.json2xml(malformedJson, false)); + } + @Test + public void json2xmlErrorTest() throws IOException { + String malformedJson = "{\"name\" \"myName\"}"; + assertNull(JsonUtils.json2xml(malformedJson)); + } + @Test + public void getJsonValueErrorTest() throws IOException { + String response = this.getJson("SDNCServiceResponseExample.json"); + assertNull(JsonUtils.getJsonValue(response,null)); + } + @Test + public void getJsonNodeValueErrorTest() throws IOException { + String response = this.getJson("SDNCServiceResponseExample.json"); + assertNull(JsonUtils.getJsonNodeValue(response,null)); + } + @Test + public void getJsonIntValueErrorTest() throws IOException { + String response = this.getJson("SDNCServiceResponseExample.json"); + assertEquals(0, JsonUtils.getJsonIntValue(response,null)); + } + @Test + public void getJsonBooleanValueErrorTest() throws IOException { + String response = this.getJson("SDNCServiceResponseExample.json"); + assertEquals(false, JsonUtils.getJsonBooleanValue(response,null)); + } + @Test + public void getJsonValueForKeyErrorTest() throws IOException { + String malformedJson = "{\"name\" \"myName\"}"; + assertNull(JsonUtils.getJsonValueForKey(malformedJson, "name")); + } + @Test + public void updJsonValueTest() throws IOException { + String expectedJson = "{\"name\": \"yourName\"}"; + String json = "{\"name\":\"myName\"}"; + assertEquals(expectedJson, JsonUtils.updJsonValue(json, "name", "yourName")); + } + @Test + public void updJsonValueErrorTest() throws IOException { + String expectedJson = "{\"name\" \"myName\"}"; + String json = "{\"name\" \"myName\"}"; + assertEquals(expectedJson, JsonUtils.updJsonValue(json, "name", "yourName")); + } + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/utils/CamundaDBSetup.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/utils/CamundaDBSetup.java new file mode 100644 index 0000000000..f3cc094873 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/utils/CamundaDBSetup.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.core.utils; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +import org.onap.so.logger.MsoLogger; + +/** + * Sets up the unit test (H2) database for Camunda. + */ +public class CamundaDBSetup { + private static boolean isDBConfigured = false; + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CamundaDBSetup.class); + + private CamundaDBSetup() { + } + + public static synchronized void configure() throws SQLException { + if (isDBConfigured) { + return; + } + + LOGGER.debug ("Configuring the Camunda H2 database for MSO"); + + Connection connection = null; + PreparedStatement stmt = null; + + try { + + + isDBConfigured = true; + + } finally { + if (stmt != null) { + try { + stmt.close(); + } catch (Exception e) { + LOGGER.debug("Exception :",e); + } + } + + if (connection != null) { + try { + connection.close(); + } catch (Exception e) { + LOGGER.debug("Exception :",e); + } + } + } + } +} \ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/xml/XmlToolTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/xml/XmlToolTest.java new file mode 100644 index 0000000000..6bad0c6c29 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/xml/XmlToolTest.java @@ -0,0 +1,82 @@ +/* +* ============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.onap.so.bpmn.core.xml; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.Optional; + +import org.junit.Test; + +public class XmlToolTest { + + private String response = "good"; + private String responseModified = "veryGood"; + private String encodeResponse = "<Response>good</Response>"; + private String encodeResponseNamespace = "good"; + private String attribute = "good&\"bad\""; + private String updatedAttribute = "<Response>good&"bad"</Response>"; + + private String content = "" + + "test" + + "test" + + "123" + + "" + + "test" + + "test" + + ""; + + @Test + public void test() throws Exception { + Object xmlMessage = new String(response); + String xmlResponse = XmlTool.normalize(xmlMessage); + assertEquals(response, xmlResponse.toString()); + String xmlEncode = XmlTool.encode(xmlMessage); + assertEquals(encodeResponse, xmlEncode.toString()); + Optional optXml = XmlTool.modifyElement(response, "Response", "veryGood"); + Object obj1 = new String(optXml.get().toString()); + String noPreamble = XmlTool.removePreamble(obj1); + assertEquals(responseModified, noPreamble.toString()); + Object obj2 = new String(encodeResponseNamespace); + String noNamespace = XmlTool.removeNamespaces(obj2); + assertEquals(response, noNamespace.toString()); + Object obj3 = new String(attribute); + + assertEquals(null, XmlTool.normalize(null)); + assertEquals(null, XmlTool.encode(null)); + assertEquals(null, XmlTool.removePreamble(null)); + assertEquals(null, XmlTool.removeNamespaces(null)); + assertEquals(Optional.empty(), XmlTool.modifyElement(null, "Response", "veryGood")); + } + + @Test + public void normalizeTest() throws Exception { + String response = XmlTool.normalize(content); + assertNotNull(response); + } + + @Test + public void modifyElementTest() throws Exception { + String response = XmlTool.modifyElement(content, "event-type", "uCPE-VMS").get(); + assertNotNull(response); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/HealthCheckHandlerTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/HealthCheckHandlerTest.java deleted file mode 100644 index 1086cc75ef..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/HealthCheckHandlerTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============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 - * - * 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.core; - -import org.junit.Test; - -public class HealthCheckHandlerTest { - - HealthCheckHandler healthCheckHandler = new HealthCheckHandler(); - - @Test - public void nodeHealthcheck() throws Exception { - healthCheckHandler.nodeHealthcheck(); - } - - @Test - public void healthcheck() throws Exception { - healthCheckHandler.healthcheck("test-123"); - } - -} \ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java deleted file mode 100644 index 9643db7834..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java +++ /dev/null @@ -1,356 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -/*- - * ============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.core; - - - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; - -import org.json.JSONObject; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openecomp.mso.apihandler.common.ValidationException; -import org.openecomp.mso.bpmn.core.json.JsonUtils; -import org.openecomp.mso.bpmn.core.xml.XmlTool; -import org.xmlunit.builder.DiffBuilder; -import org.xmlunit.diff.DefaultNodeMatcher; -import org.xmlunit.diff.Diff; -import org.xmlunit.diff.ElementSelectors; - -/** - * @version 1.0 - */ -public class JsonUtilsTest { - - private static final String EOL = "\n"; - private static final String XML_REQ = - "" + EOL + - " " + EOL + - " DEV-VF-0021" + EOL + - " CREATE_VF_MODULE" + EOL + - " PORTAL" + EOL + - " " + EOL + - " " + EOL + - " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + - " STMTN5MMSC21" + EOL + - " asc_heat-int" + EOL + - " STMTN5MMSC21-MMSC::module-0-0" + EOL + - " STMTN5MMSC21-MMSC::model-1-0" + EOL + - " true" + EOL + - " 00000000-0000-0000-0000-000000000000" + EOL + - " 1.0" + EOL + - " 999999999-0000-0000-0000-000000000000" + EOL + - " 1.5" + EOL + - " 00000000-0000-0000-0000-000000000000" + EOL + - " SDN-ETHERNET-INTERNET" + EOL + - " fba1bd1e195a404cacb9ce17a9b2b421" + EOL + - " pending-delete" + EOL + - " RDM2WAGPLCP" + EOL + - " 1" + EOL + - " " + EOL + - " " + EOL + - " network1111" + EOL + - " server1111" + EOL + - " " + EOL + - "" + EOL; - - private static final String XML_REQ_NO_ATTRS = - "" + EOL + - " " + EOL + - " DELETE_VF_MODULE" + EOL + - " PORTAL" + EOL + - " " + EOL + - " " + EOL + - " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + - " STMTN5MMSC21" + EOL + - " asc_heat-int" + EOL + - " 973ed047-d251-4fb9-bf1a-65b8949e0a73" + EOL + - " STMTN5MMSC21-MMSC::module-0-0" + EOL + - " 00000000-0000-0000-0000-000000000000" + EOL + - " SDN-ETHERNET-INTERNET" + EOL + - " fba1bd1e195a404cacb9ce17a9b2b421" + EOL + - " pending-delete" + EOL + - " RDM2WAGPLCP" + EOL + - " " + EOL + - " " + EOL + - "" + EOL; - - private static final String XML_ARRAY_REQ = - "" + EOL + - " BROADBAND" + EOL + - " IVLAN" + EOL + - " SHELLUCPE31" + EOL + - " " + EOL + - " " + EOL + - " AVPN" + EOL + - " 1000BASE-T" + EOL + - " ATT" + EOL + - " BT/SLIR/70911" + EOL + - " Active" + EOL + - " WAN1" + EOL + - " ATT" + EOL + - " 100" + EOL + - " ELECTRICAL" + EOL + - " " + EOL + - " " + EOL + - " AVPN" + EOL + - " 10/100/1000BASE-T" + EOL + - " ATT" + EOL + - " AS/KRFN/34611" + EOL + - " Active" + EOL + - " WAN2" + EOL + - " ATT" + EOL + - " 10000" + EOL + - " MMF" + EOL + - " " + EOL + - " " + EOL + - " ASD-987-M31" + EOL + - " USOSTCDALTX0101UJZZ31" + EOL + - " FG-VM00*" + EOL + - ""; - - // JSON request w/ embedded XML will be read from a file - private static String jsonReq; - private static String jsonReqArray; - - @BeforeClass - public static void initialize() throws Exception { - jsonReq = readFileToString("src/test/resources/request.json"); - jsonReqArray = readFileToString("src/test/resources/requestArray.json"); - } - - private static String readFileToString(String path) throws IOException { - File file = new File(path); - return new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); - } - - @Test - public void shouldConvertXmlToJsonAndBackToSameXml() throws Exception { - // Note: the current version of the JsonUtils.json2xml() method - // does not support converting the JSONObject representation - // of XML attributes (JSONArray) back to XML. So this test will - // only succeed if the original XML does not contain attributes - - // given - String xmlIn = XmlTool.removeNamespaces(XML_REQ_NO_ATTRS); - // when - String json = JsonUtils.xml2json(XML_REQ_NO_ATTRS); - String xmlOut = JsonUtils.json2xml(json); - // then - Diff diffXml = DiffBuilder.compare(xmlIn).withTest(xmlOut).ignoreWhitespace() - .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)).checkForSimilar().build(); - - assertThat(diffXml.hasDifferences()).withFailMessage(diffXml.toString()).isFalse(); - } - - @Test - public void shouldReadValuesForAbsoluteJsonPaths() throws Exception { - // given - String json = JsonUtils.xml2json(XML_REQ); - // when, then - assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-name")).isEqualTo("STMTN5MMSC21"); - assertThat(JsonUtils.getJsonValue(json, "vnf-request.request-info.action")).isEqualTo("CREATE_VF_MODULE"); - assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.persona-model-version")).isEqualTo("1"); - assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-persona-model-version")).isEqualTo("1.5"); - assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.is-base-module")).isEqualTo("true"); - } - - @Test - public void shouldReturnValueForJsonKey() throws Exception { - // given - String json = JsonUtils.xml2json(XML_REQ); - // when, then - assertThat(JsonUtils.getJsonValueForKey(json, "source")).isEqualTo("PORTAL"); - } - - @Test - public void shouldReturnNullForNonexistentJsonNode() throws Exception { - // given - String json = JsonUtils.xml2json(XML_REQ); - // when, then - assertThat(JsonUtils.getJsonValueForKey(json, "nonexistent-node")).isNull(); - } - - @Test - public void shouldReturnNullForNonExistentParameter() throws Exception { - // given - String json = JsonUtils.xml2json(XML_REQ); - // when, then - assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.bad")).isNull(); - } - - @Test - public void shouldGetJasonParametersFromArray() throws Exception { - // given - String json = JsonUtils.xml2json(XML_REQ); - // when, then - assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name")).isEqualTo("network"); - assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "content")) - .isEqualTo("network1111"); - assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name", 1)).isEqualTo("server"); - assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "content", 1)) - .isEqualTo("server1111"); - assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "badParam")) - .withFailMessage("Expected null for nonexistent param").isNull(); - assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name", 2)) - .withFailMessage("Expected null for index out of bound").isNull(); - } - - @Test - public void shouldAddJsonValue() throws Exception { - // given - String json = JsonUtils.xml2json(XML_REQ); - String key = "vnf-request.request-info.comment"; - String value = "Some comment"; - // when - String jsonUpd = JsonUtils.addJsonValue(json, key, value); - // then - String extractedValue = JsonUtils.getJsonValue(jsonUpd, key); - assertThat(extractedValue).isEqualTo(value); - } - - @Test - public void shouldIgnoreAddIfFieldAlreadyExists() throws Exception { - // given - String json = JsonUtils.xml2json(XML_REQ); - String key = "vnf-request.vnf-inputs.vnf-name"; - String newValue = "STMTN5MMSC22"; - String oldValue = JsonUtils.getJsonValue(json, key); - // when - String jsonUpd = JsonUtils.addJsonValue(json, key, newValue); - // then - String extractedValue = JsonUtils.getJsonValue(jsonUpd, key); - assertThat(extractedValue).isEqualTo(oldValue).isNotEqualTo(newValue); - } - - @Test - public void shouldUpdateValueInJson() throws Exception { - // given - String json = JsonUtils.xml2json(XML_REQ); - String key = "vnf-request.vnf-inputs.vnf-name"; - String newValue = "STMTN5MMSC22"; - String oldValue = JsonUtils.getJsonValue(json, key); - // when - String jsonUpd = JsonUtils.updJsonValue(json, key, newValue); - // then - String extractedValue = JsonUtils.getJsonValue(jsonUpd, key); - assertThat(extractedValue).isNotEqualTo(oldValue).isEqualTo(newValue); - } - - @Test - public void shouldDeleteValue() throws Exception { - // given - String json = JsonUtils.xml2json(XML_REQ); - String key = "vnf-request.vnf-inputs.vnf-name"; - String oldValue = JsonUtils.getJsonValue(json, key); - // when - String jsonUpd = JsonUtils.delJsonValue(json, key); - // then - String extractedValue = JsonUtils.getJsonValue(jsonUpd, key); - assertThat(extractedValue).isNotEqualTo(oldValue).isNull(); - JSONObject jsonObj = new JSONObject(json); - Integer intValue = JsonUtils.getJsonIntValueForKey(jsonObj, "persona-model-version"); - Assert.assertTrue(intValue == 1); - Boolean boolValue = JsonUtils.getJsonBooleanValueForKey(jsonObj, "is-base-module"); - Assert.assertTrue(boolValue); - } - - @Test - public void shouldReturnOriginalJsonWhenTryingToRemoveNonexistentField() throws Exception { - // given - String json = JsonUtils.xml2json(XML_REQ); - String key = "vnf-request.vnf-inputs.does-not-exist"; - // when - String jsonUpd = JsonUtils.delJsonValue(json, key); - // then - assertThat(jsonUpd).isEqualTo(json); - } - - @Test - public void shouldConvertXmlToJsonAndBackToSameXmlExtractedFromTheRequest() throws Exception { - // given - String value = JsonUtils.getJsonValue(jsonReq, "variables.bpmnRequest.value"); - String xmlReq = XmlTool.removeNamespaces(XmlTool.normalize(value)); - // when - String json = JsonUtils.xml2json(xmlReq); - String xmlOut = JsonUtils.json2xml(json); - // then - Diff diffXml = DiffBuilder.compare(xmlReq).withTest(xmlOut).ignoreWhitespace() - .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)).checkForSimilar().build(); - assertThat(diffXml.hasDifferences()).withFailMessage(diffXml.toString()).isFalse(); - } - - @Test - public void shouldConvertJsonContainingArrayToXml() throws Exception { - // when - String jsonParm = JsonUtils.getJsonNodeValue(jsonReqArray, "requestDetails.requestParameters.ucpeInfo"); - String xmlOut = JsonUtils.json2xml(jsonParm); - // then - Diff diffXml = DiffBuilder.compare(XML_ARRAY_REQ).withTest(xmlOut).ignoreWhitespace() - .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)).checkForSimilar().build(); - assertThat(diffXml.hasDifferences()).withFailMessage(diffXml.toString()).isFalse(); - } - - @Test - // Tests the jsonSchemaValidation() method - public void testJsonSchemaValidation() { - try { - String myReqArray = jsonReqArray; - String result = JsonUtils.jsonSchemaValidation(myReqArray, "src/test/resources/requestSchema.json"); - System.out.println("Schema Validation Result: " + result); - Assert.assertTrue(result.contains("success")); - // remove a required parameter from the JSON doc so that validation fails - myReqArray = JsonUtils.delJsonValue(myReqArray, "requestDetails.requestParameters.ucpeInfo.ucpeHostName"); - result = JsonUtils.jsonSchemaValidation(myReqArray, "src/test/resources/requestSchema.json"); - System.out.println("Schema Validation Result: " + result); - Assert.assertTrue(result.contains("failure")); - Assert.assertTrue(result.contains("error: object has missing required properties ([\"ucpeHostName\"])")); - } catch (ValidationException e) { - e.printStackTrace(); - } - } -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/PropertyConfigurationTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/PropertyConfigurationTest.java deleted file mode 100644 index 57a512891f..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/PropertyConfigurationTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -/*- - * ============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.core; - -import java.io.IOException; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - - -public class PropertyConfigurationTest { - @Before - public void beforeTest() throws IOException { - PropertyConfiguration.resetPropertyConfigurationSingletonInstance(); - - Map defaultProperties = PropertyConfigurationSetup.createBpmnProperties(); - defaultProperties.put("testValue", "testKey"); - PropertyConfigurationSetup.init(defaultProperties); - } - - @Test - public void testPropertyFileWatcher() throws InterruptedException, IOException { - Assert.assertEquals(true, PropertyConfiguration.getInstance().isFileWatcherRunning()); - } - - @Test - public void testPropertyLoading() throws IOException, InterruptedException { - PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); - Map props = propertyConfiguration.getProperties(PropertyConfiguration.MSO_BPMN_PROPERTIES); - Assert.assertNotNull(props); - Assert.assertEquals("testValue", props.get("testKey")); - } - - @Test - public void testPropertyReload() throws IOException, InterruptedException { - PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); - Map properties = propertyConfiguration.getProperties(PropertyConfiguration.MSO_BPMN_PROPERTIES); - Assert.assertNotNull(properties); - Assert.assertEquals("testValue", properties.get("testKey")); - - Map newProperties = PropertyConfigurationSetup.createBpmnProperties(); - newProperties.put("newKey", "newValue"); - PropertyConfigurationSetup.addProperties(newProperties, 10000); - - // Reload and check for the new value - properties = propertyConfiguration.getProperties(PropertyConfiguration.MSO_BPMN_PROPERTIES); - Assert.assertNotNull(properties); - Assert.assertEquals("newValue", properties.get("newKey")); - } - - @Test(expected=IllegalArgumentException.class) - public void testPropertyFileDoesNotExists_NotIntheList() throws IOException { - PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); - propertyConfiguration.getProperties("badfile.properties"); - Assert.fail("Expected IllegalArgumentException"); - } - - @Test(expected=java.lang.UnsupportedOperationException.class) - public void testPropertyModificationException() throws IOException { - PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); - Map props = propertyConfiguration.getProperties(PropertyConfiguration.MSO_BPMN_PROPERTIES); - Assert.assertNotNull(props); - Assert.assertEquals("testValue", props.get("testKey")); - props.put("newKey", "newvalue"); - } -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataTest.java deleted file mode 100644 index c51af23e30..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.core; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.entry; - -import org.junit.Test; - -public class RollbackDataTest { - - private final static String TYPE_A = "typeA"; - private final static String TYPE_B = "typeB"; - private static final String KEY_1 = "key1"; - private static final String VALUE_1 = "value1"; - private static final String VALUE_2 = "value2"; - - @Test - public void shouldReturnStringRepresentationOfDataInAnyPermutation() throws Exception { - // given - RollbackData data = new RollbackData(); - data.put(TYPE_A, KEY_1, VALUE_1); - data.put(TYPE_A, "key2", "value2"); - data.put(TYPE_B, "key3", "value3"); - // when, then - assertThat(data.toString()).isIn( - "[typeB{key3=value3},typeA{key1=value1, key2=value2}]", - "[typeB{key3=value3},typeA{key2=value2, key1=value1}]", - "[typeA{key1=value1, key2=value2},typeB{key3=value3}]", - "[typeA{key2=value2, key1=value1},typeB{key3=value3}]"); - } - - @Test - public void shouldBeEmptyOnCreation() throws Exception { - // given - RollbackData data = new RollbackData(); - // then - assertThat(data.hasType(TYPE_A)).isFalse(); - assertThat(data.get(TYPE_A, KEY_1)).isNull(); - } - - @Test - public void shouldHaveTypeAfterPuttingDataOfThatType() throws Exception { - // given - RollbackData data = new RollbackData(); - // when - data.put(TYPE_A, KEY_1, VALUE_1); - // then - assertThat(data.hasType(TYPE_A)).isTrue(); - assertThat(data.hasType(TYPE_B)).isFalse(); - assertThat(data.get(TYPE_A, KEY_1)).isEqualTo(VALUE_1); - } - - @Test - public void shouldKeepTwoValuesWithSameKeysButDifferentTypes() throws Exception { - // given - RollbackData data = new RollbackData(); - // when - data.put(TYPE_A, KEY_1, VALUE_1); - data.put(TYPE_B, KEY_1, VALUE_2); - // then - assertThat(data.get(TYPE_A, KEY_1)).isEqualTo(VALUE_1); - assertThat(data.get(TYPE_A)).containsExactly(entry(KEY_1, VALUE_1)); - assertThat(data.get(TYPE_B, KEY_1)).isEqualTo(VALUE_2); - assertThat(data.get(TYPE_B)).containsExactly(entry(KEY_1, VALUE_2)); - } -} \ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java deleted file mode 100644 index 1346fde674..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java +++ /dev/null @@ -1,271 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.core; - -import static org.junit.Assert.assertNotNull; - -import java.util.HashMap; -import java.util.Map; - -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.Expression; -import org.camunda.bpm.engine.test.Deployment; -import org.camunda.bpm.engine.test.ProcessEngineRule; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; - -import org.openecomp.mso.bpmn.core.utils.CamundaDBSetup; -import org.openecomp.mso.logger.MsoLogger; - -/** - * Unit test for BaseTask class. - */ -public class TestBaseTask { - - @Rule - public ProcessEngineRule processEngineRule = new ProcessEngineRule(); - - @BeforeClass - public static void setUpClass() { - System.setProperty("mso.config.path", "src/test/resources"); - PropertyConfiguration.resetPropertyConfigurationSingletonInstance(); - } - - @Before - public void beforeTest() throws Exception { - CamundaDBSetup.configure(); - PropertyConfigurationSetup.init(); - } - - @Test - @Deployment(resources={"BaseTaskTest.bpmn"}) - public void shouldInvokeService() { - Map variables = new HashMap<>(); - variables.put("firstName", "Jane"); - variables.put("lastName", "Doe"); - variables.put("age", 25); - variables.put("lastVisit", 1438270117000L); - - RuntimeService runtimeService = processEngineRule.getRuntimeService(); - assertNotNull(runtimeService); - processEngineRule.getTaskService(); - runtimeService.startProcessInstanceByKey("BaseTaskTest", variables); - } - - /** - * Unit test code for BaseTask. - */ - public static class TestTask extends BaseTask { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - - private Expression existingString; - private Expression nonExistingString; - private Expression existingStringFromVar; - private Expression nonExistingStringFromVar; - - private Expression existingInteger; - private Expression nonExistingInteger; - private Expression existingIntegerFromVar; - private Expression nonExistingIntegerFromVar; - - private Expression existingLong; - private Expression nonExistingLong; - private Expression existingLongFromVar; - private Expression nonExistingLongFromVar; - - private Expression existingOutputVar; - private Expression nonExistingOutputVar; - private Expression existingBadOutputVar; - - public void execute(DelegateExecution execution) throws Exception { - msoLogger.debug("Started executing " + getClass().getSimpleName()); - - /*********************************************************************/ - msoLogger.debug("Running String Field Tests"); - /*********************************************************************/ - - String s = getStringField(existingString, execution, "existingString"); - Assert.assertEquals("Hello World", s); - - try { - s = getStringField(nonExistingString, execution, "nonExistingString"); - Assert.fail("Expected BadInjectedFieldException for nonExistingString"); - } catch (Exception e) { - if (!(e instanceof BadInjectedFieldException)) { - Assert.fail("Expected BadInjectedFieldException for nonExistingString"); - } - } - - s = getOptionalStringField(existingString, execution, "existingString"); - Assert.assertEquals("Hello World", s); - - s = getOptionalStringField(nonExistingString, execution, "nonExistingString"); - Assert.assertEquals(null, s); - - /*********************************************************************/ - msoLogger.debug("Running String Expression Tests"); - /*********************************************************************/ - - s = getStringField(existingStringFromVar, execution, "existingStringFromVar"); - Assert.assertEquals("Jane", s); - - try { - s = getStringField(nonExistingStringFromVar, execution, "nonExistingStringFromVar"); - Assert.fail("Expected BadInjectedFieldException for nonExistingString"); - } catch (Exception e) { - if (!(e instanceof BadInjectedFieldException)) { - Assert.fail("Expected BadInjectedFieldException for nonExistingStringFromVar"); - } - } - - s = getOptionalStringField(existingStringFromVar, execution, "existingStringFromVar"); - Assert.assertEquals("Jane", s); - - s = getOptionalStringField(nonExistingStringFromVar, execution, "nonExistingStringFromVar"); - Assert.assertEquals(null, s); - - /*********************************************************************/ - msoLogger.debug("Running Integer Field Tests"); - /*********************************************************************/ - - Integer i = getIntegerField(existingInteger, execution, "existingInteger"); - Assert.assertEquals((Integer)42, i); - - try { - i = getIntegerField(nonExistingInteger, execution, "nonExistingInteger"); - Assert.fail("Expected BadInjectedFieldException for nonExistingInteger"); - } catch (Exception e) { - if (!(e instanceof BadInjectedFieldException)) { - Assert.fail("Expected BadInjectedFieldException for nonExistingInteger"); - } - } - - i = getOptionalIntegerField(existingInteger, execution, "existingInteger"); - Assert.assertEquals((Integer)42, i); - - i = getOptionalIntegerField(nonExistingInteger, execution, "nonExistingInteger"); - Assert.assertEquals(null, i); - - /*********************************************************************/ - msoLogger.debug("Running Integer Expression Tests"); - /*********************************************************************/ - - i = getIntegerField(existingIntegerFromVar, execution, "existingIntegerFromVar"); - Assert.assertEquals((Integer)25, i); - - try { - i = getIntegerField(nonExistingIntegerFromVar, execution, "nonExistingIntegerFromVar"); - Assert.fail("Expected BadInjectedFieldException for nonExistingInteger"); - } catch (Exception e) { - if (!(e instanceof BadInjectedFieldException)) { - Assert.fail("Expected BadInjectedFieldException for nonExistingIntegerFromVar"); - } - } - - i = getOptionalIntegerField(existingIntegerFromVar, execution, "existingIntegerFromVar"); - Assert.assertEquals((Integer)25, i); - - i = getOptionalIntegerField(nonExistingIntegerFromVar, execution, "nonExistingIntegerFromVar"); - Assert.assertEquals(null, i); - - /*********************************************************************/ - msoLogger.debug("Running Long Field Tests"); - /*********************************************************************/ - - Long l = getLongField(existingLong, execution, "existingLong"); - Assert.assertEquals((Long)123456789L, l); - - try { - l = getLongField(nonExistingLong, execution, "nonExistingLong"); - Assert.fail("Expected BadInjectedFieldException for nonExistingLong"); - } catch (Exception e) { - if (!(e instanceof BadInjectedFieldException)) { - Assert.fail("Expected BadInjectedFieldException for nonExistingLong"); - } - } - - l = getOptionalLongField(existingLong, execution, "existingLong"); - Assert.assertEquals((Long)123456789L, l); - - l = getOptionalLongField(nonExistingLong, execution, "nonExistingLong"); - Assert.assertEquals(null, l); - - /*********************************************************************/ - msoLogger.debug("Running Long Expression Tests"); - /*********************************************************************/ - - l = getLongField(existingLongFromVar, execution, "existingLongFromVar"); - Assert.assertEquals((Long)1438270117000L, l); - - try { - l = getLongField(nonExistingLongFromVar, execution, "nonExistingLongFromVar"); - Assert.fail("Expected BadInjectedFieldException for nonExistingLong"); - } catch (Exception e) { - if (!(e instanceof BadInjectedFieldException)) { - Assert.fail("Expected BadInjectedFieldException for nonExistingLongFromVar"); - } - } - - l = getOptionalLongField(existingLongFromVar, execution, "existingLongFromVar"); - Assert.assertEquals((Long)1438270117000L, l); - - l = getOptionalLongField(nonExistingLongFromVar, execution, "nonExistingLongFromVar"); - Assert.assertEquals(null, i); - - /*********************************************************************/ - msoLogger.debug("Running Output Variable Field Tests"); - /*********************************************************************/ - - String var = getOutputField(existingOutputVar, execution, "existingOutputVar"); - Assert.assertEquals("goodVariable", var); - - try { - var = getOutputField(nonExistingOutputVar, execution, "nonExistingOutputVar"); - Assert.fail("Expected BadInjectedFieldException for nonExistingString"); - } catch (Exception e) { - if (!(e instanceof BadInjectedFieldException)) { - Assert.fail("Expected BadInjectedFieldException for nonExistingString"); - } - } - - var = getOptionalOutputField(existingOutputVar, execution, "existingOutputVar"); - Assert.assertEquals("goodVariable", var); - - var = getOptionalOutputField(nonExistingOutputVar, execution, "nonExistingOutputVar"); - Assert.assertEquals(null, var); - - try { - var = getOutputField(existingBadOutputVar, execution, "existingBadOutputVar"); - Assert.fail("Expected BadInjectedFieldException for nonExistingString"); - } catch (Exception e) { - if (!(e instanceof BadInjectedFieldException)) { - Assert.fail("Expected BadInjectedFieldException for nonExistingString"); - } - } - - msoLogger.debug("Finished executing " + getClass().getSimpleName()); - } - } -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/AllottedResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/AllottedResourceTest.java deleted file mode 100644 index 09720be9b9..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/AllottedResourceTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class AllottedResourceTest { - private AllottedResource ar = new AllottedResource(); - TunnelConnect tc = new TunnelConnect(); - - @Test - public void testAllottedResource() { - ar.setAllottedResourceType("allottedResourceType"); - ar.setAllottedResourceRole("allottedResourceRole"); - ar.setProvidingServiceModelName("providingServiceModelName"); - ar.setProvidingServiceModelInvariantUuid("providingServiceModelInvariantUuid"); - ar.setProvidingServiceModelUuid("providingServiceModelUuid"); - ar.setNfFunction("nfFunction"); - ar.setNfType("nfType"); - ar.setNfRole("nfRole"); - ar.setNfNamingCode("nfNamingCode"); - ar.setOrchestrationStatus("orchestrationStatus"); - ar.setTunnelConnect(tc); - assertEquals(ar.getAllottedResourceType(), "allottedResourceType"); - assertEquals(ar.getAllottedResourceRole(), "allottedResourceRole"); - assertEquals(ar.getProvidingServiceModelName(), "providingServiceModelName"); - assertEquals(ar.getProvidingServiceModelInvariantUuid(), "providingServiceModelInvariantUuid"); - assertEquals(ar.getProvidingServiceModelUuid(), "providingServiceModelUuid"); - assertEquals(ar.getNfFunction(), "nfFunction"); - assertEquals(ar.getNfType(), "nfType"); - assertEquals(ar.getNfRole(), "nfRole"); - assertEquals(ar.getNfNamingCode(), "nfNamingCode"); - assertEquals(ar.getOrchestrationStatus(), "orchestrationStatus"); - assertEquals(ar.getTunnelConnect(), tc); - - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResultTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResultTest.java deleted file mode 100644 index 90cb7362cf..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResultTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* ============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.bpmn.core.domain; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -public class CompareModelsResultTest { - - private CompareModelsResult modelsResult; - private List addedResourceList; - private List deletedResourceList; - private ResourceModelInfo resourceModelInfo1; - private ResourceModelInfo resourceModelInfo2; - private List requestInputs; - - @Before - public void before() { - resourceModelInfo1 = new ResourceModelInfo(); - resourceModelInfo1.setResourceCustomizationUuid("f1d563e8-e714-4393-8f99-cc480144a05e"); - resourceModelInfo1.setResourceInvariantUuid("e1d563e8-e714-4393-8f99-cc480144a05f"); - resourceModelInfo1.setResourceName("resourceName1"); - resourceModelInfo1.setResourceUuid("f1d563e8-e714-4393-8f99-cc480144a05g"); - resourceModelInfo2 = new ResourceModelInfo(); - resourceModelInfo2.setResourceCustomizationUuid("a1d563e8-e714-4393-8f99-cc480144a05d"); - resourceModelInfo2.setResourceInvariantUuid("b1d563e8-e714-4393-8f99-cc480144a05e"); - resourceModelInfo2.setResourceName("resourceName2"); - resourceModelInfo2.setResourceUuid("c1d563e8-e714-4393-8f99-cc480144a05f"); - } - - @Test - public void testSetAddedResourceList() { - addedResourceList = new ArrayList(); - addedResourceList.add(resourceModelInfo1); - addedResourceList.add(resourceModelInfo2); - modelsResult = new CompareModelsResult(); - modelsResult.setAddedResourceList(addedResourceList); - assertEquals(addedResourceList, modelsResult.getAddedResourceList()); - } - - @Test - public void testSetDeletedResourceList() { - deletedResourceList = new ArrayList(); - deletedResourceList.add(resourceModelInfo1); - deletedResourceList.add(resourceModelInfo2); - modelsResult = new CompareModelsResult(); - modelsResult.setDeletedResourceList(deletedResourceList); - assertEquals(deletedResourceList, modelsResult.getDeletedResourceList()); - } - - @Test - public void testSetRequestInputs() { - requestInputs = new ArrayList(); - requestInputs.add("requestInput1"); - requestInputs.add("requestInput2"); - modelsResult = new CompareModelsResult(); - modelsResult.setRequestInputs(requestInputs); - assertEquals(requestInputs, modelsResult.getRequestInputs()); - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigResourceTest.java deleted file mode 100644 index ecaf601c90..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigResourceTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ConfigResourceTest { - private ConfigResource configresource = new ConfigResource();{ - configresource.resourceType = ResourceType.CONFIGURATION; - } - - @Test - public void testConfigResource() { - configresource.setToscaNodeType("toscaNodeType"); - assertEquals(configresource.getToscaNodeType(), "toscaNodeType"); - - - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigurationTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigurationTest.java deleted file mode 100644 index df8440addf..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ConfigurationTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ConfigurationTest { - private Configuration configuration = new Configuration(); - - @Test - public void testConfigurationTest() { - configuration.setId("id"); - configuration.setName("name"); - configuration.setType("type"); - configuration.setOrchestrationStatus("orchestrationStatus"); - configuration.setTunnelBandwidth("tunnelBandwidth"); - configuration.setVendorAllowedMaxBandwidth("vendorAllowedMaxBandwidth"); - configuration.setResourceVersion("resourceVersion"); - assertEquals(configuration.getId(), "id"); - assertEquals(configuration.getName(), "name"); - assertEquals(configuration.getType(), "type"); - assertEquals(configuration.getOrchestrationStatus(), "orchestrationStatus"); - assertEquals(configuration.getTunnelBandwidth(), "tunnelBandwidth"); - assertEquals(configuration.getVendorAllowedMaxBandwidth(), "vendorAllowedMaxBandwidth"); - assertEquals(configuration.getResourceVersion(), "resourceVersion"); - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CustomerTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CustomerTest.java deleted file mode 100644 index 1a4e0898ee..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CustomerTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class CustomerTest { - private Customer customer = new Customer(); - - @Test - public void testCustomer() { - customer.setSubscriptionServiceType("subscriptionServiceType"); - customer.setGlobalSubscriberId("globalSubscriberId"); - assertEquals(customer.getSubscriptionServiceType(), "subscriptionServiceType"); - assertEquals(customer.getGlobalSubscriberId(), "globalSubscriberId"); - - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/HomingSolutionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/HomingSolutionTest.java deleted file mode 100644 index e334348b5d..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/HomingSolutionTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class HomingSolutionTest { - - private HomingSolution homingsolution = new HomingSolution(); - InventoryType inventory = InventoryType.cloud; - VnfResource vnfresource = new VnfResource(); - License license = new License(); - - @Test - public void testHomingSolution() { - homingsolution.setInventoryType(inventory); - homingsolution.setRehome(true); - homingsolution.setServiceInstanceId("serviceInstanceId"); - homingsolution.setCloudOwner("cloudOwner"); - homingsolution.setCloudRegionId("cloudRegionId"); - homingsolution.setAicClli("aicClli"); - homingsolution.setAicVersion("aicVersion"); - homingsolution.setTenant("tenant"); - homingsolution.setVnf(vnfresource); - homingsolution.setLicense(license); - assertEquals(homingsolution.getInventoryType(), inventory); - assertEquals(homingsolution.isRehome(), true); - assertEquals(homingsolution.getServiceInstanceId(), "serviceInstanceId"); - assertEquals(homingsolution.getCloudOwner(), "cloudOwner"); - assertEquals(homingsolution.getCloudRegionId(), "cloudRegionId"); - assertEquals(homingsolution.getAicClli(), "aicClli"); - assertEquals(homingsolution.getAicVersion(), "aicVersion"); - assertEquals(homingsolution.getTenant(), "tenant"); - assertEquals(homingsolution.getVnf(), vnfresource); - assertEquals(homingsolution.getLicense(), license); - - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/LicenseTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/LicenseTest.java deleted file mode 100644 index 9ed194c455..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/LicenseTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.BDDMockito.Then; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - - -//@RunWith(PowerMockRunner.class) -//@PrepareForTest({License.class}) -public class LicenseTest { - - //@Mock - private License license= new License(); - //@InjectMocks - //private LicenseTest licenceTest; - List entitlementPoolList = new ArrayList(); - private List licenseKeyGroupList = new ArrayList(); - //JSONArray array = new JSONArray(entitlementPoolList); - //JSONArray array1 = new JSONArray(licenseKeyGroupList); - //@PrepareForTest({License.class}) - Long serialVersionUID = 333L; - - @Test - public void testLicense() { - license.setEntitlementPoolList(entitlementPoolList); - license.setLicenseKeyGroupList(licenseKeyGroupList); - //license.addEntitlementPool("entitlementPoolUuid"); - license.addLicenseKeyGroup("licenseKeyGroupUuid"); - assertEquals(license.getEntitlementPoolList(), entitlementPoolList); - assertEquals(license.getLicenseKeyGroupList(), licenseKeyGroupList); - assert(license.getEntitlementPoolListAsString()!= null); - assert(license.getLicenseKeyGroupListAsString()!=null); - license.addEntitlementPool("entitlementPoolUuid"); - //assertEquals(license.getSerialversionuid(), serialVersionUID); - //assertArrayEquals(license.getSerialversionuid(), serialVersionUID); - //assert - - /*PowerMockito.mockStatic(License.class); - Mockito.when(License.getSerialversionuid()).thenReturn(getserial()); - assertEquals(License.getSerialversionuid(),"abc");*/ - - } - // @Before - // public void mocksetUp() { -// Long serialVersionUID = 333L; -// PowerMockito.mockStatic(License.class); -// expect (license.getSerialversionuid()).andReturn(serialVersionUID); -// //PowerMockito.when(license.getSerialversionuid(). -// //PowerMockito.when(MathUtil.addInteger(2, 2)).thenReturn(1); -// } - - /*private Long getserial() { - - return abc; - }*/ - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModelInfoTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModelInfoTest.java deleted file mode 100644 index 90eb230a4c..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModelInfoTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ModelInfoTest { - private ModelInfo modelinfo = new ModelInfo(); - - @Test - public void testModelInfo() { - modelinfo.setModelName("modelName"); - modelinfo.setModelUuid("modelUuid"); - modelinfo.setModelInvariantUuid("modelInvariantUuid"); - modelinfo.setModelVersion("modelVersion"); - modelinfo.setModelCustomizationUuid("modelCustomizationUuid"); - modelinfo.setModelInstanceName("modelInstanceName"); - modelinfo.setModelType("modelType"); - assertEquals(modelinfo.getModelName(), "modelName"); - assertEquals(modelinfo.getModelUuid(), "modelUuid"); - assertEquals(modelinfo.getModelInvariantUuid(), "modelInvariantUuid"); - assertEquals(modelinfo.getModelVersion(), "modelVersion"); - assertEquals(modelinfo.getModelCustomizationUuid(), "modelCustomizationUuid"); - assertEquals(modelinfo.getModelInstanceName(), "modelInstanceName"); - assertEquals(modelinfo.getModelType(), "modelType"); - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModuleResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModuleResourceTest.java deleted file mode 100644 index 58cd45c3f1..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ModuleResourceTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ModuleResourceTest { - private ModuleResource moduleresource = new ModuleResource(); - - @Test - public void testModuleResource() { - - moduleresource.setVfModuleName("vfModuleName"); - moduleresource.setHeatStackId("heatStackId"); - moduleresource.setIsBase(true); - moduleresource.setVfModuleLabel("vfModuleLabel"); - moduleresource.setInitialCount(0); - moduleresource.setVfModuleType("vfModuleType"); - moduleresource.setHasVolumeGroup(true); - assertEquals(moduleresource.getVfModuleName(), "vfModuleName"); - assertEquals(moduleresource.getHeatStackId(), "heatStackId"); - assertEquals(moduleresource.getIsBase(), true); - assertEquals(moduleresource.getVfModuleLabel(), "vfModuleLabel"); - assertEquals(moduleresource.getInitialCount(), 0); - assertEquals(moduleresource.getVfModuleType(), "vfModuleType"); - assertEquals(moduleresource.isHasVolumeGroup(), true); - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/NetworkResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/NetworkResourceTest.java deleted file mode 100644 index 22e62663c9..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/NetworkResourceTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class NetworkResourceTest { - private NetworkResource nr = new NetworkResource(); - - @Test - public void testNetworkResource() { - nr.setNetworkType("networkType"); - nr.setNetworkRole("networkRole"); - nr.setNetworkTechnology("networkTechnology"); - nr.setNetworkScope("networkScope"); - assertEquals(nr.getNetworkType(), "networkType"); - assertEquals(nr.getNetworkRole(), "networkRole"); - assertEquals(nr.getNetworkTechnology(), "networkTechnology"); - assertEquals(nr.getNetworkScope(), "networkScope"); - - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/OwningEntityTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/OwningEntityTest.java deleted file mode 100644 index 215fa3cff9..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/OwningEntityTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class OwningEntityTest { - private OwningEntity oe = new OwningEntity(); - - @Test - public void testOwingEntity() { - oe.setOwningEntityId("owningEntityId"); - oe.setOwningEntityName("owningEntityName"); - assertEquals(oe.getOwningEntityId(), "owningEntityId"); - assertEquals(oe.getOwningEntityName(), "owningEntityName"); - - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ProjectTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ProjectTest.java deleted file mode 100644 index 3a9a53f743..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ProjectTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ProjectTest { - - private Project project = new Project(); - - @Test - public void testProject() { - project.setProjectName("projectName"); - assertEquals(project.getProjectName(), "projectName"); - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/RequestTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/RequestTest.java deleted file mode 100644 index 9a9d41567a..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/RequestTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class RequestTest { - - private Request request = new Request(); - ModelInfo model = new ModelInfo(); - - @Test - public void testRequest() { - request.setSdncRequestId("sdncRequestId"); - request.setRequestId("requestId"); - request.setModelInfo(model); - request.setProductFamilyId("productFamilyId"); - assertEquals(request.getSdncRequestId(), "sdncRequestId"); - assertEquals(request.getRequestId(), "requestId"); - assertEquals(request.getModelInfo(), model); - assertEquals(request.getProductFamilyId(), "productFamilyId"); - - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceDecompositionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceDecompositionTest.java deleted file mode 100644 index 5eaa60260b..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceDecompositionTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ResourceDecompositionTest { - - private ResourceDecomposition rd = new ResourceDecomposition() { - private static final long serialVersionUID = 1L; - }; - ModelInfo model = new ModelInfo(); - ResourceInstance ri = new ResourceInstance(); - - - - @Test - public void testResourceDecomposition() { - rd.setModelInfo(model); - rd.setInstanceData(ri); - rd.setResourceType("resourceType"); - rd.setResourceInstanceId("newInstanceId"); - rd.setResourceInstanceName("newInstanceName"); - assertEquals(rd.getResourceModel(), model); - assertEquals(rd.getModelInfo(), model); - assertEquals(rd.getInstanceData(), ri); - assertEquals(rd.getResourceInstanceId(), "newInstanceId"); - assertEquals(rd.getResourceInstanceName(), "newInstanceName"); - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceTest.java deleted file mode 100644 index 8d6b61f4aa..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ResourceTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ResourceTest { - private Resource resource = new Resource() { - private static final long serialVersionUID = 1L; - - - }; - ModelInfo model = new ModelInfo(); - ResourceInstance ri = new ResourceInstance(); - HomingSolution hs = new HomingSolution(); - ResourceType rt = ResourceType.VNF; - public long concurrencyCounter = 1L; - long initval = resource.getConcurrencyCounter(); - - @Test - public void testResource() { - resource.setResourceId("resourceId"); - resource.setModelInfo(model); - resource.setResourceInstance(ri); - resource.setHomingSolution(hs); - resource.setCurrentHomingSolution(hs); - resource.setResourceType(rt); - resource.setToscaNodeType("toscaNodeType"); - resource.setResourceInstanceId("newInstanceId"); - resource.setResourceInstanceName("newInstanceName"); - resource.incrementConcurrencyCounter(); - assertEquals(resource.getResourceId(), "resourceId"); - assertEquals(resource.getModelInfo(), model); - assertEquals(resource.getResourceInstance(), ri); - assertEquals(resource.getHomingSolution(), hs); - assertEquals(resource.getCurrentHomingSolution(), hs); - assertEquals(resource.getResourceType(), rt); - assertEquals(resource.getToscaNodeType(), "toscaNodeType"); - assertEquals(resource.getResourceInstanceId(), "newInstanceId"); - assertEquals(resource.getResourceInstanceName(), "newInstanceName"); - assertEquals(resource.getConcurrencyCounter(), initval+1); - - - - - - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceDecompositionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceDecompositionTest.java deleted file mode 100644 index 58548db23b..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceDecompositionTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import java.util.List; - -import org.junit.Test; - -public class ServiceDecompositionTest { - private ServiceDecomposition sd = new ServiceDecomposition(); - ModelInfo model= new ModelInfo(); - ServiceInstance si= new ServiceInstance(); - Project project= new Project(); - OwningEntity oe= new OwningEntity(); - //VnfResource vnf = new VnfResource(); - List vnfResources; - List networkResources; - List configResources; - List allottedResources; - Request request= new Request(); - Customer customer= new Customer(); - - - @Test - public void testServiceDecomposition() { - sd.setModelInfo(model); - sd.setServiceInstance(si); - sd.setProject(project); - sd.setOwningEntity(oe); - sd.setServiceVnfs(vnfResources); - sd.setServiceConfigs(configResources); - sd.setServiceNetworks(networkResources); - sd.setServiceAllottedResources(allottedResources); - sd.setServiceConfigResources(configResources); - sd.setServiceType("serviceType"); - sd.setServiceRole("serviceRole"); - sd.setRequest(request); - sd.setCustomer(customer); - sd.setCallbackURN("callbackURN"); - sd.setSdncVersion("sdncVersion"); - assertEquals(sd.getModelInfo(), model); - assertEquals(sd.getServiceInstance(), si); - assertEquals(sd.getProject(), project); - assertEquals(sd.getOwningEntity(), oe); - assertEquals(sd.getServiceVnfs(), vnfResources); - assertEquals(sd.getServiceConfigs(), configResources); - assertEquals(sd.getServiceNetworks(), networkResources); - assertEquals(sd.getServiceAllottedResources(), allottedResources); - assertEquals(sd.getServiceConfigResources(), configResources); - assertEquals(sd.getRequest(), request); - assertEquals(sd.getCustomer(), customer); - assertEquals(sd.getCallbackURN(), "callbackURN"); - assertEquals(sd.getSdncVersion(), "sdncVersion"); - - - - - - - - - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceInstanceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceInstanceTest.java deleted file mode 100644 index b600fef3fd..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/ServiceInstanceTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import java.util.Map; - -import org.junit.Test; - -public class ServiceInstanceTest { - - private ServiceInstance si= new ServiceInstance(); - Map serviceParams; - Configuration config= new Configuration(); - ModelInfo model= new ModelInfo(); - - @Test - public void testServiceInstance() { - si.setServiceType("serviceType"); - si.setServiceId("serviceId"); - si.setServiceParams(serviceParams); - si.setInstanceId("instanceId"); - si.setInstanceName("instanceName"); - si.setOrchestrationStatus("orchestrationStatus"); - si.setConfiguration(config); - si.setModelInfo(model); - si.setEnvironmentContext("environmentContext"); - si.setWorkloadContext("workloadContext"); - assertEquals(si.getServiceType(), "serviceType"); - assertEquals(si.getServiceId(), "serviceId"); - assertEquals(si.getServiceParams(), serviceParams); - assertEquals(si.getInstanceId(), "instanceId"); - assertEquals(si.getInstanceName(), "instanceName"); - assertEquals(si.getOrchestrationStatus(), "orchestrationStatus"); - assertEquals(si.getConfiguration(), config); - assertEquals(si.getModelInfo(), model); - assertEquals(si.getEnvironmentContext(), "environmentContext"); - assertEquals(si.getWorkloadContext(), "workloadContext"); - - - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/SubscriberTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/SubscriberTest.java deleted file mode 100644 index 7e9aef29a6..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/SubscriberTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class SubscriberTest { - Subscriber subscriber= new Subscriber("globalId", "name", "commonSiteId"); - - @Test - public void testSubscriber() { - subscriber.setGlobalId("globalId"); - subscriber.setName("name"); - subscriber.setCommonSiteId("commonSiteId"); - assertEquals(subscriber.getGlobalId(), "globalId"); - assertEquals(subscriber.getName(), "name"); - assertEquals(subscriber.getCommonSiteId(), "commonSiteId"); - - - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/TunnelConnectTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/TunnelConnectTest.java deleted file mode 100644 index 2a5639f0ff..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/TunnelConnectTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class TunnelConnectTest { - private TunnelConnect tc= new TunnelConnect(); - - @Test - public void testTunnelConnect() { - tc.setId("id"); - tc.setUpBandwidth("upBandwidth"); - tc.setDownBandwidth("downBandwidth"); - tc.setUpBandwidth2("upBandwidth2"); - tc.setDownBandwidth2("downBandwidth2"); - assertEquals(tc.getId(), "id"); - assertEquals(tc.getUpBandwidth(), "upBandwidth"); - assertEquals(tc.getDownBandwidth(), "downBandwidth"); - assertEquals(tc.getUpBandwidth2(), "upBandwidth2"); - assertEquals(tc.getDownBandwidth2(), "downBandwidth2"); - - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/VnfResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/VnfResourceTest.java deleted file mode 100644 index e476ef9fd5..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/VnfResourceTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.core.domain; - -import static org.junit.Assert.*; - -import java.util.List; - -import org.junit.Test; - -public class VnfResourceTest { - - private VnfResource vnf= new VnfResource(); - List moduleResources; - - @Test - public void testVnfResource() { - vnf.setModules(moduleResources); - vnf.setVnfHostname("vnfHostname"); - vnf.setVnfType("vnfType"); - vnf.setNfFunction("nfFunction"); - vnf.setNfType("nfType"); - vnf.setNfRole("nfRole"); - vnf.setNfNamingCode("nfNamingCode"); - vnf.setMultiStageDesign("multiStageDesign"); - assertEquals(vnf.getVfModules(), moduleResources); - assertEquals(vnf.getVnfHostname(), "vnfHostname"); - assertEquals(vnf.getVnfType(), "vnfType"); - assertEquals(vnf.getNfFunction(), "nfFunction"); - assertEquals(vnf.getNfType(), "nfType"); - assertEquals(vnf.getNfRole(), "nfRole"); - assertEquals(vnf.getNfNamingCode(), "nfNamingCode"); - assertEquals(vnf.getMultiStageDesign(), "multiStageDesign"); - - - } - -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java deleted file mode 100644 index 57f479f7cb..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.core.internal; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Optional; -import org.junit.Test; - -public class VariableNameExtractorTest { - - @Test - public void shouldExtractVariableName() throws Exception { - // given - String name = "A_different_NAME123"; - String variable = "${A_different_NAME123}"; - VariableNameExtractor extractor = new VariableNameExtractor(variable); - // when - Optional extracted = extractor.extract(); - // then - assertThat(extracted).isPresent().contains(name); - } - - @Test - public void shouldExtractVariableNameFromWhitespaces() throws Exception { - // given - String name = "name"; - String variable = " \n\t$ \n\t{ \n\tname \n\t} \n\t"; - VariableNameExtractor extractor = new VariableNameExtractor(variable); - // when - Optional extracted = extractor.extract(); - // then - assertThat(extracted).isPresent().contains(name); - } - - @Test - public void shouldReturnEmptyIfThereIsMoreThanVariable() throws Exception { - // given - String variable = "a ${test}"; - VariableNameExtractor extractor = new VariableNameExtractor(variable); - // when - Optional extracted = extractor.extract(); - // then - assertThat(extracted).isNotPresent(); - } - - @Test - public void shouldReturnEmptyIfVariableNameIsIncorrect() throws Exception { - // given - String variable = "${name with space}"; - VariableNameExtractor extractor = new VariableNameExtractor(variable); - // when - Optional extracted = extractor.extract(); - // then - assertThat(extracted).isNotPresent(); - } - - @Test - public void shouldReturnEmptyIfTwoVariablesPresent() throws Exception { - // given - String variable = "${var1} ${var2}"; - VariableNameExtractor extractor = new VariableNameExtractor(variable); - // when - Optional extracted = extractor.extract(); - // then - assertThat(extracted).isNotPresent(); - } -} \ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsTest.java deleted file mode 100644 index 644f98349c..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.core.json; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Map; - -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.json.JSONArray; -import org.json.JSONObject; -import org.junit.Test; -import org.mockito.Mock; - -public class JsonUtilsTest { - - @Mock public DelegateExecution execution; - private final String fileLocation = "src/test/resources/json-examples/"; - - @Test - public void jsonStringToMapTest() throws IOException { - - JsonUtils utils = new JsonUtils(); - String response = this.getJson("SDNCServiceResponseExample.json"); - String entry = utils.getJsonValue(response, "SDNCServiceResponse.params"); - Map map = utils.jsonStringToMap(execution, entry); - assertEquals(map.get("e2e-vpn-key"), "my-key"); - } - - @Test - public void entryArrayToMapTest() throws IOException { - JsonUtils utils = new JsonUtils(); - String response = this.getJson("SNIROExample.json"); - String entry = utils.getJsonValue(response, "solutionInfo.placement"); - JSONArray arr = new JSONArray(entry); - JSONObject homingDataJson = arr.getJSONObject(0); - JSONArray assignmentInfo = homingDataJson.getJSONArray("assignmentInfo"); - Map map = utils.entryArrayToMap(execution, assignmentInfo.toString(), "variableName", "variableValue"); - assertEquals(map.get("cloudOwner"), "att-aic"); - } - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); - } -} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/utils/CamundaDBSetup.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/utils/CamundaDBSetup.java deleted file mode 100644 index f29ccc75e0..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/utils/CamundaDBSetup.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.core.utils; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.SQLException; - -import org.openecomp.mso.logger.MsoLogger; - -/** - * Sets up the unit test (H2) database for Camunda. - */ -public class CamundaDBSetup { - private static boolean isDBConfigured = false; - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - - private CamundaDBSetup() { - } - - public static synchronized void configure() throws SQLException { - if (isDBConfigured) { - return; - } - - LOGGER.debug ("Configuring the Camunda H2 database for MSO"); - - Connection connection = null; - PreparedStatement stmt = null; - - try { - connection = DriverManager.getConnection( - "jdbc:h2:mem:camunda;DB_CLOSE_DELAY=-1", "sa", ""); - - stmt = connection.prepareStatement("delete from ACT_HI_VARINST"); - stmt.executeUpdate(); - stmt.close(); - stmt = null; - - stmt = connection.prepareStatement("ALTER TABLE ACT_HI_VARINST alter column TEXT_ clob"); - stmt.executeUpdate(); - stmt.close(); - stmt = null; - -// stmt = connection.prepareStatement("ALTER TABLE ACT_HI_VARINST alter column NAME_ clob"); -// stmt.executeUpdate(); -// stmt.close(); -// stmt = null; - - stmt = connection.prepareStatement("delete from ACT_HI_DETAIL"); - stmt.executeUpdate(); - stmt.close(); - stmt = null; - - stmt = connection.prepareStatement("ALTER TABLE ACT_HI_DETAIL alter column TEXT_ clob"); - stmt.executeUpdate(); - stmt.close(); - stmt = null; - -// stmt = connection.prepareStatement("ALTER TABLE ACT_HI_DETAIL alter column NAME_ clob"); -// stmt.executeUpdate(); -// stmt.close(); -// stmt = null; - - stmt = connection.prepareStatement("ALTER TABLE ACT_RU_VARIABLE alter column TEXT_ clob"); - stmt.executeUpdate(); - stmt.close(); - stmt = null; - - connection.close(); - connection = null; - - isDBConfigured = true; - } catch (SQLException e) { - LOGGER.debug ("CamundaDBSetup caught " + e.getClass().getSimpleName()); - LOGGER.debug("SQLException :",e); - } finally { - if (stmt != null) { - try { - stmt.close(); - } catch (Exception e) { - LOGGER.debug("Exception :",e); - } - } - - if (connection != null) { - try { - connection.close(); - } catch (Exception e) { - LOGGER.debug("Exception :",e); - } - } - } - } -} \ No newline at end of file -- cgit 1.2.3-korg