use of org.apache.ignite.internal.configuration.tree.ConverterToMapVisitor in project ignite-3 by apache.
the class ConfigurationUtilTest method testGetInternalConfigs.
@Test
void testGetInternalConfigs() {
Map<Class<?>, Set<Class<?>>> internalExtensions = internalSchemaExtensions(List.of(InternalFirstRootConfigurationSchema.class, InternalSecondRootConfigurationSchema.class, InternalFirstConfigurationSchema.class, InternalSecondConfigurationSchema.class));
ConfigurationAsmGenerator generator = new ConfigurationAsmGenerator();
generator.compileRootSchema(InternalRootConfigurationSchema.class, internalExtensions, Map.of());
InnerNode innerNode = generator.instantiateNode(InternalRootConfigurationSchema.class);
addDefaults(innerNode);
Map<String, Object> config = (Map<String, Object>) innerNode.accept(null, new ConverterToMapVisitor(false));
// Check that no internal configuration will be received.
assertEquals(4, config.size());
assertNull(config.get("str0"));
assertEquals("foo", config.get("str1"));
assertNotNull(config.get("subCfg"));
assertNotNull(config.get("namedCfg"));
Map<String, Object> subConfig = (Map<String, Object>) config.get("subCfg");
assertEquals(1, subConfig.size());
assertEquals("foo", subConfig.get("str00"));
// Check that no internal configuration will be received.
config = (Map<String, Object>) innerNode.accept(null, new ConverterToMapVisitor(true));
assertEquals(7, config.size());
assertNull(config.get("str0"));
assertNull(config.get("str2"));
assertEquals("foo", config.get("str1"));
assertEquals("foo", config.get("str3"));
assertNotNull(config.get("subCfg"));
assertNotNull(config.get("subCfg1"));
assertNotNull(config.get("namedCfg"));
subConfig = (Map<String, Object>) config.get("subCfg");
assertEquals(3, subConfig.size());
assertEquals("foo", subConfig.get("str00"));
assertEquals("foo", subConfig.get("str01"));
assertEquals("foo", subConfig.get("str02"));
subConfig = (Map<String, Object>) config.get("subCfg1");
assertEquals(3, subConfig.size());
assertEquals("foo", subConfig.get("str00"));
assertEquals("foo", subConfig.get("str01"));
assertEquals("foo", subConfig.get("str02"));
}
use of org.apache.ignite.internal.configuration.tree.ConverterToMapVisitor in project ignite-3 by apache.
the class ConfigurationUtilTest method testSuperRootWithInternalConfig.
@Test
void testSuperRootWithInternalConfig() {
ConfigurationAsmGenerator generator = new ConfigurationAsmGenerator();
Class<?> schemaClass = InternalWithoutSuperclassConfigurationSchema.class;
RootKey<?, ?> schemaKey = InternalWithoutSuperclassConfiguration.KEY;
generator.compileRootSchema(schemaClass, Map.of(), Map.of());
SuperRoot superRoot = new SuperRoot(s -> new RootInnerNode(schemaKey, generator.instantiateNode(schemaClass)));
assertThrows(NoSuchElementException.class, () -> superRoot.construct(schemaKey.key(), null, false));
superRoot.construct(schemaKey.key(), null, true);
superRoot.addRoot(schemaKey, generator.instantiateNode(schemaClass));
assertThrows(KeyNotFoundException.class, () -> find(List.of(schemaKey.key()), superRoot, false));
assertNotNull(find(List.of(schemaKey.key()), superRoot, true));
Map<String, Object> config = (Map<String, Object>) superRoot.accept(schemaKey.key(), new ConverterToMapVisitor(false));
assertTrue(config.isEmpty());
config = (Map<String, Object>) superRoot.accept(schemaKey.key(), new ConverterToMapVisitor(true));
assertEquals(1, config.size());
assertNotNull(config.get(schemaKey.key()));
}
Aggregations