2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2020 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.fail;
25 import com.fasterxml.jackson.core.JsonProcessingException;
26 import org.junit.Test;
27 import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.ScopeRegistration;
28 import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper;
30 public class TestDeserialize {
32 private static final String SCOPE_REGISTRATION_JSON = "{\n" + " \"data\":\"scopes\",\n" + " \"scopes\":[\n"
33 + " {\n" + " \"node-id\":\"ROADM-A\",\n" + " \"schema\":{\n"
34 + " \"namespace\":\"onf:params:xml:ns:yang:microwave-model\",\n"
35 + " \"revision\":\"2018-10-10\",\n" + " \"notification\":[\"problem-notification\"]\n"
36 + " }\n" + " }\n" + " ]\n" + "}";
37 private static final String SCOPE_REGISTRATION2_JSON = "{\n" + " \"data\":\"scopes\",\n" + " \"scopes\":[\n"
38 + " {\n" + " \"node-id\":\"ROADM-A\",\n" + " \"schema\":{\n"
39 + " \"namespace\":\"onf:params:xml:ns:yang:microwave-model\",\n"
40 + " \"revision\":\"2018-10-10\",\n" + " \"notification\":[\"problem-notification\"]\n"
41 + " }\n" + " }\n" + " ],\n" + " \"ratio\":\"120/min\"\n" + "}";
42 private static final String SCOPE_REGISTRATION3_INVALID_JSON = "{\n" + " \"data\":\"scopes\",\n"
43 + " \"scopes\":[\n" + " {\n" + " \"node-id\":\"ROADM-A\",\n" + " \"schema\":{\n"
44 + " \"namespace\":\"onf:params:xml:ns:yang:microwave-model\",\n"
45 + " \"revision\":\"2018-10-10\",\n" + " \"notification\":[\"problem-notification\"]\n"
46 + " }\n" + " }\n" + " ],\n" + " \"ratio\":\"120/sec\"\n" + "}";
49 public void testScopeRegistration() {
50 YangToolsMapper mapper = new YangToolsMapper();
51 ScopeRegistration obj = null;
53 obj = mapper.readValue(SCOPE_REGISTRATION_JSON, ScopeRegistration.class);
54 } catch (JsonProcessingException e) {
58 System.out.println(obj);
62 public void testScopeRegistration2() {
63 YangToolsMapper mapper = new YangToolsMapper();
64 ScopeRegistration obj = null;
66 obj = mapper.readValue(SCOPE_REGISTRATION2_JSON, ScopeRegistration.class);
67 } catch (JsonProcessingException e) {
71 System.out.println(obj);
75 public void testScopeRegistration3() {
76 YangToolsMapper mapper = new YangToolsMapper();
78 mapper.readValue(SCOPE_REGISTRATION3_INVALID_JSON, ScopeRegistration.class);
79 } catch (JsonProcessingException | IllegalArgumentException e) {
80 // e.printStackTrace();
83 fail("json should not contain a valid ratio");