Use version 13.1.0 of openroadm-service models
[transportpce.git] / servicehandler / src / test / java / org / opendaylight / transportpce / servicehandler / validation / checks / ServicehandlerTxRxCheckTest.java
1 /*
2  * Copyright © 2019 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
9 package org.opendaylight.transportpce.servicehandler.validation.checks;
10
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;
14
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.rev230526.service.ServiceAEndBuilder;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat;
19 import org.opendaylight.yangtools.yang.common.Uint32;
20
21 public class ServicehandlerTxRxCheckTest {
22
23     @Test
24     void checkForServiceEndNull() {
25         ComplianceCheckResult result = ServicehandlerTxRxCheck.check(null, ServiceEndpointType.SERVICEAEND);
26
27         assertFalse(result.hasPassed());
28         assertEquals(LogMessages.endpointTypeNotSet(ServiceEndpointType.SERVICEAEND), result.getMessage());
29     }
30
31     @Test
32     void checkForServiceRateNull() {
33         ComplianceCheckResult result = ServicehandlerTxRxCheck
34             .check(new ServiceAEndBuilder().build(), ServiceEndpointType.SERVICEAEND);
35
36         assertFalse(result.hasPassed());
37         assertEquals(LogMessages.rateNull(ServiceEndpointType.SERVICEAEND), result.getMessage());
38     }
39
40     @Test
41     void checkForServiceRateEquals0() {
42         ComplianceCheckResult result = ServicehandlerTxRxCheck
43             .check(new ServiceAEndBuilder().setServiceRate(Uint32.valueOf(0)).build(), ServiceEndpointType.SERVICEAEND);
44
45         assertFalse(result.hasPassed());
46         assertEquals(LogMessages.rateNotSet(ServiceEndpointType.SERVICEAEND), result.getMessage());
47     }
48
49     @Test
50     void checkForServiceFormatNull() {
51         ComplianceCheckResult result = ServicehandlerTxRxCheck
52             .check(new ServiceAEndBuilder().setServiceRate(Uint32.valueOf(3)).build(), ServiceEndpointType.SERVICEAEND);
53
54         assertFalse(result.hasPassed());
55         assertEquals(LogMessages.formatNotSet(ServiceEndpointType.SERVICEAEND), result.getMessage());
56     }
57
58     @Test
59     void checkForClliEmpty() {
60         ComplianceCheckResult result = ServicehandlerTxRxCheck.check(new ServiceAEndBuilder()
61                 .setServiceRate(Uint32.valueOf(3)).setClli("").setServiceFormat(ServiceFormat.Ethernet).build(),
62             ServiceEndpointType.SERVICEAEND);
63
64         assertFalse(result.hasPassed());
65         assertEquals(LogMessages.clliNotSet(ServiceEndpointType.SERVICEAEND), result.getMessage());
66     }
67 }