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