import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import static org.opendaylight.mdsal.binding.generator.impl.SupportTestUtil.containsInterface;
import static org.opendaylight.mdsal.binding.generator.impl.SupportTestUtil.containsMethods;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.generator.api.BindingGenerator;
-import org.opendaylight.mdsal.binding.generator.impl.BindingGeneratorImpl;
import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.mdsal.binding.model.api.GeneratedType;
-import org.opendaylight.mdsal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class UsesTest {
-
- private static List<File> loadTestResources(final String testFile) {
- try {
- final List<File> testModels = new ArrayList<>();
- final File listModelFile = new File(UsesTest.class.getResource(testFile).toURI());
- testModels.add(listModelFile);
- return testModels;
- } catch (URISyntaxException e) {
- throw new IllegalStateException(e);
- }
- }
-
@Test
- public void usesInGroupingDependenciesTest() throws IOException, SourceException, ReactorException {
- List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-dependencies.yang");
- final SchemaContext context = YangParserTestUtils.parseYangFiles(testModels);
-
- assertNotNull(context);
- final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
- final List<Type> genTypes = bindingGen.generateTypes(context);
+ public void usesInGroupingDependenciesTest() {
+ final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ "/uses-of-grouping/uses-of-grouping-dependencies.yang"));
GeneratedType groupingU = null;
GeneratedType groupingX = null;
GeneratedType groupingV = null;
int groupingXCounter = 0;
int groupingVCounter = 0;
- for (Type type : genTypes) {
- if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
- GeneratedType genType = (GeneratedType) type;
+ for (GeneratedType genType : genTypes) {
+ if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("GroupingU")) {
groupingU = genType;
groupingUCounter++;
}
@Test
- public void usesInCaseTest() throws IOException, SourceException, ReactorException {
- List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-case.yang");
-
- final SchemaContext context = YangParserTestUtils.parseYangFiles(testModels);
-
- assertNotNull(context);
- final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
- final List<Type> genTypes = bindingGen.generateTypes(context);
+ public void usesInCaseTest() {
+ final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ "/uses-of-grouping/uses-of-grouping-case.yang"));
GeneratedType groupingCaseTest = null;
int groupingCaseTestCounter = 0;
GeneratedType caseC = null;
int caseCCounter = 0;
- for (Type type : genTypes) {
- if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
- GeneratedType genType = (GeneratedType) type;
+ for (GeneratedType genType : genTypes) {
+ if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("C")) {
caseC = genType;
caseCCounter++;
"org.opendaylight.yang.gen.v1.urn.grouping.uses._case.rev130718", groupingCaseTest.getPackageName());
containsInterface("GroupingCaseTest", caseC);
- assertTrue("Case C shouldn't contain any method.", caseC.getMethodDefinitions().isEmpty());
+ // FIXME: split this into getter/default/static asserts
+ assertEquals(4, caseC.getMethodDefinitions().size());
- assertEquals("Number of method in GroupingCaseTest is incorrect", 1, groupingCaseTest.getMethodDefinitions()
+ assertEquals("Number of method in GroupingCaseTest is incorrect", 3, groupingCaseTest.getMethodDefinitions()
.size());
- containsMethods(groupingCaseTest.getMethodDefinitions(), new NameTypePattern("getLeafGroupingCaseTest1",
- "String"));
+ containsMethods(groupingCaseTest.getMethodDefinitions(),
+ new NameTypePattern("getLeafGroupingCaseTest1", "String"),
+ new NameTypePattern("requireLeafGroupingCaseTest1", "String"));
}
@Test
- public void usesInContainerTest() throws IOException, SourceException, ReactorException {
- List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-container.yang");
-
- final SchemaContext context = YangParserTestUtils.parseYangFiles(testModels);
-
- assertNotNull(context);
- final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
- final List<Type> genTypes = bindingGen.generateTypes(context);
+ public void usesInContainerTest() {
+ final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ "/uses-of-grouping/uses-of-grouping-container.yang"));
int containerTestCount = 0;
int groupingContainerTestCounter = 0;
GeneratedType containerTest = null;
GeneratedType groupingContainerTest = null;
- for (Type type : genTypes) {
- if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
- GeneratedType genType = (GeneratedType) type;
+ for (GeneratedType genType : genTypes) {
+ if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("GroupingContainerTest")) {
groupingContainerTest = genType;
groupingContainerTestCounter++;
containsInterface("GroupingContainerTest", containerTest);
- assertEquals("Number of method in GroupingContainerTestis incorrect", 2, groupingContainerTest
+ assertEquals("Number of method in GroupingContainerTestis incorrect", 5, groupingContainerTest
.getMethodDefinitions().size());
- assertEquals("Number of method in ContainerTest is incorrect", 1, containerTest.getMethodDefinitions().size());
-
- containsMethods(groupingContainerTest.getMethodDefinitions(), new NameTypePattern(
- "getLeafGroupingContainerTest1", "String"), new NameTypePattern("getLeafGroupingContainerTest2",
- "Short"));
-
- containsMethods(containerTest.getMethodDefinitions(), new NameTypePattern("getContainerLeafTest", "String"));
+ // FIXME: split this into getter/default/static asserts
+ assertEquals(6, containerTest.getMethodDefinitions().size());
+
+ containsMethods(groupingContainerTest.getMethodDefinitions(),
+ new NameTypePattern("getLeafGroupingContainerTest1", "String"),
+ new NameTypePattern("requireLeafGroupingContainerTest1", "String"),
+ new NameTypePattern("getLeafGroupingContainerTest2", "Uint8"),
+ new NameTypePattern("requireLeafGroupingContainerTest2", "Uint8"));
+
+ containsMethods(containerTest.getMethodDefinitions(),
+ new NameTypePattern("getContainerLeafTest", "String"),
+ new NameTypePattern("requireContainerLeafTest", "String"));
}
@Test
- public void usesInGroupingTest() throws IOException, SourceException, ReactorException {
- List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-grouping.yang");
-
- final SchemaContext context = YangParserTestUtils.parseYangFiles(testModels);
-
- assertNotNull(context);
- final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
- final List<Type> genTypes = bindingGen.generateTypes(context);
+ public void usesInGroupingTest() {
+ final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ "/uses-of-grouping/uses-of-grouping-grouping.yang"));
int groupingTestCount = 0;
int groupingGroupingTestCounter = 0;
GeneratedType groupingTest = null;
GeneratedType groupingGroupingTest = null;
- for (Type type : genTypes) {
- if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
- GeneratedType genType = (GeneratedType) type;
+ for (GeneratedType genType : genTypes) {
+ if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("GroupingGroupingTest")) {
groupingGroupingTest = genType;
groupingGroupingTestCounter++;
containsInterface("GroupingGroupingTest", groupingTest);
- assertEquals("Number of method in GroupingGroupingTest is incorrect", 1, groupingGroupingTest
+ assertEquals("Number of method in GroupingGroupingTest is incorrect", 3, groupingGroupingTest
.getMethodDefinitions().size());
- assertEquals("Number of method in GroupingTest is incorrect", 1, groupingTest.getMethodDefinitions().size());
+ assertEquals("Number of method in GroupingTest is incorrect", 3, groupingTest.getMethodDefinitions().size());
- containsMethods(groupingGroupingTest.getMethodDefinitions(), new NameTypePattern("getLeafGroupingGrouping",
- "String"));
+ containsMethods(groupingGroupingTest.getMethodDefinitions(),
+ new NameTypePattern("getLeafGroupingGrouping", "String"),
+ new NameTypePattern("requireLeafGroupingGrouping", "String"));
- containsMethods(groupingTest.getMethodDefinitions(), new NameTypePattern("getLeafGroupingTest", "Byte"));
+ containsMethods(groupingTest.getMethodDefinitions(),
+ new NameTypePattern("getLeafGroupingTest", "Byte"),
+ new NameTypePattern("requireLeafGroupingTest", "Byte"));
}
@Test
- public void usesInListTest() throws IOException, SourceException, ReactorException {
- List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-list.yang");
-
- final SchemaContext context = YangParserTestUtils.parseYangFiles(testModels);
-
- assertNotNull(context);
- final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
- final List<Type> genTypes = bindingGen.generateTypes(context);
+ public void usesInListTest() {
+ final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ "/uses-of-grouping/uses-of-grouping-list.yang"));
int listTestCounter = 0;
int groupingListTestCounter = 0;
GeneratedType containerGroupingListTest = null;
GeneratedType listGroupingListTest = null;
- for (Type type : genTypes) {
- if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
- GeneratedType genType = (GeneratedType) type;
+ for (GeneratedType genType : genTypes) {
+ if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("GroupingListTest")) {
groupingListTest = genType;
groupingListTestCounter++;
containsInterface("GroupingListTest", listTest);
- assertEquals("Number of method in GroupingListTest is incorrect", 4, groupingListTest.getMethodDefinitions()
+ assertEquals("Number of method in GroupingListTest is incorrect", 8, groupingListTest.getMethodDefinitions()
.size());
- assertEquals("Number of method in ListTest is incorrect", 1, listTest.getMethodDefinitions().size());
- assertEquals("Number of method in ContainerGroupingListTest is incorrect", 1, containerGroupingListTest
- .getMethodDefinitions().size());
- assertEquals("Number of method in ListGroupingListTest is incorrect", 1, listGroupingListTest
- .getMethodDefinitions().size());
-
- containsMethods(groupingListTest.getMethodDefinitions(), new NameTypePattern("getContainerGroupingListTest",
- "ContainerGroupingListTest"), new NameTypePattern("getLeafGroupingListTest", "String"),
- new NameTypePattern("getLeaffllistGroupingListTest", "List<String>"), new NameTypePattern(
- "getListGroupingListTest", "List<ListGroupingListTest>"));
+ // FIXME: split this into getter/default/static asserts
+ assertEquals(6, listTest.getMethodDefinitions().size());
+ // FIXME: split this into getter/default/static asserts
+ assertEquals(6, containerGroupingListTest.getMethodDefinitions().size());
+ // FIXME: split this into getter/default/static asserts
+ assertEquals(6, listGroupingListTest.getMethodDefinitions().size());
+
+ containsMethods(groupingListTest.getMethodDefinitions(),
+ new NameTypePattern("getContainerGroupingListTest", "ContainerGroupingListTest"),
+ new NameTypePattern("getLeafGroupingListTest", "String"),
+ new NameTypePattern("requireLeafGroupingListTest", "String"),
+ new NameTypePattern("getLeaffllistGroupingListTest", "List<String>"),
+ new NameTypePattern("requireLeaffllistGroupingListTest", "List<String>"),
+ new NameTypePattern("getListGroupingListTest", "List<ListGroupingListTest>"));
containsMethods(listTest.getMethodDefinitions(), new NameTypePattern("getListLeafTest", "String"));
containsMethods(containerGroupingListTest.getMethodDefinitions(), new NameTypePattern(
- "getLeafContainerGroupingListTest", "Short"));
+ "getLeafContainerGroupingListTest", "Uint8"));
containsMethods(listGroupingListTest.getMethodDefinitions(), new NameTypePattern("getLeafListGroupingListTest",
"Integer"));
}
@Test
- public void usesInModulTest() throws IOException, SourceException, ReactorException {
- List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-modul.yang");
-
- final SchemaContext context = YangParserTestUtils.parseYangFiles(testModels);
-
- assertNotNull(context);
- final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
- final List<Type> genTypes = bindingGen.generateTypes(context);
+ public void usesInModulTest() {
+ final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ "/uses-of-grouping/uses-of-grouping-modul.yang"));
int groupingModulTestCounter = 0;
int groupingUsesModulDataCounter = 0;
GeneratedType groupingModulTest = null;
GeneratedType groupingUsesModulData = null;
- for (Type type : genTypes) {
- if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
- GeneratedType genType = (GeneratedType) type;
+ for (GeneratedType genType : genTypes) {
+ if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("GroupingModulTest")) {
groupingModulTest = genType;
groupingModulTestCounter++;
assertEquals("Number of method in GroupingUsesModulData is incorrect", 0, groupingUsesModulData
.getMethodDefinitions().size());
- assertEquals("Number of method in GroupingModulTest is incorrect", 2, groupingModulTest.getMethodDefinitions()
+ assertEquals("Number of method in GroupingModulTest is incorrect", 5, groupingModulTest.getMethodDefinitions()
.size());
- containsMethods(groupingModulTest.getMethodDefinitions(), new NameTypePattern("getLeafGroupingModulTest",
- "String"), new NameTypePattern("getLeafGroupingModulTest2", "Short"));
+ containsMethods(groupingModulTest.getMethodDefinitions(),
+ new NameTypePattern("getLeafGroupingModulTest", "String"),
+ new NameTypePattern("requireLeafGroupingModulTest", "String"),
+ new NameTypePattern("getLeafGroupingModulTest2", "Uint8"),
+ new NameTypePattern("requireLeafGroupingModulTest2", "Uint8"));
}
@Test
- public void usesInRpcTest() throws IOException, SourceException, ReactorException {
- List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-rpc.yang");
-
- final SchemaContext context = YangParserTestUtils.parseYangFiles(testModels);
-
- assertNotNull(context);
- final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
- final List<Type> genTypes = bindingGen.generateTypes(context);
+ public void usesInRpcTest() {
+ final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+ "/uses-of-grouping/uses-of-grouping-rpc.yang"));
int rpcTestInputCounter = 0;
int rpcTestOutputCounter = 0;
GeneratedType groupingRpcOutputTest = null;
GeneratedType containerGroupingRpcInputTest = null;
- for (Type type : genTypes) {
- if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
- GeneratedType genType = (GeneratedType) type;
+ for (GeneratedType genType : genTypes) {
+ if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("RpcTestInput")) {
rpcTestInput = genType;
rpcTestInputCounter++;
}
}
- assertNotNull("Generated type for RPC test input wasn't generated", rpcTestInput);
+ assertNotNull("Generated type for RPC test input was not generated", rpcTestInput);
assertEquals("RpcTestInput interface - incorrect number of occurences", 1, rpcTestInputCounter);
- assertEquals("RpcTestInput isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestInput.getPackageName());
+ assertEquals("RpcTestInput is not in correct package",
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestInput.getPackageName());
- assertNotNull("Generated type for RPC test output wasn't generated", rpcTestOutput);
+ assertNotNull("Generated type for RPC test output was not generated", rpcTestOutput);
assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, rpcTestOutputCounter);
- assertEquals("RpcTestOutput isn't in correct package",
+ assertEquals("RpcTestOutput is not in correct package",
"org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestOutput.getPackageName());
- assertNotNull("Generated type for grouping-rpc-input-test wasn't generated", groupingRpcInputTest);
+ assertNotNull("Generated type for grouping-rpc-input-test was not generated", groupingRpcInputTest);
assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, groupingRpcInputTestCounter);
assertEquals("GroupingRpcInputTest isn't in correct package",
"org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", groupingRpcInputTest.getPackageName());
- assertNotNull("Generated type for grouping-rpc-output-test wasn't generated", groupingRpcOutputTest);
+ assertNotNull("Generated type for grouping-rpc-output-test was not generated", groupingRpcOutputTest);
assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, groupingRpcOutputTestCounter);
assertEquals("GroupingRpcOutputTest isn't in correct package",
"org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", groupingRpcOutputTest.getPackageName());
containerGroupingRpcInputTest);
assertEquals("ContainerGroupingRpcInputTest interface - incorrect number of occurences", 1,
containerGroupingRpcInputTestCounter);
- assertEquals("ContainerGroupingRpcInputTest isn't in correct package",
+ assertEquals("ContainerGroupingRpcInputTest is not in correct package",
"org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718.grouping.rpc.input.test",
containerGroupingRpcInputTest.getPackageName());
containsInterface("GroupingRpcInputTest", rpcTestInput);
containsInterface("GroupingRpcOutputTest", rpcTestOutput);
- assertEquals("Number of method in RpcTestInput is incorrect", 0, rpcTestInput.getMethodDefinitions().size());
- assertEquals("Number of method in RpcTestOutput is incorrect", 0, rpcTestOutput.getMethodDefinitions().size());
- assertEquals("Number of method in GroupingRpcInputTest is incorrect", 2, groupingRpcInputTest
- .getMethodDefinitions().size());
- assertEquals("Number of method in GroupingRpcOutputTest is incorrect", 1, groupingRpcOutputTest
+ // FIXME: split this into getter/default/static asserts
+ assertEquals(4, rpcTestInput.getMethodDefinitions().size());
+ // FIXME: split this into getter/default/static asserts
+ assertEquals(4, rpcTestOutput.getMethodDefinitions().size());
+ assertEquals("Number of method in GroupingRpcInputTest is incorrect", 4, groupingRpcInputTest
.getMethodDefinitions().size());
- assertEquals("Number of method in ContainerGroupingRpcInputTest is incorrect", 1, containerGroupingRpcInputTest
+ assertEquals("Number of method in GroupingRpcOutputTest is incorrect", 3, groupingRpcOutputTest
.getMethodDefinitions().size());
-
- containsMethods(groupingRpcInputTest.getMethodDefinitions(), new NameTypePattern(
- "getContainerGroupingRpcInputTest", "ContainerGroupingRpcInputTest"), new NameTypePattern(
- "getLeaflistGroupingRpcInputTest", "List<Short>"));
- containsMethods(groupingRpcOutputTest.getMethodDefinitions(), new NameTypePattern(
- "getLeafGroupingRpcOutputTest", "Byte"));
- containsMethods(containerGroupingRpcInputTest.getMethodDefinitions(), new NameTypePattern(
- "getLeafContainerGroupingRpcInputTest", "String"));
+ // FIXME: split this into getter/default/static asserts
+ assertEquals(6, containerGroupingRpcInputTest.getMethodDefinitions().size());
+
+ containsMethods(groupingRpcInputTest.getMethodDefinitions(),
+ new NameTypePattern("getContainerGroupingRpcInputTest", "ContainerGroupingRpcInputTest"),
+ new NameTypePattern("getLeaflistGroupingRpcInputTest", "List<Uint8>"),
+ new NameTypePattern("requireLeaflistGroupingRpcInputTest", "List<Uint8>"));
+ containsMethods(groupingRpcOutputTest.getMethodDefinitions(),
+ new NameTypePattern("getLeafGroupingRpcOutputTest", "Byte"));
+ containsMethods(containerGroupingRpcInputTest.getMethodDefinitions(),
+ new NameTypePattern("getLeafContainerGroupingRpcInputTest", "String"));
}
@Test
- public void usesInAugmentTest() throws IOException, SourceException, ReactorException {
- List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-augment.yang");
-
- final SchemaContext context = YangParserTestUtils.parseYangFiles(testModels);
-
- assertNotNull(context);
- final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
- final List<Type> genTypes = bindingGen.generateTypes(context);
+ public void usesInAugmentTest() {
+ final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(
+ YangParserTestUtils.parseYangResource("/uses-of-grouping/uses-of-grouping-augment.yang"));
GeneratedType containerAugment1 = null;
GeneratedType groupingAugmentTest = null;
int containerAugment1Counter = 0;
int groupingAugmentTestCounter = 0;
- for (Type type : genTypes) {
- if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
- GeneratedType genType = (GeneratedType) type;
+ for (GeneratedType genType : genTypes) {
+ if (!(genType instanceof GeneratedTransferObject)) {
if (genType.getName().equals("ContainerAugment1")) {
containerAugment1 = genType;
containerAugment1Counter++;
containsInterface("GroupingAugmentTest", containerAugment1);
- assertEquals("Number of method in GroupingCaseTest is incorrect", 0, containerAugment1.getMethodDefinitions()
- .size());
-
- assertEquals("Number of method in ContainerAugment1 is incorrect", 0, containerAugment1.getMethodDefinitions()
- .size());
- assertEquals("Number of method in GroupingCaseTest is incorrect", 1, groupingAugmentTest.getMethodDefinitions()
+ // FIXME: split this into getter/default/static asserts
+ assertEquals(4, containerAugment1.getMethodDefinitions().size());
+ // FIXME: split this into getter/default/static asserts
+ assertEquals(4, containerAugment1.getMethodDefinitions().size());
+ assertEquals("Number of method in GroupingCaseTest is incorrect", 3, groupingAugmentTest.getMethodDefinitions()
.size());
- containsMethods(groupingAugmentTest.getMethodDefinitions(), new NameTypePattern("getLeafGroupingAugmentTest",
- "String"));
+ containsMethods(groupingAugmentTest.getMethodDefinitions(),
+ new NameTypePattern("getLeafGroupingAugmentTest", "String"),
+ new NameTypePattern("requireLeafGroupingAugmentTest", "String"));
}
@Test
- public void usesInNotification() throws IOException, SourceException, ReactorException {
- List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-notification.yang");
-
- final SchemaContext context = YangParserTestUtils.parseYangFiles(testModels);
-
- assertNotNull(context);
- final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
- final List<Type> genTypes = bindingGen.generateTypes(context);
+ public void usesInNotification() {
+ final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(
+ YangParserTestUtils.parseYangResource("/uses-of-grouping/uses-of-grouping-notification.yang"));
GeneratedType notificationTest = null;
GeneratedType groupingNotificationTest = null;
int groupingNotificationTestCounter = 0;
int containerGroupingNotificationTestCounter = 0;
- for (Type type : genTypes) {
+ for (GeneratedType type : genTypes) {
if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
- GeneratedType genType = (GeneratedType) type;
+ GeneratedType genType = type;
if (genType.getName().equals("NotificationTest")) {
notificationTest = genType;
notificationTestCounter++;
containsInterface("GroupingNotificationTest", notificationTest);
- assertEquals("Number of method in NotificationTest is incorrect", 1, notificationTest.getMethodDefinitions()
- .size());
- assertEquals("Number of method in GroupingNotificationTest is incorrect", 2, groupingNotificationTest
+ // FIXME: split this into getter/default/static asserts
+ assertEquals(6, notificationTest.getMethodDefinitions().size());
+ assertEquals("Number of method in GroupingNotificationTest is incorrect", 4, groupingNotificationTest
.getMethodDefinitions().size());
- assertEquals("Number of method in ContainerGroupingNotificationTest is incorrect", 1,
- containerGroupingNotificationTest.getMethodDefinitions().size());
-
- containsMethods(notificationTest.getMethodDefinitions(), new NameTypePattern("getLeafNotificationTest",
- "String"));
- containsMethods(groupingNotificationTest.getMethodDefinitions(), new NameTypePattern(
- "getContainerGroupingNotificationTest", "ContainerGroupingNotificationTest"), new NameTypePattern(
- "getLeaffllistGroupingNotificationTest", "List<String>"));
- containsMethods(containerGroupingNotificationTest.getMethodDefinitions(), new NameTypePattern(
- "getLeafContainerGroupingNotificationTest", "Long"));
+ // FIXME: split this into getter/default/static asserts
+ assertEquals(6, containerGroupingNotificationTest.getMethodDefinitions().size());
+
+ containsMethods(notificationTest.getMethodDefinitions(),
+ new NameTypePattern("getLeafNotificationTest", "String"));
+ containsMethods(groupingNotificationTest.getMethodDefinitions(),
+ new NameTypePattern("getContainerGroupingNotificationTest", "ContainerGroupingNotificationTest"),
+ new NameTypePattern("getLeaffllistGroupingNotificationTest", "List<String>"),
+ new NameTypePattern("requireLeaffllistGroupingNotificationTest", "List<String>"));
+ containsMethods(containerGroupingNotificationTest.getMethodDefinitions(),
+ new NameTypePattern("getLeafContainerGroupingNotificationTest", "Uint32"),
+ new NameTypePattern("requireLeafContainerGroupingNotificationTest", "Uint32"));
}
}