Instance identifier support
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / RestCodecExceptionsTest.java
1 package org.opendaylight.controller.sal.restconf.impl.test;
2
3 import static org.junit.Assert.*;
4 import static org.mockito.Mockito.mock;
5
6 import org.junit.Test;
7 import org.opendaylight.controller.sal.restconf.impl.RestCodec;
8 import org.opendaylight.yangtools.concepts.Codec;
9 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
10 import org.opendaylight.yangtools.yang.model.util.BitsType;
11
12 public class RestCodecExceptionsTest {
13
14     @Test
15     public void serializeExceptionTest() {
16         Codec<Object, Object> codec = RestCodec.from(new BitsType(null), null);
17         String serializedValue = (String) codec.serialize("incorrect value"); // set
18                                                                               // expected
19         assertEquals("incorrect value", serializedValue);
20     }
21
22     @Test
23     public void deserializeExceptionTest() {
24         IdentityrefTypeDefinition mockedIidentityrefType = mock(IdentityrefTypeDefinition.class);
25
26         Codec<Object, Object> codec = RestCodec.from(mockedIidentityrefType, null);
27         assertNull(codec.deserialize("incorrect value"));
28     }
29
30 }