2 * Copyright (c) 2014 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.controller.sal.restconf.impl.test;
10 import static org.junit.Assert.*;
11 import static org.mockito.Mockito.mock;
13 import org.junit.Test;
14 import org.opendaylight.controller.sal.restconf.impl.RestCodec;
15 import org.opendaylight.yangtools.concepts.Codec;
16 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
17 import org.opendaylight.yangtools.yang.model.util.BitsType;
19 public class RestCodecExceptionsTest {
22 public void serializeExceptionTest() {
23 Codec<Object, Object> codec = RestCodec.from(new BitsType(null), null);
24 String serializedValue = (String) codec.serialize("incorrect value"); // set
26 assertEquals("incorrect value", serializedValue);
30 public void deserializeExceptionTest() {
31 IdentityrefTypeDefinition mockedIidentityrefType = mock(IdentityrefTypeDefinition.class);
33 Codec<Object, Object> codec = RestCodec.from(mockedIidentityrefType, null);
34 assertNull(codec.deserialize("incorrect value"));