Search in sources :

Example 1 with StoreConfiguration

use of com.buschmais.jqassistant.core.store.api.StoreConfiguration in project jqa-maven-plugin by jQAssistant.

the class AbstractMojo method getStoreConfiguration.

/**
 * Creates the {@link StoreConfiguration}. This is a copy of the {@link #store}
 * enriched by default values and additional command line parameters.
 *
 * @param rootModule
 *            The root module.
 * @return The directory.
 */
private StoreConfiguration getStoreConfiguration(MavenProject rootModule) {
    StoreConfiguration.StoreConfigurationBuilder builder = StoreConfiguration.builder();
    File storeDirectory = coalesce(this.storeDirectory, new File(rootModule.getBuild().getDirectory(), STORE_DIRECTORY));
    builder.uri(coalesce(storeUri, store.getUri(), new File(storeDirectory, "/").toURI()));
    builder.username(coalesce(storeUserName, store.getUsername()));
    builder.password(coalesce(storePassword, store.getPassword()));
    builder.encryption(coalesce(storeEncryption, store.getEncryption()));
    builder.trustStrategy(coalesce(storeTrustStrategy, store.getTrustStrategy()));
    builder.trustCertificate(coalesce(storeTrustCertificate, store.getTrustCertificate()));
    builder.properties(store.getProperties());
    builder.embedded(getEmbeddedNeo4jConfiguration());
    StoreConfiguration storeConfiguration = builder.build();
    getLog().debug("Using store configuration " + storeConfiguration);
    return storeConfiguration;
}
Also used : StoreConfiguration(com.buschmais.jqassistant.core.store.api.StoreConfiguration) File(java.io.File)

Example 2 with StoreConfiguration

use of com.buschmais.jqassistant.core.store.api.StoreConfiguration in project jqa-maven-plugin by jQAssistant.

the class AbstractMojo method getStore.

/**
 * Determine the store instance to use for the given root module.
 *
 * @param rootModule
 *            The root module.
 * @return The store instance.
 * @throws MojoExecutionException
 *             If the store cannot be opened.
 */
private Store getStore(MavenProject rootModule) throws MojoExecutionException {
    StoreConfiguration configuration = getStoreConfiguration(rootModule);
    Object existingStore = cachingStoreProvider.getStore(configuration, getPluginRepository());
    if (!Store.class.isAssignableFrom(existingStore.getClass())) {
        throw new MojoExecutionException("Cannot re-use store instance from reactor. Either declare the plugin as extension or execute Maven using the property -D" + PROPERTY_STORE_LIFECYCLE + "=" + StoreLifecycle.MODULE + " on the command line.");
    }
    return (Store) existingStore;
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) StoreConfiguration(com.buschmais.jqassistant.core.store.api.StoreConfiguration) Store(com.buschmais.jqassistant.core.store.api.Store)

Example 3 with StoreConfiguration

use of com.buschmais.jqassistant.core.store.api.StoreConfiguration in project jqa-core-framework by jQAssistant.

the class AbstractPluginIT method startStore.

/**
 * Initializes and resets the store.
 */
private void startStore(TestInfo testInfo) throws URISyntaxException {
    Method method = testInfo.getTestMethod().orElseThrow(() -> new AssertionError("Unabled to get the test method for test '" + testInfo.getDisplayName() + "'."));
    TestStore testStore = method.getAnnotation(TestStore.class);
    TestStore.Type type = testStore != null ? testStore.type() : TestStore.Type.MEMORY;
    StoreConfiguration.StoreConfigurationBuilder storeConfigurationBuilder = StoreConfiguration.builder();
    switch(type) {
        case FILE:
            String fileName = "target/jqassistant/test-store";
            storeConfigurationBuilder.uri(new File(fileName).toURI());
            storeConfigurationBuilder.embedded(getEmbeddedNeo4jConfiguration());
            break;
        case MEMORY:
            storeConfigurationBuilder.uri(new URI("memory:///"));
            storeConfigurationBuilder.embedded(getEmbeddedNeo4jConfiguration());
            break;
        case REMOTE:
            storeConfigurationBuilder.uri(new URI("bolt://localhost:7687"));
            storeConfigurationBuilder.encryption("NONE");
            storeConfigurationBuilder.username("neo4j").password("jqassistant");
            Properties properties = new Properties();
            properties.put("neo4j.remote.statement.log.level", "info");
            storeConfigurationBuilder.properties(properties);
            break;
        default:
            throw new AssertionError("Test store type not supported: " + type);
    }
    /*
         * You might break IT of depending jQAssistant plugins if you change the
         * location of the used database. Oliver B. Fischer, 2017-06-10
         */
    StoreConfiguration configuration = storeConfigurationBuilder.build();
    store = StoreFactory.getStore(configuration, pluginRepository.getStorePluginRepository());
    store.start();
    if (testStore == null || testStore.reset()) {
        store.reset();
    }
}
Also used : StoreConfiguration(com.buschmais.jqassistant.core.store.api.StoreConfiguration) Method(java.lang.reflect.Method) ToString(lombok.ToString) File(java.io.File) URI(java.net.URI)

Aggregations

StoreConfiguration (com.buschmais.jqassistant.core.store.api.StoreConfiguration)3 File (java.io.File)2 Store (com.buschmais.jqassistant.core.store.api.Store)1 Method (java.lang.reflect.Method)1 URI (java.net.URI)1 ToString (lombok.ToString)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1