import org.opendaylight.mdsal.binding.javav2.generator.util.BindingGeneratorUtil;
import org.opendaylight.mdsal.binding.javav2.model.api.Type;
import org.opendaylight.mdsal.binding.javav2.model.api.type.builder.GeneratedTypeBuilder;
+import org.opendaylight.mdsal.binding.javav2.spec.runtime.BindingNamespaceType;
import org.opendaylight.mdsal.binding.javav2.util.BindingMapping;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
return otherIt.hasNext() ? -1 : 0;
};
+ /**
+ * Comparator based on augment target path.
+ */
+ private static final Comparator<Map.Entry<SchemaPath, List<AugmentationSchema>>> AUGMENTS_COMP = (o1, o2) -> {
+ final Iterator<QName> thisIt = o1.getKey().getPathFromRoot().iterator();
+ final Iterator<QName> otherIt = o2.getKey().getPathFromRoot().iterator();
+
+ while (thisIt.hasNext()) {
+ if (!otherIt.hasNext()) {
+ return 1;
+ }
+
+ final int comp = thisIt.next().compareTo(otherIt.next());
+ if (comp != 0) {
+ return comp;
+ }
+ }
+
+ return otherIt.hasNext() ? -1 : 0;
+ };
+
private AugmentToGenType() {
throw new UnsupportedOperationException("Utility class");
}
Map<SchemaPath, List<AugmentationSchema>> augmentationsGrouped =
augmentations.stream().collect(Collectors.groupingBy(AugmentationSchema::getTargetPath));
+ List<Map.Entry<SchemaPath, List<AugmentationSchema>>> sortedAugmentationsGrouped =
+ new ArrayList<>(augmentationsGrouped.entrySet());
+ Collections.sort(sortedAugmentationsGrouped, AUGMENTS_COMP);
+
//process child nodes of grouped augment entries
- for (Entry<SchemaPath, List<AugmentationSchema>> schemaPathAugmentListEntry : augmentationsGrouped.entrySet()) {
+ for (Map.Entry<SchemaPath, List<AugmentationSchema>> schemaPathAugmentListEntry : sortedAugmentationsGrouped) {
resultCtx = augmentationToGenTypes(basePackageName, schemaPathAugmentListEntry, module, schemaContext,
verboseClassComments, resultCtx, genTypeBuilders, typeProvider);
* <code>augSchema</code> node or a generated types for cases are added if
* augmented node is choice.
*
- * @param augmentPackageName
+ * @param basePackageName
* string with the name of the package to which the augmentation
* belongs
* @param schemaPathAugmentListEntry
final SchemaContext schemaContext, final boolean verboseClassComments,
Map<Module, ModuleContext> genCtx, Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders,
final TypeProvider typeProvider) {
-
- final SchemaPath targetPath = schemaPathAugmentListEntry.getKey();
Preconditions.checkArgument(basePackageName != null, "Package Name cannot be NULL.");
+ Preconditions.checkArgument(schemaPathAugmentListEntry != null, "Augmentation List Entry cannot be NULL.");
+ final SchemaPath targetPath = schemaPathAugmentListEntry.getKey();
Preconditions.checkState(targetPath != null,
- "Augmentation Schema does not contain Target Path (Target Path is NULL).");
+ "Augmentation List Entry does not contain Target Path (Target Path is NULL).");
- SchemaNode targetSchemaNode;
+ final List<AugmentationSchema> augmentationSchemaList = schemaPathAugmentListEntry.getValue();
+ Preconditions.checkState(augmentationSchemaList.size() > 0,
+ "Augmentation List cannot be empty.");
- targetSchemaNode = SchemaContextUtil.findDataSchemaNode(schemaContext, targetPath);
+ SchemaNode targetSchemaNode = SchemaContextUtil.findDataSchemaNode(schemaContext, targetPath);
if (targetSchemaNode instanceof DataSchemaNode && ((DataSchemaNode) targetSchemaNode).isAddedByUses()) {
if (targetSchemaNode instanceof DerivableSchemaNode) {
targetSchemaNode = ((DerivableSchemaNode) targetSchemaNode).getOriginal().orNull();
throw new IllegalArgumentException("augment target not found: " + targetPath);
}
- //TODO: loose this assignment afterwards #2 done
- Map<Module, ModuleContext> generatedCtx = genCtx;
-
GeneratedTypeBuilder targetTypeBuilder = GenHelperUtil.findChildNodeByPath(targetSchemaNode.getPath(),
- generatedCtx);
+ genCtx);
if (targetTypeBuilder == null) {
- targetTypeBuilder = GenHelperUtil.findCaseByPath(targetSchemaNode.getPath(), generatedCtx);
+ targetTypeBuilder = GenHelperUtil.findCaseByPath(targetSchemaNode.getPath(), genCtx);
}
if (targetTypeBuilder == null) {
throw new NullPointerException("Target type not yet generated: " + targetSchemaNode);
BindingGeneratorUtil.packageNameForAugmentedGeneratedType(basePackageName, targetPath);
if (!(targetSchemaNode instanceof ChoiceSchemaNode)) {
- generatedCtx = GenHelperUtil.addRawAugmentGenTypeDefinition(module, augmentNamespacePackageName,
- targetTypeBuilder.toInstance(), schemaPathAugmentListEntry.getValue(), genTypeBuilders, generatedCtx,
+ genCtx = GenHelperUtil.addRawAugmentGenTypeDefinition(module, augmentNamespacePackageName,
+ targetTypeBuilder.toInstance(), schemaPathAugmentListEntry.getValue(), genTypeBuilders, genCtx,
schemaContext, verboseClassComments, typeProvider);
} else {
- //TODO: #3 implement augmented choice cases scenario
+ genCtx = generateTypesFromAugmentedChoiceCases(schemaContext, module, basePackageName,
+ targetTypeBuilder.toInstance(), (ChoiceSchemaNode) targetSchemaNode,
+ schemaPathAugmentListEntry.getValue(),
+ null, genCtx, verboseClassComments, genTypeBuilders, typeProvider);
}
- return generatedCtx;
+ return genCtx;
}
static Map<Module, ModuleContext> usesAugmentationToGenTypes(final SchemaContext schemaContext,
final TypeProvider typeProvider) {
Preconditions.checkArgument(augmentPackageName != null, "Package Name cannot be NULL.");
+ Preconditions.checkArgument(schemaPathAugmentListEntry != null,
+ "Augmentation Schema List Entry cannot be NULL.");
+ Preconditions.checkState(schemaPathAugmentListEntry.size() > 0,
+ "Augmentation Schema List cannot be empty");
final SchemaPath targetPath = schemaPathAugmentListEntry.get(0).getTargetPath();
+ Preconditions.checkState(targetPath != null,
+ "Augmentation Schema does not contain Target Path (Target Path is NULL).");
+
final SchemaNode targetSchemaNode = findOriginalTargetFromGrouping(schemaContext, targetPath, usesNode);
if (targetSchemaNode == null) {
throw new IllegalArgumentException("augment target not found: " + targetPath);
} else if (usesNodeParent instanceof AugmentationSchema) {
Type parentTypeBuilder = genCtx.get(module).getTargetToAugmentation()
.get(((AugmentationSchema) usesNodeParent).getTargetPath());
- packageName = parentTypeBuilder.getFullyQualifiedName();
+ packageName = BindingGeneratorUtil.packageNameForAugmentedGeneratedType(parentTypeBuilder.getPackageName(),
+ (AugmentationSchema)usesNodeParent);
}
genCtx = GenHelperUtil.addRawAugmentGenTypeDefinition(module, packageName,
targetTypeBuilder.toInstance(), schemaPathAugmentListEntry, genTypeBuilders, genCtx,
} else {
genCtx = generateTypesFromAugmentedChoiceCases(schemaContext, module, augmentPackageName,
targetTypeBuilder.toInstance(), (ChoiceSchemaNode) targetSchemaNode,
- schemaPathAugmentListEntry.get(0).getChildNodes(),
- usesNodeParent, genCtx, verboseClassComments, genTypeBuilders, typeProvider);
- return genCtx;
- }
- }
-
- //TODO: delete this method eventually when uses-augments & augmented choice cases are implemented
- @Deprecated
- public static Map<Module, ModuleContext> usesAugmentationToGenTypes(final SchemaContext schemaContext, final String
- augmentPackageName, final AugmentationSchema augSchema, final Module module, final UsesNode usesNode, final DataNodeContainer
- usesNodeParent, Map<Module, ModuleContext> genCtx,
- Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders,
- final boolean verboseClassComments, final TypeProvider typeProvider) {
-
- Preconditions.checkArgument(augmentPackageName != null, "Package Name cannot be NULL.");
- Preconditions.checkArgument(augSchema != null, "Augmentation Schema cannot be NULL.");
- Preconditions.checkState(augSchema.getTargetPath() != null,
- "Augmentation Schema does not contain Target Path (Target Path is NULL).");
-
- final SchemaPath targetPath = augSchema.getTargetPath();
- final SchemaNode targetSchemaNode = findOriginalTargetFromGrouping(schemaContext, targetPath, usesNode);
- if (targetSchemaNode == null) {
- throw new IllegalArgumentException("augment target not found: " + targetPath);
- }
-
- GeneratedTypeBuilder targetTypeBuilder = GenHelperUtil.findChildNodeByPath(targetSchemaNode.getPath(),
- genCtx);
- if (targetTypeBuilder == null) {
- targetTypeBuilder = GenHelperUtil.findCaseByPath(targetSchemaNode.getPath(), genCtx);
- }
- if (targetTypeBuilder == null) {
- throw new NullPointerException("Target type not yet generated: " + targetSchemaNode);
- }
-
- if (!(targetSchemaNode instanceof ChoiceSchemaNode)) {
- String packageName = augmentPackageName;
- if (usesNodeParent instanceof SchemaNode) {
- packageName = BindingGeneratorUtil.packageNameForAugmentedGeneratedType(augmentPackageName,
- ((SchemaNode) usesNodeParent).getPath());
- } else if (usesNodeParent instanceof AugmentationSchema) {
- Type parentTypeBuilder = genCtx.get(module).getTypeToAugmentation().inverse().get(usesNodeParent);
- packageName = BindingGeneratorUtil.packageNameForAugmentedGeneratedType(
- parentTypeBuilder.getPackageName(), (AugmentationSchema)usesNodeParent);
- }
- genCtx = GenHelperUtil.addRawAugmentGenTypeDefinition(module, packageName, augmentPackageName,
- targetTypeBuilder.toInstance(), augSchema, genTypeBuilders, genCtx, schemaContext,
- verboseClassComments, typeProvider);
- return genCtx;
- } else {
- genCtx = generateTypesFromAugmentedChoiceCases(schemaContext, module, augmentPackageName,
- targetTypeBuilder.toInstance(), (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes(),
+ schemaPathAugmentListEntry,
usesNodeParent, genCtx, verboseClassComments, genTypeBuilders, typeProvider);
return genCtx;
}
throw new IllegalArgumentException("Failed to generate code for augment in " + parentUsesNode);
}
- final GroupingDefinition grouping = (GroupingDefinition) targetGrouping;
- SchemaNode result = grouping;
+ SchemaNode result = targetGrouping;
for (final QName node : targetPath.getPathFromRoot()) {
if (result instanceof DataNodeContainer) {
final QName resultNode = QName.create(result.getQName().getModule(), node.getLocalName());
* Type which represents target choice
* @param targetNode
* node which represents target choice
- * @param augmentedNodes
- * set of choice case nodes for which is checked if are/aren't
- * added to choice through augmentation
+ * @param schemaPathAugmentListEntry
+ * list of AugmentationSchema nodes grouped by target path
* @return list of generated types which represents augmented cases of
* choice <code>refChoiceType</code>
* @throws IllegalArgumentException
* <li>if <code>augmentedNodes</code> is null</li>
* </ul>
*/
- private static Map<Module, ModuleContext> generateTypesFromAugmentedChoiceCases(final SchemaContext schemaContext, final Module module,
- final String basePackageName, final Type targetType, final ChoiceSchemaNode targetNode,
- final Iterable<DataSchemaNode> augmentedNodes, final DataNodeContainer usesNodeParent,
- Map<Module, ModuleContext> genCtx, final boolean verboseClassComments,
- Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders, final TypeProvider typeProvider) {
+ private static Map<Module, ModuleContext> generateTypesFromAugmentedChoiceCases(
+ final SchemaContext schemaContext, final Module module,
+ final String basePackageName, final Type targetType, final ChoiceSchemaNode targetNode,
+ final List<AugmentationSchema> schemaPathAugmentListEntry,
+ final DataNodeContainer usesNodeParent,
+ Map<Module, ModuleContext> genCtx, final boolean verboseClassComments,
+ Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders, final TypeProvider typeProvider) {
Preconditions.checkArgument(basePackageName != null, "Base Package Name cannot be NULL.");
Preconditions.checkArgument(targetType != null, "Referenced Choice Type cannot be NULL.");
- Preconditions.checkArgument(augmentedNodes != null, "Set of Choice Case Nodes cannot be NULL.");
-
- for (final DataSchemaNode caseNode : augmentedNodes) {
- if (caseNode != null) {
- final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName,
- caseNode.getPath(), null);
- final GeneratedTypeBuilder caseTypeBuilder = GenHelperUtil.addDefaultInterfaceDefinition(packageName,
- caseNode, module, genCtx, schemaContext, verboseClassComments, genTypeBuilders, typeProvider);
- caseTypeBuilder.addImplementsType(targetType);
-
- SchemaNode parent;
- final SchemaPath nodeSp = targetNode.getPath();
- parent = SchemaContextUtil.findDataSchemaNode(schemaContext, nodeSp.getParent());
-
- GeneratedTypeBuilder childOfType = null;
- if (parent instanceof Module) {
- childOfType = genCtx.get(parent).getModuleNode();
- } else if (parent instanceof ChoiceCaseNode) {
- childOfType = GenHelperUtil.findCaseByPath(parent.getPath(), genCtx);
- } else if (parent instanceof DataSchemaNode || parent instanceof NotificationDefinition) {
- childOfType = GenHelperUtil.findChildNodeByPath(parent.getPath(), genCtx);
- } else if (parent instanceof GroupingDefinition) {
- childOfType = GenHelperUtil.findGroupingByPath(parent.getPath(), genCtx);
- }
+ Preconditions.checkArgument(schemaPathAugmentListEntry != null, "Set of Choice Case Nodes cannot be NULL.");
+
+
+ for (final AugmentationSchema augmentationSchema : schemaPathAugmentListEntry) {
+ for (final DataSchemaNode caseNode : augmentationSchema.getChildNodes()) {
+ if (caseNode != null) {
+ final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName,
+ caseNode.getPath(), BindingNamespaceType.Data);
+ final GeneratedTypeBuilder caseTypeBuilder = GenHelperUtil.addDefaultInterfaceDefinition(packageName,
+ caseNode, module, genCtx, schemaContext, verboseClassComments, genTypeBuilders, typeProvider);
+ caseTypeBuilder.addImplementsType(targetType);
+
+ SchemaNode parent;
+ final SchemaPath nodeSp = targetNode.getPath();
+ parent = SchemaContextUtil.findDataSchemaNode(schemaContext, nodeSp.getParent());
+
+ GeneratedTypeBuilder childOfType = null;
+ if (parent instanceof Module) {
+ childOfType = genCtx.get(parent).getModuleNode();
+ } else if (parent instanceof ChoiceCaseNode) {
+ childOfType = GenHelperUtil.findCaseByPath(parent.getPath(), genCtx);
+ } else if (parent instanceof DataSchemaNode || parent instanceof NotificationDefinition) {
+ childOfType = GenHelperUtil.findChildNodeByPath(parent.getPath(), genCtx);
+ } else if (parent instanceof GroupingDefinition) {
+ childOfType = GenHelperUtil.findGroupingByPath(parent.getPath(), genCtx);
+ }
- if (childOfType == null) {
- throw new IllegalArgumentException("Failed to find parent type of choice " + targetNode);
- }
+ if (childOfType == null) {
+ throw new IllegalArgumentException("Failed to find parent type of choice " + targetNode);
+ }
- ChoiceCaseNode node = null;
- final String caseLocalName = caseNode.getQName().getLocalName();
- if (caseNode instanceof ChoiceCaseNode) {
- node = (ChoiceCaseNode) caseNode;
- } else if (targetNode.getCaseNodeByName(caseLocalName) == null) {
- final String targetNodeLocalName = targetNode.getQName().getLocalName();
- for (DataSchemaNode dataSchemaNode : usesNodeParent.getChildNodes()) {
- if (dataSchemaNode instanceof ChoiceSchemaNode && targetNodeLocalName.equals(dataSchemaNode.getQName
- ().getLocalName())) {
- node = ((ChoiceSchemaNode) dataSchemaNode).getCaseNodeByName(caseLocalName);
- break;
+ ChoiceCaseNode node = null;
+ final String caseLocalName = caseNode.getQName().getLocalName();
+ if (caseNode instanceof ChoiceCaseNode) {
+ node = (ChoiceCaseNode) caseNode;
+ } else if (targetNode.getCaseNodeByName(caseLocalName) == null) {
+ final String targetNodeLocalName = targetNode.getQName().getLocalName();
+ for (DataSchemaNode dataSchemaNode : usesNodeParent.getChildNodes()) {
+ if (dataSchemaNode instanceof ChoiceSchemaNode && targetNodeLocalName.equals(dataSchemaNode.getQName
+ ().getLocalName())) {
+ node = ((ChoiceSchemaNode) dataSchemaNode).getCaseNodeByName(caseLocalName);
+ break;
+ }
}
+ } else {
+ node = targetNode.getCaseNodeByName(caseLocalName);
}
- } else {
- node = targetNode.getCaseNodeByName(caseLocalName);
- }
- final Iterable<DataSchemaNode> childNodes = node.getChildNodes();
- if (childNodes != null) {
- GenHelperUtil.resolveDataSchemaNodes(module, basePackageName, caseTypeBuilder, childOfType,
- childNodes, genCtx, schemaContext, verboseClassComments, genTypeBuilders, typeProvider);
+ final Iterable<DataSchemaNode> childNodes = node.getChildNodes();
+ if (childNodes != null) {
+ GenHelperUtil.resolveDataSchemaNodes(module, basePackageName, caseTypeBuilder, childOfType,
+ childNodes, genCtx, schemaContext, verboseClassComments, genTypeBuilders, typeProvider);
+ }
+ genCtx.get(module).addCaseType(caseNode.getPath(), caseTypeBuilder);
+ genCtx.get(module).addChoiceToCaseMapping(targetType, caseTypeBuilder, node);
}
- genCtx.get(module).addCaseType(caseNode.getPath(), caseTypeBuilder);
- genCtx.get(module).addChoiceToCaseMapping(targetType, caseTypeBuilder, node);
}
}
return genCtx;
import org.opendaylight.mdsal.binding.javav2.generator.yang.types.TypeProviderImpl;
import org.opendaylight.mdsal.binding.javav2.model.api.Type;
import org.opendaylight.mdsal.binding.javav2.model.api.type.builder.GeneratedTypeBuilder;
+import org.opendaylight.mdsal.binding.javav2.spec.structural.Augmentation;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
assertEquals(result.get(1), augmentationSchema2);
}
- @Ignore
@SuppressWarnings({ "rawtypes" })
@Test
public void augmentationToGenTypesNullPckgNameTest() throws Exception {
- final Class[] parameterTypes = { String.class, AugmentationSchema.class, Module.class, SchemaContext.class,
+ final Class[] parameterTypes = { String.class, Map.Entry.class, Module.class, SchemaContext.class,
boolean.class, Map.class, Map.class, TypeProvider.class };
final Method generate = AugmentToGenType.class.getDeclaredMethod("augmentationToGenTypes", parameterTypes);
assertNotNull(generate);
generate.setAccessible(true);
final String augmPackName = null;
- final AugmentationSchema augmSchema = null;
+ final Map.Entry<SchemaPath, List<AugmentationSchema>> schemaPathAugmentListEntry = null;
final SchemaContext context = null;
final TypeProvider typeProvider = null;
final Map<Module, ModuleContext> genCtx = new HashMap<>();
final Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders = new HashMap<>();
final Module m = null;
- final Object[] args = { augmPackName, augmSchema, m, context, false, genCtx, genTypeBuilders, typeProvider };
+ final Object[] args = { augmPackName, schemaPathAugmentListEntry, m, context, false, genCtx, genTypeBuilders, typeProvider };
try {
generate.invoke(AugmentToGenType.class, args);
fail();
}
}
- @Ignore
@SuppressWarnings({ "rawtypes" })
@Test
public void augmentationToGenTypesNullAugSchemaTest() throws Exception {
- final Class[] parameterTypes = { String.class, AugmentationSchema.class, Module.class, SchemaContext.class,
+ final Class[] parameterTypes = { String.class, Map.Entry.class, Module.class, SchemaContext.class,
boolean.class, Map.class, Map.class, TypeProvider.class };
final Method generate = AugmentToGenType.class.getDeclaredMethod("augmentationToGenTypes", parameterTypes);
assertNotNull(generate);
generate.setAccessible(true);
final String augmPackName = "pckg.name";
- final AugmentationSchema augmSchema = null;
+ final Map.Entry<SchemaPath, List<AugmentationSchema>> schemaPathAugmentListEntry = null;
final SchemaContext context = null;
final TypeProvider typeProvider = null;
final Map<Module, ModuleContext> genCtx = new HashMap<>();
final Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders = new HashMap<>();
final Module m = null;
- final Object[] args = { augmPackName, augmSchema, m, context, false, genCtx, genTypeBuilders, typeProvider };
+ final Object[] args = { augmPackName, schemaPathAugmentListEntry, m, context, false, genCtx, genTypeBuilders, typeProvider };
try {
generate.invoke(AugmentToGenType.class, args);
fail();
final Throwable cause = e.getCause();
assertNotNull(cause);
assertTrue(cause instanceof IllegalArgumentException);
- assertEquals("Augmentation Schema cannot be NULL.", cause.getMessage());
+ assertEquals("Augmentation List Entry cannot be NULL.", cause.getMessage());
}
}
- @Ignore
@SuppressWarnings({ "rawtypes" })
@Test
public void augmentationToGenTypesNullAugSchemaTargetPathTest() throws Exception {
- final Class[] parameterTypes = { String.class, AugmentationSchema.class, Module.class, SchemaContext.class,
+ final Class[] parameterTypes = { String.class, Map.Entry.class, Module.class, SchemaContext.class,
boolean.class, Map.class, Map.class, TypeProvider.class };
final Method generate = AugmentToGenType.class.getDeclaredMethod("augmentationToGenTypes", parameterTypes);
assertNotNull(generate);
final AugmentationSchema augmSchema = mock(AugmentationSchema.class);
when(augmSchema.getTargetPath()).thenReturn(null);
+ final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
+ final Map.Entry<SchemaPath, List<AugmentationSchema>> schemaPathAugmentListEntry = mock(Map.Entry.class);
+ when(schemaPathAugmentListEntry.getKey()).thenReturn(null);
+ when(schemaPathAugmentListEntry.getValue()).thenReturn(augmentationSchemaList);
+
+ final SchemaContext context = null;
+ final TypeProvider typeProvider = null;
+ final Map<Module, ModuleContext> genCtx = new HashMap<>();
+ final Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders = new HashMap<>();
+ final Module m = null;
+
+ final Object[] args = { augmPackName, schemaPathAugmentListEntry, m, context, false, genCtx, genTypeBuilders, typeProvider };
+ try {
+ generate.invoke(AugmentToGenType.class, args);
+ fail();
+ } catch (final Exception e) {
+ assertNotNull(e);
+ assertTrue(e instanceof InvocationTargetException);
+ final Throwable cause = e.getCause();
+ assertNotNull(cause);
+ assertTrue(cause instanceof IllegalStateException);
+ assertEquals("Augmentation List Entry does not contain Target Path (Target Path is NULL).", cause.getMessage());
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes" })
+ @Test
+ public void augmentationToGenTypesNullAugSchemaListTest() throws Exception {
+ final Class[] parameterTypes = { String.class, Map.Entry.class, Module.class, SchemaContext.class,
+ boolean.class, Map.class, Map.class, TypeProvider.class };
+ final Method generate = AugmentToGenType.class.getDeclaredMethod("augmentationToGenTypes", parameterTypes);
+ assertNotNull(generate);
+ generate.setAccessible(true);
+
+ final String augmPackName = "pckg.name";
+ final AugmentationSchema augmSchema = mock(AugmentationSchema.class);
+ final QName qnamePath = QName.create("test", "2017-04-04", "aug");
+ final SchemaPath path = SchemaPath.create(true, qnamePath);
+ when(augmSchema.getTargetPath()).thenReturn(path);
+
+ final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
+ final Map.Entry<SchemaPath, List<AugmentationSchema>> schemaPathAugmentListEntry = mock(Map.Entry.class);
+ when(schemaPathAugmentListEntry.getKey()).thenReturn(path);
+ when(schemaPathAugmentListEntry.getValue()).thenReturn(augmentationSchemaList);
+
final SchemaContext context = null;
final TypeProvider typeProvider = null;
final Map<Module, ModuleContext> genCtx = new HashMap<>();
final Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders = new HashMap<>();
final Module m = null;
- final Object[] args = { augmPackName, augmSchema, m, context, false, genCtx, genTypeBuilders, typeProvider };
+ final Object[] args = { augmPackName, schemaPathAugmentListEntry, m, context, false, genCtx, genTypeBuilders, typeProvider };
try {
generate.invoke(AugmentToGenType.class, args);
fail();
final Throwable cause = e.getCause();
assertNotNull(cause);
assertTrue(cause instanceof IllegalStateException);
- assertEquals("Augmentation Schema does not contain Target Path (Target Path is NULL).", cause.getMessage());
+ assertEquals("Augmentation List cannot be empty.", cause.getMessage());
}
}
- @Ignore
@SuppressWarnings({ "rawtypes" })
@Test
public void augmentationToGenTypesNullAugSchemaTargetNodeTest() throws Exception {
- final Class[] parameterTypes = { String.class, AugmentationSchema.class, Module.class, SchemaContext.class,
+ final Class[] parameterTypes = { String.class, Map.Entry.class, Module.class, SchemaContext.class,
boolean.class, Map.class, Map.class, TypeProvider.class };
final Method generate = AugmentToGenType.class.getDeclaredMethod("augmentationToGenTypes", parameterTypes);
assertNotNull(generate);
final Set<UsesNode> uses = new HashSet<>();
when(augmSchema.getUses()).thenReturn(uses);
+ final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
+ augmentationSchemaList.add(augmSchema);
+ final Map.Entry<SchemaPath, List<AugmentationSchema>> schemaPathAugmentListEntry = mock(Map.Entry.class);
+ when(schemaPathAugmentListEntry.getKey()).thenReturn(path);
+ when(schemaPathAugmentListEntry.getValue()).thenReturn(augmentationSchemaList);
+
final SchemaContext context = mock(SchemaContext.class);
final Module moduleAug = mock(Module.class);
final DataSchemaNode schNode = null;
when(m.getNamespace()).thenReturn(qnamePath.getNamespace());
when(m.getRevision()).thenReturn(qnamePath.getRevision());
- final Object[] args = { augmPackName, augmSchema, m, context, false, genCtx, genTypeBuilders, typeProvider };
+ final Object[] args = { augmPackName, schemaPathAugmentListEntry, m, context, false, genCtx, genTypeBuilders, typeProvider };
try {
generate.invoke(AugmentToGenType.class, args);
fail();
}
}
- @Ignore
@SuppressWarnings({ "rawtypes" })
@Test
public void augmentationToGenTypesNullAugTargetGTBTest() throws Exception {
- final Class[] parameterTypes = { String.class, AugmentationSchema.class, Module.class, SchemaContext.class,
+ final Class[] parameterTypes = { String.class, Map.Entry.class, Module.class, SchemaContext.class,
boolean.class, Map.class, Map.class, TypeProvider.class };
final Method generate = AugmentToGenType.class.getDeclaredMethod("augmentationToGenTypes", parameterTypes);
assertNotNull(generate);
final Set<UsesNode> uses = new HashSet<>();
when(augmSchema.getUses()).thenReturn(uses);
+ final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
+ augmentationSchemaList.add(augmSchema);
+ final Map.Entry<SchemaPath, List<AugmentationSchema>> schemaPathAugmentListEntry = mock(Map.Entry.class);
+ when(schemaPathAugmentListEntry.getKey()).thenReturn(path);
+ when(schemaPathAugmentListEntry.getValue()).thenReturn(augmentationSchemaList);
+
final SchemaContext context = mock(SchemaContext.class);
final Module moduleAug = mock(Module.class);
final DataSchemaNode schNode = mock(DataSchemaNode.class);
when(m.getNamespace()).thenReturn(qnamePath.getNamespace());
when(m.getRevision()).thenReturn(qnamePath.getRevision());
- final Object[] args = { augmPackName, augmSchema, m, context, false, genCtx, genTypeBuilders, typeProvider };
+ final Object[] args = { augmPackName, schemaPathAugmentListEntry, m, context, false, genCtx, genTypeBuilders, typeProvider };
try {
generate.invoke(AugmentToGenType.class, args);
fail();
}
}
- @Ignore
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void augmentationToGenTypesAugUsesNullOrigTargetTest() throws Exception {
- final Class[] parameterTypes = { String.class, AugmentationSchema.class, Module.class, SchemaContext.class,
+ final Class[] parameterTypes = { String.class, Map.Entry.class, Module.class, SchemaContext.class,
boolean.class, Map.class, Map.class, TypeProvider.class };
final Method generate = AugmentToGenType.class.getDeclaredMethod("augmentationToGenTypes", parameterTypes);
assertNotNull(generate);
final Set<UsesNode> uses = new HashSet<>();
when(augmSchema.getUses()).thenReturn(uses);
+ final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
+ augmentationSchemaList.add(augmSchema);
+ final Map.Entry<SchemaPath, List<AugmentationSchema>> schemaPathAugmentListEntry = mock(Map.Entry.class);
+ when(schemaPathAugmentListEntry.getKey()).thenReturn(path);
+ when(schemaPathAugmentListEntry.getValue()).thenReturn(augmentationSchemaList);
+
final SchemaContext context = mock(SchemaContext.class);
final Module moduleAug = mock(Module.class);
final DerivableSchemaNode targetSchNode = mock(DerivableSchemaNode.class);
when(m.getNamespace()).thenReturn(qnamePath.getNamespace());
when(m.getRevision()).thenReturn(qnamePath.getRevision());
- final Object[] args = { augmPackName, augmSchema, m, context, false, genCtx, genTypeBuilders, typeProvider };
+ final Object[] args = { augmPackName, schemaPathAugmentListEntry, m, context, false, genCtx, genTypeBuilders, typeProvider };
try {
generate.invoke(AugmentToGenType.class, args);
fail();
}
}
- @Ignore
@SuppressWarnings({ "rawtypes" })
@Test
public void augmentationToGenTypesTargetChoicSchemaNodeTest() throws Exception {
- final Class[] parameterTypes = { String.class, AugmentationSchema.class, Module.class, SchemaContext.class,
+ final Class[] parameterTypes = { String.class, Map.Entry.class, Module.class, SchemaContext.class,
boolean.class, Map.class, Map.class, TypeProvider.class };
final Method generate = AugmentToGenType.class.getDeclaredMethod("augmentationToGenTypes", parameterTypes);
assertNotNull(generate);
final Set<UsesNode> uses = new HashSet<>();
when(augmSchema.getUses()).thenReturn(uses);
+ final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
+ augmentationSchemaList.add(augmSchema);
+ final Map.Entry<SchemaPath, List<AugmentationSchema>> schemaPathAugmentListEntry = mock(Map.Entry.class);
+ when(schemaPathAugmentListEntry.getKey()).thenReturn(path);
+ when(schemaPathAugmentListEntry.getValue()).thenReturn(augmentationSchemaList);
+
final SchemaContext context = mock(SchemaContext.class);
final Module moduleAug = mock(Module.class);
final ChoiceSchemaNode targetSchNode = mock(ChoiceSchemaNode.class);
when(m.getNamespace()).thenReturn(qnamePath.getNamespace());
when(m.getRevision()).thenReturn(qnamePath.getRevision());
- final Object[] args = { augmPackName, augmSchema, m, context, false, genCtx, genTypeBuilders, typeProvider };
+ final Object[] args = { augmPackName, schemaPathAugmentListEntry, m, context, false, genCtx, genTypeBuilders, typeProvider };
final Map result = (Map) generate.invoke(AugmentToGenType.class, args);
assertNotNull(result);
}
- @Ignore
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void augmentationToGenTypesTest() throws Exception {
- final Class[] parameterTypes = { String.class, AugmentationSchema.class, Module.class, SchemaContext.class,
+ final Class[] parameterTypes = { String.class, Map.Entry.class, Module.class, SchemaContext.class,
boolean.class, Map.class, Map.class, TypeProvider.class };
final Method generate = AugmentToGenType.class.getDeclaredMethod("augmentationToGenTypes", parameterTypes);
assertNotNull(generate);
final List<UnknownSchemaNode> unknownSchemaNodes = new ArrayList<>();
when(augmSchema.getUnknownSchemaNodes()).thenReturn(unknownSchemaNodes);
+ final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
+ augmentationSchemaList.add(augmSchema);
+ final Map.Entry<SchemaPath, List<AugmentationSchema>> schemaPathAugmentListEntry = mock(Map.Entry.class);
+ when(schemaPathAugmentListEntry.getKey()).thenReturn(path);
+ when(schemaPathAugmentListEntry.getValue()).thenReturn(augmentationSchemaList);
+
final SchemaContext context = mock(SchemaContext.class);
final Module moduleAug = mock(Module.class);
final DerivableSchemaNode targetSchNode = mock(DerivableSchemaNode.class);
when(moduleAug.getRevision()).thenReturn(qnamePath.getRevision());
final Object[] args =
- { augmPackName, augmSchema, moduleAug, context, false, genCtx, genTypeBuilders, typeProvider };
+ { augmPackName, schemaPathAugmentListEntry, moduleAug, context, false, genCtx, genTypeBuilders, typeProvider };
final Map<Module, ModuleContext> result =
(Map<Module, ModuleContext>) generate.invoke(AugmentToGenType.class, args);
assertNotNull(result);
final ModuleContext moduleContext = result.get(moduleAug);
assertTrue(moduleContext.getAugmentations().get(0).getName().contains("Augm"));
- assertEquals("pckg.name", moduleContext.getAugmentations().get(0).getPackageName());
+ assertEquals("pckg.name.data.aug", moduleContext.getAugmentations().get(0).getPackageName());
assertTrue(moduleContext.getChildNode(path).getName().contains("Augm"));
assertEquals("pckg.name", moduleContext.getChildNode(path).getPackageName());
}
@Test
public void usesAugmentationToGenTypesNullPckgNameTest() throws Exception {
try {
- AugmentToGenType.usesAugmentationToGenTypes(null, null, (AugmentationSchema) null, null, null, null, null, null, false, null);
+ AugmentToGenType.usesAugmentationToGenTypes(null, null, null, null, null, null, null, null, false, null);
} catch (final Exception e) {
assertNotNull(e);
assertTrue(e instanceof IllegalArgumentException);
}
@Test
- public void usesAugmentationToGenTypesNullAugSchemaNodeTest() throws Exception {
+ public void usesAugmentationToGenTypesNullAugSchemaListEntryTest() throws Exception {
try {
- AugmentToGenType.usesAugmentationToGenTypes(null, "", (AugmentationSchema) null, null, null, null, null, null, false, null);
+ AugmentToGenType.usesAugmentationToGenTypes(null, "", null, null, null, null, null, null, false, null);
} catch (final Exception e) {
assertNotNull(e);
assertTrue(e instanceof IllegalArgumentException);
- assertEquals(e.getMessage(), "Augmentation Schema cannot be NULL.");
+ assertEquals(e.getMessage(), "Augmentation Schema List Entry cannot be NULL.");
+ }
+ }
+
+ @Test
+ public void usesAugmentationToGenTypesEmptyAugSchemaListTest() throws Exception {
+ final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
+ try {
+ AugmentToGenType.usesAugmentationToGenTypes(null, "", augmentationSchemaList, null, null, null, null, null,
+ false, null);
+ } catch (final Exception e) {
+ assertNotNull(e);
+ assertTrue(e instanceof IllegalStateException);
+ assertEquals(e.getMessage(), "Augmentation Schema List cannot be empty");
}
}
public void usesAugmentationToGenTypesNullAugSchemaNodeTargetPathTest() throws Exception {
final AugmentationSchema augmentationSchema = mock(AugmentationSchema.class);
when(augmentationSchema.getTargetPath()).thenReturn(null);
+ final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
+ augmentationSchemaList.add(augmentationSchema);
try {
- AugmentToGenType.usesAugmentationToGenTypes(null, "", augmentationSchema, null, null, null, null, null,
+ AugmentToGenType.usesAugmentationToGenTypes(null, "", augmentationSchemaList, null, null, null, null, null,
false, null);
} catch (final Exception e) {
assertNotNull(e);
final Set<UsesNode> uses = new HashSet<>();
when(augmentationSchema.getUses()).thenReturn(uses);
+ final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
+ augmentationSchemaList.add(augmentationSchema);
+
final SchemaContext context = mock(SchemaContext.class);
final Module moduleAug = mock(Module.class);
when(moduleAug.getName()).thenReturn("augm-module");
when(usesNode.getGroupingPath()).thenReturn(path);
try {
- AugmentToGenType.usesAugmentationToGenTypes(context, "pckg.test.augm", augmentationSchema, moduleAug,
+ AugmentToGenType.usesAugmentationToGenTypes(context, "pckg.test.augm", augmentationSchemaList, moduleAug,
usesNode, usesNodeParent, genCtx, genTypeBuilders, false, null);
} catch (final Exception e) {
assertNotNull(e);
final Set<UsesNode> uses = new HashSet<>();
when(augmentationSchema.getUses()).thenReturn(uses);
+ final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
+ augmentationSchemaList.add(augmentationSchema);
+
final SchemaContext context = mock(SchemaContext.class);
final Module moduleAug = mock(Module.class);
when(moduleAug.getName()).thenReturn("augm-module");
when(usesNode.getGroupingPath()).thenReturn(path);
try {
- AugmentToGenType.usesAugmentationToGenTypes(context, "pckg.test.augm", augmentationSchema, moduleAug,
+ AugmentToGenType.usesAugmentationToGenTypes(context, "pckg.test.augm", augmentationSchemaList, moduleAug,
usesNode, usesNodeParent, genCtx, genTypeBuilders, false, null);
} catch (final Exception e) {
assertNotNull(e);
final Set<UsesNode> uses = new HashSet<>();
when(augmentationSchema.getUses()).thenReturn(uses);
+ final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
+ augmentationSchemaList.add(augmentationSchema);
+
final SchemaContext context = mock(SchemaContext.class);
final Module moduleAug = mock(Module.class);
when(moduleAug.getName()).thenReturn("augm-module");
when(usesNode.getGroupingPath()).thenReturn(path);
final Map<Module, ModuleContext> result = AugmentToGenType.usesAugmentationToGenTypes(context, "pckg.test.augm",
- augmentationSchema, moduleAug, usesNode, usesNodeParent, genCtx, genTypeBuilders, false, null);
+ augmentationSchemaList, moduleAug, usesNode, usesNodeParent, genCtx, genTypeBuilders, false, null);
assertNotNull(result);
}
final Set<UsesNode> uses = new HashSet<>();
when(augmentationSchema.getUses()).thenReturn(uses);
+ final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
+ augmentationSchemaList.add(augmentationSchema);
+
final SchemaContext context = mock(SchemaContext.class);
final Module moduleAug = mock(Module.class);
when(moduleAug.getName()).thenReturn("augm-module");
when(usesNode.getGroupingPath()).thenReturn(path);
final Map<Module, ModuleContext> result = AugmentToGenType.usesAugmentationToGenTypes(context, "pckg.test.augm",
- augmentationSchema, moduleAug, usesNode, usesNodeParent, genCtx, genTypeBuilders, false, null);
+ augmentationSchemaList, moduleAug, usesNode, usesNodeParent, genCtx, genTypeBuilders, false, null);
assertNotNull(result);
}
@Test
public void generateTypesFromAugmentedChoiceCasesNullPckgNameTest() throws Exception {
final Class[] parameterTypes =
- { SchemaContext.class, Module.class, String.class, Type.class, ChoiceSchemaNode.class, Iterable.class,
+ { SchemaContext.class, Module.class, String.class, Type.class, ChoiceSchemaNode.class, List.class,
DataNodeContainer.class, Map.class, boolean.class, Map.class, TypeProvider.class };
final Method generate =
AugmentToGenType.class.getDeclaredMethod("generateTypesFromAugmentedChoiceCases", parameterTypes);
final String pckgName = null;
final Type targetType = null;
final ChoiceSchemaNode targetNode = null;
- final Iterable augmentNodes = null;
+ final List<AugmentationSchema> schemaPathAugmentListEntry = null;
final DataNodeContainer usesNodeParent = null;
final Map<Module, ModuleContext> genCtx = new HashMap<>();
final Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilder = new HashMap<>();
- final Object[] args = { schemaContext, module, pckgName, targetType, targetNode, augmentNodes, usesNodeParent,
- genCtx, false, genTypeBuilder, null };
+ final Object[] args = { schemaContext, module, pckgName, targetType, targetNode, schemaPathAugmentListEntry,
+ usesNodeParent, genCtx, false, genTypeBuilder, null };
try {
generate.invoke(AugmentToGenType.class, args);
fail();
@Test
public void generateTypesFromAugmentedChoiceCasesNullTargetType() throws Exception {
final Class[] parameterTypes =
- { SchemaContext.class, Module.class, String.class, Type.class, ChoiceSchemaNode.class, Iterable.class,
+ { SchemaContext.class, Module.class, String.class, Type.class, ChoiceSchemaNode.class, List.class,
DataNodeContainer.class, Map.class, boolean.class, Map.class, TypeProvider.class };
final Method generate =
AugmentToGenType.class.getDeclaredMethod("generateTypesFromAugmentedChoiceCases", parameterTypes);
final String pckgName = "";
final Type targetType = null;
final ChoiceSchemaNode targetNode = null;
- final Iterable augmentNodes = null;
+ final List<AugmentationSchema> schemaPathAugmentListEntry = null;
final DataNodeContainer usesNodeParent = null;
final Map<Module, ModuleContext> genCtx = new HashMap<>();
final Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilder = new HashMap<>();
- final Object[] args = { schemaContext, module, pckgName, targetType, targetNode, augmentNodes, usesNodeParent,
- genCtx, false, genTypeBuilder, null };
+ final Object[] args = { schemaContext, module, pckgName, targetType, targetNode, schemaPathAugmentListEntry,
+ usesNodeParent, genCtx, false, genTypeBuilder, null };
try {
generate.invoke(AugmentToGenType.class, args);
fail();
@Test
public void generateTypesFromAugmentedChoiceCasesNullAugmentNodes() throws Exception {
final Class[] parameterTypes =
- { SchemaContext.class, Module.class, String.class, Type.class, ChoiceSchemaNode.class, Iterable.class,
+ { SchemaContext.class, Module.class, String.class, Type.class, ChoiceSchemaNode.class, List.class,
DataNodeContainer.class, Map.class, boolean.class, Map.class, TypeProvider.class };
final Method generate =
AugmentToGenType.class.getDeclaredMethod("generateTypesFromAugmentedChoiceCases", parameterTypes);
final String pckgName = "";
final Type targetType = mock(Type.class);
final ChoiceSchemaNode targetNode = null;
- final Iterable augmentNodes = null;
+ final List<AugmentationSchema> schemaPathAugmentListEntry = null;
final DataNodeContainer usesNodeParent = null;
final Map<Module, ModuleContext> genCtx = new HashMap<>();
final Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilder = new HashMap<>();
- final Object[] args = { schemaContext, module, pckgName, targetType, targetNode, augmentNodes, usesNodeParent,
+ final Object[] args = { schemaContext, module, pckgName, targetType, targetNode, schemaPathAugmentListEntry, usesNodeParent,
genCtx, false, genTypeBuilder, null };
try {
generate.invoke(AugmentToGenType.class, args);
@Test
public void generateTypesFromAugmentedChoiceCasesNullCaseNodeTest() throws Exception {
final Class[] parameterTypes =
- { SchemaContext.class, Module.class, String.class, Type.class, ChoiceSchemaNode.class, Iterable.class,
+ { SchemaContext.class, Module.class, String.class, Type.class, ChoiceSchemaNode.class, List.class,
DataNodeContainer.class, Map.class, boolean.class, Map.class, TypeProvider.class };
final Method generate =
AugmentToGenType.class.getDeclaredMethod("generateTypesFromAugmentedChoiceCases", parameterTypes);
final Set<DataSchemaNode> augmentNodes = new HashSet<>();
final DataSchemaNode caseNode = null;
augmentNodes.add(caseNode);
+
+ final AugmentationSchema augmentationSchema = mock(AugmentationSchema.class);
+ when(augmentationSchema.getChildNodes()).thenReturn(augmentNodes);
+ final List<AugmentationSchema> schemaPathAugmentListEntry = new ArrayList<>();
+ schemaPathAugmentListEntry.add(augmentationSchema);
+
final DataNodeContainer usesNodeParent = null;
final Map<Module, ModuleContext> genCtx = new HashMap<>();
final Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilder = new HashMap<>();
- final Object[] args = { schemaContext, module, pckgName, targetType, targetNode, augmentNodes, usesNodeParent,
+ final Object[] args = { schemaContext, module, pckgName, targetType, targetNode, schemaPathAugmentListEntry, usesNodeParent,
genCtx, false, genTypeBuilder, null };
final Map<Module, ModuleContext> result =
(Map<Module, ModuleContext>) generate.invoke(AugmentToGenType.class, args);
@Test
public void generateTypesFromAugmentedChoiceCasesNullChildTest() throws Exception {
final Class[] parameterTypes =
- { SchemaContext.class, Module.class, String.class, Type.class, ChoiceSchemaNode.class, Iterable.class,
+ { SchemaContext.class, Module.class, String.class, Type.class, ChoiceSchemaNode.class, List.class,
DataNodeContainer.class, Map.class, boolean.class, Map.class, TypeProvider.class };
final Method generate =
AugmentToGenType.class.getDeclaredMethod("generateTypesFromAugmentedChoiceCases", parameterTypes);
when(caseNode.getPath()).thenReturn(path);
when(caseNode.getQName()).thenReturn(qnamePath);
augmentNodes.add(caseNode);
+
+ final AugmentationSchema augmentationSchema = mock(AugmentationSchema.class);
+ when(augmentationSchema.getChildNodes()).thenReturn(augmentNodes);
+ final List<AugmentationSchema> schemaPathAugmentListEntry = new ArrayList<>();
+ schemaPathAugmentListEntry.add(augmentationSchema);
+
final DataNodeContainer usesNodeParent = null;
final ChoiceSchemaNode targetNode = mock(ChoiceSchemaNode.class);
when(targetNode.getPath()).thenReturn(path);
when(schemaContext.findModuleByNamespaceAndRevision(qnamePath.getNamespace(), qnamePath.getRevision()))
.thenReturn(module);
- final Object[] args = { schemaContext, module, pckgName, targetType, targetNode, augmentNodes, usesNodeParent,
+ final Object[] args = { schemaContext, module, pckgName, targetType, targetNode, schemaPathAugmentListEntry, usesNodeParent,
genCtx, false, genTypeBuilder, null };
try {
generate.invoke(AugmentToGenType.class, args);
@Test
public void generateTypesFromAugmentedChoiceCasesTest() throws Exception {
final Class[] parameterTypes =
- { SchemaContext.class, Module.class, String.class, Type.class, ChoiceSchemaNode.class, Iterable.class,
+ { SchemaContext.class, Module.class, String.class, Type.class, ChoiceSchemaNode.class, List.class,
DataNodeContainer.class, Map.class, boolean.class, Map.class, TypeProvider.class };
final Method generate =
AugmentToGenType.class.getDeclaredMethod("generateTypesFromAugmentedChoiceCases", parameterTypes);
when(caseNode.getPath()).thenReturn(path);
when(caseNode.getQName()).thenReturn(qnamePath);
augmentNodes.add(caseNode);
+
+ final AugmentationSchema augmentationSchema = mock(AugmentationSchema.class);
+ when(augmentationSchema.getChildNodes()).thenReturn(augmentNodes);
+ final List<AugmentationSchema> schemaPathAugmentListEntry = new ArrayList<>();
+ schemaPathAugmentListEntry.add(augmentationSchema);
+
final DataNodeContainer usesNodeParent = null;
final ChoiceSchemaNode targetNode = mock(ChoiceSchemaNode.class);
when(targetNode.getPath()).thenReturn(path);
when(schemaContext.findModuleByNamespaceAndRevision(qnamePath.getNamespace(), qnamePath.getRevision()))
.thenReturn(module);
- final Object[] args = { schemaContext, module, pckgName, targetType, targetNode, augmentNodes, usesNodeParent,
+ final Object[] args = { schemaContext, module, pckgName, targetType, targetNode, schemaPathAugmentListEntry, usesNodeParent,
genCtx, false, genTypeBuilder, null };
final Map<Module, ModuleContext> result =
(Map<Module, ModuleContext>) generate.invoke(AugmentToGenType.class, args);