aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2019-02-01 12:11:04 +0100
committerWojciech Sliwka <wojciech.sliwka@nokia.com>2019-03-18 09:28:45 +0100
commitdecbd5f538625d4d5f69927083e2ab0bab44e801 (patch)
treeb79900cebd16cc59b20ee551d147f161cbb5fb61 /vid-app-common/src
parent37ad0cc1d36ec6ff68ec39fcaaf2617eef7d08fe (diff)
second part of tests
Change-Id: I799ddd9b8a7b9224e195c1fccf4706f5ff76c0e0 Issue-ID: VID-385 Signed-off-by: Wojciech Sliwka <wojciech.sliwka@nokia.com>
Diffstat (limited to 'vid-app-common/src')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java1
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java216
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/ServicePropertiesTest.java97
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/SubscriberWithFilterTest.java36
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java84
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipListTest.java35
6 files changed, 206 insertions, 263 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java
index 8bcadd139..5bdfd1207 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java
@@ -18,7 +18,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.onap.vid.aai;
import com.google.common.collect.ImmutableList;
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java
index 76cd21391..7f5e362ba 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java
@@ -3,13 +3,14 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,190 +21,43 @@
package org.onap.vid.aai;
-import org.junit.Test;
-import org.onap.vid.aai.model.RelationshipList;
-public class OperationalEnvironmentTest {
-
- private OperationalEnvironment createTestSubject() {
- return new OperationalEnvironment();
- }
-
- @Test
- public void testGetOperationalEnvironmentId() throws Exception {
- OperationalEnvironment testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperationalEnvironmentId();
- }
-
- @Test
- public void testSetOperationalEnvironmentId() throws Exception {
- OperationalEnvironment testSubject;
- String operationalEnvironmentId = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonOperationalEnvironmentId(operationalEnvironmentId);
- }
-
- @Test
- public void testGetOperationalEnvironmentName() throws Exception {
- OperationalEnvironment testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperationalEnvironmentName();
- }
-
- @Test
- public void testSetOperationalEnvironmentName() throws Exception {
- OperationalEnvironment testSubject;
- String operationalEnvironmentName = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonOperationalEnvironmentName(operationalEnvironmentName);
- }
-
- @Test
- public void testGetOperationalEnvironmentType() throws Exception {
- OperationalEnvironment testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperationalEnvironmentType();
- }
-
- @Test
- public void testSetOperationalEnvironmentType() throws Exception {
- OperationalEnvironment testSubject;
- String operationalEnvironmentType = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonOperationalEnvironmentType(operationalEnvironmentType);
- }
-
- @Test
- public void testGetOperationalEnvironmentStatus() throws Exception {
- OperationalEnvironment testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperationalEnvironmentStatus();
- }
-
- @Test
- public void testSetOperationalEnvironmentStatus() throws Exception {
- OperationalEnvironment testSubject;
- String operationalEnvironmentStatus = "";
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.testng.annotations.Test;
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonOperationalEnvironmentStatus(operationalEnvironmentStatus);
- }
+import java.io.IOException;
- @Test
- public void testGetTenantContext() throws Exception {
- OperationalEnvironment testSubject;
- String result;
+import static org.assertj.core.api.Assertions.assertThat;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getTenantContext();
- }
-
- @Test
- public void testSetTenantContext() throws Exception {
- OperationalEnvironment testSubject;
- String tenantContext = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonTenantContext(tenantContext);
- }
-
- @Test
- public void testGetWorkloadContext() throws Exception {
- OperationalEnvironment testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getWorkloadContext();
- }
-
- @Test
- public void testSetWorkloadContext() throws Exception {
- OperationalEnvironment testSubject;
- String workloadContext = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonWorkloadContext(workloadContext);
- }
-
- @Test
- public void testGetResourceVersion() throws Exception {
- OperationalEnvironment testSubject;
- String result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getResourceVersion();
- }
-
- @Test
- public void testSetResourceVersion() throws Exception {
- OperationalEnvironment testSubject;
- String resourceVersion = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonResourceVersion(resourceVersion);
- }
-
- @Test
- public void testGetRelationshipList() throws Exception {
- OperationalEnvironment testSubject;
- RelationshipList result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRelationshipList();
- }
-
- @Test
- public void testSetRelationshipList() throws Exception {
- OperationalEnvironment testSubject;
- RelationshipList relationshipList = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonRelationshipList(relationshipList);
- }
-
- @Test
- public void testOperationalEnvironment() throws Exception {
- OperationalEnvironment testSubject;
- String operationalEnvironmentId = "";
- String operationalEnvironmentName = "";
- String operationalEnvironmentType = "";
- String operationalEnvironmentStatus = "";
- String tenantContext = "";
- String workloadContext = "";
- String resourceVersion = "";
- RelationshipList relationshipList = null;
+public class OperationalEnvironmentTest {
- // default test
- testSubject = new OperationalEnvironment(operationalEnvironmentId, operationalEnvironmentName,
- operationalEnvironmentType, operationalEnvironmentStatus, tenantContext, workloadContext,
- resourceVersion, relationshipList);
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ private static final String OPERATIONAL_ENVIRONMENT_TEST = "{\n" +
+ "\"operational-environment-id\": \"environmentId\",\n" +
+ "\"operational-environment-name\": \"environmentName\",\n" +
+ "\"operational-environment-type\": \"environmentType\",\n" +
+ "\"operational-environment-status\": \"environmentStatus\",\n" +
+ "\"tenant-context\": \"tenantContext\",\n" +
+ "\"workload-context\": \"workloadContext\",\n" +
+ "\"resource-version\": \"resourceVersion\",\n" +
+ "\"relationship-list\": {\n" +
+ "\"relationship\": []\n" +
+ "}\n" +
+ "}";
+
+ @Test
+ public void shouldProperlyConvertJsonToOperationalEnvironment() throws IOException {
+ OperationalEnvironment operationalEnvironment = OBJECT_MAPPER.readValue(OPERATIONAL_ENVIRONMENT_TEST, OperationalEnvironment.class);
+
+ assertThat(operationalEnvironment.getOperationalEnvironmentId()).isEqualTo("environmentId");
+ assertThat(operationalEnvironment.getWorkloadContext()).isEqualTo("workloadContext");
+ assertThat(operationalEnvironment.getRelationshipList().getRelationship()).hasSize(0);
+ assertThat(operationalEnvironment.getResourceVersion()).isEqualTo("resourceVersion");
+ assertThat(operationalEnvironment.getTenantContext()).isEqualTo("tenantContext");
+ assertThat(operationalEnvironment.getOperationalEnvironmentType()).isEqualTo("environmentType");
+ assertThat(operationalEnvironment.getOperationalEnvironmentStatus()).isEqualTo("environmentStatus");
+ assertThat(operationalEnvironment.getOperationalEnvironmentName()).isEqualTo("environmentName");
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/ServicePropertiesTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/ServicePropertiesTest.java
index 6ff766413..4c0875320 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/ServicePropertiesTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/ServicePropertiesTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,35 +20,76 @@
package org.onap.vid.aai;
-import java.util.Map;
+import java.io.IOException;
-import org.junit.Test;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.vid.aai.model.ServiceProperties;
+import org.testng.annotations.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
public class ServicePropertiesTest {
- private ServiceProperties createTestSubject() {
- return new ServiceProperties();
- }
-
- @Test
- public void testGetAdditionalProperties() throws Exception {
- ServiceProperties testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAdditionalProperties();
- }
-
- @Test
- public void testSetAdditionalProperty() throws Exception {
- ServiceProperties testSubject;
- String name = "";
- Object value = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAdditionalProperty(name, value);
- }
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+ private static final String SERVICE_PROPERTIES_JSON = "{\n" +
+ "\"service-instance-id\": \"instanceId\",\n" +
+ "\"service-instance-name\": \"instanceName\",\n" +
+ "\"model-invariant-id\": \"invariantId\",\n" +
+ "\"model-version-id\": \"versionId\",\n" +
+ "\"resource-version\": \"version\",\n" +
+ "\"orchestration-status\": \"status\",\n" +
+ "\"global-customer-id\": \"customerId\",\n" +
+ "\"subscriber-name\": \"subscriberName\",\n" +
+ "\"subscriber-type\": \"subscriberType\",\n" +
+ "\"vnf-id\": \"vnfId\",\n" +
+ "\"vnf-name\": \"vnfName\",\n" +
+ "\"vnf-type\": \"vnfType\",\n" +
+ "\"service-id\": \"serviceId\",\n" +
+ "\"prov-status\": \"provStatus\",\n" +
+ "\"in-maint\": false,\n" +
+ "\"is-closed-loop-disabled\": false,\n" +
+ "\"model-customization-id\": \"customizationId\",\n" +
+ "\"nf-type\": \"nfType\",\n" +
+ "\"nf-function\": \"nfFunction\",\n" +
+ "\"nf-role\": \"nfRole\",\n" +
+ "\"nf-naming-code\": \"namingCode\",\n" +
+ "\"not-listed-property\":\"value\"}"+
+ "}";
+
+
+ @Test
+ public void shouldProperlyConvertJsonToServiceProperties() throws IOException {
+ ServiceProperties serviceProperties = OBJECT_MAPPER.readValue(SERVICE_PROPERTIES_JSON, ServiceProperties.class);
+
+
+ assertThat(serviceProperties.isClosedLoopDisabled).isFalse();
+ assertThat(serviceProperties.globalCustomerId).isEqualTo("customerId");
+ assertThat(serviceProperties.inMaint).isFalse();
+ assertThat(serviceProperties.modelCustomizationId).isEqualTo("customizationId");
+ assertThat(serviceProperties.modelInvariantId).isEqualTo("invariantId");
+ assertThat(serviceProperties.modelVersionId).isEqualTo("versionId");
+ assertThat(serviceProperties.nfRole).isEqualTo("nfRole");
+ assertThat(serviceProperties.nfFunction).isEqualTo("nfFunction");
+ assertThat(serviceProperties.nfType).isEqualTo("nfType");
+ assertThat(serviceProperties.nfNamingCode).isEqualTo("namingCode");
+ assertThat(serviceProperties.serviceId).isEqualTo("serviceId");
+ assertThat(serviceProperties.serviceInstanceName).isEqualTo("instanceName");
+ assertThat(serviceProperties.serviceInstanceId).isEqualTo("instanceId");
+ assertThat(serviceProperties.provStatus).isEqualTo("provStatus");
+ assertThat(serviceProperties.vnfId).isEqualTo("vnfId");
+ assertThat(serviceProperties.vnfName).isEqualTo("vnfName");
+ assertThat(serviceProperties.vnfType).isEqualTo("vnfType");
+ }
+
+ @Test
+ public void shouldProperlyAddAdditionalProperty() throws IOException {
+ ServiceProperties serviceProperties = OBJECT_MAPPER.readValue(SERVICE_PROPERTIES_JSON, ServiceProperties.class);
+
+
+ serviceProperties.setAdditionalProperty("additional", "property");
+
+ assertThat(serviceProperties.getAdditionalProperties())
+ .containsOnlyKeys("not-listed-property","additional")
+ .containsValues("value","property");
+ }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberWithFilterTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberWithFilterTest.java
index 2842b08dc..c690b5fa0 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberWithFilterTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberWithFilterTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,31 +20,15 @@
package org.onap.vid.aai;
-import org.junit.Test;
-public class SubscriberWithFilterTest {
-
- private SubscriberWithFilter createTestSubject() {
- return new SubscriberWithFilter();
- }
-
- @Test
- public void testGetIsPermitted() throws Exception {
- SubscriberWithFilter testSubject;
- boolean result;
+import org.testng.annotations.Test;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getIsPermitted();
- }
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
- @Test
- public void testSetIsPermitted() throws Exception {
- SubscriberWithFilter testSubject;
- boolean isPermitted = false;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setIsPermitted(isPermitted);
- }
+public class SubscriberWithFilterTest {
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(SubscriberWithFilter.class, hasValidGettersAndSetters());
+ }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java
index 6f403d9da..7ee3b6152 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,34 +20,64 @@
package org.onap.vid.aai;
-import org.junit.Test;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.vid.aai.model.VnfResult;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+
+import static org.assertj.core.api.Assertions.assertThat;
-import java.util.Map;
public class VnfResultTest {
- private VnfResult createTestSubject() {
- return new VnfResult();
- }
-
- @Test
- public void testGetAdditionalProperties() throws Exception {
- VnfResult testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAdditionalProperties();
- }
-
- @Test
- public void testSetAdditionalProperty() throws Exception {
- VnfResult testSubject;
- String name = "";
- Object value = null;
-
- // default test
- testSubject = createTestSubject();
- }
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ private static final String VNF_RESULT_JSON = "{\n" +
+ "\"id\": \"sample\",\n" +
+ "\"node-type\": \"sampleNodeType\",\n" +
+ "\"url\": \"sample\",\n" +
+ "\"properties\": {\n" +
+ "\"service-instance-id\": \"sample\",\n" +
+ "\"service-instance-name\": \"sample\",\n" +
+ "\"model-invariant-id\": \"sample\",\n" +
+ "\"model-version-id\": \"sample\",\n" +
+ "\"resource-version\": \"sample\",\n" +
+ "\"orchestration-status\": \"sample\",\n" +
+ "\"global-customer-id\": \"sample\",\n" +
+ "\"subscriber-name\": \"sample\",\n" +
+ "\"subscriber-type\": \"sample\",\n" +
+ "\"vnf-id\": \"sample\",\n" +
+ "\"vnf-name\": \"sample\",\n" +
+ "\"vnf-type\": \"sample\",\n" +
+ "\"service-id\": \"sample\",\n" +
+ "\"prov-status\": \"sample\",\n" +
+ "\"in-maint\": false,\n" +
+ "\"is-closed-loop-disabled\": false,\n" +
+ "\"model-customization-id\": \"sample\",\n" +
+ "\"nf-type\": \"sample\",\n" +
+ "\"nf-function\": \"sample\",\n" +
+ "\"nf-role\": \"sample\",\n" +
+ "\"nf-naming-code\": \"sample\"\n" +
+ "},\n" +
+ "\"related-to\": [{\n" +
+ "\"id\": \"sample\",\n" +
+ "\"relationship-label\": \"sample\",\n" +
+ "\"node-type\": \"sample\",\n" +
+ "\"url\": \"sample\"\n" +
+ "\t}]\n" +
+ "}";
+
+
+ @Test
+ public void shouldProperlyConvertJsonToVnfResult() throws IOException {
+ VnfResult vnfResult = OBJECT_MAPPER.readValue(VNF_RESULT_JSON, VnfResult.class);
+
+ assertThat(vnfResult.nodeType).isEqualTo("sampleNodeType");
+ assertThat(vnfResult.id).isEqualTo("sample");
+ assertThat(vnfResult.url).isEqualTo("sample");
+ assertThat(vnfResult.relatedTo).hasSize(1);
+ assertThat(vnfResult.properties.globalCustomerId).isEqualTo("sample");
+ assertThat(vnfResult.getAdditionalProperties()).isEmpty();
+ }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipListTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipListTest.java
new file mode 100644
index 000000000..cc57171b8
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipListTest.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.aai.model;
+
+
+import org.testng.annotations.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class RelationshipListTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(RelationshipList.class, hasValidGettersAndSetters());
+ }
+}