blob: 095ae8313cb24ce0feb0fc0525c32ae268f7eb15 [file] [log] [blame]
Sean Condon87b78502018-09-17 20:53:24 +01001/*
2 * Copyright 2018-present Open Networking Foundation
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
17package org.onosproject.ui.impl.gui2;
18
19import com.fasterxml.jackson.core.JsonProcessingException;
20import com.fasterxml.jackson.databind.ObjectMapper;
21import com.fasterxml.jackson.databind.module.SimpleModule;
22import org.junit.Before;
23import org.junit.Test;
24import org.onosproject.ui.UiExtension;
25import org.onosproject.ui.UiView;
26
27import java.util.ArrayList;
28import java.util.List;
29
30import static org.junit.Assert.assertEquals;
31
32public class UiViewSerializerTest {
33
34 UiView uiView1 = new UiView(UiView.Category.NETWORK, "uiView1", "uiView1", "icon1");
35 UiView uiView2 = new UiView(UiView.Category.OTHER, "uiView2", "uiView2", "icon2");
36
37 @Before
38 public void init() {
39 }
40
41 @Test
42 public void uiViewSerializerTest() throws JsonProcessingException {
43 UiViewSerializer serializer = new UiViewSerializer(UiView.class);
44 ObjectMapper mapper = new ObjectMapper();
45
46 SimpleModule module =
47 new SimpleModule("UiViewSerializer");
48 module.addSerializer(serializer);
49 mapper.registerModule(module);
50 String ext = mapper.writeValueAsString(uiView1);
51 assertEquals("{\"id\":\"uiView1\",\"icon\":\"icon1\",\"cat\":\"NETWORK\",\"label\":\"uiView1\"}", ext);
52 }
53}