3eeca57e06f00483240998e7beddb6c90fd35ac2
[transportpce.git] / common / src / test / java / org / opendaylight / transportpce / common / service / ServiceTypeTest.java
1 /*
2  * Copyright © 2021 Orange.  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.common.service;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNull;
13
14 import org.junit.Test;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.MappingBuilder;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.PortQual;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
19 import org.opendaylight.yangtools.yang.common.Uint32;
20
21 public class ServiceTypeTest {
22
23     @Test
24     public void getServiceTypeForServiceFormatUnknownTest() {
25         String serviceType = ServiceTypes.getServiceType("toto", null, null);
26         assertNull("service-type should be null", serviceType);
27     }
28
29     @Test
30     public void getServiceTypeForServiceFormatOCTest() {
31         String serviceType = ServiceTypes.getServiceType("OC", Uint32.valueOf(100), null);
32         assertEquals("service-type should be 100GEt", "100GEt", serviceType);
33         serviceType = ServiceTypes.getServiceType("OC", null, null);
34         assertNull("service-type should be null", serviceType);
35     }
36
37     @Test
38     public void getServiceTypeForServiceFormatEthernetTest() {
39         String serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(400), null);
40         assertEquals("service-type should be 400GE", "400GE", serviceType);
41         serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(100), null);
42         assertEquals("service-type should be 100GEt", "100GEt", serviceType);
43         Mapping mapping = new MappingBuilder()
44             .setLogicalConnectionPoint("logicalConnectionPoint")
45             .setPortQual(PortQual.XpdrClient.getName())
46             .build();
47         serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(100), mapping);
48         assertEquals("service-type should be 100GEt", "100GEt", serviceType);
49
50         mapping = new MappingBuilder()
51             .setLogicalConnectionPoint("logicalConnectionPoint")
52             .setPortQual(PortQual.SwitchClient.getName())
53             .build();
54         serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(100), mapping);
55         assertEquals("service-type should be 100GEm", "100GEm", serviceType);
56         serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(10), mapping);
57         assertEquals("service-type should be 10GE", "10GE", serviceType);
58         serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(1), mapping);
59         assertEquals("service-type should be 1GE", "1GE", serviceType);
60
61         mapping = new MappingBuilder()
62             .setLogicalConnectionPoint("logicalConnectionPoint")
63             .setPortQual(PortQual.SwitchClient.getName())
64             .setXponderType(XpdrNodeTypes.Switch)
65             .build();
66         serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(100), mapping);
67         assertEquals("service-type should be 100GEs", "100GEs", serviceType);
68     }
69
70     @Test
71     public void getOtnServiceTypeForServiceFormatEthernetTest() {
72         String serviceType = ServiceTypes.getOtnServiceType("toto", Uint32.valueOf(123));
73         assertNull("service-type should be null", serviceType);
74         serviceType = ServiceTypes.getOtnServiceType("Ethernet", Uint32.valueOf(123));
75         assertNull("service-type should be null", serviceType);
76         serviceType = ServiceTypes.getOtnServiceType("Ethernet", Uint32.valueOf(1));
77         assertEquals("service-type should be 1GE", "1GE", serviceType);
78         serviceType = ServiceTypes.getOtnServiceType("Ethernet", Uint32.valueOf(10));
79         assertEquals("service-type should be 10GE", "10GE", serviceType);
80         serviceType = ServiceTypes.getOtnServiceType("Ethernet", Uint32.valueOf(100));
81         assertEquals("service-type should be 100GEm", "100GEm", serviceType);
82
83         serviceType = ServiceTypes.getOtnServiceType("OTU", Uint32.valueOf(100));
84         assertEquals("service-type should be OTU4", "OTU4", serviceType);
85         serviceType = ServiceTypes.getOtnServiceType("OTU", Uint32.valueOf(400));
86         assertEquals("service-type should be OTUC4", "OTUC4", serviceType);
87
88         serviceType = ServiceTypes.getOtnServiceType("ODU", Uint32.valueOf(100));
89         assertEquals("service-type should be ODU4", "ODU4", serviceType);
90         serviceType = ServiceTypes.getOtnServiceType("ODU", Uint32.valueOf(400));
91         assertEquals("service-type should be ODUC4", "ODUC4", serviceType);
92     }
93
94 }