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);
}
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);
}
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);
}
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);
}
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();
}
Aggregations