2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.test;
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;
37 public class TestSerializer {
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";
46 ObjectCreationNotification notification = new ObjectCreationNotificationBuilder().setCounter(Integer.valueOf(5)).build();
47 NotificationOutput output = new NotificationOutput(notification, NODEID, ObjectCreationNotification.QNAME,DateAndTime.getDefaultInstance(TIMESTAMP));
50 sOutput = mapper.writeValueAsString(output);
52 } catch (JsonProcessingException e) {
56 assertNotNull(sOutput);
57 assertTrue(sOutput.contains("\"type\""));
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;
65 // sOutput = mapper.writeValueAsString(output);
66 // LOG.debug(sOutput);
67 // } catch (JsonProcessingException e) {
68 // e.printStackTrace();
69 // fail(e.getMessage());
71 // assertNotNull(sOutput);
72 // assertTrue(sOutput.contains("\"type\""));