Preconditions.checkState(module.getAugmentations() != null, "Augmentations Set cannot be NULL.");
final String basePackageName = BindingMapping.getRootPackageName(module);
- final List<AugmentationSchema> augmentations = resolveAugmentations(module);
+ final List<AugmentationSchema> augmentations = resolveAugmentations(module, schemaContext);
Map<Module, ModuleContext> resultCtx = genCtx;
//let's group augments by target path
* @throws IllegalStateException
* if set of module augmentations is null
*/
- private static List<AugmentationSchema> resolveAugmentations(final Module module) {
+ private static List<AugmentationSchema> resolveAugmentations(final Module module, final SchemaContext schemaContext) {
Preconditions.checkArgument(module != null, "Module reference cannot be NULL.");
Preconditions.checkState(module.getAugmentations() != null, "Augmentations Set cannot be NULL.");
final Set<AugmentationSchema> augmentations = module.getAugmentations();
- final List<AugmentationSchema> sortedAugmentations = new ArrayList<>(augmentations);
+ final List<AugmentationSchema> sortedAugmentations = new ArrayList<>(augmentations).stream()
+ .filter(aug -> !module.equals(schemaContext.findModuleByNamespaceAndRevision(
+ aug.getTargetPath().getLastComponent().getNamespace(),
+ aug.getTargetPath().getLastComponent().getRevision())))
+ .collect(Collectors.toList());
Collections.sort(sortedAugmentations, AUGMENT_COMP);
return sortedAugmentations;
return genCtx;
}
+ @Deprecated
static Map<Module, ModuleContext> usesAugmentationToGenTypes(final SchemaContext schemaContext,
final String augmentPackageName, final List<AugmentationSchema> schemaPathAugmentListEntry, final Module module,
final UsesNode usesNode, final DataNodeContainer usesNodeParent, Map<Module, ModuleContext> genCtx,
@SuppressWarnings("rawtypes")
@Test
public void resolveAugmentationsNullModuleTest() throws Exception {
- final Class[] parameterTypes = { Module.class };
+ final Class[] parameterTypes = { Module.class, SchemaContext.class };
final Method generate = AugmentToGenType.class.getDeclaredMethod("resolveAugmentations", parameterTypes);
assertNotNull(generate);
generate.setAccessible(true);
final Module m = null;
+ final SchemaContext schemaContext = null;
- final Object[] args = { m };
+ final Object[] args = { m, schemaContext };
try {
generate.invoke(AugmentToGenType.class, args);
fail();
@SuppressWarnings("rawtypes")
@Test
public void resolveAugmentationsNullAugmentationsTest() throws Exception {
- final Class[] parameterTypes = { Module.class };
+ final Class[] parameterTypes = { Module.class, SchemaContext.class };
final Method generate = AugmentToGenType.class.getDeclaredMethod("resolveAugmentations", parameterTypes);
assertNotNull(generate);
generate.setAccessible(true);
final Module m = mock(Module.class);
when(m.getAugmentations()).thenReturn(null);
+ final SchemaContext schemaContext = mock(SchemaContext.class);
- final Object[] args = { m };
+ final Object[] args = { m, schemaContext };
try {
generate.invoke(AugmentToGenType.class, args);
fail();
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void resolveAugmentationsTest() throws Exception {
- final Class[] parameterTypes = { Module.class };
+ final Class[] parameterTypes = { Module.class, SchemaContext.class };
final Method generate = AugmentToGenType.class.getDeclaredMethod("resolveAugmentations", parameterTypes);
assertNotNull(generate);
generate.setAccessible(true);
final Module m = mock(Module.class);
+ final Module m2 = mock(Module.class);
+ final SchemaContext schemaContext = mock(SchemaContext.class);
final Set<AugmentationSchema> augmentations = new HashSet<>();
augmentations.add(augmentationSchema2);
when(m.getAugmentations()).thenReturn(augmentations);
+ when(schemaContext.findModuleByNamespaceAndRevision(q2.getNamespace(), q2.getRevision())).thenReturn(m2);
+ when(schemaContext.findModuleByNamespaceAndRevision(q5.getNamespace(), q5.getRevision())).thenReturn(m2);
- final Object[] args = { m };
+ final Object[] args = { m, schemaContext };
final List<AugmentationSchema> result =
(List<AugmentationSchema>) generate.invoke(AugmentToGenType.class, args);
assertEquals("pckg.name", moduleContext.getChildNode(path).getPackageName());
}
+ @Deprecated
@Test
public void usesAugmentationToGenTypesNullPckgNameTest() throws Exception {
try {
}
}
+ @Deprecated
@Test
public void usesAugmentationToGenTypesNullAugSchemaListEntryTest() throws Exception {
try {
}
}
+ @Deprecated
@Test
public void usesAugmentationToGenTypesEmptyAugSchemaListTest() throws Exception {
final List<AugmentationSchema> augmentationSchemaList = new ArrayList<>();
}
}
+ @Deprecated
@Test
public void usesAugmentationToGenTypesNullAugSchemaNodeTargetPathTest() throws Exception {
final AugmentationSchema augmentationSchema = mock(AugmentationSchema.class);
}
}
+ @Deprecated
@Test
public void usesAugmentationToGenTypesNullAugmentTargetTest() throws Exception {
final QName qnamePath = QName.create("test", "2017-04-04", "aug");
}
}
+ @Deprecated
@Test
public void usesAugmentationToGenTypesNullTargetGTBTest() throws Exception {
final QName qnamePath = QName.create("test", "2017-04-04", "aug");
}
}
+ @Deprecated
@Test
public void usesAugmentationToGenTypesTest() throws Exception {
final QName qnamePath = QName.create("test", "2017-04-04", "aug");
assertNotNull(result);
}
+ @Deprecated
@Test
public void usesAugmentationToGenTypesChoiceTest() throws Exception {
final QName qnamePath = QName.create("test", "2017-04-04", "aug");