blob: c44b0eb1d40ddf31f3b08320b8b3c1ac1d63356d [file] [log] [blame]
HIGUCHI Yuta5bb99a42015-03-19 16:52:15 -07001/*
2 * Copyright 2015 Open Networking Laboratory
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.codec.impl;
18
19import static org.hamcrest.MatcherAssert.assertThat;
20import static org.hamcrest.Matchers.is;
21import static org.hamcrest.Matchers.notNullValue;
22import static org.onosproject.codec.impl.JsonCodecUtils.assertJsonEncodable;
23
24import org.junit.Test;
25import org.onosproject.codec.JsonCodec;
26import org.onosproject.net.DefaultLink;
27import org.onosproject.net.Link;
28import org.onosproject.net.device.DeviceService;
29import org.onosproject.net.device.DeviceServiceAdapter;
30
31/**
32 * Unit test for LinkCodec.
33 */
34public class LinkCodecTest {
35
36 private final Link link = new DefaultLink(JsonCodecUtils.PID,
37 JsonCodecUtils.CP1,
38 JsonCodecUtils.CP2,
39 Link.Type.DIRECT,
40 Link.State.ACTIVE,
41 false,
42 JsonCodecUtils.A1);
43
44 @Test
45 public void linkCodecTest() {
46 final MockCodecContext context = new MockCodecContext();
47 context.registerService(DeviceService.class, new DeviceServiceAdapter());
48 final JsonCodec<Link> codec = context.codec(Link.class);
49 assertThat(codec, is(notNullValue()));
50 final Link pojoIn = link;
51
52 assertJsonEncodable(context, codec, pojoIn);
53 }
54}