Migrate users of Builders/ImmutableNodes
[mdsal.git] / binding / mdsal-binding-dom-codec / src / test / java / org / opendaylight / mdsal / binding / dom / codec / impl / IdentityKeyTest.java
1 /*
2  * Copyright (c) 2023 PANTHEON.tech, s.r.o. 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.mdsal.binding.dom.codec.impl;
9
10 import static org.junit.Assert.assertEquals;
11
12 import org.junit.Test;
13 import org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal483.norev.Bar;
14 import org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal483.norev.BarBuilder;
15 import org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal483.norev.Foo;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 import org.opendaylight.yangtools.yang.common.Uint64;
18
19 public class IdentityKeyTest extends AbstractBindingCodecTest {
20     @Test
21     public void testIdentityKey() {
22         final var expected = new BarBuilder()
23             .setOne(Uint64.ONE)
24             .setTwo(Foo.VALUE)
25             .build();
26
27         final var actual = thereAndBackAgain(InstanceIdentifier.builder(Bar.class, expected.key()).build(), expected);
28         assertEquals(expected, actual);
29         assertEquals(expected.key(), actual.key());
30     }
31 }