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.assertEquals;
11 import static org.junit.Assert.assertNull;
12 import static org.mockito.Mockito.mock;
14 import org.junit.Test;
15 import org.opendaylight.netconf.sal.restconf.impl.RestCodec;
16 import org.opendaylight.yangtools.concepts.IllegalArgumentCodec;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
19 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
21 public class RestCodecExceptionsTest {
23 public void serializeExceptionTest() {
24 final IllegalArgumentCodec<Object, Object> codec = RestCodec.from(
25 BaseTypes.bitsTypeBuilder(QName.create("test", "2014-05-30", "test")).build(), null, null);
26 final String serializedValue = (String) codec.serialize("incorrect value"); // set
28 assertEquals("incorrect value", serializedValue);
32 public void deserializeExceptionTest() {
33 final IdentityrefTypeDefinition mockedIidentityrefType = mock(IdentityrefTypeDefinition.class);
35 final IllegalArgumentCodec<Object, Object> codec = RestCodec.from(mockedIidentityrefType, null, null);
36 assertNull(codec.deserialize("incorrect value"));