diff options
author | 2019-03-04 15:55:31 +0100 | |
---|---|---|
committer | 2019-03-08 13:45:31 +0100 | |
commit | b81d99e45042cfd7a4356465b653896f658316ee (patch) | |
tree | 30ab1773dcee2c4cd128002f6ae3e56c5ca0ef69 /vid-app-common/src/test/java/org | |
parent | 8ebd71ed51786d84d9b3cadae421db409a719034 (diff) |
Increasing test coverage for vid.mso.model
Change-Id: Id9e5aefddbb47a60bb937c89a25d5584505e2edb
Issue-ID: VID-387
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Diffstat (limited to 'vid-app-common/src/test/java/org')
2 files changed, 52 insertions, 59 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java index 2a69e0e79..131e5dd46 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.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,45 +20,48 @@ package org.onap.vid.mso.model; -import org.junit.Test; import org.onap.vid.controller.OperationalEnvironmentController; -import org.onap.vid.controller.OperationalEnvironmentController.OperationalEnvironmentActivateBody; import org.onap.vid.controller.OperationalEnvironmentController.OperationalEnvironmentManifest; +import org.testng.annotations.Test; -public class OperationalEnvironmentActivateInfoTest { +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; - private OperationalEnvironmentActivateInfo createTestSubject() { - OperationalEnvironmentController.OperationalEnvironmentActivateBody a = new OperationalEnvironmentActivateBody("a", "b", "c", new OperationalEnvironmentManifest()); - return new OperationalEnvironmentActivateInfo(a, "", ""); - } +public class OperationalEnvironmentActivateInfoTest { @Test - public void testGetUserId() throws Exception { - OperationalEnvironmentActivateInfo testSubject; - String result; + public void shouldProperlyCreateOperationalEnvironmentActivateInfoWithParameters() { + // given + String relatedInstanceId = "testRelatedInstanceId"; + String relatedInstanceName = "testRelatedInstanceName"; + String workloadContext = "testWorkloadContext"; + OperationalEnvironmentManifest manifest = new OperationalEnvironmentManifest(); - // default test - testSubject = createTestSubject(); - result = testSubject.getUserId(); - } + String userId = "testUserId"; + String operationalEnvironmentId = "testOperationalEnvironmentId"; - @Test - public void testGetOperationalEnvironmentId() throws Exception { - OperationalEnvironmentActivateInfo testSubject; - String result; + OperationalEnvironmentController.OperationalEnvironmentActivateBody operationalEnvironmentActivateBody = + new OperationalEnvironmentController.OperationalEnvironmentActivateBody + (relatedInstanceId,relatedInstanceName,workloadContext,manifest); - // default test - testSubject = createTestSubject(); - result = testSubject.getOperationalEnvironmentId(); - } + // when + OperationalEnvironmentActivateInfo operationalEnvironmentActivateInfo = + new OperationalEnvironmentActivateInfo(operationalEnvironmentActivateBody, userId, operationalEnvironmentId); - @Test - public void testToString() throws Exception { - OperationalEnvironmentActivateInfo testSubject; - String result; - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); + // then + assertThat(operationalEnvironmentActivateInfo.getUserId()).isEqualTo(userId); + assertThat(operationalEnvironmentActivateInfo.getOperationalEnvironmentId()).isEqualTo(operationalEnvironmentId); + + assertThat(operationalEnvironmentActivateInfo.toString()).isEqualToIgnoringWhitespace( + "OperationalEnvironmentActivateInfo{operationalEnvironmentId="+operationalEnvironmentId+"," + + " userId="+userId+"," + + " super=OperationalEnvironmentActivateInfo{" + + " relatedInstanceId="+relatedInstanceId+"," + + " relatedInstanceName="+relatedInstanceName+"," + + " workloadContext="+workloadContext+"," + + " manifest="+manifest.toString()+"}}" + ); + } -} + +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java index 22310d2e2..72fb9d6dc 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java @@ -20,41 +20,31 @@ package org.onap.vid.mso.model; -import org.junit.Test; +import org.testng.annotations.Test; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; public class OperationalEnvironmentDeactivateInfoTest { - private OperationalEnvironmentDeactivateInfo createTestSubject() { - return new OperationalEnvironmentDeactivateInfo("", ""); - } - @Test - public void testGetUserId() throws Exception { - OperationalEnvironmentDeactivateInfo testSubject; - String result; + public void shouldProperlyCreateOperationalEnvironmentActivateInfoWithParameters() { + // given + String userId = "testUserId"; + String operationalEnvironmentId = "testOperationalEnvironmentId"; - // default test - testSubject = createTestSubject(); - result = testSubject.getUserId(); - } - @Test - public void testGetOperationalEnvironmentId() throws Exception { - OperationalEnvironmentDeactivateInfo testSubject; - String result; + // when + OperationalEnvironmentDeactivateInfo operationalEnvironmentDeactivateInfo = + new OperationalEnvironmentDeactivateInfo(userId, operationalEnvironmentId); - // default test - testSubject = createTestSubject(); - result = testSubject.getOperationalEnvironmentId(); - } - @Test - public void testToString() throws Exception { - OperationalEnvironmentDeactivateInfo testSubject; - String result; + // then + assertThat(operationalEnvironmentDeactivateInfo.getUserId()).isEqualTo(userId); + assertThat(operationalEnvironmentDeactivateInfo.getOperationalEnvironmentId()).isEqualTo(operationalEnvironmentId); + + assertThat(operationalEnvironmentDeactivateInfo.toString()).isEqualToIgnoringWhitespace( + "OperationalEnvironmentDeactivateInfo{operationalEnvironmentId="+operationalEnvironmentId+"," + + " userId="+userId+"}" + ); - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); } } |