blob: 321385c4677904691abb5861250ff5a9de18c88d [file] [log] [blame]
HIGUCHI Yuta5bb99a42015-03-19 16:52:15 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
HIGUCHI Yuta5bb99a42015-03-19 16:52:15 -07003 *
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.codec.impl;
18
19import static org.hamcrest.MatcherAssert.assertThat;
20import static org.hamcrest.Matchers.notNullValue;
21import static org.hamcrest.Matchers.is;
22import static org.onosproject.codec.impl.JsonCodecUtils.assertJsonEncodable;
23
24import org.junit.Test;
25import org.onosproject.codec.JsonCodec;
26import org.onosproject.net.DefaultDevice;
27import org.onosproject.net.Device;
28import org.onosproject.net.device.DeviceService;
29import org.onosproject.net.device.DeviceServiceAdapter;
30
31/**
32 * Unit test for DeviceCodec.
33 */
34public class DeviceCodecTest {
35
36 private Device device = new DefaultDevice(JsonCodecUtils.PID,
37 JsonCodecUtils.DID1,
38 Device.Type.SWITCH,
39 JsonCodecUtils.MFR,
40 JsonCodecUtils.HW,
41 JsonCodecUtils.SW1,
42 JsonCodecUtils.SN,
43 JsonCodecUtils.CID,
44 JsonCodecUtils.A1);
45
46
47
48 @Test
49 public void deviceCodecTest() {
50 final MockCodecContext context = new MockCodecContext();
51 context.registerService(DeviceService.class, new DeviceServiceAdapter());
52 final JsonCodec<Device> codec = context.codec(Device.class);
53 assertThat(codec, is(notNullValue()));
54 final Device pojoIn = device;
55
56 assertJsonEncodable(context, codec, pojoIn);
57 }
58
59}