2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.yangtools.yang.data.impl.codecs;
11 import static org.junit.Assert.assertEquals;
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;
19 * Unit tests for EmptyCodecString.
21 * @author Thomas Pantelis
23 public class EmptyCodecStringTest {
25 @SuppressWarnings("unchecked")
27 public void testSerialize() {
28 EmptyCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.emptyType(), EmptyCodec.class);
30 assertEquals("serialize", "", codec.serialize(Empty.getInstance()));
33 @SuppressWarnings("unchecked")
35 public void testDeserialize() {
36 EmptyCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.emptyType(), EmptyCodec.class);
38 assertEquals("deserialize", Empty.getInstance(), codec.deserialize(""));
40 TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "foo");