Test case added for code coverage
[sdnc/northbound.git] / generic-resource-api / provider / src / test / java / org / onap / sdnc / northbound / GetpathsegmentTopologyOperationRPCTest.java
1 package org.onap.sdnc.northbound;
2
3 import org.junit.Before;
4 import org.junit.Test;
5 import org.junit.runner.RunWith;
6 import org.mockito.runners.MockitoJUnitRunner;
7 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationInput;
8 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationOutput;
9 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.information.ServiceInformationBuilder;
10 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.onap.model.information.OnapModelInformationBuilder;
11 import org.opendaylight.yangtools.yang.common.RpcResult;
12
13 import static org.junit.Assert.assertEquals;
14 import static org.onap.sdnc.northbound.util.MDSALUtil.*;
15
16 @RunWith(MockitoJUnitRunner.class)
17 public class GetpathsegmentTopologyOperationRPCTest extends GenericResourceApiProviderTest {
18
19     private static final String SVC_OPERATION = "getpathsegment-topology-operation";
20
21     @Before
22     public void setUp() throws Exception {
23         super.setUp();
24         svcClient.setScvOperation(SVC_OPERATION);
25     }
26
27     @Test
28     public void should_fail_when_invalid_vnf_topology() throws Exception {
29
30         GetpathsegmentTopologyOperationInput input = build(GetpathsegmentTopologyOperationInput());
31
32         GetpathsegmentTopologyOperationOutput output =
33                 exec(genericResourceApiProvider::getpathsegmentTopologyOperation, input, RpcResult::getResult);
34
35         assertEquals("404", output.getResponseCode());
36         assertEquals("invalid input, null or empty service-instance-id", output.getResponseMessage());
37         assertEquals("Y", output.getAckFinalIndicator());
38     }
39
40     @Test
41     public void should_fail_when_valid_vnf_topology() throws Exception {
42
43         GetpathsegmentTopologyOperationInput input = build(GetpathsegmentTopologyOperationInput()
44                 .setServiceInformation(new ServiceInformationBuilder().setServiceInstanceId("ServiceInstanceID").build()));
45
46         GetpathsegmentTopologyOperationOutput output =
47                 exec(genericResourceApiProvider::getpathsegmentTopologyOperation, input, RpcResult::getResult);
48
49         assertEquals("404", output.getResponseCode());
50         assertEquals("invalid input, no model-uuid provided", output.getResponseMessage());
51         assertEquals("Y", output.getAckFinalIndicator());
52     }
53
54     @Test
55     public void should_fail_when_valid_serice_excep_vnf_topology() throws Exception {
56
57         GetpathsegmentTopologyOperationInput input = build(GetpathsegmentTopologyOperationInput()
58                 .setServiceInformation(new ServiceInformationBuilder().setServiceInstanceId("ServiceInstanceID")
59                         .setOnapModelInformation(new OnapModelInformationBuilder().setModelUuid("moduleUUID").build()).build()));
60
61         GetpathsegmentTopologyOperationOutput output =
62                 exec(genericResourceApiProvider::getpathsegmentTopologyOperation, input, RpcResult::getResult);
63
64         assertEquals("503", output.getResponseCode());
65         assertEquals("No service logic active for generic-resource-api: 'getpathsegment-topology-operation'",
66                 output.getResponseMessage());
67         assertEquals("Y", output.getAckFinalIndicator());
68     }
69 }