Search in sources :

Example 11 with Studio

use of org.neo4j.ogm.domain.music.Studio in project neo4j-ogm by neo4j.

the class TransactionTest method defaultTransactionShouldWorkAfterManagedTransaction.

@Test
public void defaultTransactionShouldWorkAfterManagedTransaction() {
    Transaction tx = session.beginTransaction();
    Studio emi = new Studio("EMI Studios, London");
    session.save(emi);
    tx.commit();
    tx.close();
    session.purgeDatabase();
}
Also used : Transaction(org.neo4j.ogm.transaction.Transaction) Studio(org.neo4j.ogm.domain.music.Studio) Test(org.junit.Test)

Example 12 with Studio

use of org.neo4j.ogm.domain.music.Studio in project neo4j-ogm by neo4j.

the class TransactionTest method shouldBeAbleToRetrySaveOnTransactionRollback.

// GH-126
@Test
public void shouldBeAbleToRetrySaveOnTransactionRollback() {
    Transaction tx = session.beginTransaction();
    Studio emi = new Studio("EMI Studios, London");
    Artist theBeatles = new Artist("The Beatles");
    Album please = new Album("Please Please Me");
    Recording pleaseRecording = new Recording(please, emi, 1963);
    please.setRecording(pleaseRecording);
    theBeatles.getAlbums().add(please);
    please.setArtist(theBeatles);
    session.save(theBeatles);
    tx.rollback();
    session.save(theBeatles);
    session.clear();
    theBeatles = session.loadAll(Artist.class, -1).iterator().next();
    assertThat(theBeatles.getName()).isEqualTo("The Beatles");
    assertThat(theBeatles.getAlbums()).hasSize(1);
    assertThat(theBeatles.getAlbums().iterator().next().getName()).isEqualTo("Please Please Me");
    assertThat(theBeatles.getAlbums().iterator().next().getRecording().getStudio().getName()).isEqualTo("EMI Studios, London");
}
Also used : Artist(org.neo4j.ogm.domain.music.Artist) Transaction(org.neo4j.ogm.transaction.Transaction) Album(org.neo4j.ogm.domain.music.Album) Recording(org.neo4j.ogm.domain.music.Recording) Studio(org.neo4j.ogm.domain.music.Studio) Test(org.junit.Test)

Example 13 with Studio

use of org.neo4j.ogm.domain.music.Studio in project neo4j-ogm by neo4j.

the class FilterIntegrationTest method ignoreCaseShouldBeApplicableToEquals.

@Test
public void ignoreCaseShouldBeApplicableToEquals() {
    final String emi = "EMI Studios, London";
    session.save(new Studio(emi));
    final Filter nameFilter = new Filter("name", ComparisonOperator.EQUALS, "eMi Studios, London").ignoreCase();
    assertThat(session.loadAll(Studio.class, nameFilter, 0)).hasSize(1).extracting(Studio::getName).containsExactly(emi);
}
Also used : Studio(org.neo4j.ogm.domain.music.Studio) Test(org.junit.Test)

Example 14 with Studio

use of org.neo4j.ogm.domain.music.Studio in project neo4j-ogm by neo4j.

the class FilterIntegrationTest method ignoreCaseShouldBeApplicableToEndingWith.

@Test
public void ignoreCaseShouldBeApplicableToEndingWith() {
    final String emi = "EMI Studios, London";
    session.save(new Studio(emi));
    final Filter nameFilter = new Filter("name", ComparisonOperator.ENDING_WITH, "london").ignoreCase();
    assertThat(session.loadAll(Studio.class, nameFilter, 0)).hasSize(1).extracting(Studio::getName).containsExactly(emi);
}
Also used : Studio(org.neo4j.ogm.domain.music.Studio) Test(org.junit.Test)

Example 15 with Studio

use of org.neo4j.ogm.domain.music.Studio in project neo4j-ogm by neo4j.

the class MusicIntegrationTest method shouldLoadStudioWithLocationMissingInDomainModel.

/**
 * @see DATAGRAPH-631
 */
@Test
public void shouldLoadStudioWithLocationMissingInDomainModel() {
    session.query("CREATE (s:Studio {`studio-name`:'Abbey Road Studios'})", Collections.emptyMap());
    Studio studio = session.loadAll(Studio.class, new Filter("name", ComparisonOperator.EQUALS, "Abbey Road Studios")).iterator().next();
    assertThat(studio).isNotNull();
}
Also used : Filter(org.neo4j.ogm.cypher.Filter) Studio(org.neo4j.ogm.domain.music.Studio) Test(org.junit.Test)

Aggregations

Studio (org.neo4j.ogm.domain.music.Studio)29 Test (org.junit.Test)27 Album (org.neo4j.ogm.domain.music.Album)21 Recording (org.neo4j.ogm.domain.music.Recording)21 Artist (org.neo4j.ogm.domain.music.Artist)19 Neo4jSession (org.neo4j.ogm.session.Neo4jSession)8 Session (org.neo4j.ogm.session.Session)7 Filter (org.neo4j.ogm.cypher.Filter)4 Transaction (org.neo4j.ogm.transaction.Transaction)3 List (java.util.List)2 Map (java.util.Map)2 Before (org.junit.Before)2 MappingContext (org.neo4j.ogm.context.MappingContext)1 Filters (org.neo4j.ogm.cypher.Filters)1 SortOrder (org.neo4j.ogm.cypher.query.SortOrder)1 Actor (org.neo4j.ogm.domain.cineasts.annotated.Actor)1 Knows (org.neo4j.ogm.domain.cineasts.annotated.Knows)1 SessionFactory (org.neo4j.ogm.session.SessionFactory)1