Yixiao Chen | 39828a6 | 2016-09-14 14:37:06 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.teyang.utils.topology; |
| 17 | |
| 18 | import static org.junit.Assert.assertEquals; |
| 19 | |
| 20 | import org.junit.Before; |
| 21 | import org.junit.Test; |
| 22 | import org.onosproject.teyang.api.OperationType; |
| 23 | import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network |
| 24 | .rev20151208.ietfnetwork.networks.Network; |
| 25 | import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology.networks.network.node.AugmentedNwNode; |
| 26 | import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeAdminStatus; |
| 27 | import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.teadminstatus.TeAdminStatusEnum; |
| 28 | |
| 29 | |
| 30 | /** |
| 31 | * Unit tests for converter functions. |
| 32 | */ |
| 33 | public class ConverterTest { |
| 34 | |
| 35 | Network output; |
| 36 | |
| 37 | @Before |
| 38 | public void setUp() { |
| 39 | output = NetworkConverter.teSubsystem2YangNetwork( |
| 40 | DefaultBuilder.sampleTeSubsystemNetworkBuilder(), |
| 41 | OperationType.NONE); |
| 42 | } |
| 43 | |
| 44 | @Test |
| 45 | public void basics() { |
| 46 | assertEquals("Wrong networkId", |
| 47 | output.networkId().uri().string(), |
| 48 | "HUAWEI_NETWORK_NEW"); |
| 49 | assertEquals("Wrong 1st nodeId", |
| 50 | output.node().get(0).nodeId().uri().string(), |
| 51 | "HUAWEI_ROADM_1"); |
| 52 | assertEquals("Wrong 2dn nodeId", |
| 53 | output.node().get(1).nodeId().uri().string(), |
| 54 | "HUAWEI_ROADM_2"); |
| 55 | AugmentedNwNode augmentedNode = (AugmentedNwNode) output.node().get(0) |
| 56 | .yangAugmentedInfo(AugmentedNwNode.class); |
| 57 | |
| 58 | assertEquals("Wrong adminStatus", |
| 59 | augmentedNode.te().config().teNodeAttributes().adminStatus(), |
| 60 | TeAdminStatus.of(TeAdminStatusEnum.UP)); |
| 61 | } |
| 62 | |
| 63 | } |