Bump versions to 4.0.0-SNAPSHOT
[netconf.git] / restconf / restconf-nb-bierman02 / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / RestCodecExceptionsTest.java
1 /*
2  * Copyright (c) 2014 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 package org.opendaylight.controller.sal.restconf.impl.test;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNull;
12 import static org.mockito.Mockito.mock;
13
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;
20
21 public class RestCodecExceptionsTest {
22     @Test
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
27                                                                               // expected
28         assertEquals("incorrect value", serializedValue);
29     }
30
31     @Test
32     public void deserializeExceptionTest() {
33         final IdentityrefTypeDefinition mockedIidentityrefType = mock(IdentityrefTypeDefinition.class);
34
35         final IllegalArgumentCodec<Object, Object> codec = RestCodec.from(mockedIidentityrefType, null, null);
36         assertNull(codec.deserialize("incorrect value"));
37     }
38 }