363d84f3a6fcbb718eab41877439a538356cec4b
[ccsdk/features.git] /
1 /*******************************************************************************
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18
19 package org.onap.ccsdk.features.sdnr.wt.devicemanager.test;
20
21 import java.util.Arrays;
22
23 import org.junit.Test;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
27 import org.onap.ccsdk.features.sdnr.wt.yangtools.YangToolsCloner;
28 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeState;
29 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.Equipment;
30 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.EquipmentBuilder;
31 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
32 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ContainedHolderBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Faultcurrent;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.InventoryBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.InventoryEntity;
37
38 public class TestYangCloning {
39
40     @Test
41     public void testEquipment() {
42         EquipmentBuilder equipmentBuilder = new EquipmentBuilder();
43         equipmentBuilder.setUuid( new UniversalId("EquipmentId"));
44         equipmentBuilder.setContainedHolder(Arrays.asList(new ContainedHolderBuilder()
45                 .setUuid(new UniversalId("HolderId"))
46                 .setAdministrativeState(AdministrativeState.Locked)
47                 .setSupportedEquipment(Arrays.asList("eq1"))
48                 .build()));
49         Equipment equipment = equipmentBuilder.build();
50         InventoryEntity output = YangToolsCloner.instance().cloneToBuilder(equipment,  new InventoryBuilder())
51                 .setNodeId("node1").setUuid("a.a.a").setId("node1"+"/"+"a.a.a").build();
52
53
54         System.out.println("source:");
55         System.out.println(equipment);
56         System.out.println("result:");
57         System.out.println(output);
58
59
60     }
61     @Test
62     public void testFaultCurrent() {
63         ProblemNotificationXml source = new ProblemNotificationXml("node", "uuid", "problem", InternalSeverity.Critical,54,InternalDateAndTime.getTestpattern());
64         FaultcurrentEntity output = YangToolsCloner.instance().clone(source,Faultcurrent.class);
65
66           System.out.println("source:");
67             System.out.println(source);
68             System.out.println("result:");
69             System.out.println(output);
70     }
71 }