Search in sources :

Example 21 with Album

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

the class SessionAndMappingContextTest method init.

@Before
public void init() throws IOException {
    session = (Neo4jSession) sessionFactory.openSession();
    artist1 = new Artist();
    artist1.setName("MainArtist");
    Artist artist2 = new Artist();
    artist2.setName("GuestArtist");
    album1 = new Album();
    album1.setName("First");
    album1.setGuestArtist(artist2);
    album2 = new Album();
    album2.setName("Second");
    album3 = new Album();
    album3.setName("Third");
    artist1.addAlbum(album1);
    artist1.addAlbum(album2);
    artist1.addAlbum(album3);
    Studio studio = new Studio();
    studio.setName("Studio");
    Recording recording = new Recording();
    recording.setAlbum(album1);
    recording.setAlbum(album2);
    recording.setAlbum(album3);
    recording.setStudio(studio);
    recording.setYear(2001);
    session.save(artist1);
    actor1 = new Actor("Actor1");
    actor2 = new Actor("Actor2");
    knows = new Knows();
    knows.setFirstActor(actor1);
    knows.setSecondActor(actor2);
    actor1.knows.add(knows);
    session.save(actor1);
    Actor actor3 = new Actor("Actor3");
    Actor actor4 = new Actor("Actor4");
    knows2 = new Knows();
    knows2.setFirstActor(actor3);
    knows2.setSecondActor(actor4);
    actor3.knows.add(knows2);
    session.save(actor3);
}
Also used : Artist(org.neo4j.ogm.domain.music.Artist) Actor(org.neo4j.ogm.domain.cineasts.annotated.Actor) Album(org.neo4j.ogm.domain.music.Album) Recording(org.neo4j.ogm.domain.music.Recording) Knows(org.neo4j.ogm.domain.cineasts.annotated.Knows) Studio(org.neo4j.ogm.domain.music.Studio) Before(org.junit.Before)

Example 22 with Album

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

the class TransactionTest method shouldNotCommitWhenTransactionIsManaged.

@Test
public void shouldNotCommitWhenTransactionIsManaged() {
    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);
    // the previous saves shouldn't have been committed
    tx.rollback();
    assertThat(session.countEntitiesOfType(Artist.class)).isEqualTo(0);
}
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 23 with Album

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

the class DeleteCapabilityTest method canDeleteEntityArray.

// GH-509
@Test
public void canDeleteEntityArray() {
    Album album1 = new Album();
    Album album2 = new Album();
    session.save(album1);
    session.save(album2);
    assertEntityCount(2);
    List<Object> albumList = new ArrayList<>();
    albumList.add(album1);
    albumList.add(album2);
    session.delete(albumList.toArray());
    assertEntityCount(0);
}
Also used : ArrayList(java.util.ArrayList) Album(org.neo4j.ogm.domain.music.Album) Test(org.junit.Test)

Example 24 with Album

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

the class DeleteCapabilityTest method canDeleteSingleEntry.

@Test
public void canDeleteSingleEntry() {
    Album album = new Album();
    session.save(album);
    assertEntityCount(1);
    session.delete(album);
    assertEntityCount(0);
}
Also used : Album(org.neo4j.ogm.domain.music.Album) Test(org.junit.Test)

Example 25 with Album

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

the class GraphIdCapabilityTest method init.

@Before
public void init() throws IOException {
    SessionFactory sessionFactory = new SessionFactory(getDriver(), "org.neo4j.ogm.domain.music");
    session = sessionFactory.openSession();
    session.purgeDatabase();
    // Create some data
    theBeatles = new Artist("The Beatles");
    please = new Album("Please Please Me");
    theBeatles.getAlbums().add(please);
    please.setArtist(theBeatles);
    session.save(theBeatles);
    Studio studio = new Studio("EMI Studios, London");
    recording = new Recording(please, studio, 1963);
    please.setRecording(recording);
    session.save(recording);
    pleaseId = please.getId();
    beatlesId = theBeatles.getId();
    recordingId = recording.getId();
}
Also used : SessionFactory(org.neo4j.ogm.session.SessionFactory) Artist(org.neo4j.ogm.domain.music.Artist) Album(org.neo4j.ogm.domain.music.Album) Recording(org.neo4j.ogm.domain.music.Recording) Studio(org.neo4j.ogm.domain.music.Studio) Before(org.junit.Before)

Aggregations

Album (org.neo4j.ogm.domain.music.Album)33 Test (org.junit.Test)30 Artist (org.neo4j.ogm.domain.music.Artist)27 Recording (org.neo4j.ogm.domain.music.Recording)21 Studio (org.neo4j.ogm.domain.music.Studio)21 Neo4jSession (org.neo4j.ogm.session.Neo4jSession)9 Session (org.neo4j.ogm.session.Session)7 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Before (org.junit.Before)3 Filter (org.neo4j.ogm.cypher.Filter)3 Map (java.util.Map)2 MappingContext (org.neo4j.ogm.context.MappingContext)2 SessionFactory (org.neo4j.ogm.session.SessionFactory)2 Transaction (org.neo4j.ogm.transaction.Transaction)2 LocalDate (java.time.LocalDate)1 ZoneId (java.time.ZoneId)1 Date (java.util.Date)1 EntityGraphMapper (org.neo4j.ogm.context.EntityGraphMapper)1 Filters (org.neo4j.ogm.cypher.Filters)1