diff options
author | Michal Kabaj <michal.kabaj@nokia.com> | 2018-10-22 14:42:31 +0200 |
---|---|---|
committer | Michal Kabaj <michal.kabaj@nokia.com> | 2018-10-23 10:05:11 +0200 |
commit | 4b4e939ad40da621e8669787922e0c6de2c85f68 (patch) | |
tree | 8f8bd4e0241a3fefc3d5d4cc2268de3016a0b884 /vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java | |
parent | 257b1c097a15a6f13f8fad8e218af4a7a8e690e3 (diff) |
Fix and improvement for MsoBusinessLogic tests
- Merged two test classes into one
Moved unit tests from MsoBusinessLogic to MsoBusinessLogicImpl
- unified unit test framework - using junit instead of testng
- Fixed issue with broken unit tests when run in IDE
- improved readability of unit tests
- Fixed commented/ignored unit tests
- RequestDetailsWrapper encapsulation fix
Change-Id: I7f589b36757b09f41b3568d8aa8a932bd914ac0d
Issue-ID: VID-283
Signed-off-by: Michal Kabaj <michal.kabaj@nokia.com>
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java')
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java deleted file mode 100644 index af7f74b3..00000000 --- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.onap.vid.mso; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.vid.mso.MsoBusinessLogicImpl; -import org.onap.vid.mso.MsoInterface; -import org.onap.vid.mso.MsoResponseWrapper; -import org.onap.vid.mso.rest.RequestDetails; -import org.onap.vid.mso.rest.RequestDetailsWrapper; -import org.testng.annotations.Test; - -import java.net.URL; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -@RunWith(MockitoJUnitRunner.class) -public class MsoBusinessLogicTest { - - @InjectMocks - private MsoBusinessLogicImpl msoBusinessLogic; - - @Mock - private MsoInterface msoClient; - - @Test - public void testCreateInstance() throws Exception { - String instanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d"; - final RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); - requestDetailsWrapper.requestDetails = setRequestDetails("mso_request_create_configuration.json"); - Mockito.doReturn(getOkResponse(instanceId)).when(msoClient).createConfigurationInstance(requestDetailsWrapper, "/serviceInstances/v6/3f93c7cb-2fd0-4557-9514-e189b7b04f9d/configurations"); - final MsoResponseWrapper msoResponseWrapper = msoBusinessLogic.createConfigurationInstance(requestDetailsWrapper, instanceId); - - assertNotNull(msoResponseWrapper); - assertEquals(202, msoResponseWrapper.getStatus()); - } - - private MsoResponseWrapper getOkResponse(String instanceId){ - MsoResponseWrapper responseWrapper = new MsoResponseWrapper(); - String entity = " \"body\": {\n" + - " \"requestReferences\": {\n" + - " \"instanceId\": \""+instanceId+"\",\n" + - " \"requestId\": \"b6dc9806-b094-42f7-9386-a48de8218ce8\"\n" + - " }"; - responseWrapper.setEntity(entity); - responseWrapper.setStatus(202); - return responseWrapper; - } - - private RequestDetails setRequestDetails(String bodyFileName)throws Exception { - final URL resource = this.getClass().getResource("/payload_jsons/" + bodyFileName); - ObjectMapper mapper = new ObjectMapper(); - RequestDetails requestDetails = mapper.readValue(resource, RequestDetails.class); - return requestDetails; - - } -} |