Search in sources :

Example 1 with ClassScanner

use of com.yahoo.elide.core.utils.ClassScanner in project elide by yahoo.

the class MultiplexManagerTest method setup.

@BeforeAll
public void setup() {
    ClassScanner scanner = DefaultClassScanner.getInstance();
    entityDictionary = EntityDictionary.builder().build();
    final HashMapDataStore inMemoryDataStore1 = new HashMapDataStore(scanner, FirstBean.class.getPackage());
    final HashMapDataStore inMemoryDataStore2 = new HashMapDataStore(scanner, OtherBean.class.getPackage());
    multiplexManager = new MultiplexManager(inMemoryDataStore1, inMemoryDataStore2);
    multiplexManager.populateEntityDictionary(entityDictionary);
}
Also used : ClassScanner(com.yahoo.elide.core.utils.ClassScanner) DefaultClassScanner(com.yahoo.elide.core.utils.DefaultClassScanner) HashMapDataStore(com.yahoo.elide.core.datastore.inmemory.HashMapDataStore) FirstBean(com.yahoo.elide.example.beans.FirstBean) OtherBean(com.yahoo.elide.example.other.OtherBean) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with ClassScanner

use of com.yahoo.elide.core.utils.ClassScanner in project elide by yahoo.

the class AggregationDataStoreTestHarness method getDataStore.

@Override
public DataStore getDataStore() {
    AggregationDataStore.AggregationDataStoreBuilder aggregationDataStoreBuilder = AggregationDataStore.builder();
    ClassScanner scanner = DefaultClassScanner.getInstance();
    MetaDataStore metaDataStore;
    if (validator != null) {
        metaDataStore = new MetaDataStore(scanner, validator.getElideTableConfig().getTables(), validator.getElideNamespaceConfig().getNamespaceconfigs(), true);
        aggregationDataStoreBuilder.dynamicCompiledClasses(metaDataStore.getDynamicTypes());
    } else {
        metaDataStore = new MetaDataStore(scanner, true);
    }
    AggregationDataStore aggregationDataStore = aggregationDataStoreBuilder.queryEngine(new SQLQueryEngine(metaDataStore, (name) -> connectionDetailsMap.getOrDefault(name, defaultConnectionDetails), new HashSet<>(Arrays.asList(new AggregateBeforeJoinOptimizer(metaDataStore))), new DefaultQueryPlanMerger(metaDataStore), new DefaultQueryValidator(metaDataStore.getMetadataDictionary()))).queryLogger(new Slf4jQueryLogger()).build();
    Consumer<EntityManager> txCancel = em -> em.unwrap(Session.class).cancelQuery();
    DataStore jpaStore = new JpaDataStore(() -> entityManagerFactory.createEntityManager(), em -> new NonJtaTransaction(em, txCancel));
    return new MultiplexManager(jpaStore, metaDataStore, aggregationDataStore);
}
Also used : SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) Arrays(java.util.Arrays) SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) Session(org.hibernate.Session) MultiplexManager(com.yahoo.elide.datastores.multiplex.MultiplexManager) NonJtaTransaction(com.yahoo.elide.datastores.jpa.transaction.NonJtaTransaction) HashSet(java.util.HashSet) ClassScanner(com.yahoo.elide.core.utils.ClassScanner) AggregateBeforeJoinOptimizer(com.yahoo.elide.datastores.aggregation.queryengines.sql.query.AggregateBeforeJoinOptimizer) Map(java.util.Map) DataSource(javax.sql.DataSource) AggregationDataStore(com.yahoo.elide.datastores.aggregation.AggregationDataStore) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) JpaDataStore(com.yahoo.elide.datastores.jpa.JpaDataStore) Slf4jQueryLogger(com.yahoo.elide.datastores.aggregation.core.Slf4jQueryLogger) SQLDialectFactory(com.yahoo.elide.datastores.aggregation.queryengines.sql.dialects.SQLDialectFactory) DynamicConfigValidator(com.yahoo.elide.modelconfig.validator.DynamicConfigValidator) DefaultClassScanner(com.yahoo.elide.core.utils.DefaultClassScanner) DefaultQueryValidator(com.yahoo.elide.datastores.aggregation.DefaultQueryValidator) EntityManager(javax.persistence.EntityManager) DataStoreTestHarness(com.yahoo.elide.core.datastore.test.DataStoreTestHarness) ConnectionDetails(com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails) Consumer(java.util.function.Consumer) EntityManagerFactory(javax.persistence.EntityManagerFactory) DataStore(com.yahoo.elide.core.datastore.DataStore) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) AllArgsConstructor(lombok.AllArgsConstructor) Collections(java.util.Collections) JpaDataStore(com.yahoo.elide.datastores.jpa.JpaDataStore) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) NonJtaTransaction(com.yahoo.elide.datastores.jpa.transaction.NonJtaTransaction) MultiplexManager(com.yahoo.elide.datastores.multiplex.MultiplexManager) DefaultQueryValidator(com.yahoo.elide.datastores.aggregation.DefaultQueryValidator) Slf4jQueryLogger(com.yahoo.elide.datastores.aggregation.core.Slf4jQueryLogger) EntityManager(javax.persistence.EntityManager) AggregateBeforeJoinOptimizer(com.yahoo.elide.datastores.aggregation.queryengines.sql.query.AggregateBeforeJoinOptimizer) ClassScanner(com.yahoo.elide.core.utils.ClassScanner) DefaultClassScanner(com.yahoo.elide.core.utils.DefaultClassScanner) AggregationDataStore(com.yahoo.elide.datastores.aggregation.AggregationDataStore) JpaDataStore(com.yahoo.elide.datastores.jpa.JpaDataStore) DataStore(com.yahoo.elide.core.datastore.DataStore) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) AggregationDataStore(com.yahoo.elide.datastores.aggregation.AggregationDataStore) HashSet(java.util.HashSet) Session(org.hibernate.Session)

Example 3 with ClassScanner

use of com.yahoo.elide.core.utils.ClassScanner in project elide by yahoo.

the class ElideAutoConfiguration method buildQueryEngine.

/**
 * Create a QueryEngine instance for aggregation data store to use.
 * @param defaultDataSource DataSource for JPA.
 * @param dynamicConfig An instance of DynamicConfiguration.
 * @param settings Elide configuration settings.
 * @param dataSourceConfiguration DataSource Configuration
 * @param dbPasswordExtractor Password Extractor Implementation
 * @return An instance of a QueryEngine
 */
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(name = "elide.aggregation-store.enabled", havingValue = "true")
@Scope(SCOPE_PROTOTYPE)
public QueryEngine buildQueryEngine(DataSource defaultDataSource, @Autowired(required = false) DynamicConfiguration dynamicConfig, ElideConfigProperties settings, ClassScanner scanner, DataSourceConfiguration dataSourceConfiguration, DBPasswordExtractor dbPasswordExtractor) {
    boolean enableMetaDataStore = settings.getAggregationStore().isEnableMetaDataStore();
    ConnectionDetails defaultConnectionDetails = new ConnectionDetails(defaultDataSource, SQLDialectFactory.getDialect(settings.getAggregationStore().getDefaultDialect()));
    if (isDynamicConfigEnabled(settings)) {
        MetaDataStore metaDataStore = new MetaDataStore(scanner, dynamicConfig.getTables(), dynamicConfig.getNamespaceConfigurations(), enableMetaDataStore);
        Map<String, ConnectionDetails> connectionDetailsMap = new HashMap<>();
        dynamicConfig.getDatabaseConfigurations().forEach(dbConfig -> {
            connectionDetailsMap.put(dbConfig.getName(), new ConnectionDetails(dataSourceConfiguration.getDataSource(dbConfig, dbPasswordExtractor), SQLDialectFactory.getDialect(dbConfig.getDialect())));
        });
        Function<String, ConnectionDetails> connectionDetailsLookup = (name) -> {
            if (StringUtils.isEmpty(name)) {
                return defaultConnectionDetails;
            }
            return Optional.ofNullable(connectionDetailsMap.get(name)).orElseThrow(() -> new IllegalStateException("ConnectionDetails undefined for connection: " + name));
        };
        return new SQLQueryEngine(metaDataStore, connectionDetailsLookup, new HashSet<>(Arrays.asList(new AggregateBeforeJoinOptimizer(metaDataStore))), new DefaultQueryPlanMerger(metaDataStore), new DefaultQueryValidator(metaDataStore.getMetadataDictionary()));
    }
    MetaDataStore metaDataStore = new MetaDataStore(scanner, enableMetaDataStore);
    return new SQLQueryEngine(metaDataStore, (unused) -> defaultConnectionDetails);
}
Also used : Arrays(java.util.Arrays) DynamicConfiguration(com.yahoo.elide.modelconfig.DynamicConfiguration) Autowired(org.springframework.beans.factory.annotation.Autowired) Role(com.yahoo.elide.core.security.checks.prefab.Role) StringUtils(org.apache.commons.lang3.StringUtils) ClassType(com.yahoo.elide.core.type.ClassType) DataSourceConfiguration(com.yahoo.elide.datastores.aggregation.queryengines.sql.DataSourceConfiguration) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) RSQLFilterDialect(com.yahoo.elide.core.filter.dialect.RSQLFilterDialect) DefaultJSONApiLinks(com.yahoo.elide.jsonapi.links.DefaultJSONApiLinks) ClassScanner(com.yahoo.elide.core.utils.ClassScanner) AggregateBeforeJoinOptimizer(com.yahoo.elide.datastores.aggregation.queryengines.sql.query.AggregateBeforeJoinOptimizer) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) Map(java.util.Map) JsonApiMapper(com.yahoo.elide.jsonapi.JsonApiMapper) AggregationDataStore(com.yahoo.elide.datastores.aggregation.AggregationDataStore) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) TableExport(com.yahoo.elide.async.models.TableExport) TemplateConfigValidator(com.yahoo.elide.datastores.aggregation.validator.TemplateConfigValidator) Elide(com.yahoo.elide.Elide) SQLDialectFactory(com.yahoo.elide.datastores.aggregation.queryengines.sql.dialects.SQLDialectFactory) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) DynamicConfigValidator(com.yahoo.elide.modelconfig.validator.DynamicConfigValidator) Cache(com.yahoo.elide.datastores.aggregation.cache.Cache) DefaultClassScanner(com.yahoo.elide.core.utils.DefaultClassScanner) TimeZone(java.util.TimeZone) AsyncQuery(com.yahoo.elide.async.models.AsyncQuery) CaffeineCache(com.yahoo.elide.datastores.aggregation.cache.CaffeineCache) Set(java.util.Set) CoerceUtil(com.yahoo.elide.core.utils.coerce.CoerceUtil) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) QueryRunners(com.yahoo.elide.graphql.QueryRunners) Info(io.swagger.models.Info) ConnectionDetails(com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails) Configuration(org.springframework.context.annotation.Configuration) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) EntityManagerFactory(javax.persistence.EntityManagerFactory) DataStore(com.yahoo.elide.core.datastore.DataStore) SwaggerBuilder(com.yahoo.elide.swagger.SwaggerBuilder) Optional(java.util.Optional) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) Slf4jLogger(com.yahoo.elide.core.audit.Slf4jLogger) QueryLogger(com.yahoo.elide.datastores.aggregation.core.QueryLogger) ErrorMapper(com.yahoo.elide.core.exceptions.ErrorMapper) SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) TransactionRegistry(com.yahoo.elide.core.TransactionRegistry) SwaggerController(com.yahoo.elide.spring.controllers.SwaggerController) ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) Session(org.hibernate.Session) AutowireCapableBeanFactory(org.springframework.beans.factory.config.AutowireCapableBeanFactory) HashMap(java.util.HashMap) MultiplexManager(com.yahoo.elide.datastores.multiplex.MultiplexManager) Function(java.util.function.Function) Scope(org.springframework.context.annotation.Scope) ArrayList(java.util.ArrayList) NonJtaTransaction(com.yahoo.elide.datastores.jpa.transaction.NonJtaTransaction) HashSet(java.util.HashSet) DBPasswordExtractor(com.yahoo.elide.modelconfig.DBPasswordExtractor) ConditionalOnExpression(org.springframework.boot.autoconfigure.condition.ConditionalOnExpression) Injector(com.yahoo.elide.core.dictionary.Injector) Qualifier(org.springframework.beans.factory.annotation.Qualifier) DataSource(javax.sql.DataSource) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty) CaffeineCacheMetrics(io.micrometer.core.instrument.binder.cache.CaffeineCacheMetrics) JpaDataStore(com.yahoo.elide.datastores.jpa.JpaDataStore) Slf4jQueryLogger(com.yahoo.elide.datastores.aggregation.core.Slf4jQueryLogger) QueryEngine(com.yahoo.elide.datastores.aggregation.QueryEngine) DEFAULT_LOGGER(com.yahoo.elide.datastores.jpa.JpaDataStore.DEFAULT_LOGGER) SCOPE_PROTOTYPE(org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE) Check(com.yahoo.elide.core.security.checks.Check) DefaultQueryValidator(com.yahoo.elide.datastores.aggregation.DefaultQueryValidator) RefreshableElide(com.yahoo.elide.RefreshableElide) IOException(java.io.IOException) ConfigChecks(com.yahoo.elide.modelconfig.store.models.ConfigChecks) EntityManager(javax.persistence.EntityManager) ConfigDataStore(com.yahoo.elide.modelconfig.store.ConfigDataStore) Consumer(java.util.function.Consumer) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Type(com.yahoo.elide.core.type.Type) Bean(org.springframework.context.annotation.Bean) SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) HashMap(java.util.HashMap) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) ConnectionDetails(com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) DefaultQueryValidator(com.yahoo.elide.datastores.aggregation.DefaultQueryValidator) AggregateBeforeJoinOptimizer(com.yahoo.elide.datastores.aggregation.queryengines.sql.query.AggregateBeforeJoinOptimizer) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Scope(org.springframework.context.annotation.Scope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)

Example 4 with ClassScanner

use of com.yahoo.elide.core.utils.ClassScanner in project elide by yahoo.

the class ElideStandaloneConfigStoreTest method init.

@BeforeAll
public void init() throws Exception {
    configRoot = Files.createTempDirectory("test");
    settings = new ElideStandaloneTestSettings() {

        @Override
        public EntityDictionary getEntityDictionary(ServiceLocator injector, ClassScanner scanner, Optional<DynamicConfiguration> dynamicConfiguration, Set<Type<?>> entitiesToExclude) {
            Map<String, Class<? extends Check>> checks = new HashMap<>();
            if (getAnalyticProperties().enableDynamicModelConfigAPI()) {
                checks.put(ConfigChecks.CAN_CREATE_CONFIG, ConfigChecks.CanCreate.class);
                checks.put(ConfigChecks.CAN_READ_CONFIG, ConfigChecks.CanRead.class);
                checks.put(ConfigChecks.CAN_DELETE_CONFIG, ConfigChecks.CanDelete.class);
                checks.put(ConfigChecks.CAN_UPDATE_CONFIG, ConfigChecks.CanNotUpdate.class);
            }
            EntityDictionary dictionary = new EntityDictionary(// Checks
            checks, // Role Checks
            new HashMap<>(), new Injector() {

                @Override
                public void inject(Object entity) {
                    injector.inject(entity);
                }

                @Override
                public <T> T instantiate(Class<T> cls) {
                    return injector.create(cls);
                }
            }, // Serde Lookup
            CoerceUtil::lookup, entitiesToExclude, scanner);
            dynamicConfiguration.map(DynamicConfiguration::getRoles).orElseGet(Collections::emptySet).forEach(role -> dictionary.addRoleCheck(role, new Role.RoleMemberCheck(role)));
            return dictionary;
        }

        @Override
        public ElideStandaloneAnalyticSettings getAnalyticProperties() {
            return new ElideStandaloneAnalyticSettings() {

                @Override
                public boolean enableDynamicModelConfig() {
                    return true;
                }

                @Override
                public boolean enableDynamicModelConfigAPI() {
                    return true;
                }

                @Override
                public String getDynamicConfigPath() {
                    return configRoot.toFile().getAbsolutePath();
                }

                @Override
                public boolean enableAggregationDataStore() {
                    return true;
                }

                @Override
                public boolean enableMetaDataStore() {
                    return true;
                }
            };
        }
    };
    elide = new ElideStandalone(settings);
    elide.start(false);
}
Also used : ElideStandalone(com.yahoo.elide.standalone.ElideStandalone) HttpStatus(com.yahoo.elide.core.exceptions.HttpStatus) DynamicConfiguration(com.yahoo.elide.modelconfig.DynamicConfiguration) JSONAPI_CONTENT_TYPE(com.yahoo.elide.Elide.JSONAPI_CONTENT_TYPE) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) ElideStandaloneSettings(com.yahoo.elide.standalone.config.ElideStandaloneSettings) HashMap(java.util.HashMap) Role(com.yahoo.elide.core.security.checks.prefab.Role) JsonApiDSL.attr(com.yahoo.elide.test.jsonapi.JsonApiDSL.attr) AfterAll(org.junit.jupiter.api.AfterAll) MediaType(javax.ws.rs.core.MediaType) TestInstance(org.junit.jupiter.api.TestInstance) BeforeAll(org.junit.jupiter.api.BeforeAll) GraphQLDSL.mutation(com.yahoo.elide.test.graphql.GraphQLDSL.mutation) ClassScanner(com.yahoo.elide.core.utils.ClassScanner) Injector(com.yahoo.elide.core.dictionary.Injector) Map(java.util.Map) RestAssured.when(io.restassured.RestAssured.when) GraphQLDSL.argument(com.yahoo.elide.test.graphql.GraphQLDSL.argument) JsonApiDSL.datum(com.yahoo.elide.test.jsonapi.JsonApiDSL.datum) Path(java.nio.file.Path) JsonApiDSL.type(com.yahoo.elide.test.jsonapi.JsonApiDSL.type) JsonApiDSL.links(com.yahoo.elide.test.jsonapi.JsonApiDSL.links) GraphQLDSL.selection(com.yahoo.elide.test.graphql.GraphQLDSL.selection) JsonApiDSL.attributes(com.yahoo.elide.test.jsonapi.JsonApiDSL.attributes) Check(com.yahoo.elide.core.security.checks.Check) Files(java.nio.file.Files) GraphQLDSL.selections(com.yahoo.elide.test.graphql.GraphQLDSL.selections) GraphQLDSL.field(com.yahoo.elide.test.graphql.GraphQLDSL.field) ElideStandaloneAnalyticSettings(com.yahoo.elide.standalone.config.ElideStandaloneAnalyticSettings) Set(java.util.Set) ConfigChecks(com.yahoo.elide.modelconfig.store.models.ConfigChecks) CoerceUtil(com.yahoo.elide.core.utils.coerce.CoerceUtil) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) JsonApiDSL.resource(com.yahoo.elide.test.jsonapi.JsonApiDSL.resource) GraphQLDSL(com.yahoo.elide.test.graphql.GraphQLDSL) Test(org.junit.jupiter.api.Test) JsonApiDSL.id(com.yahoo.elide.test.jsonapi.JsonApiDSL.id) GraphQLDSL.arguments(com.yahoo.elide.test.graphql.GraphQLDSL.arguments) JsonApiDSL.data(com.yahoo.elide.test.jsonapi.JsonApiDSL.data) Type(com.yahoo.elide.core.type.Type) Optional(java.util.Optional) RestAssured.given(io.restassured.RestAssured.given) ServiceLocator(org.glassfish.hk2.api.ServiceLocator) Collections(java.util.Collections) HashMap(java.util.HashMap) ClassScanner(com.yahoo.elide.core.utils.ClassScanner) DynamicConfiguration(com.yahoo.elide.modelconfig.DynamicConfiguration) Injector(com.yahoo.elide.core.dictionary.Injector) Collections(java.util.Collections) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) ElideStandaloneAnalyticSettings(com.yahoo.elide.standalone.config.ElideStandaloneAnalyticSettings) ServiceLocator(org.glassfish.hk2.api.ServiceLocator) Role(com.yahoo.elide.core.security.checks.prefab.Role) MediaType(javax.ws.rs.core.MediaType) Type(com.yahoo.elide.core.type.Type) ElideStandalone(com.yahoo.elide.standalone.ElideStandalone) HashMap(java.util.HashMap) Map(java.util.Map) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with ClassScanner

use of com.yahoo.elide.core.utils.ClassScanner in project elide by yahoo.

the class SubscriptionScannerTest method testLifeCycleHookBindings.

@Test
public void testLifeCycleHookBindings() {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    ClassScanner classScanner = DefaultClassScanner.getInstance();
    EntityDictionary dictionary = EntityDictionary.builder().scanner(classScanner).build();
    SubscriptionScanner subscriptionScanner = SubscriptionScanner.builder().connectionFactory(connectionFactory).dictionary(dictionary).scanner(classScanner).build();
    subscriptionScanner.bindLifecycleHooks();
    assertEquals(1, dictionary.getTriggers(ClassType.of(Book.class), LifeCycleHookBinding.Operation.CREATE, LifeCycleHookBinding.TransactionPhase.POSTCOMMIT, CLASS_NO_FIELD).size());
    assertEquals(0, dictionary.getTriggers(ClassType.of(Book.class), LifeCycleHookBinding.Operation.DELETE, LifeCycleHookBinding.TransactionPhase.POSTCOMMIT, CLASS_NO_FIELD).size());
    assertEquals(1, dictionary.getTriggers(ClassType.of(Book.class), LifeCycleHookBinding.Operation.UPDATE, LifeCycleHookBinding.TransactionPhase.POSTCOMMIT, "title").size());
    assertEquals(1, dictionary.getTriggers(ClassType.of(Book.class), LifeCycleHookBinding.Operation.UPDATE, LifeCycleHookBinding.TransactionPhase.POSTCOMMIT, "genre").size());
    assertEquals(1, dictionary.getTriggers(ClassType.of(Book.class), LifeCycleHookBinding.Operation.UPDATE, LifeCycleHookBinding.TransactionPhase.POSTCOMMIT, "authors").size());
    assertEquals(1, dictionary.getTriggers(ClassType.of(Book.class), LifeCycleHookBinding.Operation.UPDATE, LifeCycleHookBinding.TransactionPhase.POSTCOMMIT, "previews").size());
    assertEquals(0, dictionary.getTriggers(ClassType.of(Book.class), LifeCycleHookBinding.Operation.UPDATE, LifeCycleHookBinding.TransactionPhase.POSTCOMMIT, "price").size());
    assertEquals(1, dictionary.getTriggers(ClassType.of(Author.class), LifeCycleHookBinding.Operation.CREATE, LifeCycleHookBinding.TransactionPhase.POSTCOMMIT, CLASS_NO_FIELD).size());
    assertEquals(1, dictionary.getTriggers(ClassType.of(Author.class), LifeCycleHookBinding.Operation.DELETE, LifeCycleHookBinding.TransactionPhase.POSTCOMMIT, CLASS_NO_FIELD).size());
    assertEquals(1, dictionary.getTriggers(ClassType.of(Author.class), LifeCycleHookBinding.Operation.UPDATE, LifeCycleHookBinding.TransactionPhase.POSTCOMMIT, "name").size());
    assertEquals(1, dictionary.getTriggers(ClassType.of(Author.class), LifeCycleHookBinding.Operation.UPDATE, LifeCycleHookBinding.TransactionPhase.POSTCOMMIT, "type").size());
    assertEquals(1, dictionary.getTriggers(ClassType.of(Author.class), LifeCycleHookBinding.Operation.UPDATE, LifeCycleHookBinding.TransactionPhase.POSTCOMMIT, "homeAddress").size());
    assertEquals(0, dictionary.getTriggers(ClassType.of(Author.class), LifeCycleHookBinding.Operation.UPDATE, LifeCycleHookBinding.TransactionPhase.POSTCOMMIT, "birthDate").size());
}
Also used : ConnectionFactory(javax.jms.ConnectionFactory) ClassScanner(com.yahoo.elide.core.utils.ClassScanner) DefaultClassScanner(com.yahoo.elide.core.utils.DefaultClassScanner) Book(example.Book) Author(example.Author) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) Test(org.junit.jupiter.api.Test)

Aggregations

ClassScanner (com.yahoo.elide.core.utils.ClassScanner)5 DefaultClassScanner (com.yahoo.elide.core.utils.DefaultClassScanner)4 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)3 Map (java.util.Map)3 DataStore (com.yahoo.elide.core.datastore.DataStore)2 Injector (com.yahoo.elide.core.dictionary.Injector)2 Check (com.yahoo.elide.core.security.checks.Check)2 Role (com.yahoo.elide.core.security.checks.prefab.Role)2 AggregationDataStore (com.yahoo.elide.datastores.aggregation.AggregationDataStore)2 DefaultQueryValidator (com.yahoo.elide.datastores.aggregation.DefaultQueryValidator)2 Slf4jQueryLogger (com.yahoo.elide.datastores.aggregation.core.Slf4jQueryLogger)2 MetaDataStore (com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore)2 DefaultQueryPlanMerger (com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger)2 ConnectionDetails (com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails)2 SQLQueryEngine (com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine)2 SQLDialectFactory (com.yahoo.elide.datastores.aggregation.queryengines.sql.dialects.SQLDialectFactory)2 AggregateBeforeJoinOptimizer (com.yahoo.elide.datastores.aggregation.queryengines.sql.query.AggregateBeforeJoinOptimizer)2 JpaDataStore (com.yahoo.elide.datastores.jpa.JpaDataStore)2 NonJtaTransaction (com.yahoo.elide.datastores.jpa.transaction.NonJtaTransaction)2 MultiplexManager (com.yahoo.elide.datastores.multiplex.MultiplexManager)2