<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common-netty</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-impl</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
<artifactId>rfc6991-ietf-yang-types</artifactId>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>mockito-configuration</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-data-spi</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bgp-parser-impl</artifactId>
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
public final class EvpnTestUtil {
public static final int VALUE_SIZE = 9;
}
public static DataContainerNodeBuilder<NodeIdentifier, ContainerNode> createContBuilder(final NodeIdentifier nid) {
- return Builders.containerBuilder().withNodeIdentifier(nid);
+ return ImmutableNodes.newContainerBuilder().withNodeIdentifier(nid);
}
public static <T> LeafNode<T> createValue(final T value, final NodeIdentifier nid) {
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
public class LanParserTest {
private static final Uint16 PRIORITY = Uint16.valueOf(514);
}
public static ChoiceNode createLanChoice() {
- return Builders.choiceBuilder()
+ return ImmutableNodes.newChoiceBuilder()
.withNodeIdentifier(NodeIdentifier.create(Esi.QNAME))
.addChild(createLanCont())
.build();
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.LD;
import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.VALUE_SIZE;
import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createContBuilder;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
public class RouterIdParserTest {
public static final byte[] RESULT = {(byte) 0x04, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x02,
}
public static ChoiceNode createRouterIdCase() {
- return Builders.choiceBuilder()
+ return ImmutableNodes.newChoiceBuilder()
.withNodeIdentifier(new NodeIdentifier(RouterIdGeneratedCase.QNAME))
.addChild(createRouteContainer())
.build();
.build();
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void wrongCaseTest() {
- parser.serializeEsi(new ArbitraryCaseBuilder().build(), null);
+ assertThrows(IllegalArgumentException.class,
+ () -> parser.serializeEsi(new ArbitraryCaseBuilder().build(), null));
}
}
\ No newline at end of file
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.EsRouteCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.EthernetADRouteCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.EthernetADRouteCaseBuilder;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
public class EthADRParserTest {
public static final byte[] RESULT = {
}
public static ChoiceNode createEthADRModel() {
- final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
- choice.withNodeIdentifier(EVPN_NID);
- return choice.addChild(createArbitraryContainer()).build();
+ return ImmutableNodes.newChoiceBuilder()
+ .withNodeIdentifier(EVPN_NID)
+ .addChild(createArbitraryContainer())
+ .build();
}
private static ContainerNode createArbitraryContainer() {
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
public class EvpnNlriParserTest {
private static final NodeIdentifier EVPN_CHOICE_NID = new NodeIdentifier(EvpnChoice.QNAME);
private final EvpnNlriParser parser = new EvpnNlriParser();
private static ChoiceNode createMACIpAdvChoice() {
- return Builders.choiceBuilder()
+ return ImmutableNodes.newChoiceBuilder()
.withNodeIdentifier(EVPN_CHOICE_NID)
.addChild(MACIpAdvRParserTest.createMacIpCont())
.build();
@Test
public void testExtractEvpnDestination() {
- final EvpnDestination destResult = EvpnNlriParser.extractEvpnDestination(Builders.unkeyedListEntryBuilder()
- .withNodeIdentifier(EVPN_NID)
- .withChild(createMACIpAdvChoice())
- .withChild(createValue(RD_MODEL, RD_NID))
- .build());
- final EvpnDestination expected = new EvpnDestinationBuilder()
+ assertEquals(new EvpnDestinationBuilder()
.setRouteDistinguisher(RD)
.setEvpnChoice(MACIpAdvRParserTest.createdExpectedResult())
- .build();
- assertEquals(expected, destResult);
+ .build(), EvpnNlriParser.extractEvpnDestination(ImmutableNodes.newUnkeyedListEntryBuilder()
+ .withNodeIdentifier(EVPN_NID)
+ .withChild(createMACIpAdvChoice())
+ .withChild(createValue(RD_MODEL, RD_NID))
+ .build()));
}
@Test
public void testExtractRouteKey() {
- final EvpnDestination destResult = EvpnNlriParser.extractRouteKeyDestination(Builders.unkeyedListEntryBuilder()
- .withNodeIdentifier(EVPN_CHOICE_NID)
- .withChild(createValue(RD_MODEL, RD_NID))
- .withChild(createMACIpAdvChoice())
- .build());
- final EvpnDestination expected = new EvpnDestinationBuilder()
+ assertEquals(new EvpnDestinationBuilder()
.setRouteDistinguisher(RD)
.setEvpnChoice(MACIpAdvRParserTest.createdExpectedRouteKey())
- .build();
- assertEquals(expected, destResult);
+ .build(), EvpnNlriParser.extractRouteKeyDestination(ImmutableNodes.newUnkeyedListEntryBuilder()
+ .withNodeIdentifier(EVPN_CHOICE_NID)
+ .withChild(createValue(RD_MODEL, RD_NID))
+ .withChild(createMACIpAdvChoice())
+ .build()));
}
}
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.VALUE_SIZE;
import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.createContBuilder;
import static org.opendaylight.protocol.bgp.evpn.impl.nlri.EthADRParserTest.ETHERNET_AD_ROUTE_CASE;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
public final class SimpleEvpnNlriRegistryTest {
private static final class NotRegistered implements EvpnChoice {
assertEquals(ETHERNET_AD_ROUTE_CASE, SimpleEvpnNlriRegistry.getInstance().parseEvpn(type, buff));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void registryParseTest() {
- SimpleEvpnNlriRegistry.getInstance().parseEvpn(NlriType.EthADDisc, null);
+ assertThrows(IllegalArgumentException.class,
+ () -> SimpleEvpnNlriRegistry.getInstance().parseEvpn(NlriType.EthADDisc, null));
}
@Test
@Test
public void registryNullModelTest() {
- assertNull(SimpleEvpnNlriRegistry.getInstance().serializeEvpnModel(Builders.choiceBuilder()
+ assertNull(SimpleEvpnNlriRegistry.getInstance().serializeEvpnModel(ImmutableNodes.newChoiceBuilder()
.withNodeIdentifier(EVPN_NID)
.addChild(createContBuilder(new NodeIdentifier(QName.create(Evpn.QNAME, "test").intern())).build())
.build()));
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.RouterIdParserTest.ROUTE_ID_CASE;
import io.netty.buffer.ByteBuf;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.routes.evpn.routes.EvpnRoute;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
public class SimpleEsiTypeRegistryTest {
private static final class NotRegistered implements Esi {
assertEquals(RouterIdParserTest.ROUTE_ID_CASE, reg.parseEsi(Unpooled.wrappedBuffer(buff)));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void registryParseTest() {
- SimpleEsiTypeRegistry.getInstance().parseEsi(null);
+ assertThrows(IllegalArgumentException.class, () -> SimpleEsiTypeRegistry.getInstance().parseEsi(null));
}
@Test
assertEquals(0, body.readableBytes());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void registryNullModelTest() {
- assertNull(SimpleEsiTypeRegistry.getInstance().parseEsiModel(Builders.choiceBuilder()
- .withNodeIdentifier(new NodeIdentifier(QName.create(EvpnRoute.QNAME, "no-register").intern()))
- .build()));
+ assertThrows(IllegalArgumentException.class,
+ () -> SimpleEsiTypeRegistry.getInstance().parseEsiModel(ImmutableNodes.newChoiceBuilder()
+ .withNodeIdentifier(new NodeIdentifier(QName.create(EvpnRoute.QNAME, "no-register")))
+ .build()));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void registryEmptyModelTest() {
- assertNull(SimpleEsiTypeRegistry.getInstance().parseEsiModel(null));
+ assertThrows(IllegalArgumentException.class, () -> SimpleEsiTypeRegistry.getInstance().parseEsiModel(null));
}
}