diff options
author | r.bogacki <r.bogacki@samsung.com> | 2019-03-28 14:08:45 +0100 |
---|---|---|
committer | r.bogacki <r.bogacki@samsung.com> | 2019-03-28 14:09:17 +0100 |
commit | da8e738a75e8cfe9a8a8e2863a4a643c3ac367ba (patch) | |
tree | 282bbc0df928f963ebf715eb981041b4e5ddfdfa | |
parent | d3f349b01202b3cbd7219d1232949979e9e3fca5 (diff) |
JUnit tests for NetworkAdapterRest
Increased junit tests coverage according to Sonar analyses.
Added test for a network rollback.
Change-Id: I85622f62246b4bf3cc8d2ad253facaa2823923e7
Issue-ID: SO-1692
Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
2 files changed, 41 insertions, 1 deletions
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java index 3910d9ec44..4e2d5e5da2 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java @@ -51,9 +51,10 @@ import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; import org.onap.so.adapters.nwrest.DeleteNetworkResponse; -import org.onap.so.adapters.nwrest.NetworkTechnology; import org.onap.so.adapters.nwrest.QueryNetworkError; import org.onap.so.adapters.nwrest.QueryNetworkResponse; +import org.onap.so.adapters.nwrest.RollbackNetworkRequest; +import org.onap.so.adapters.nwrest.RollbackNetworkResponse; import org.onap.so.adapters.nwrest.UpdateNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.adapters.vnf.BaseRestTestUtils; @@ -193,6 +194,40 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { } @Test + public void testRollbackNetwork() throws IOException { + + RollbackNetworkRequest request = new RollbackNetworkRequest(); + + MsoRequest msoReq = new MsoRequest(); + + msoReq.setRequestId(MSO_REQUEST_ID); + msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); + + mockOpenStackResponseAccess(wireMockPort); + + mockOpenStackPublicUrlStackByID_200(wireMockPort); + + mockOpenStackGetPublicUrlStackByNameAndID_204(wireMockPort); + + mockOpenStackDeletePublicUrlStackByNameAndID_204(); + + headers.add("Accept", MediaType.APPLICATION_JSON); + + HttpEntity<RollbackNetworkRequest> entity = new HttpEntity<>(request, headers); + + ResponseEntity<RollbackNetworkResponse> response = restTemplate + .exchange(createURLWithPort("/services/rest/v1/networks/da886914-efb2-4917-b335-c8381528d90b/rollback"), + HttpMethod.DELETE, entity, RollbackNetworkResponse.class); + + RollbackNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper() + .readValue(new File("src/test/resources/__files/RollbackNetworkResponse.json"), RollbackNetworkResponse.class); + + assertThat(response.getBody(), sameBeanAs(expectedResponse)); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + + } + + @Test public void testQueryNetwork_Exception() throws IOException{ MsoRequest msoReq = new MsoRequest(); msoReq.setRequestId(MSO_REQUEST_ID); diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/RollbackNetworkResponse.json b/adapters/mso-openstack-adapters/src/test/resources/__files/RollbackNetworkResponse.json new file mode 100644 index 0000000000..d319fedecd --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/__files/RollbackNetworkResponse.json @@ -0,0 +1,5 @@ +{ + "rollbackNetworkResponse" : { + "networkRolledBack" : true + } +} |