diff options
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java')
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java | 216 |
1 files changed, 35 insertions, 181 deletions
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"); } } |