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.mdsal.binding.dom.codec.test;
10 import static org.junit.Assert.assertNotNull;
12 import java.util.Collections;
13 import org.junit.Test;
14 import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTree;
15 import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
16 import org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101.BooleanContainer;
17 import org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101.BooleanContainerBuilder;
18 import org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101._boolean.container.BooleanListBuilder;
19 import org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101._boolean.container.BooleanListIntBuilder;
20 import org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101._boolean.container.BooleanListIntKey;
21 import org.opendaylight.yang.gen.v1.urn.yang.foo.rev160101._boolean.container.BooleanListKey;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
25 public class Bug5845booleanKeyTest extends AbstractBindingCodecTest {
27 public void testBug5845() throws Exception {
28 final BooleanContainer booleanContainer = new BooleanContainerBuilder().setBooleanList(Collections
29 .singletonList(new BooleanListBuilder()
30 .withKey(new BooleanListKey(true, true))
31 .setBooleanLeaf1(true)
32 .setBooleanLeaf2(true)
36 final BooleanContainer booleanContainerInt = new BooleanContainerBuilder().setBooleanListInt(Collections
37 .singletonList(new BooleanListIntBuilder()
38 .withKey(new BooleanListIntKey((byte) 1))
39 .setBooleanLeafInt((byte) 1)
43 final BindingCodecTree codecContext = registry.getCodecContext();
44 final BindingDataObjectCodecTreeNode<BooleanContainer> subtreeCodec = codecContext.getSubtreeCodec(
45 InstanceIdentifier.create(BooleanContainer.class));
46 final NormalizedNode<?, ?> serializedInt = subtreeCodec.serialize(booleanContainerInt);
47 assertNotNull(serializedInt);
48 final NormalizedNode<?, ?> serialized = subtreeCodec.serialize(booleanContainer);
49 assertNotNull(serialized);