Search in sources :

Example 6 with ConfigurationAsmGenerator

use of org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator in project ignite-3 by apache.

the class ConstructableTreeNodeTest method beforeAll.

/**
 * Before all.
 */
@BeforeAll
public static void beforeAll() {
    cgen = new ConfigurationAsmGenerator();
    cgen.compileRootSchema(TraversableTreeNodeTest.ParentConfigurationSchema.class, Map.of(), Map.of());
}
Also used : ConfigurationAsmGenerator(org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 7 with ConfigurationAsmGenerator

use of org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator in project ignite-3 by apache.

the class ConfigurationUtilTest method beforeAll.

/**
 * Before all.
 */
@BeforeAll
public static void beforeAll() {
    cgen = new ConfigurationAsmGenerator();
    cgen.compileRootSchema(ParentConfigurationSchema.class, Map.of(), Map.of());
    cgen.compileRootSchema(PolymorphicRootConfigurationSchema.class, Map.of(), Map.of(PolymorphicConfigurationSchema.class, Set.of(FirstPolymorphicInstanceConfigurationSchema.class, SecondPolymorphicInstanceConfigurationSchema.class)));
}
Also used : ConfigurationAsmGenerator(org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 8 with ConfigurationAsmGenerator

use of org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator 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()));
}
Also used : RootInnerNode(org.apache.ignite.internal.configuration.RootInnerNode) ConfigurationAsmGenerator(org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator) ConverterToMapVisitor(org.apache.ignite.internal.configuration.tree.ConverterToMapVisitor) SuperRoot(org.apache.ignite.internal.configuration.SuperRoot) Matchers.hasToString(org.hamcrest.Matchers.hasToString) Map(java.util.Map) ConfigurationFlattener.createFlattenedUpdatesMap(org.apache.ignite.internal.configuration.util.ConfigurationFlattener.createFlattenedUpdatesMap) HashMap(java.util.HashMap) Collections.singletonMap(java.util.Collections.singletonMap) Matchers.anEmptyMap(org.hamcrest.Matchers.anEmptyMap) Test(org.junit.jupiter.api.Test)

Example 9 with ConfigurationAsmGenerator

use of org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator in project ignite-3 by apache.

the class ConfigurationUtilTest method testFindInternalConfigs.

@Test
void testFindInternalConfigs() {
    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);
    // Check that no internal configuration will be found.
    assertThrows(KeyNotFoundException.class, () -> find(List.of("str2"), innerNode, false));
    assertThrows(KeyNotFoundException.class, () -> find(List.of("str3"), innerNode, false));
    assertThrows(KeyNotFoundException.class, () -> find(List.of("subCfg1"), innerNode, false));
    assertThrows(KeyNotFoundException.class, () -> find(List.of("subCfg", "str01"), innerNode, false));
    assertThrows(KeyNotFoundException.class, () -> find(List.of("subCfg", "str02"), innerNode, false));
    // Check that internal configuration will be found.
    assertNull(find(List.of("str2"), innerNode, true));
    assertEquals("foo", find(List.of("str3"), innerNode, true));
    assertNotNull(find(List.of("subCfg1"), innerNode, true));
    assertEquals("foo", find(List.of("subCfg", "str01"), innerNode, true));
    assertEquals("foo", find(List.of("subCfg", "str02"), innerNode, true));
}
Also used : Set(java.util.Set) ConfigurationAsmGenerator(org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator) RootInnerNode(org.apache.ignite.internal.configuration.RootInnerNode) InnerNode(org.apache.ignite.internal.configuration.tree.InnerNode) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationAsmGenerator (org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator)9 BeforeAll (org.junit.jupiter.api.BeforeAll)4 RootInnerNode (org.apache.ignite.internal.configuration.RootInnerNode)3 Test (org.junit.jupiter.api.Test)3 Collections.singletonMap (java.util.Collections.singletonMap)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 ExecutorService (java.util.concurrent.ExecutorService)2 ConverterToMapVisitor (org.apache.ignite.internal.configuration.tree.ConverterToMapVisitor)2 InnerNode (org.apache.ignite.internal.configuration.tree.InnerNode)2 ConfigurationFlattener.createFlattenedUpdatesMap (org.apache.ignite.internal.configuration.util.ConfigurationFlattener.createFlattenedUpdatesMap)2 Matchers.anEmptyMap (org.hamcrest.Matchers.anEmptyMap)2 Matchers.hasToString (org.hamcrest.Matchers.hasToString)2 ConfigObject (com.typesafe.config.ConfigObject)1 Field (java.lang.reflect.Field)1 Parameter (java.lang.reflect.Parameter)1 SuperRoot (org.apache.ignite.internal.configuration.SuperRoot)1 ParameterResolutionException (org.junit.jupiter.api.extension.ParameterResolutionException)1