ff0437e2b62e717ccd7c22d16510020ad72bd882
[ccsdk/features.git] / sdnr / wt / websocketmanager / provider / src / test / java / org / onap / ccsdk / features / sdnr / wt / websocketmanager2 / test / TestSerializer.java
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk features
4  * ================================================================================
5  * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
6  * All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  */
22 package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.test;
23
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertTrue;
26 import static org.junit.Assert.fail;
27 import com.fasterxml.jackson.core.JsonProcessingException;
28 import org.junit.Test;
29 import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.NotificationOutput;
30 import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ObjectCreationNotification;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ObjectCreationNotificationBuilder;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
36
37 public class TestSerializer {
38
39     private static final Logger LOG = LoggerFactory.getLogger(TestSerializer.class);
40      private static final YangToolsMapper mapper = new YangToolsMapper();
41     private static final String TIMESTAMP = "2020-04-01T10:20:40.0Z";
42     private static final String NODEID = "node1";
43
44     @Test
45     public void test1() {
46         ObjectCreationNotification notification = new ObjectCreationNotificationBuilder().setCounter(Integer.valueOf(5)).build();
47         NotificationOutput output = new NotificationOutput(notification, NODEID, ObjectCreationNotification.QNAME,DateAndTime.getDefaultInstance(TIMESTAMP));
48         String sOutput=null;
49         try {
50             sOutput = mapper.writeValueAsString(output);
51             LOG.debug(sOutput);
52         } catch (JsonProcessingException e) {
53             e.printStackTrace();
54             fail(e.getMessage());
55         }
56         assertNotNull(sOutput);
57         assertTrue(sOutput.contains("\"type\""));
58     }
59 //    @Test
60 //    public void test2() {
61 //        InstanceChanged notification = new InstanceChangedBuilder().setChangeStatus("stop SUCCESS").setName("NTS_FUNCTION_TYPE_OPENROADM_6_1_0-1").setFunctionType(NTS_FUNCTION_TYPE_OPENROADM_6_1_0.class)
62 //        NotificationOutput output = new NotificationOutput(notification, NODEID, ObjectCreationNotification.QNAME,DateAndTime.getDefaultInstance(TIMESTAMP));
63 //        String sOutput=null;
64 //        try {
65 //            sOutput = mapper.writeValueAsString(output);
66 //            LOG.debug(sOutput);
67 //        } catch (JsonProcessingException e) {
68 //            e.printStackTrace();
69 //            fail(e.getMessage());
70 //        }
71 //        assertNotNull(sOutput);
72 //        assertTrue(sOutput.contains("\"type\""));
73 //    }
74 }