aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCoreBPMN/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCoreBPMN/src/test')
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BadInjectedFiledExceptionTest.java61
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BaseTaskTest.java440
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BeansTest.java67
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/MissingInjectedFiledExceptionTest.java47
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/ResponseBuilderTest.java173
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/RollbackDataTest.java13
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/UrnPropertiesReaderTest.java13
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/WorkflowExceptionTest.java60
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/AllottedResourceTest.java97
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CompareModelsResultTest.java127
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigResourceTest.java47
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ConfigurationTest.java62
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/CustomerTest.java44
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/DomainPojoTest.java38
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/HomingSolutionTest.java84
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/LicenseTest.java71
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModelInfoTest.java62
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ModuleResourceTest.java64
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/NetworkResourceTest.java73
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/OwningEntityTest.java44
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ProjectTest.java40
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/RequestTest.java56
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceDecompositionTest.java68
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ResourceTest.java102
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java208
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceInstanceTest.java101
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/SubscriberTest.java50
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java159
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/internal/VariableNameExtractorTest.java4
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/DecomposeJsonUtilTest.java295
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonDecomposingExceptionTest.java45
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtils2Test.java220
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java429
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/utils/CamundaDBSetup.java66
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/xml/XmlToolTest.java118
35 files changed, 1738 insertions, 1910 deletions
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
index b35e65485f..67b33602dd 100644
--- 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
@@ -1,22 +1,17 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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;
@@ -25,22 +20,22 @@ 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());
-
- }
+ 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
index 40fcb982c1..49f373c01e 100644
--- 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
@@ -1,22 +1,17 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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;
@@ -24,7 +19,6 @@ 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;
@@ -33,215 +27,215 @@ 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);
- }
-
+ 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
index 2415e619d7..965a9cc04d 100644
--- 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
@@ -24,17 +24,14 @@ 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;
@@ -55,37 +52,35 @@ 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/");
- }
- }
+ 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
index b0aa41b05d..1bc0153956 100644
--- 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
@@ -1,22 +1,17 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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;
@@ -25,15 +20,15 @@ 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());
- }
+ 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
index b605209739..b06837aa0d 100644
--- 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
@@ -1,29 +1,23 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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;
@@ -33,78 +27,79 @@ 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 = "<ErrorMessage>any error message!</ErrorMessage><ErrorCode>200</ErrorCode>";
- private String response = "<WorkflowResponse>bad</WorkflowResponse>";
-
- 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());
- }
+ 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 = "<ErrorMessage>any error message!</ErrorMessage><ErrorCode>200</ErrorCode>";
+ private String response = "<WorkflowResponse>bad</WorkflowResponse>";
+
+ 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 = "<WorkflowResponse>good</WorkflowResponse>";
+ when(mockExecution.getVariable("WorkflowResponse")).thenReturn(workflowResponse);
+ obj = responseBuilder.buildWorkflowResponse(mockExecution);
+ assertEquals(workflowResponse, obj);
+ }
- @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 = "<WorkflowResponse>good</WorkflowResponse>";
- 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
index 875df6cf94..86a9ecf57e 100644
--- 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
@@ -29,7 +29,6 @@ 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 {
@@ -48,11 +47,11 @@ public class RollbackDataTest {
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}]")));
+ 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
@@ -89,4 +88,4 @@ public class RollbackDataTest {
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
index 5d9a1d61f2..f0c3d39625 100644
--- 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
@@ -24,36 +24,35 @@ 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() {
+ public void testGetVariableFromExecution() {
ExecutionEntity mockExecution = mock(ExecutionEntity.class);
when(mockExecution.getVariable("testKey")).thenReturn("testValue");
- String value = UrnPropertiesReader.getVariable("testKey",mockExecution);
+ String value = UrnPropertiesReader.getVariable("testKey", mockExecution);
Assert.assertEquals("testValue", value);
verify(mockExecution).getVariable("testKey");
verify(mockExecution, never()).setVariable("testKey", value);
}
@Test
- public void testGetVariableFromEnvironment() {
+ 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);
+ String value = UrnPropertiesReader.getVariable("testKey", mockExecution);
+ Assert.assertEquals("testValue", value);
verify(mockExecution).getVariable("testKey");
verify(mockExecution).setVariable("testKey", value);
}
@Test
- public void testGetVariableNotExist() {
+ public void testGetVariableNotExist() {
ExecutionEntity mockExecution = mock(ExecutionEntity.class);
String value = UrnPropertiesReader.getVariable("notExist", mockExecution);
Assert.assertEquals(null, 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
index c1e9b8776b..2792b1bd73 100644
--- 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
@@ -1,47 +1,41 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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());
- }
+ 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
index cca28d411f..fcd502f982 100644
--- 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
@@ -1,66 +1,59 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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 com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
-
import java.io.IOException;
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");
-
- }
-
- @Test
- public void allottedResourceMapperTest() throws IOException {
- String jsonStr = "{\"allottedResourceType\": \"code123\", \"resourceInput\": \"sample\"}";
- ObjectMapper objectMapper = new ObjectMapper();
- AllottedResource vnfResource = objectMapper.readValue(jsonStr, AllottedResource.class);
-
- assertTrue(vnfResource != null);
- }
+ 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");
+
+ }
+
+ @Test
+ public void allottedResourceMapperTest() throws IOException {
+ String jsonStr = "{\"allottedResourceType\": \"code123\", \"resourceInput\": \"sample\"}";
+ ObjectMapper objectMapper = new ObjectMapper();
+ AllottedResource vnfResource = objectMapper.readValue(jsonStr, AllottedResource.class);
+
+ assertTrue(vnfResource != null);
+ }
}
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
index af9c7a7fa6..4c371d3cff 100644
--- 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
@@ -1,83 +1,76 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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<ResourceModelInfo> addedResourceList;
- private List<ResourceModelInfo> deletedResourceList;
- private ResourceModelInfo resourceModelInfo1;
- private ResourceModelInfo resourceModelInfo2;
- private List<String> 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<ResourceModelInfo>();
- addedResourceList.add(resourceModelInfo1);
- addedResourceList.add(resourceModelInfo2);
- modelsResult = new CompareModelsResult();
- modelsResult.setAddedResourceList(addedResourceList);
- assertEquals(addedResourceList, modelsResult.getAddedResourceList());
- }
- @Test
- public void testSetDeletedResourceList() {
- deletedResourceList = new ArrayList<ResourceModelInfo>();
- deletedResourceList.add(resourceModelInfo1);
- deletedResourceList.add(resourceModelInfo2);
- modelsResult = new CompareModelsResult();
- modelsResult.setDeletedResourceList(deletedResourceList);
- assertEquals(deletedResourceList, modelsResult.getDeletedResourceList());
- }
+ private CompareModelsResult modelsResult;
+ private List<ResourceModelInfo> addedResourceList;
+ private List<ResourceModelInfo> deletedResourceList;
+ private ResourceModelInfo resourceModelInfo1;
+ private ResourceModelInfo resourceModelInfo2;
+ private List<String> 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<ResourceModelInfo>();
+ addedResourceList.add(resourceModelInfo1);
+ addedResourceList.add(resourceModelInfo2);
+ modelsResult = new CompareModelsResult();
+ modelsResult.setAddedResourceList(addedResourceList);
+ assertEquals(addedResourceList, modelsResult.getAddedResourceList());
+ }
+
+ @Test
+ public void testSetDeletedResourceList() {
+ deletedResourceList = new ArrayList<ResourceModelInfo>();
+ deletedResourceList.add(resourceModelInfo1);
+ deletedResourceList.add(resourceModelInfo2);
+ modelsResult = new CompareModelsResult();
+ modelsResult.setDeletedResourceList(deletedResourceList);
+ assertEquals(deletedResourceList, modelsResult.getDeletedResourceList());
+ }
+
+ @Test
+ public void testSetRequestInputs() {
+ requestInputs = new ArrayList<String>();
+ requestInputs.add("requestInput1");
+ requestInputs.add("requestInput2");
+ modelsResult = new CompareModelsResult();
+ modelsResult.setRequestInputs(requestInputs);
+ assertEquals(requestInputs, modelsResult.getRequestInputs());
+ }
- @Test
- public void testSetRequestInputs() {
- requestInputs = new ArrayList<String>();
- 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
index 13a30d26ee..1e1595f048 100644
--- 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
@@ -1,39 +1,34 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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;
- }
+ private ConfigResource configresource = new ConfigResource();
+ {
+ configresource.resourceType = ResourceType.CONFIGURATION;
+ }
+
+ @Test
+ public void testConfigResource() {
+ configresource.setToscaNodeType("toscaNodeType");
+ assertEquals(configresource.getToscaNodeType(), "toscaNodeType");
+
- @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
index fe84a1b5a7..68839a7ad6 100644
--- 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
@@ -1,47 +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
+ * ============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
+ * 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.
+ * 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();
+ 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");
- }
+ @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
index 86eb717664..9640cfce07 100644
--- 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
@@ -1,38 +1,32 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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();
+ private Customer customer = new Customer();
+
+ @Test
+ public void testCustomer() {
+ customer.setSubscriptionServiceType("subscriptionServiceType");
+ customer.setGlobalSubscriberId("globalSubscriberId");
+ assertEquals(customer.getSubscriptionServiceType(), "subscriptionServiceType");
+ assertEquals(customer.getGlobalSubscriberId(), "globalSubscriberId");
- @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
index b4860c6323..ae1aff7275 100644
--- 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
@@ -21,7 +21,6 @@
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;
@@ -33,24 +32,21 @@ 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/");
- }
- }
+ 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
index 9750e03b4c..249307cbbc 100644
--- 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
@@ -1,58 +1,52 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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);
-
- }
+ 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
index f3a96bf4eb..bacaaf77c9 100644
--- 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
@@ -1,54 +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
+ * ============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
+ * 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.
+ * 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.assertEquals;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
-public class LicenseTest {
-
- private License license= new License();
- List<String> entitlementPoolList = new ArrayList<String>();
- private List<String> licenseKeyGroupList = new ArrayList<String>();
-
- Long serialVersionUID = 333L;
-
- @Test
- public void testLicense() {
- license.setEntitlementPoolList(entitlementPoolList);
- license.setLicenseKeyGroupList(licenseKeyGroupList);
- license.addLicenseKeyGroup("licenseKeyGroupUuid");
- assertEquals(license.getEntitlementPoolList(), entitlementPoolList);
- assertEquals(license.getLicenseKeyGroupList(), licenseKeyGroupList);
- assert(license.getEntitlementPoolListAsString()!= null);
- assert(license.getLicenseKeyGroupListAsString()!=null);
- license.addEntitlementPool("entitlementPoolUuid");
-
-
- }
-
+public class LicenseTest {
+
+ private License license = new License();
+ List<String> entitlementPoolList = new ArrayList<String>();
+ private List<String> licenseKeyGroupList = new ArrayList<String>();
+
+ Long serialVersionUID = 333L;
+
+ @Test
+ public void testLicense() {
+ license.setEntitlementPoolList(entitlementPoolList);
+ license.setLicenseKeyGroupList(licenseKeyGroupList);
+ license.addLicenseKeyGroup("licenseKeyGroupUuid");
+ assertEquals(license.getEntitlementPoolList(), entitlementPoolList);
+ assertEquals(license.getLicenseKeyGroupList(), licenseKeyGroupList);
+ assert (license.getEntitlementPoolListAsString() != null);
+ assert (license.getLicenseKeyGroupListAsString() != null);
+ license.addEntitlementPool("entitlementPoolUuid");
+
+
+ }
+
}
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
index 3d07f85c04..807338745f 100644
--- 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
@@ -1,47 +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
+ * ============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
+ * 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.
+ * 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();
+ 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");
- }
+ @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
index dcb62cfc40..6e915b2a60 100644
--- 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
@@ -1,48 +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
+ * ============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
+ * 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.
+ * 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();
+ private ModuleResource moduleresource = new ModuleResource();
+
+ @Test
+ public void testModuleResource() {
- @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);
- }
+ 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
index ee23ebd438..668d6dc1de 100644
--- 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
@@ -1,54 +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
+ * ============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
+ * 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.
+ * 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 com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
-
import java.io.IOException;
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");
-
- }
-
- @Test
- public void networkResourceMapperTest() throws IOException {
- String jsonStr = "{\"networkScope\": \"code123\", \"resourceInput\": \"sample\"}";
- ObjectMapper objectMapper = new ObjectMapper();
- NetworkResource networkResource = objectMapper.readValue(jsonStr, NetworkResource.class);
-
- assertTrue(networkResource != null);
- }
+ 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");
+
+ }
+
+ @Test
+ public void networkResourceMapperTest() throws IOException {
+ String jsonStr = "{\"networkScope\": \"code123\", \"resourceInput\": \"sample\"}";
+ ObjectMapper objectMapper = new ObjectMapper();
+ NetworkResource networkResource = objectMapper.readValue(jsonStr, NetworkResource.class);
+
+ assertTrue(networkResource != null);
+ }
}
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
index 396d866446..23a1d866a2 100644
--- 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
@@ -1,39 +1,33 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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();
+ private OwningEntity oe = new OwningEntity();
+
+ @Test
+ public void testOwingEntity() {
+ oe.setOwningEntityId("owningEntityId");
+ oe.setOwningEntityName("owningEntityName");
+ assertEquals(oe.getOwningEntityId(), "owningEntityId");
+ assertEquals(oe.getOwningEntityName(), "owningEntityName");
- @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
index 9081f9dd14..47ce61b8fe 100644
--- 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
@@ -1,36 +1,30 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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");
- }
+ 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
index 0c552ce19e..a890289943 100644
--- 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
@@ -1,44 +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
+ * ============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
+ * 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.
+ * 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");
-
- }
+ 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
index 573ffab4aa..112139ce95 100644
--- 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
@@ -1,50 +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
+ * ============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
+ * 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.
+ * 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");
- }
+ 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
index afdbcd9f98..271ed6b32e 100644
--- 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
@@ -1,68 +1,60 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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();
+ 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);
+
+
- @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
index 5d8d55152c..5db277628e 100644
--- 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
@@ -1,22 +1,17 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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;
@@ -24,104 +19,109 @@ 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);
-
- System.out.println(serviceDecomp.toJsonString());
-
- 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());
- }
+ 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);
+
+ System.out.println(serviceDecomp.toJsonString());
+
+ 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
index c04dc9d601..1fb51412f6 100644
--- 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
@@ -1,71 +1,64 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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.io.IOException;
import java.util.Map;
-
import com.fasterxml.jackson.databind.ObjectMapper;
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");
-
-
- }
+ 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");
+
+
+ }
- @Test
- public void serviceInstanceMapperTest() throws IOException {
- String jsonStr = "{\"workloadContext\": \"code123\", \"resourceOrder\": \"sample\"}";
- ObjectMapper objectMapper = new ObjectMapper();
- ServiceInstance serviceInstance = objectMapper.readValue(jsonStr, ServiceInstance.class);
- assertTrue(serviceInstance != null);
- }
+ @Test
+ public void serviceInstanceMapperTest() throws IOException {
+ String jsonStr = "{\"workloadContext\": \"code123\", \"resourceOrder\": \"sample\"}";
+ ObjectMapper objectMapper = new ObjectMapper();
+ ServiceInstance serviceInstance = objectMapper.readValue(jsonStr, ServiceInstance.class);
+ assertTrue(serviceInstance != null);
+ }
}
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
index b862c8704f..8f1b666d0b 100644
--- 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
@@ -1,41 +1,35 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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");
+ 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");
+
- @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
index 5271bb3c53..09bcfe8470 100644
--- 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
@@ -1,100 +1,93 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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.io.IOException;
import java.util.ArrayList;
import java.util.List;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
public class VnfResourceTest {
- private final static String ALL_VF_MODULES_JSON =
- "{\"ArrayList\":[{\"resourceType\":\"MODULE\",\"resourceInstance\":{},\"homingSolution\":{\"license\":{},\"rehome\":false},\"vfModuleName\":\"vfModuleName\",\"vfModuleType\":\"vfModuleType\",\"heatStackId\":\"heatStackId\",\"hasVolumeGroup\":true,\"isBase\":true,\"vfModuleLabel\":\"vfModuleLabel\",\"initialCount\":0},{\"resourceType\":\"MODULE\",\"resourceInstance\":{},\"homingSolution\":{\"license\":{},\"rehome\":false},\"vfModuleName\":\"vfModuleName\",\"vfModuleType\":\"vfModuleType\",\"heatStackId\":\"heatStackId\",\"hasVolumeGroup\":true,\"isBase\":true,\"vfModuleLabel\":\"vfModuleLabel\",\"initialCount\":0}]}";
-
- private VnfResource vnf= new VnfResource();
- List<ModuleResource> 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");
-
-
- }
-
- @Test
- public void vnfResourceMapperTest() throws IOException {
- String jsonStr = "{\"vnfHostname\": \"home\", \"resourceInput\": \"sample\"}";
- ObjectMapper objectMapper = new ObjectMapper();
- VnfResource vnfResource = objectMapper.readValue(jsonStr, VnfResource.class);
-
- assertTrue(vnfResource != null);
- }
-
- @Test
- public void testVfModules() {
-
- moduleResources = new ArrayList<>();
-
- ModuleResource moduleresource = new ModuleResource();
- moduleresource.setVfModuleName("vfModuleName");
- moduleresource.setHeatStackId("heatStackId");
- moduleresource.setIsBase(true);
- moduleresource.setVfModuleLabel("vfModuleLabel");
- moduleresource.setInitialCount(0);
- moduleresource.setVfModuleType("vfModuleType");
- moduleresource.setHasVolumeGroup(true);
-
- moduleResources.add(moduleresource);
-
- vnf.setModules(moduleResources);
- assertEquals(vnf.getVfModules(), moduleResources);
-
- List<ModuleResource> moduleResources = vnf.getAllVfModuleObjects();
- assertEquals(1, moduleResources.size());
-
- vnf.addVfModule(moduleresource);
- moduleResources = vnf.getAllVfModuleObjects();
- assertEquals(2, moduleResources.size());
-
- assertEquals(ALL_VF_MODULES_JSON, vnf.getAllVfModulesJson());
-
- }
+ private final static String ALL_VF_MODULES_JSON =
+ "{\"ArrayList\":[{\"resourceType\":\"MODULE\",\"resourceInstance\":{},\"homingSolution\":{\"license\":{},\"rehome\":false},\"vfModuleName\":\"vfModuleName\",\"vfModuleType\":\"vfModuleType\",\"heatStackId\":\"heatStackId\",\"hasVolumeGroup\":true,\"isBase\":true,\"vfModuleLabel\":\"vfModuleLabel\",\"initialCount\":0},{\"resourceType\":\"MODULE\",\"resourceInstance\":{},\"homingSolution\":{\"license\":{},\"rehome\":false},\"vfModuleName\":\"vfModuleName\",\"vfModuleType\":\"vfModuleType\",\"heatStackId\":\"heatStackId\",\"hasVolumeGroup\":true,\"isBase\":true,\"vfModuleLabel\":\"vfModuleLabel\",\"initialCount\":0}]}";
+
+ private VnfResource vnf = new VnfResource();
+ List<ModuleResource> 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");
+
+
+ }
+
+ @Test
+ public void vnfResourceMapperTest() throws IOException {
+ String jsonStr = "{\"vnfHostname\": \"home\", \"resourceInput\": \"sample\"}";
+ ObjectMapper objectMapper = new ObjectMapper();
+ VnfResource vnfResource = objectMapper.readValue(jsonStr, VnfResource.class);
+
+ assertTrue(vnfResource != null);
+ }
+
+ @Test
+ public void testVfModules() {
+
+ moduleResources = new ArrayList<>();
+
+ ModuleResource moduleresource = new ModuleResource();
+ moduleresource.setVfModuleName("vfModuleName");
+ moduleresource.setHeatStackId("heatStackId");
+ moduleresource.setIsBase(true);
+ moduleresource.setVfModuleLabel("vfModuleLabel");
+ moduleresource.setInitialCount(0);
+ moduleresource.setVfModuleType("vfModuleType");
+ moduleresource.setHasVolumeGroup(true);
+
+ moduleResources.add(moduleresource);
+
+ vnf.setModules(moduleResources);
+ assertEquals(vnf.getVfModules(), moduleResources);
+
+ List<ModuleResource> moduleResources = vnf.getAllVfModuleObjects();
+ assertEquals(1, moduleResources.size());
+
+ vnf.addVfModule(moduleresource);
+ moduleResources = vnf.getAllVfModuleObjects();
+ assertEquals(2, moduleResources.size());
+
+ assertEquals(ALL_VF_MODULES_JSON, vnf.getAllVfModulesJson());
+
+ }
}
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
index 14b8c49655..e62ff09545 100644
--- 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
@@ -19,10 +19,10 @@
*/
package org.onap.so.bpmn.core.internal;
+
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.contains;
-
import java.util.Optional;
import org.junit.Test;
@@ -86,4 +86,4 @@ public class VariableNameExtractorTest {
// 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
index c1f7cce30b..3a8948c00d 100644
--- 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
@@ -1,27 +1,21 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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;
@@ -34,137 +28,140 @@ 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;
- }
+ 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
index 6c8b7326e2..a9df2d9ea6 100644
--- 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
@@ -1,22 +1,17 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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;
@@ -25,14 +20,14 @@ 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());
- }
+ 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
index 667027f8de..1a2ceb5b39 100644
--- 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
@@ -22,12 +22,10 @@ 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;
@@ -46,102 +44,78 @@ import org.xmlunit.diff.ElementSelectors;
public class JsonUtils2Test {
private static final String EOL = "\n";
- private static final String XML_REQ =
- "<vnf-request xmlns=\"http://org.onap/so/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <request-id>DEV-VF-0021</request-id>" + EOL +
- " <action>CREATE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
- " <vnf-type>asc_heat-int</vnf-type>" + EOL +
- " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
- " <vf-module-model-name>STMTN5MMSC21-MMSC::model-1-0</vf-module-model-name>" + EOL +
- " <is-base-module>true</is-base-module>" + EOL +
- " <persona-model-id>00000000-0000-0000-0000-000000000000</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <vnf-persona-model-id>999999999-0000-0000-0000-000000000000</vnf-persona-model-id>" + EOL +
- " <vnf-persona-model-version>1.5</vnf-persona-model-version>" + EOL +
- " <service-id>00000000-0000-0000-0000-000000000000</service-id>" + EOL +
- " <service-type>SDN-ETHERNET-INTERNET</service-type>" + EOL +
- " <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id>" + EOL +
- " <orchestration-status>pending-delete</orchestration-status>" + EOL +
- " <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region>" + EOL +
- " <asdc-service-model-version>1</asdc-service-model-version>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://org.onap/so/infra/vnf-request/v1\">" + EOL +
- " <param name=\"network\">network1111</param>" + EOL +
- " <param name=\"server\">server1111</param>" + EOL +
- " </vnf-params> " + EOL +
- "</vnf-request>" + EOL;
-
- private static final String XML_REQ_NO_ATTRS =
- "<vnf-request xmlns=\"http://org.onap/so/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>DELETE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
- " <vnf-type>asc_heat-int</vnf-type>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
- " <service-id>00000000-0000-0000-0000-000000000000</service-id>" + EOL +
- " <service-type>SDN-ETHERNET-INTERNET</service-type>" + EOL +
- " <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id>" + EOL +
- " <orchestration-status>pending-delete</orchestration-status>" + EOL +
- " <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://org.onap/so/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
+ private static final String XML_REQ = "<vnf-request xmlns=\"http://org.onap/so/infra/vnf-request/v1\">" + EOL
+ + " <request-info>" + EOL + " <request-id>DEV-VF-0021</request-id>" + EOL
+ + " <action>CREATE_VF_MODULE</action>" + EOL + " <source>PORTAL</source>" + EOL + " </request-info>"
+ + EOL + " <vnf-inputs>" + EOL + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL + " <vnf-type>asc_heat-int</vnf-type>" + EOL
+ + " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <vf-module-model-name>STMTN5MMSC21-MMSC::model-1-0</vf-module-model-name>" + EOL
+ + " <is-base-module>true</is-base-module>" + EOL
+ + " <persona-model-id>00000000-0000-0000-0000-000000000000</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <vnf-persona-model-id>999999999-0000-0000-0000-000000000000</vnf-persona-model-id>" + EOL
+ + " <vnf-persona-model-version>1.5</vnf-persona-model-version>" + EOL
+ + " <service-id>00000000-0000-0000-0000-000000000000</service-id>" + EOL
+ + " <service-type>SDN-ETHERNET-INTERNET</service-type>" + EOL
+ + " <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id>" + EOL
+ + " <orchestration-status>pending-delete</orchestration-status>" + EOL
+ + " <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region>" + EOL
+ + " <asdc-service-model-version>1</asdc-service-model-version>" + EOL + " </vnf-inputs>" + EOL
+ + " <vnf-params xmlns:tns=\"http://org.onap/so/infra/vnf-request/v1\">" + EOL
+ + " <param name=\"network\">network1111</param>" + EOL + " <param name=\"server\">server1111</param>"
+ + EOL + " </vnf-params> " + EOL + "</vnf-request>" + EOL;
+
+ private static final String XML_REQ_NO_ATTRS = "<vnf-request xmlns=\"http://org.onap/so/infra/vnf-request/v1\">"
+ + EOL + " <request-info>" + EOL + " <action>DELETE_VF_MODULE</action>" + EOL
+ + " <source>PORTAL</source>" + EOL + " </request-info>" + EOL + " <vnf-inputs>" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL + " <vnf-type>asc_heat-int</vnf-type>" + EOL
+ + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <service-id>00000000-0000-0000-0000-000000000000</service-id>" + EOL
+ + " <service-type>SDN-ETHERNET-INTERNET</service-type>" + EOL
+ + " <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id>" + EOL
+ + " <orchestration-status>pending-delete</orchestration-status>" + EOL
+ + " <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region>" + EOL + " </vnf-inputs>" + EOL
+ + " <vnf-params xmlns:tns=\"http://org.onap/so/infra/vnf-request/v1\"/>" + EOL + "</vnf-request>" + EOL;
private static final String XML_ARRAY_REQ =
- "<ucpeInfo>" + EOL +
- " <outOfBandManagementModem>BROADBAND</outOfBandManagementModem>" + EOL +
- " <internetTopology>IVLAN</internetTopology>" + EOL +
- " <ucpeAliasHostName>SHELLUCPE31</ucpeAliasHostName>" + EOL +
- " <wanList>" + EOL +
- " <wanInfo>" + EOL +
- " <wanType>AVPN</wanType>" + EOL +
- " <interfaceType>1000BASE-T</interfaceType>" + EOL +
- " <transportProviderName>ATT</transportProviderName>" + EOL +
- " <circuitId>BT/SLIR/70911</circuitId>" + EOL +
- " <dualMode>Active</dualMode>" + EOL +
- " <wanPortNumber>WAN1</wanPortNumber>" + EOL +
- " <transportManagementOption>ATT</transportManagementOption>" + EOL +
- " <transportVendorTotalBandwidth>100</transportVendorTotalBandwidth>" + EOL +
- " <mediaType>ELECTRICAL</mediaType>" + EOL +
- " </wanInfo>" + EOL +
- " <wanInfo>" + EOL +
- " <wanType>AVPN</wanType>" + EOL +
- " <interfaceType>10/100/1000BASE-T</interfaceType>" + EOL +
- " <transportProviderName>ATT</transportProviderName>" + EOL +
- " <circuitId>AS/KRFN/34611</circuitId>" + EOL +
- " <dualMode>Active</dualMode>" + EOL +
- " <wanPortNumber>WAN2</wanPortNumber>" + EOL +
- " <transportManagementOption>ATT</transportManagementOption>" + EOL +
- " <transportVendorTotalBandwidth>10000</transportVendorTotalBandwidth>" + EOL +
- " <mediaType>MMF</mediaType>" + EOL +
- " </wanInfo>" + EOL +
- " </wanList>" + EOL +
- " <ucpeActivationCode>ASD-987-M31</ucpeActivationCode>" + EOL +
- " <ucpeHostName>USOSTCDALTX0101UJZZ31</ucpeHostName>" + EOL +
- " <ucpePartNumber>FG-VM00*</ucpePartNumber>" + EOL +
- "</ucpeInfo>";
+ "<ucpeInfo>" + EOL + " <outOfBandManagementModem>BROADBAND</outOfBandManagementModem>" + EOL
+ + " <internetTopology>IVLAN</internetTopology>" + EOL
+ + " <ucpeAliasHostName>SHELLUCPE31</ucpeAliasHostName>" + EOL + " <wanList>" + EOL
+ + " <wanInfo>" + EOL + " <wanType>AVPN</wanType>" + EOL
+ + " <interfaceType>1000BASE-T</interfaceType>" + EOL
+ + " <transportProviderName>ATT</transportProviderName>" + EOL
+ + " <circuitId>BT/SLIR/70911</circuitId>" + EOL
+ + " <dualMode>Active</dualMode>" + EOL
+ + " <wanPortNumber>WAN1</wanPortNumber>" + EOL
+ + " <transportManagementOption>ATT</transportManagementOption>" + EOL
+ + " <transportVendorTotalBandwidth>100</transportVendorTotalBandwidth>" + EOL
+ + " <mediaType>ELECTRICAL</mediaType>" + EOL + " </wanInfo>" + EOL
+ + " <wanInfo>" + EOL + " <wanType>AVPN</wanType>" + EOL
+ + " <interfaceType>10/100/1000BASE-T</interfaceType>" + EOL
+ + " <transportProviderName>ATT</transportProviderName>" + EOL
+ + " <circuitId>AS/KRFN/34611</circuitId>" + EOL
+ + " <dualMode>Active</dualMode>" + EOL
+ + " <wanPortNumber>WAN2</wanPortNumber>" + EOL
+ + " <transportManagementOption>ATT</transportManagementOption>" + EOL
+ + " <transportVendorTotalBandwidth>10000</transportVendorTotalBandwidth>" + EOL
+ + " <mediaType>MMF</mediaType>" + EOL + " </wanInfo>" + EOL
+ + " </wanList>" + EOL + " <ucpeActivationCode>ASD-987-M31</ucpeActivationCode>" + EOL
+ + " <ucpeHostName>USOSTCDALTX0101UJZZ31</ucpeHostName>" + EOL
+ + " <ucpePartNumber>FG-VM00*</ucpePartNumber>" + EOL + "</ucpeInfo>";
// 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);
@@ -149,16 +123,16 @@ public class JsonUtils2Test {
@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
-
+ // 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);
+ String xmlOut = JsonUtils.json2xml(json);
// then
Diff diffXml = DiffBuilder.compare(xmlIn).withTest(xmlOut).ignoreWhitespace()
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)).checkForSimilar().build();
@@ -214,7 +188,7 @@ public class JsonUtils2Test {
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
@@ -265,11 +239,11 @@ public class JsonUtils2Test {
// 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);
+ 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
@@ -282,26 +256,26 @@ public class JsonUtils2Test {
// 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));
+ 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);
+ 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);
+ 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();
@@ -311,19 +285,19 @@ public class JsonUtils2Test {
@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();
- }
+ 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
index 067ae9806d..36ffc0b04d 100644
--- 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
@@ -23,13 +23,11 @@ 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;
@@ -43,203 +41,232 @@ 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<String, String> 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<String, String> map = utils.entryArrayToMap(execution, assignmentInfo.toString(), "variableName", "variableValue");
- assertEquals(map.get("cloudOwner"), "CloudOwner");
- }
- @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<String, String> map = utils.entryArrayToMap(assignmentInfo.toString(), "variableName", "variableValue");
- assertEquals(map.get("cloudOwner"), "CloudOwner");
- }
- @Test
- public void entryArrayToMapStringTestOof() throws IOException {
- JsonUtils utils = new JsonUtils();
- String response = this.getJson("OofExample.json");
- String entry = JsonUtils.getJsonValue(response, "solutions.placementSolutions");
- JSONArray arr = new JSONArray(entry);
- JSONArray arr2 = arr.getJSONArray(0);
- JSONObject homingDataJson = arr2.getJSONObject(0);
- JSONArray assignmentInfo = homingDataJson.getJSONArray("assignmentInfo");
- Map<String, String> map = utils.entryArrayToMap(assignmentInfo.toString(), "key", "value");
- assertEquals(map.get("cloudOwner"), "HPA-cloud");
- }
- @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<String> 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<String> 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<String> 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 = "<name>myName</name>";
- assertEquals(expectedJson, JsonUtils.xml2json(xml,false));
- }
- @Test
- public void xml2jsonErrorTest() throws IOException {
- String malformedXml = "<name>myName<name>";
- assertNull(JsonUtils.xml2json(malformedXml));
- }
- @Test
- public void json2xmlTest() throws IOException {
- String expectedXml = "<name>myName</name>";
- 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)));
- }
+ @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<String, String> 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<String, String> map =
+ utils.entryArrayToMap(execution, assignmentInfo.toString(), "variableName", "variableValue");
+ assertEquals(map.get("cloudOwner"), "CloudOwner");
+ }
+
+ @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<String, String> map = utils.entryArrayToMap(assignmentInfo.toString(), "variableName", "variableValue");
+ assertEquals(map.get("cloudOwner"), "CloudOwner");
+ }
+
+ @Test
+ public void entryArrayToMapStringTestOof() throws IOException {
+ JsonUtils utils = new JsonUtils();
+ String response = this.getJson("OofExample.json");
+ String entry = JsonUtils.getJsonValue(response, "solutions.placementSolutions");
+ JSONArray arr = new JSONArray(entry);
+ JSONArray arr2 = arr.getJSONArray(0);
+ JSONObject homingDataJson = arr2.getJSONObject(0);
+ JSONArray assignmentInfo = homingDataJson.getJSONArray("assignmentInfo");
+ Map<String, String> map = utils.entryArrayToMap(assignmentInfo.toString(), "key", "value");
+ assertEquals(map.get("cloudOwner"), "HPA-cloud");
+ }
+
+ @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<String> 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<String> 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<String> 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 = "<name>myName</name>";
+ assertEquals(expectedJson, JsonUtils.xml2json(xml, false));
+ }
+
+ @Test
+ public void xml2jsonErrorTest() throws IOException {
+ String malformedXml = "<name>myName<name>";
+ assertNull(JsonUtils.xml2json(malformedXml));
+ }
+
+ @Test
+ public void json2xmlTest() throws IOException {
+ String expectedXml = "<name>myName</name>";
+ 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
index 15f6fbe008..b6a2e789ba 100644
--- 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
@@ -25,7 +25,6 @@ package org.onap.so.bpmn.core.utils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,43 +32,42 @@ import org.slf4j.LoggerFactory;
* Sets up the unit test (H2) database for Camunda.
*/
public class CamundaDBSetup {
- private static boolean isDBConfigured = false;
- private static final Logger logger = LoggerFactory.getLogger(CamundaDBSetup.class);
-
- private CamundaDBSetup() {
- }
-
- public static synchronized void configure() throws SQLException {
- if (isDBConfigured) {
- return;
- }
+ private static boolean isDBConfigured = false;
+ private static final Logger logger = LoggerFactory.getLogger(CamundaDBSetup.class);
+
+ private CamundaDBSetup() {}
+
+ public static synchronized void configure() throws SQLException {
+ if (isDBConfigured) {
+ return;
+ }
+
+ logger.debug("Configuring the Camunda H2 database for MSO");
- logger.debug ("Configuring the Camunda H2 database for MSO");
+ Connection connection = null;
+ PreparedStatement stmt = null;
- Connection connection = null;
- PreparedStatement stmt = null;
+ try {
- try {
+ isDBConfigured = true;
- isDBConfigured = true;
-
- } finally {
- if (stmt != null) {
- try {
- stmt.close();
- } catch (Exception e) {
- logger.debug("Exception :",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);
- }
- }
- }
- }
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ }
+ }
+ }
+ }
}
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
index 6bad0c6c29..d099cbebcc 100644
--- 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
@@ -1,82 +1,72 @@
/*
-* ============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
+ * ============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
+ * 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.
+ * 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 = "<Response>good</Response>";
- private String responseModified = "<Response>veryGood</Response>";
- private String encodeResponse = "&lt;Response&gt;good&lt;/Response&gt;";
- private String encodeResponseNamespace = "<Response xmlns:ns2=\"http://ecomp.att.com/mso/request/types/v1\">good</Response>";
- private String attribute = "<Response>good&\"bad\"</Response>";
- private String updatedAttribute = "&lt;Response&gt;good&amp;&quot;bad&quot;&lt;/Response&gt;";
+ private String response = "<Response>good</Response>";
+ private String responseModified = "<Response>veryGood</Response>";
+ private String encodeResponse = "&lt;Response&gt;good&lt;/Response&gt;";
+ private String encodeResponseNamespace =
+ "<Response xmlns:ns2=\"http://ecomp.att.com/mso/request/types/v1\">good</Response>";
+ private String attribute = "<Response>good&\"bad\"</Response>";
+ private String updatedAttribute = "&lt;Response&gt;good&amp;&quot;bad&quot;&lt;/Response&gt;";
+
+ private String content = "<dummy><configuration-event>" + "<event-type>test</event-type>"
+ + "<event-correlator-type>test</event-correlator-type>" + "<event-correlator>123</event-correlator>"
+ + "<event-parameters><event-parameter>" + "<tag-name>test</tag-name>"
+ + "<tag-value>test</tag-value></event-parameter></event-parameters>" + "</configuration-event></dummy>";
+
+ @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<String> 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);
- private String content = "<dummy><configuration-event>" +
- "<event-type>test</event-type>" +
- "<event-correlator-type>test</event-correlator-type>" +
- "<event-correlator>123</event-correlator>" +
- "<event-parameters><event-parameter>" +
- "<tag-name>test</tag-name>" +
- "<tag-value>test</tag-value></event-parameter></event-parameters>" +
- "</configuration-event></dummy>";
-
- @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<String> 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"));
- }
+ 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 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);
- }
+ @Test
+ public void modifyElementTest() throws Exception {
+ String response = XmlTool.modifyElement(content, "event-type", "uCPE-VMS").get();
+ assertNotNull(response);
+ }
}