Bump upstream dependencies to Ca
[transportpce.git] / renderer / src / test / java / org / opendaylight / transportpce / renderer / utils / MountPointUtils.java
1 /*
2  * Copyright © 2018 Orange Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.transportpce.renderer.utils;
10
11
12 import static org.mockito.ArgumentMatchers.any;
13 import static org.mockito.Mockito.doReturn;
14 import static org.mockito.Mockito.spy;
15
16 import com.google.common.util.concurrent.ListenableFuture;
17 import java.util.List;
18 import org.opendaylight.mdsal.binding.api.DataBroker;
19 import org.opendaylight.mdsal.binding.api.RpcService;
20 import org.opendaylight.transportpce.test.stub.MountPointStub;
21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.Mapping;
22 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.MappingBuilder;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.MappingKey;
24 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.GetConnectionPortTrail;
25 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.GetConnectionPortTrailOutput;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.GetConnectionPortTrailOutputBuilder;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.get.connection.port.trail.output.Ports;
28 import org.opendaylight.yangtools.yang.common.RpcResult;
29 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
30
31
32 public final class MountPointUtils {
33
34     public static MountPointStub getMountPoint(List<Ports> ports, DataBroker dataBroker) {
35         RpcService rpcService = spy(RpcService.class);
36         GetConnectionPortTrail getConnectionPortTrail = spy(GetConnectionPortTrail.class);
37         GetConnectionPortTrailOutputBuilder getConnectionPortTrailOutputBldr
38                 = new GetConnectionPortTrailOutputBuilder();
39         getConnectionPortTrailOutputBldr.setPorts(ports);
40         ListenableFuture<RpcResult<GetConnectionPortTrailOutput>> rpcResultFuture =
41                 RpcResultBuilder.success(getConnectionPortTrailOutputBldr.build()).buildFuture();
42         doReturn(rpcResultFuture).when(getConnectionPortTrail.invoke(any()));
43         doReturn(getConnectionPortTrail).when(rpcService).getRpc(any());
44         MountPointStub mountPoint = new MountPointStub(dataBroker);
45         mountPoint.setRpcService(rpcService);
46         return mountPoint;
47     }
48
49     public static Mapping createMapping(String nodeId, String logicalConnPoint) {
50         return new MappingBuilder()
51             .withKey(new MappingKey(logicalConnPoint))
52             .setLogicalConnectionPoint(logicalConnPoint)
53             .setSupportingOts("supporting-OTS")
54             .setSupportingCircuitPackName("2/0")
55             .setSupportingOms("supporting-OMS")
56             .setSupportingPort("port")
57             .setSupportingCircuitPackName("circuit-pack")
58             .build();
59     }
60
61     private MountPointUtils() {
62     }
63
64 }