Create a Junit test for ServiceTopologyOperation
[sdnc/northbound.git] / generic-resource-api / provider / src / test / java / org / onap / sdnc / northbound / NetworkTopologyOperationRPCTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.sdnc.northbound;
23
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.mockito.runners.MockitoJUnitRunner;
27 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInputBuilder;
28 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutput;
29 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.information.NetworkInformationBuilder;
30 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
31 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformationBuilder;
32 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
33 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeaderBuilder;
34 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.information.ServiceInformationBuilder;
35 import org.opendaylight.yangtools.yang.common.RpcResult;
36
37 import static org.junit.Assert.assertEquals;
38 import static org.junit.Assert.fail;
39
40 @RunWith(MockitoJUnitRunner.class)
41 public class NetworkTopologyOperationRPCTest extends GenericResourceApiProviderTest {
42
43     @Test
44     public void testNetworkTopologyOperation() {
45
46         NetworkTopologyOperationInputBuilder inputBuilder = new NetworkTopologyOperationInputBuilder();
47
48         SdncRequestHeaderBuilder sdncRequestHeaderBuilder = new SdncRequestHeaderBuilder();
49         sdncRequestHeaderBuilder.setSvcRequestId("1111");
50         sdncRequestHeaderBuilder.setSvcAction(SvcAction.Create);
51         inputBuilder.setSdncRequestHeader(sdncRequestHeaderBuilder.build());
52
53         RequestInformationBuilder requestInformationBuilder = new RequestInformationBuilder();
54         requestInformationBuilder.setRequestId("1111");
55         requestInformationBuilder.setRequestAction(RequestInformation.RequestAction.CreateNetworkInstance);
56         inputBuilder.setRequestInformation(requestInformationBuilder.build());
57
58         ServiceInformationBuilder serviceInformationBuilder = new ServiceInformationBuilder();
59         serviceInformationBuilder.setServiceInstanceId("1111");
60         inputBuilder.setServiceInformation(serviceInformationBuilder.build());
61
62         NetworkInformationBuilder networkInformationBuilder = new NetworkInformationBuilder();
63         inputBuilder.setNetworkInformation(networkInformationBuilder.build());
64
65         java.util.concurrent.Future<RpcResult<NetworkTopologyOperationOutput>> future = genericResourceApiProvider
66                 .networkTopologyOperation(inputBuilder.build());
67         RpcResult<NetworkTopologyOperationOutput> rpcResult = null;
68         try {
69             rpcResult = future.get();
70         } catch (Exception e) {
71             fail("Error : " + e);
72         }
73         LOG.info("result: {}", rpcResult);
74         assertEquals("1111", rpcResult.getResult().getSvcRequestId());
75     }
76
77
78
79 }