use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class CineastsRelationshipEntityTest method shouldLoadASingleRating.
@Test
public void shouldLoadASingleRating() {
Movie movie = new Movie("Pulp Fiction", 1994);
session.save(movie);
User michal = new User();
michal.setName("Michal");
michal.setLogin("bachmania");
Rating awesome = new Rating();
awesome.setMovie(movie);
awesome.setUser(michal);
awesome.setStars(5);
michal.setRatings(Collections.singleton(awesome));
session.save(michal);
// Add a rating from luanne for the same movie
User luanne = new User();
luanne.setName("luanne");
luanne.setLogin("luanne");
luanne.setPassword("luanne");
Rating rating = new Rating();
rating.setMovie(movie);
rating.setUser(luanne);
rating.setStars(3);
luanne.setRatings(Collections.singleton(rating));
session.save(luanne);
session.clear();
Rating loadedRating = session.load(Rating.class, rating.getId(), 3);
assertThat(loadedRating).isNotNull();
assertThat(loadedRating.getId()).isEqualTo(rating.getId());
assertThat(loadedRating.getStars()).isEqualTo(rating.getStars());
}
use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class UserTest method testDeserialiseUserWithArrayOfEnums.
@Test
public void testDeserialiseUserWithArrayOfEnums() {
MetaData metadata = new MetaData("org.neo4j.ogm.domain.cineasts.annotated");
Neo4jSession session = new Neo4jSession(metadata, true, new UsersRequest());
User user = session.load(User.class, "luanne", 1);
assertThat(user.getLogin()).isEqualTo("luanne");
assertThat(user.getSecurityRoles()).isNotNull();
assertThat(user.getSecurityRoles().length).isEqualTo(2);
}
use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class LookupByPrimaryIndexTests method loadUsesPrimaryIndexWhenPresentOnSuperclass.
@Test
public void loadUsesPrimaryIndexWhenPresentOnSuperclass() {
ExtendedUser user1 = new ExtendedUser("login2", "Name 2", "password");
session.save(user1);
final Session session2 = sessionFactory.openSession();
final User retrievedUser1 = session2.load(ExtendedUser.class, "login2");
assertThat(retrievedUser1).isNotNull();
assertThat(retrievedUser1.getLogin()).isEqualTo(user1.getLogin());
}
use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class LookupByPrimaryIndexTests method loadShouldNotMixPrimaryKeysOfDifferentLabels.
@Test
public void loadShouldNotMixPrimaryKeysOfDifferentLabels() {
User user = new User("login", "name", "password");
session.save(user);
IdAndGenerationType entity = new IdAndGenerationType();
entity.identifier = "login";
session.save(entity);
User loadedUser = session.load(User.class, "login");
assertThat(loadedUser).isEqualTo(user);
IdAndGenerationType loadedEntity = session.load(IdAndGenerationType.class, "login");
assertThat(loadedEntity).isEqualTo(entity);
}
use of org.neo4j.ogm.domain.cineasts.annotated.User in project neo4j-ogm by neo4j.
the class LookupByPrimaryIndexTests method loadAllUsesPrimaryIndexWhenPresent.
@Test
public void loadAllUsesPrimaryIndexWhenPresent() {
User user1 = new User("login1", "Name 1", "password");
session.save(user1);
User user2 = new User("login2", "Name 2", "password");
session.save(user2);
session.clear();
Collection<User> users = session.loadAll(User.class, asList("login1", "login2"));
assertThat(users.size()).isEqualTo(2);
session.clear();
users = session.loadAll(User.class, asList("login1", "login2"), 0);
assertThat(users.size()).isEqualTo(2);
session.clear();
users = session.loadAll(User.class, asList("login1", "login2"), -1);
assertThat(users.size()).isEqualTo(2);
}
Aggregations