Search in sources :

Example 26 with AttributeConfig

use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.

the class ExtractorsAndIndexesTest method testExtractorsAreRespectedByEntriesReturnedFromIndexes.

@Test
public void testExtractorsAreRespectedByEntriesReturnedFromIndexes() {
    String mapName = randomMapName();
    Config config = new Config();
    config.getMapConfig(mapName).setInMemoryFormat(inMemoryFormat).addIndexConfig(new IndexConfig(IndexType.SORTED, "last")).addAttributeConfig(new AttributeConfig("generated", Extractor.class.getName()));
    config.getNativeMemoryConfig().setEnabled(true);
    config.setProperty(ClusterProperty.PARTITION_COUNT.getName(), "1");
    config.setProperty(QueryEngineImpl.DISABLE_MIGRATION_FALLBACK.getName(), "true");
    HazelcastInstance instance = createHazelcastInstance(config);
    IMap<Integer, Person> map = instance.getMap(mapName);
    populateMap(map);
    // this predicate queries the index
    Predicate lastPredicate = equal("last", "last");
    // this predicate is not indexed and acts on the entries returned from
    // the index which must support extractors otherwise this test will fail
    Predicate alwaysFirst = equal("generated", "first");
    Predicate composed = Predicates.and(lastPredicate, alwaysFirst);
    Collection<Person> values = map.values(composed);
    assertEquals(100, values.size());
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) AttributeConfig(com.hazelcast.config.AttributeConfig) Config(com.hazelcast.config.Config) IndexConfig(com.hazelcast.config.IndexConfig) AttributeConfig(com.hazelcast.config.AttributeConfig) Predicate(com.hazelcast.query.Predicate) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 27 with AttributeConfig

use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.

the class ExtractorHelperTest method instantiate_extractors_accessException.

@Test
public void instantiate_extractors_accessException() {
    // GIVEN
    AttributeConfig string = new AttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$AccessExceptionExtractor");
    // EXPECT
    expected.expect(IllegalArgumentException.class);
    // WHEN
    instantiateExtractors(singletonList(string));
}
Also used : AttributeConfig(com.hazelcast.config.AttributeConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 28 with AttributeConfig

use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.

the class ExtractorHelperTest method instantiate_extractors.

@Test
public void instantiate_extractors() {
    // GIVEN
    AttributeConfig iqExtractor = new AttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$IqExtractor");
    AttributeConfig nameExtractor = new AttributeConfig("name", "com.hazelcast.query.impl.getters.ExtractorHelperTest$NameExtractor");
    // WHEN
    Map<String, ValueExtractor> extractors = instantiateExtractors(asList(iqExtractor, nameExtractor));
    // THEN
    assertThat(extractors.get("iq"), instanceOf(IqExtractor.class));
    assertThat(extractors.get("name"), instanceOf(NameExtractor.class));
}
Also used : ValueExtractor(com.hazelcast.query.extractor.ValueExtractor) AttributeConfig(com.hazelcast.config.AttributeConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 29 with AttributeConfig

use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.

the class ExtractorHelperTest method instantiate_extractor.

@Test
public void instantiate_extractor() {
    // GIVEN
    AttributeConfig config = new AttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$IqExtractor");
    // WHEN
    ValueExtractor extractor = instantiateExtractor(config);
    // THEN
    assertThat(extractor, instanceOf(IqExtractor.class));
}
Also used : ValueExtractor(com.hazelcast.query.extractor.ValueExtractor) AttributeConfig(com.hazelcast.config.AttributeConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 30 with AttributeConfig

use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.

the class ExtractorHelperTest method instantiate_extractors_duplicateExtractor.

@Test
public void instantiate_extractors_duplicateExtractor() {
    // GIVEN
    AttributeConfig iqExtractor = new AttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$IqExtractor");
    AttributeConfig iqExtractorDuplicate = new AttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$IqExtractor");
    // EXPECT
    expected.expect(IllegalArgumentException.class);
    // WHEN
    instantiateExtractors(asList(iqExtractor, iqExtractorDuplicate));
}
Also used : AttributeConfig(com.hazelcast.config.AttributeConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

AttributeConfig (com.hazelcast.config.AttributeConfig)31 QuickTest (com.hazelcast.test.annotation.QuickTest)17 Test (org.junit.Test)17 MapConfig (com.hazelcast.config.MapConfig)11 Config (com.hazelcast.config.Config)9 IndexConfig (com.hazelcast.config.IndexConfig)9 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)6 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)4 EventJournalConfig (com.hazelcast.config.EventJournalConfig)4 EvictionConfig (com.hazelcast.config.EvictionConfig)4 MapPartitionLostListenerConfig (com.hazelcast.config.MapPartitionLostListenerConfig)4 MapStoreConfig (com.hazelcast.config.MapStoreConfig)4 MergePolicyConfig (com.hazelcast.config.MergePolicyConfig)4 MultiMapConfig (com.hazelcast.config.MultiMapConfig)4 NearCacheConfig (com.hazelcast.config.NearCacheConfig)4 AwsConfig (com.hazelcast.config.AwsConfig)3 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)3 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)3 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)3 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)3