Refactor NBINotification & add ServiceListener tests
[transportpce.git] / nbinotifications / src / test / java / org / opendaylight / transportpce / nbinotifications / utils / NotificationServiceDataUtils.java
1 /*
2  * Copyright © 2020 Orange, 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 package org.opendaylight.transportpce.nbinotifications.utils;
9
10 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev181130.NodeIdType;
11 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
12 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirection;
13 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirection;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.lgx.LgxBuilder;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.port.PortBuilder;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat;
18 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService;
19 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationServiceBuilder;
20 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceAEndBuilder;
21 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceZEndBuilder;
22 import org.opendaylight.yangtools.yang.common.Uint32;
23
24 public final class NotificationServiceDataUtils {
25
26     private NotificationServiceDataUtils() {
27     }
28
29     public static NotificationService buildSendEventInput() {
30         NotificationServiceBuilder notificationServiceBuilder = new NotificationServiceBuilder()
31                 .setMessage("message")
32                 .setServiceName("service1")
33                 .setOperationalState(State.InService)
34                 .setResponseFailed("")
35                 .setCommonId("commond-id")
36                 .setConnectionType(ConnectionType.Service)
37                 .setServiceZEnd(getServiceZEndBuild().build())
38                 .setServiceAEnd(getServiceAEndBuild().build());
39
40         return notificationServiceBuilder.build();
41     }
42
43     public static org.opendaylight.yang.gen.v1
44         .nbi.notifications.rev210628.get.notifications.service.output.NotificationService buildReceivedEvent() {
45         org.opendaylight.yang.gen.v1
46             .nbi.notifications.rev210628.get.notifications.service.output.NotificationServiceBuilder
47             notificationServiceBuilder = new org.opendaylight.yang.gen.v1
48             .nbi.notifications.rev210628.get.notifications.service.output.NotificationServiceBuilder()
49                 .setMessage("message")
50                 .setServiceName("service1")
51                 .setOperationalState(State.InService)
52                 .setResponseFailed("")
53                 .setCommonId("commond-id")
54                 .setConnectionType(ConnectionType.Service)
55                 .setServiceZEnd(getServiceZEndBuild().build())
56                 .setServiceAEnd(getServiceAEndBuild().build());
57
58         return notificationServiceBuilder.build();
59     }
60
61     public static org.opendaylight.yang.gen.v1
62             .nbi.notifications.rev210628.get.notifications.alarm.service.output.NotificationAlarmService
63             buildReceivedAlarmEvent() {
64         org.opendaylight.yang.gen.v1
65                 .nbi.notifications.rev210628.get.notifications.alarm.service.output.NotificationAlarmServiceBuilder
66                 notificationAlarmServiceBuilder = new org.opendaylight.yang.gen.v1
67                 .nbi.notifications.rev210628.get.notifications.alarm.service.output.NotificationAlarmServiceBuilder()
68                 .setMessage("message")
69                 .setServiceName("service1")
70                 .setOperationalState(State.InService)
71                 .setConnectionType(ConnectionType.Service);
72         return notificationAlarmServiceBuilder.build();
73     }
74
75     public static ServiceAEndBuilder getServiceAEndBuild() {
76         return new ServiceAEndBuilder()
77                 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
78                 .setNodeId(new NodeIdType("XPONDER-1-2"))
79                 .setTxDirection(getTxDirection())
80                 .setRxDirection(getRxDirection());
81     }
82
83     public static ServiceZEndBuilder getServiceZEndBuild() {
84         return new ServiceZEndBuilder()
85                 .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
86                 .setNodeId(new NodeIdType("XPONDER-1-2"))
87                 .setTxDirection(getTxDirection())
88                 .setRxDirection(getRxDirection());
89     }
90
91     private static TxDirection getTxDirection() {
92         return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service
93                 .endpoint.TxDirectionBuilder().setPort(new PortBuilder().setPortDeviceName("device name")
94                 .setPortName("port name").setPortRack("port rack").setPortShelf("port shelf")
95                 .setPortSlot("port slot").setPortSubSlot("port subslot").setPortType("port type").build())
96                 .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name").setLgxPortName("lgx port name")
97                         .setLgxPortRack("lgx port rack").setLgxPortShelf("lgx port shelf").build())
98                 .build();
99     }
100
101     private static RxDirection getRxDirection() {
102         return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service
103                 .endpoint.RxDirectionBuilder()
104                 .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
105                         .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
106                         .setPortSubSlot("port subslot").setPortType("port type").build())
107                 .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
108                         .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
109                         .setLgxPortShelf("lgx port shelf").build())
110                 .build();
111     }
112 }