2 * Copyright © 2019 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
9 package org.opendaylight.transportpce.servicehandler.validation.checks;
11 import static org.junit.jupiter.api.Assertions.assertEquals;
12 import static org.junit.jupiter.api.Assertions.assertFalse;
13 import static org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerTxRxCheck.LogMessages;
15 import org.junit.jupiter.api.Test;
16 import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.ServiceAEndBuilder;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat;
19 import org.opendaylight.yangtools.yang.common.Uint32;
21 public class ServicehandlerTxRxCheckTest {
24 void checkForServiceEndNull() {
25 ComplianceCheckResult result = ServicehandlerTxRxCheck.check(null, ServiceEndpointType.SERVICEAEND);
27 assertFalse(result.hasPassed());
28 assertEquals(LogMessages.endpointTypeNotSet(ServiceEndpointType.SERVICEAEND), result.getMessage());
32 void checkForServiceRateNull() {
33 ComplianceCheckResult result = ServicehandlerTxRxCheck
34 .check(new ServiceAEndBuilder().build(), ServiceEndpointType.SERVICEAEND);
36 assertFalse(result.hasPassed());
37 assertEquals(LogMessages.rateNull(ServiceEndpointType.SERVICEAEND), result.getMessage());
41 void checkForServiceRateEquals0() {
42 ComplianceCheckResult result = ServicehandlerTxRxCheck
43 .check(new ServiceAEndBuilder().setServiceRate(Uint32.valueOf(0)).build(), ServiceEndpointType.SERVICEAEND);
45 assertFalse(result.hasPassed());
46 assertEquals(LogMessages.rateNotSet(ServiceEndpointType.SERVICEAEND), result.getMessage());
50 void checkForServiceFormatNull() {
51 ComplianceCheckResult result = ServicehandlerTxRxCheck
52 .check(new ServiceAEndBuilder().setServiceRate(Uint32.valueOf(3)).build(), ServiceEndpointType.SERVICEAEND);
54 assertFalse(result.hasPassed());
55 assertEquals(LogMessages.formatNotSet(ServiceEndpointType.SERVICEAEND), result.getMessage());
59 void checkForClliEmpty() {
60 ComplianceCheckResult result = ServicehandlerTxRxCheck.check(new ServiceAEndBuilder()
61 .setServiceRate(Uint32.valueOf(3)).setClli("").setServiceFormat(ServiceFormat.Ethernet).build(),
62 ServiceEndpointType.SERVICEAEND);
64 assertFalse(result.hasPassed());
65 assertEquals(LogMessages.clliNotSet(ServiceEndpointType.SERVICEAEND), result.getMessage());