Search in sources :

Example 1 with InternalId

use of org.apache.ignite.configuration.annotation.InternalId in project ignite-3 by apache.

the class InternalIdTest method testPolymorphicExtension.

/**
 * Tests that internal id, decared in polymorphic configuration, works properly.
 */
@Test
public void testPolymorphicExtension() throws Exception {
    InternalIdParentConfiguration cfg = registry.getConfiguration(InternalIdParentConfiguration.KEY);
    // Create polymorphic instance.
    cfg.polymorphic().change(list -> list.create("a", element -> {
        // Check that id is accessible via "raw" instance.
        UUID internalId = element.id();
        assertThat(internalId, is(notNullValue()));
        // Check that id is accessible via "specific" instance.
        InternalIdFooChange foo = element.convert(InternalIdFooChange.class);
        assertThat(foo.id(), is(equalTo(internalId)));
    })).get(1, TimeUnit.SECONDS);
    // Read internal id from the named list directly.
    var list = (NamedListNode<InternalIdPolymorphicView>) cfg.polymorphic().value();
    UUID internalId = list.internalId("a");
    // Check that this internal id matches the one from raw InnerNode list element.
    assertThat(list.getInnerNode("a").internalId(), is(equalTo(internalId)));
    // Check that internal id mathes the one from "specific" configuration view instance.
    assertThat(list.get("a").id(), is(equalTo(internalId)));
    // Check that intetnal id is accessible from the polymorphic Configuration instance.
    assertThat(cfg.polymorphic().get("a").id().value(), is(equalTo(internalId)));
    assertThat(cfg.polymorphic().get("a").value().id(), is(equalTo(internalId)));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) PolymorphicId(org.apache.ignite.configuration.annotation.PolymorphicId) BeforeEach(org.junit.jupiter.api.BeforeEach) ConfigurationRoot(org.apache.ignite.configuration.annotation.ConfigurationRoot) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) UUID(java.util.UUID) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) InternalId(org.apache.ignite.configuration.annotation.InternalId) TimeUnit(java.util.concurrent.TimeUnit) NamedConfigValue(org.apache.ignite.configuration.annotation.NamedConfigValue) Test(org.junit.jupiter.api.Test) DirectPropertiesTest(org.apache.ignite.internal.configuration.direct.DirectPropertiesTest) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) LOCAL(org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL) PolymorphicConfigInstance(org.apache.ignite.configuration.annotation.PolymorphicConfigInstance) Map(java.util.Map) TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) PolymorphicConfig(org.apache.ignite.configuration.annotation.PolymorphicConfig) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) InternalConfiguration(org.apache.ignite.configuration.annotation.InternalConfiguration) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test) DirectPropertiesTest(org.apache.ignite.internal.configuration.direct.DirectPropertiesTest)

Example 2 with InternalId

use of org.apache.ignite.configuration.annotation.InternalId in project ignite-3 by apache.

the class DirectPropertiesTest method testNamedListDirectNestedInternalId.

/**
 * Same as {@link #testDirectProperties} but checks Named List properties.
 */
@Test
public void testNamedListDirectNestedInternalId() throws Exception {
    DirectConfiguration cfg = registry.getConfiguration(DirectConfiguration.KEY);
    cfg.children().change(list -> list.create("foo", e -> e.changeChildren2(list2 -> list2.create("boo", e2 -> {
    })))).get(1, TimeUnit.SECONDS);
    UUID fooId = cfg.children().get("foo").id().value();
    UUID booId = cfg.children().get("foo").children2().get("boo").id().value();
    assertThat(booId, is(notNullValue()));
    // Check all possible ways to access "str", just to be sure. Some of these checks are clearly excessive, but they look organic.
    // Using names in both lists.
    assertThat(directProxy(cfg).value().children().get("foo").children2().get("boo").id(), is(equalTo(booId)));
    assertThat(directProxy(cfg).children().value().get("foo").children2().get("boo").id(), is(equalTo(booId)));
    assertThat(directProxy(cfg).children().get("foo").value().children2().get("boo").id(), is(equalTo(booId)));
    assertThat(directProxy(cfg).children().get("foo").children2().value().get("boo").id(), is(equalTo(booId)));
    assertThat(directProxy(cfg).children().get("foo").children2().get("boo").value().id(), is(equalTo(booId)));
    assertThat(directProxy(cfg).children().get("foo").children2().get("boo").id().value(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children()).value().get("foo").children2().get("boo").id(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children()).get("foo").value().children2().get("boo").id(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children()).get("foo").children2().value().get("boo").id(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children()).get("foo").children2().get("boo").value().id(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children()).get("foo").children2().get("boo").id().value(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children().get("foo")).value().children2().get("boo").id(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children().get("foo")).children2().value().get("boo").id(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children().get("foo")).children2().get("boo").value().id(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children().get("foo")).children2().get("boo").id().value(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children().get("foo").children2()).value().get("boo").id(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children().get("foo").children2()).get("boo").value().id(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children().get("foo").children2()).get("boo").id().value(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children().get("foo").children2().get("boo")).value().id(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children().get("foo").children2().get("boo")).id().value(), is(equalTo(booId)));
    assertThat(directProxy(cfg.children().get("foo").children2().get("boo").id()).value(), is(equalTo(booId)));
    // Using internalId and name.
    assertThat(getByInternalId(directProxy(cfg).value().children(), fooId).children2().get("boo").id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg).children().value(), fooId).children2().get("boo").id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg).children(), fooId).value().children2().get("boo").id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg).children(), fooId).children2().value().get("boo").id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg).children(), fooId).children2().get("boo").value().id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg).children(), fooId).children2().get("boo").id().value(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children()).value(), fooId).children2().get("boo").id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children()), fooId).value().children2().get("boo").id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children()), fooId).children2().value().get("boo").id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children()), fooId).children2().get("boo").value().id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children()), fooId).children2().get("boo").id().value(), is(equalTo(booId)));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId)).value().children2().get("boo").id(), is(equalTo(booId)));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId)).children2().value().get("boo").id(), is(equalTo(booId)));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId)).children2().get("boo").value().id(), is(equalTo(booId)));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId)).children2().get("boo").id().value(), is(equalTo(booId)));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId).children2()).value().get("boo").id(), is(equalTo(booId)));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId).children2()).get("boo").value().id(), is(equalTo(booId)));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId).children2()).get("boo").id().value(), is(equalTo(booId)));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId).children2().get("boo")).value().id(), is(equalTo(booId)));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId).children2().get("boo")).id().value(), is(equalTo(booId)));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId).children2().get("boo").id()).value(), is(equalTo(booId)));
    // Using name and internalId.
    assertThat(getByInternalId(directProxy(cfg).value().children().get("foo").children2(), booId).id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg).children().value().get("foo").children2(), booId).id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg).children().get("foo").value().children2(), booId).id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg).children().get("foo").children2().value(), booId).id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg).children().get("foo").children2(), booId).value().id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg).children().get("foo").children2(), booId).id().value(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children()).value().get("foo").children2(), booId).id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children()).get("foo").value().children2(), booId).id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children()).get("foo").children2().value(), booId).id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children()).get("foo").children2(), booId).value().id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children()).get("foo").children2(), booId).id().value(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo")).value().children2(), booId).id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo")).children2().value(), booId).id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo")).children2(), booId).value().id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo")).children2(), booId).id().value(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo").children2()).value(), booId).id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo").children2()), booId).value().id(), is(equalTo(booId)));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo").children2()), booId).id().value(), is(equalTo(booId)));
    assertThat(directProxy(getByInternalId(cfg.children().get("foo").children2(), booId)).value().id(), is(equalTo(booId)));
    assertThat(directProxy(getByInternalId(cfg.children().get("foo").children2(), booId)).id().value(), is(equalTo(booId)));
    assertThat(directProxy(getByInternalId(cfg.children().get("foo").children2(), booId).id()).value(), is(equalTo(booId)));
    // Using internalId and internalId.
    assertThat(getByInternalId(getByInternalId(directProxy(cfg).value().children(), fooId).children2(), booId).id(), is(booId));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg).children().value(), fooId).children2(), booId).id(), is(booId));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg).children(), fooId).value().children2(), booId).id(), is(booId));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg).children(), fooId).children2().value(), booId).id(), is(booId));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg).children(), fooId).children2(), booId).value().id(), is(booId));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg).children(), fooId).children2(), booId).id().value(), is(booId));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg.children()).value(), fooId).children2(), booId).id(), is(booId));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg.children()), fooId).value().children2(), booId).id(), is(booId));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg.children()), fooId).children2().value(), booId).id(), is(booId));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg.children()), fooId).children2(), booId).value().id(), is(booId));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg.children()), fooId).children2(), booId).id().value(), is(booId));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId)).value().children2(), booId).id(), is(booId));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId)).children2().value(), booId).id(), is(booId));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId)).children2(), booId).value().id(), is(booId));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId)).children2(), booId).id().value(), is(booId));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId).children2()).value(), booId).id(), is(booId));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId).children2()), booId).value().id(), is(booId));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId).children2()), booId).id().value(), is(booId));
    assertThat(directProxy(getByInternalId(getByInternalId(cfg.children(), fooId).children2(), booId)).value().id(), is(booId));
    assertThat(directProxy(getByInternalId(getByInternalId(cfg.children(), fooId).children2(), booId)).id().value(), is(booId));
    assertThat(directProxy(getByInternalId(getByInternalId(cfg.children(), fooId).children2(), booId).id()).value(), is(booId));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) ConfigurationUtil.directProxy(org.apache.ignite.internal.configuration.util.ConfigurationUtil.directProxy) ConfigurationUtil.getByInternalId(org.apache.ignite.internal.configuration.util.ConfigurationUtil.getByInternalId) CompletableFuture(java.util.concurrent.CompletableFuture) NamedConfigValue(org.apache.ignite.configuration.annotation.NamedConfigValue) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Map(java.util.Map) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) NamedConfigurationTree(org.apache.ignite.configuration.NamedConfigurationTree) NoSuchElementException(java.util.NoSuchElementException) ConfigurationListenOnlyException(org.apache.ignite.configuration.ConfigurationListenOnlyException) ConfigurationRoot(org.apache.ignite.configuration.annotation.ConfigurationRoot) Name(org.apache.ignite.configuration.annotation.Name) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) CompletableFutureMatcher.willBe(org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willBe) UUID(java.util.UUID) InternalId(org.apache.ignite.configuration.annotation.InternalId) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) ConfigValue(org.apache.ignite.configuration.annotation.ConfigValue) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) InjectedName(org.apache.ignite.configuration.annotation.InjectedName) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) LOCAL(org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Config(org.apache.ignite.configuration.annotation.Config) TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) Matchers.is(org.hamcrest.Matchers.is) Value(org.apache.ignite.configuration.annotation.Value) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 3 with InternalId

use of org.apache.ignite.configuration.annotation.InternalId in project ignite-3 by apache.

the class DirectPropertiesTest method testNamedListDirectInternalId.

/**
 * Checks simple scenarios of getting internalId of named list element.
 */
@Test
public void testNamedListDirectInternalId() throws Exception {
    DirectConfiguration cfg = registry.getConfiguration(DirectConfiguration.KEY);
    cfg.children().change(change -> change.create("foo", value -> {
    })).get(1, TimeUnit.SECONDS);
    UUID fooId = cfg.children().get("foo").id().value();
    assertThat(fooId, is(notNullValue()));
    // Check all possible ways to access "str" of element named "foo".
    assertThat(directProxy(cfg).value().children().get("foo").id(), is(equalTo(fooId)));
    assertThat(directProxy(cfg).children().value().get("foo").id(), is(equalTo(fooId)));
    assertThat(directProxy(cfg).children().get("foo").value().id(), is(equalTo(fooId)));
    assertThat(directProxy(cfg).children().get("foo").id().value(), is(equalTo(fooId)));
    assertThat(directProxy(cfg.children()).value().get("foo").id(), is(equalTo(fooId)));
    assertThat(directProxy(cfg.children()).get("foo").value().id(), is(equalTo(fooId)));
    assertThat(directProxy(cfg.children()).get("foo").id().value(), is(equalTo(fooId)));
    assertThat(directProxy(cfg.children().get("foo")).value().id(), is(equalTo(fooId)));
    assertThat(directProxy(cfg.children().get("foo")).id().value(), is(equalTo(fooId)));
    assertThat(directProxy(cfg.children().get("foo").id()).value(), is(equalTo(fooId)));
    // Check all possible ways to access "str" of element with given internal id.
    assertThat(getByInternalId(directProxy(cfg).value().children(), fooId).id(), is(equalTo(fooId)));
    assertThat(getByInternalId(directProxy(cfg).children().value(), fooId).id(), is(equalTo(fooId)));
    assertThat(getByInternalId(directProxy(cfg).children(), fooId).value().id(), is(equalTo(fooId)));
    assertThat(getByInternalId(directProxy(cfg).children(), fooId).id().value(), is(equalTo(fooId)));
    assertThat(getByInternalId(directProxy(cfg.children()).value(), fooId).id(), is(equalTo(fooId)));
    assertThat(getByInternalId(directProxy(cfg.children()), fooId).value().id(), is(equalTo(fooId)));
    assertThat(getByInternalId(directProxy(cfg.children()), fooId).id().value(), is(equalTo(fooId)));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId)).value().id(), is(equalTo(fooId)));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId)).id().value(), is(equalTo(fooId)));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId).id()).value(), is(equalTo(fooId)));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) ConfigurationUtil.directProxy(org.apache.ignite.internal.configuration.util.ConfigurationUtil.directProxy) ConfigurationUtil.getByInternalId(org.apache.ignite.internal.configuration.util.ConfigurationUtil.getByInternalId) CompletableFuture(java.util.concurrent.CompletableFuture) NamedConfigValue(org.apache.ignite.configuration.annotation.NamedConfigValue) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Map(java.util.Map) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) NamedConfigurationTree(org.apache.ignite.configuration.NamedConfigurationTree) NoSuchElementException(java.util.NoSuchElementException) ConfigurationListenOnlyException(org.apache.ignite.configuration.ConfigurationListenOnlyException) ConfigurationRoot(org.apache.ignite.configuration.annotation.ConfigurationRoot) Name(org.apache.ignite.configuration.annotation.Name) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) CompletableFutureMatcher.willBe(org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willBe) UUID(java.util.UUID) InternalId(org.apache.ignite.configuration.annotation.InternalId) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) ConfigValue(org.apache.ignite.configuration.annotation.ConfigValue) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) InjectedName(org.apache.ignite.configuration.annotation.InjectedName) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) LOCAL(org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Config(org.apache.ignite.configuration.annotation.Config) TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) Matchers.is(org.hamcrest.Matchers.is) Value(org.apache.ignite.configuration.annotation.Value) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 4 with InternalId

use of org.apache.ignite.configuration.annotation.InternalId in project ignite-3 by apache.

the class DirectPropertiesTest method testNamedListDirectNestedProperties.

/**
 * Same as {@link #testDirectProperties} but checks Named List properties.
 */
@Test
public void testNamedListDirectNestedProperties() throws Exception {
    DirectConfiguration cfg = registry.getConfiguration(DirectConfiguration.KEY);
    cfg.children().change(list -> list.create("foo", e -> e.changeChildren2(list2 -> list2.create("boo", e2 -> {
    })))).get(1, TimeUnit.SECONDS);
    UUID fooId = cfg.children().get("foo").id().value();
    UUID booId = cfg.children().get("foo").children2().get("boo").id().value();
    assertThat(booId, is(notNullValue()));
    // Check all possible ways to access "str", just to be sure. Some of these checks are clearly excessive, but they look organic.
    // Using names in both lists.
    assertThat(directProxy(cfg).value().children().get("foo").children2().get("boo").str(), is("bar"));
    assertThat(directProxy(cfg).children().value().get("foo").children2().get("boo").str(), is("bar"));
    assertThat(directProxy(cfg).children().get("foo").value().children2().get("boo").str(), is("bar"));
    assertThat(directProxy(cfg).children().get("foo").children2().value().get("boo").str(), is("bar"));
    assertThat(directProxy(cfg).children().get("foo").children2().get("boo").value().str(), is("bar"));
    assertThat(directProxy(cfg).children().get("foo").children2().get("boo").str().value(), is("bar"));
    assertThat(directProxy(cfg.children()).value().get("foo").children2().get("boo").str(), is("bar"));
    assertThat(directProxy(cfg.children()).get("foo").value().children2().get("boo").str(), is("bar"));
    assertThat(directProxy(cfg.children()).get("foo").children2().value().get("boo").str(), is("bar"));
    assertThat(directProxy(cfg.children()).get("foo").children2().get("boo").value().str(), is("bar"));
    assertThat(directProxy(cfg.children()).get("foo").children2().get("boo").str().value(), is("bar"));
    assertThat(directProxy(cfg.children().get("foo")).value().children2().get("boo").str(), is("bar"));
    assertThat(directProxy(cfg.children().get("foo")).children2().value().get("boo").str(), is("bar"));
    assertThat(directProxy(cfg.children().get("foo")).children2().get("boo").value().str(), is("bar"));
    assertThat(directProxy(cfg.children().get("foo")).children2().get("boo").str().value(), is("bar"));
    assertThat(directProxy(cfg.children().get("foo").children2()).value().get("boo").str(), is("bar"));
    assertThat(directProxy(cfg.children().get("foo").children2()).get("boo").value().str(), is("bar"));
    assertThat(directProxy(cfg.children().get("foo").children2()).get("boo").str().value(), is("bar"));
    assertThat(directProxy(cfg.children().get("foo").children2().get("boo")).value().str(), is("bar"));
    assertThat(directProxy(cfg.children().get("foo").children2().get("boo")).str().value(), is("bar"));
    assertThat(directProxy(cfg.children().get("foo").children2().get("boo").str()).value(), is("bar"));
    // Using internalId and name.
    assertThat(getByInternalId(directProxy(cfg).value().children(), fooId).children2().get("boo").str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg).children().value(), fooId).children2().get("boo").str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg).children(), fooId).value().children2().get("boo").str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg).children(), fooId).children2().value().get("boo").str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg).children(), fooId).children2().get("boo").value().str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg).children(), fooId).children2().get("boo").str().value(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children()).value(), fooId).children2().get("boo").str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children()), fooId).value().children2().get("boo").str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children()), fooId).children2().value().get("boo").str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children()), fooId).children2().get("boo").value().str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children()), fooId).children2().get("boo").str().value(), is("bar"));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId)).value().children2().get("boo").str(), is("bar"));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId)).children2().value().get("boo").str(), is("bar"));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId)).children2().get("boo").value().str(), is("bar"));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId)).children2().get("boo").str().value(), is("bar"));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId).children2()).value().get("boo").str(), is("bar"));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId).children2()).get("boo").value().str(), is("bar"));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId).children2()).get("boo").str().value(), is("bar"));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId).children2().get("boo")).value().str(), is("bar"));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId).children2().get("boo")).str().value(), is("bar"));
    assertThat(directProxy(getByInternalId(cfg.children(), fooId).children2().get("boo").str()).value(), is("bar"));
    // Using name and internalId.
    assertThat(getByInternalId(directProxy(cfg).value().children().get("foo").children2(), booId).str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg).children().value().get("foo").children2(), booId).str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg).children().get("foo").value().children2(), booId).str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg).children().get("foo").children2().value(), booId).str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg).children().get("foo").children2(), booId).value().str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg).children().get("foo").children2(), booId).str().value(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children()).value().get("foo").children2(), booId).str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children()).get("foo").value().children2(), booId).str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children()).get("foo").children2().value(), booId).str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children()).get("foo").children2(), booId).value().str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children()).get("foo").children2(), booId).str().value(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo")).value().children2(), booId).str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo")).children2().value(), booId).str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo")).children2(), booId).value().str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo")).children2(), booId).str().value(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo").children2()).value(), booId).str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo").children2()), booId).value().str(), is("bar"));
    assertThat(getByInternalId(directProxy(cfg.children().get("foo").children2()), booId).str().value(), is("bar"));
    assertThat(directProxy(getByInternalId(cfg.children().get("foo").children2(), booId)).value().str(), is("bar"));
    assertThat(directProxy(getByInternalId(cfg.children().get("foo").children2(), booId)).str().value(), is("bar"));
    assertThat(directProxy(getByInternalId(cfg.children().get("foo").children2(), booId).str()).value(), is("bar"));
    // Using internalId and internalId.
    assertThat(getByInternalId(getByInternalId(directProxy(cfg).value().children(), fooId).children2(), booId).str(), is("bar"));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg).children().value(), fooId).children2(), booId).str(), is("bar"));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg).children(), fooId).value().children2(), booId).str(), is("bar"));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg).children(), fooId).children2().value(), booId).str(), is("bar"));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg).children(), fooId).children2(), booId).value().str(), is("bar"));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg).children(), fooId).children2(), booId).str().value(), is("bar"));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg.children()).value(), fooId).children2(), booId).str(), is("bar"));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg.children()), fooId).value().children2(), booId).str(), is("bar"));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg.children()), fooId).children2().value(), booId).str(), is("bar"));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg.children()), fooId).children2(), booId).value().str(), is("bar"));
    assertThat(getByInternalId(getByInternalId(directProxy(cfg.children()), fooId).children2(), booId).str().value(), is("bar"));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId)).value().children2(), booId).str(), is("bar"));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId)).children2().value(), booId).str(), is("bar"));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId)).children2(), booId).value().str(), is("bar"));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId)).children2(), booId).str().value(), is("bar"));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId).children2()).value(), booId).str(), is("bar"));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId).children2()), booId).value().str(), is("bar"));
    assertThat(getByInternalId(directProxy(getByInternalId(cfg.children(), fooId).children2()), booId).str().value(), is("bar"));
    assertThat(directProxy(getByInternalId(getByInternalId(cfg.children(), fooId).children2(), booId)).value().str(), is("bar"));
    assertThat(directProxy(getByInternalId(getByInternalId(cfg.children(), fooId).children2(), booId)).str().value(), is("bar"));
    assertThat(directProxy(getByInternalId(getByInternalId(cfg.children(), fooId).children2(), booId).str()).value(), is("bar"));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) ConfigurationUtil.directProxy(org.apache.ignite.internal.configuration.util.ConfigurationUtil.directProxy) ConfigurationUtil.getByInternalId(org.apache.ignite.internal.configuration.util.ConfigurationUtil.getByInternalId) CompletableFuture(java.util.concurrent.CompletableFuture) NamedConfigValue(org.apache.ignite.configuration.annotation.NamedConfigValue) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Map(java.util.Map) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) NamedConfigurationTree(org.apache.ignite.configuration.NamedConfigurationTree) NoSuchElementException(java.util.NoSuchElementException) ConfigurationListenOnlyException(org.apache.ignite.configuration.ConfigurationListenOnlyException) ConfigurationRoot(org.apache.ignite.configuration.annotation.ConfigurationRoot) Name(org.apache.ignite.configuration.annotation.Name) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) CompletableFutureMatcher.willBe(org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willBe) UUID(java.util.UUID) InternalId(org.apache.ignite.configuration.annotation.InternalId) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) ConfigValue(org.apache.ignite.configuration.annotation.ConfigValue) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) InjectedName(org.apache.ignite.configuration.annotation.InjectedName) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) LOCAL(org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Config(org.apache.ignite.configuration.annotation.Config) TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) Matchers.is(org.hamcrest.Matchers.is) Value(org.apache.ignite.configuration.annotation.Value) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 5 with InternalId

use of org.apache.ignite.configuration.annotation.InternalId in project ignite-3 by apache.

the class Processor method getInterfaceGetMethodType.

/**
 * Get types for configuration classes generation.
 *
 * @param field Field.
 * @return Bundle with all types for configuration
 */
private static TypeName getInterfaceGetMethodType(VariableElement field) {
    TypeName interfaceGetMethodType = null;
    TypeName baseType = TypeName.get(field.asType());
    ConfigValue confAnnotation = field.getAnnotation(ConfigValue.class);
    if (confAnnotation != null) {
        interfaceGetMethodType = Utils.getConfigurationInterfaceName((ClassName) baseType);
    }
    NamedConfigValue namedConfigAnnotation = field.getAnnotation(NamedConfigValue.class);
    if (namedConfigAnnotation != null) {
        ClassName interfaceGetType = Utils.getConfigurationInterfaceName((ClassName) baseType);
        TypeName viewClassType = Utils.getViewName((ClassName) baseType);
        TypeName changeClassType = Utils.getChangeName((ClassName) baseType);
        interfaceGetMethodType = ParameterizedTypeName.get(ClassName.get(NamedConfigurationTree.class), interfaceGetType, viewClassType, changeClassType);
    }
    Value valueAnnotation = field.getAnnotation(Value.class);
    PolymorphicId polymorphicIdAnnotation = field.getAnnotation(PolymorphicId.class);
    InjectedName injectedNameAnnotation = field.getAnnotation(InjectedName.class);
    InternalId internalIdAnnotation = field.getAnnotation(InternalId.class);
    if (valueAnnotation != null || polymorphicIdAnnotation != null || injectedNameAnnotation != null || internalIdAnnotation != null) {
        // It is necessary to use class names without loading classes so that we won't
        // accidentally get NoClassDefFoundError
        ClassName confValueClass = ClassName.get("org.apache.ignite.configuration", "ConfigurationValue");
        TypeName genericType = baseType;
        if (genericType.isPrimitive()) {
            genericType = genericType.box();
        }
        interfaceGetMethodType = ParameterizedTypeName.get(confValueClass, genericType);
    }
    return interfaceGetMethodType;
}
Also used : NamedConfigValue(org.apache.ignite.configuration.annotation.NamedConfigValue) PolymorphicId(org.apache.ignite.configuration.annotation.PolymorphicId) TypeName(com.squareup.javapoet.TypeName) WildcardTypeName(com.squareup.javapoet.WildcardTypeName) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) NamedConfigValue(org.apache.ignite.configuration.annotation.NamedConfigValue) ConfigValue(org.apache.ignite.configuration.annotation.ConfigValue) InternalId(org.apache.ignite.configuration.annotation.InternalId) InjectedName(org.apache.ignite.configuration.annotation.InjectedName) ClassName(com.squareup.javapoet.ClassName) NamedConfigValue(org.apache.ignite.configuration.annotation.NamedConfigValue) ConfigValue(org.apache.ignite.configuration.annotation.ConfigValue) Value(org.apache.ignite.configuration.annotation.Value)

Aggregations

InternalId (org.apache.ignite.configuration.annotation.InternalId)5 NamedConfigValue (org.apache.ignite.configuration.annotation.NamedConfigValue)5 List (java.util.List)4 Map (java.util.Map)4 UUID (java.util.UUID)4 TimeUnit (java.util.concurrent.TimeUnit)4 ConfigValue (org.apache.ignite.configuration.annotation.ConfigValue)4 ConfigurationRoot (org.apache.ignite.configuration.annotation.ConfigurationRoot)4 LOCAL (org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL)4 InjectedName (org.apache.ignite.configuration.annotation.InjectedName)4 Value (org.apache.ignite.configuration.annotation.Value)4 ConfigurationRegistry (org.apache.ignite.internal.configuration.ConfigurationRegistry)4 TestConfigurationStorage (org.apache.ignite.internal.configuration.storage.TestConfigurationStorage)4 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)4 AfterEach (org.junit.jupiter.api.AfterEach)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 Test (org.junit.jupiter.api.Test)4 NoSuchElementException (java.util.NoSuchElementException)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 ConfigurationListenOnlyException (org.apache.ignite.configuration.ConfigurationListenOnlyException)3