7e576cc54ca8e24d8a71378e8bd0b4f2ca1f5415
[transportpce.git] / servicehandler / src / test / java / org / opendaylight / transportpce / servicehandler / listensers / PceListenserImplTest.java
1 /*
2  * Copyright © 2018 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.servicehandler.listensers;
9
10 import org.junit.Test;
11 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
12 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
13 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.ServicePathRpcResult;
14 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.ServicePathRpcResultBuilder;
15 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.RpcStatusEx;
16 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.ServicePathNotificationTypes;
17
18 public class PceListenserImplTest {
19
20     private PceListenerImpl pceListener;
21     private ServicePathRpcResult servicePathRpcResult = null;
22
23     public PceListenserImplTest() {
24         this.pceListener = new PceListenerImpl();
25         this.servicePathRpcResult = ServiceDataUtils.buildServicePathRpcResult();
26     }
27
28     @Test
29     public void onServicePathRpcResultInitial() {
30         this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
31     }
32
33     @Test
34     public void onServicePathRpcResultRepeat() {
35         this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
36         this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
37     }
38
39     @Test
40     public void onServicePathRpcResultRepeatFailed() {
41         this.servicePathRpcResult = ServiceDataUtils.buildFailedServicePathRpcResult();
42         this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
43     }
44
45     @Test
46     public void onServicePathRpcResultRepeatFailedCompareCase1() {
47         this.servicePathRpcResult = ServiceDataUtils.buildServicePathRpcResult();
48         this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
49         this.servicePathRpcResult = new ServicePathRpcResultBuilder(this.servicePathRpcResult)
50             .setNotificationType(ServicePathNotificationTypes.CancelResourceReserve).build();
51         this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
52     }
53
54     @Test
55     public void onServicePathRpcResultRepeatFailedCompareCase2() {
56         this.servicePathRpcResult = ServiceDataUtils.buildServicePathRpcResult();
57         this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
58         this.servicePathRpcResult = new ServicePathRpcResultBuilder(this.servicePathRpcResult)
59             .setServiceName("service 2").build();
60         this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
61     }
62
63     @Test
64     public void onServicePathRpcResultRepeatFailedCompareCase3() {
65         this.servicePathRpcResult = ServiceDataUtils.buildServicePathRpcResult();
66         this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
67         this.servicePathRpcResult = new ServicePathRpcResultBuilder(this.servicePathRpcResult)
68             .setStatus(RpcStatusEx.Failed).build();
69         this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
70     }
71
72     @Test
73     public void onServicePathRpcResultRepeatFailedCompareCase4() {
74         this.servicePathRpcResult = ServiceDataUtils.buildServicePathRpcResult();
75         this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
76         this.servicePathRpcResult = new ServicePathRpcResultBuilder(this.servicePathRpcResult)
77             .setStatusMessage("failed").build();
78         this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
79     }
80 }