2 * Copyright © 2018 Orange, Inc. and others. All rights reserved.
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
8 package org.opendaylight.transportpce.servicehandler.listensers;
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;
19 public class PceListenserImplTest {
21 private PceListenerImpl pceListener;
22 private ServicePathRpcResult servicePathRpcResult = null;
24 public PceListenserImplTest() {
25 this.pceListener = new PceListenerImpl();
26 this.servicePathRpcResult = ServiceDataUtils.buildServicePathRpcResult();
30 public void onServicePathRpcResultInitial() {
31 this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
35 public void onServicePathRpcResultRepeat() {
36 this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
37 this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
41 public void onServicePathRpcResultRepeatFailed() {
42 this.servicePathRpcResult = ServiceDataUtils.buildFailedServicePathRpcResult();
43 this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
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);
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);
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);
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);