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