Search in sources :

Example 1 with Configuration

use of org.neo4j.ogm.config.Configuration in project spring-boot by spring-projects.

the class Neo4jProperties method createConfiguration.

/**
	 * Create a {@link Configuration} based on the state of this instance.
	 * @return a configuration
	 */
public Configuration createConfiguration() {
    Configuration configuration = new Configuration();
    configureDriver(configuration.driverConfiguration());
    if (this.compiler != null) {
        configuration.compilerConfiguration().setCompilerClassName(this.compiler);
    }
    return configuration;
}
Also used : DriverConfiguration(org.neo4j.ogm.config.DriverConfiguration) Configuration(org.neo4j.ogm.config.Configuration)

Example 2 with Configuration

use of org.neo4j.ogm.config.Configuration in project spring-boot by spring-projects.

the class Neo4jPropertiesTests method embeddedModeWithRelativeLocation.

@Test
public void embeddedModeWithRelativeLocation() {
    Neo4jProperties properties = load(true, "spring.data.neo4j.uri=target/neo4j/my.db");
    Configuration configuration = properties.createConfiguration();
    assertDriver(configuration, Neo4jProperties.EMBEDDED_DRIVER, "target/neo4j/my.db");
}
Also used : DriverConfiguration(org.neo4j.ogm.config.DriverConfiguration) Configuration(org.neo4j.ogm.config.Configuration) Test(org.junit.Test)

Example 3 with Configuration

use of org.neo4j.ogm.config.Configuration in project spring-boot by spring-projects.

the class Neo4jPropertiesTests method defaultUseHttpDriverIfEmbeddedDriverIsNotAvailable.

@Test
public void defaultUseHttpDriverIfEmbeddedDriverIsNotAvailable() {
    Neo4jProperties properties = load(false);
    Configuration configuration = properties.createConfiguration();
    assertDriver(configuration, Neo4jProperties.HTTP_DRIVER, Neo4jProperties.DEFAULT_HTTP_URI);
}
Also used : DriverConfiguration(org.neo4j.ogm.config.DriverConfiguration) Configuration(org.neo4j.ogm.config.Configuration) Test(org.junit.Test)

Example 4 with Configuration

use of org.neo4j.ogm.config.Configuration in project spring-boot by spring-projects.

the class Neo4jPropertiesTests method embeddedModeDisabledUseHttpUri.

@Test
public void embeddedModeDisabledUseHttpUri() {
    Neo4jProperties properties = load(true, "spring.data.neo4j.embedded.enabled=false");
    Configuration configuration = properties.createConfiguration();
    assertDriver(configuration, Neo4jProperties.HTTP_DRIVER, Neo4jProperties.DEFAULT_HTTP_URI);
}
Also used : DriverConfiguration(org.neo4j.ogm.config.DriverConfiguration) Configuration(org.neo4j.ogm.config.Configuration) Test(org.junit.Test)

Example 5 with Configuration

use of org.neo4j.ogm.config.Configuration in project tutorials by eugenp.

the class Neo4jOgmLiveTest method testOgm.

@Test
public void testOgm() {
    Configuration conf = new Configuration();
    conf.driverConfiguration().setDriverClassName("org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver");
    SessionFactory factory = new SessionFactory(conf, "com.baeldung.spring.data.neo4j.domain");
    Session session = factory.openSession();
    Car tesla = new Car("tesla", "modelS");
    Company baeldung = new Company("baeldung");
    baeldung.setCar(tesla);
    session.save(baeldung);
    Assert.assertEquals(1, session.countEntitiesOfType(Company.class));
    Map<String, String> params = new HashMap<>();
    params.put("make", "tesla");
    Result result = session.query("MATCH (car:Car) <-[:owns]- (company:Company)" + " WHERE car.make=$make" + " RETURN company", params);
    Map<String, Object> firstResult = result.iterator().next();
    Assert.assertEquals(firstResult.size(), 1);
    Company actual = (Company) firstResult.get("company");
    Assert.assertEquals(actual.getName(), baeldung.getName());
}
Also used : SessionFactory(org.neo4j.ogm.session.SessionFactory) Company(com.baeldung.spring.data.neo4j.domain.Company) Configuration(org.neo4j.ogm.config.Configuration) Car(com.baeldung.spring.data.neo4j.domain.Car) HashMap(java.util.HashMap) Session(org.neo4j.ogm.session.Session) Result(org.neo4j.ogm.model.Result) Test(org.junit.Test)

Aggregations

Configuration (org.neo4j.ogm.config.Configuration)11 Test (org.junit.Test)10 DriverConfiguration (org.neo4j.ogm.config.DriverConfiguration)10 Car (com.baeldung.spring.data.neo4j.domain.Car)1 Company (com.baeldung.spring.data.neo4j.domain.Company)1 HashMap (java.util.HashMap)1 Result (org.neo4j.ogm.model.Result)1 Session (org.neo4j.ogm.session.Session)1 SessionFactory (org.neo4j.ogm.session.SessionFactory)1