aboutsummaryrefslogtreecommitdiffstats
path: root/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/GetpathsegmentTopologyOperationRPCTest.java
blob: f2a92c04e8ec76d1f75fc7074c74c82639931d66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package org.onap.sdnc.northbound;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationInput;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationOutput;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.information.ServiceInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.onap.model.information.OnapModelInformationBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;

import static org.junit.Assert.assertEquals;
import static org.onap.sdnc.northbound.util.MDSALUtil.*;

@RunWith(MockitoJUnitRunner.class)
public class GetpathsegmentTopologyOperationRPCTest extends GenericResourceApiProviderTest {

    private static final String SVC_OPERATION = "getpathsegment-topology-operation";

    @Before
    public void setUp() throws Exception {
        super.setUp();
        svcClient.setScvOperation(SVC_OPERATION);
    }

    @Test
    public void should_fail_when_invalid_vnf_topology() throws Exception {

        GetpathsegmentTopologyOperationInput input = GetpathsegmentTopologyOperationInput().build();

        GetpathsegmentTopologyOperationOutput output =
                exec(genericResourceApiProvider::getpathsegmentTopologyOperation, input, RpcResult::getResult);

        assertEquals("404", output.getResponseCode());
        assertEquals("invalid input, null or empty service-instance-id", output.getResponseMessage());
        assertEquals("Y", output.getAckFinalIndicator());
    }

    @Test
    public void should_fail_when_valid_vnf_topology() throws Exception {

        GetpathsegmentTopologyOperationInput input = GetpathsegmentTopologyOperationInput()
                .setServiceInformation(new ServiceInformationBuilder().setServiceInstanceId("ServiceInstanceID").build()).build();

        GetpathsegmentTopologyOperationOutput output =
                exec(genericResourceApiProvider::getpathsegmentTopologyOperation, input, RpcResult::getResult);

        assertEquals("404", output.getResponseCode());
        assertEquals("invalid input, no model-uuid provided", output.getResponseMessage());
        assertEquals("Y", output.getAckFinalIndicator());
    }

    @Test
    public void should_fail_when_valid_serice_excep_vnf_topology() throws Exception {

        GetpathsegmentTopologyOperationInput input = GetpathsegmentTopologyOperationInput()
                .setServiceInformation(new ServiceInformationBuilder().setServiceInstanceId("ServiceInstanceID")
                        .setOnapModelInformation(new OnapModelInformationBuilder().setModelUuid("moduleUUID").build()).build()).build();

        GetpathsegmentTopologyOperationOutput output =
                exec(genericResourceApiProvider::getpathsegmentTopologyOperation, input, RpcResult::getResult);

        assertEquals("503", output.getResponseCode());
        assertEquals("No service logic active for generic-resource-api: 'getpathsegment-topology-operation'",
                output.getResponseMessage());
        assertEquals("Y", output.getAckFinalIndicator());
    }
}