Eliminate AbstractMagnesiumDataOutput
[yangtools.git] / codec / yang-data-codec-binfmt / src / test / java / org / opendaylight / yangtools / yang / data / codec / binfmt / AidSerializationTest.java
1 /*
2  * Copyright (c) 2019 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.yangtools.yang.data.codec.binfmt;
9
10 import com.google.common.collect.ImmutableSet;
11 import java.util.Collections;
12 import org.junit.Assert;
13 import org.junit.Test;
14 import org.junit.runner.RunWith;
15 import org.junit.runners.Parameterized;
16 import org.junit.runners.Parameterized.Parameter;
17 import org.junit.runners.Parameterized.Parameters;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
19
20 @RunWith(Parameterized.class)
21 public class AidSerializationTest extends AbstractSerializationTest {
22     @Parameters(name = "{0}")
23     public static Iterable<Object[]> data() {
24         return Collections.singletonList(
25             new Object[] { NormalizedNodeStreamVersion.MAGNESIUM, 4, 94, 332, 2_376, 716_618, 912_975 });
26     }
27
28     @Parameter(1)
29     public int emptySize;
30     @Parameter(2)
31     public int oneSize;
32     @Parameter(3)
33     public int size29;
34     @Parameter(4)
35     public int size256;
36     @Parameter(5)
37     public int size65536;
38     @Parameter(6)
39     public int twiceSize65536;
40
41     @Test
42     public void testEmptyIdentifier() {
43         assertSame(fillIdentifier(0), emptySize);
44     }
45
46     @Test
47     public void testOneIdentifier() {
48         assertEquals(fillIdentifier(1), oneSize);
49     }
50
51     @Test
52     public void test29() {
53         assertEquals(fillIdentifier(29), size29);
54     }
55
56     @Test
57     public void test256() {
58         assertEquals(fillIdentifier(256), size256);
59     }
60
61     @Test
62     public void test65536() {
63         final AugmentationIdentifier id = fillIdentifier(65536);
64         assertEquals(id, size65536);
65         assertEqualsTwice(id, twiceSize65536);
66     }
67
68     private static AugmentationIdentifier fillIdentifier(final int size) {
69         final AugmentationIdentifier ret = AugmentationIdentifier.create(ImmutableSet.copyOf(generateQNames(size)));
70         Assert.assertEquals(size, ret.getPossibleChildNames().size());
71         return ret;
72     }
73 }