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;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNull;
14 import org.junit.Test;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.mapping.Mapping;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.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;
21 public class ServiceTypeTest {
24 public void getServiceTypeForServiceFormatUnknownTest() {
25 String serviceType = ServiceTypes.getServiceType("toto", null, null);
26 assertNull("service-type should be null", serviceType);
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);
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())
47 serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(100), mapping);
48 assertEquals("service-type should be 100GEt", "100GEt", serviceType);
50 mapping = new MappingBuilder()
51 .setLogicalConnectionPoint("logicalConnectionPoint")
52 .setPortQual(PortQual.SwitchClient.getName())
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);
61 mapping = new MappingBuilder()
62 .setLogicalConnectionPoint("logicalConnectionPoint")
63 .setPortQual(PortQual.SwitchClient.getName())
64 .setXponderType(XpdrNodeTypes.Switch)
66 serviceType = ServiceTypes.getServiceType("Ethernet", Uint32.valueOf(100), mapping);
67 assertEquals("service-type should be 100GEs", "100GEs", serviceType);
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);
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);
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);