Merge branch 'master' of ../controller
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / codecs / EmptyCodecStringTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.yangtools.yang.data.impl.codecs;
10
11 import static org.junit.Assert.assertEquals;
12
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.common.Empty;
15 import org.opendaylight.yangtools.yang.data.api.codec.EmptyCodec;
16 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
17
18 /**
19  * Unit tests for EmptyCodecString.
20  *
21  * @author Thomas Pantelis
22  */
23 public class EmptyCodecStringTest {
24
25     @SuppressWarnings("unchecked")
26     @Test
27     public void testSerialize() {
28         EmptyCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.emptyType(), EmptyCodec.class);
29
30         assertEquals("serialize", "", codec.serialize(Empty.getInstance()));
31     }
32
33     @SuppressWarnings("unchecked")
34     @Test
35     public void testDeserialize() {
36         EmptyCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.emptyType(), EmptyCodec.class);
37
38         assertEquals("deserialize", Empty.getInstance(), codec.deserialize(""));
39
40         TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "foo");
41     }
42 }