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.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;
18 public class PceListenserImplTest {
20 private PceListenerImpl pceListener;
21 private ServicePathRpcResult servicePathRpcResult = null;
23 public PceListenserImplTest() {
24 this.pceListener = new PceListenerImpl();
25 this.servicePathRpcResult = ServiceDataUtils.buildServicePathRpcResult();
29 public void onServicePathRpcResultInitial() {
30 this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
34 public void onServicePathRpcResultRepeat() {
35 this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
36 this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
40 public void onServicePathRpcResultRepeatFailed() {
41 this.servicePathRpcResult = ServiceDataUtils.buildFailedServicePathRpcResult();
42 this.pceListener.onServicePathRpcResult(this.servicePathRpcResult);
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);
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);
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);
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);