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
8 package org.opendaylight.yangtools.yang.data.impl.codecs;
10 import static org.junit.Assert.assertEquals;
11 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
12 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.getCodec;
13 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.toEnumTypeDefinition;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.data.api.codec.EnumCodec;
19 * Unit tests for EnumCodecString.
21 * @author Thomas Pantelis
23 public class EnumCodecStringTest {
24 @SuppressWarnings("unchecked")
26 public void testSerialize() {
27 EnumCodec<String> codec = getCodec(toEnumTypeDefinition("enum1", "enum2"), EnumCodec.class);
28 assertEquals("serialize", "enum1", codec.serialize("enum1"));
31 @SuppressWarnings("unchecked")
33 public void testDeserialize() {
34 EnumCodec<String> codec = getCodec(toEnumTypeDefinition("enum1", "enum2"), EnumCodec.class);
36 assertEquals("deserialize", "enum1", codec.deserialize("enum1"));
37 assertEquals("deserialize", "enum2", codec.deserialize("enum2"));
39 deserializeWithExpectedIllegalArgEx(codec, "enum3");