Package org.springframework.data.mongodb.repository

Examples of org.springframework.data.mongodb.repository.Person


  @Test
  public void shouldSupportReturningCurrentAggregationRoot() {

    assumeTrue(mongoVersion.isGreaterThanOrEqualTo(TWO_DOT_SIX));

    mongoTemplate.save(new Person("p1_first", "p1_last", 25));
    mongoTemplate.save(new Person("p2_first", "p2_last", 32));
    mongoTemplate.save(new Person("p3_first", "p3_last", 25));
    mongoTemplate.save(new Person("p4_first", "p4_last", 15));

    List<DBObject> personsWithAge25 = mongoTemplate.find(Query.query(where("age").is(25)), DBObject.class,
        mongoTemplate.getCollectionName(Person.class));

    Aggregation agg = newAggregation(group("age").push(Aggregation.ROOT).as("users"));
View Full Code Here


    assertThat(repository, is(notNullValue()));

    repository.deleteAll();

    Person person = new Person("Dave", "Matthews");
    Person result = repository.save(person);

    assertThat(result, is(notNullValue()));
    assertThat(repository.findOne(person.getId()).getId(), is(result.getId()));
  }
View Full Code Here

  @Before
  public void setUp() {
    repository = new SimpleMongoRepository<Person, String>(personEntityInformation, template);
    repository.deleteAll();

    oliver = new Person("Oliver August", "Matthews", 4);
    dave = new Person("Dave", "Matthews", 42);
    carter = new Person("Carter", "Beauford", 49);
    boyd = new Person("Boyd", "Tinsley", 45);
    stefan = new Person("Stefan", "Lessard", 34);
    leroi = new Person("Leroi", "Moore", 41);
    alicia = new Person("Alicia", "Keys", 30, Sex.FEMALE);

    all = repository.save(Arrays.asList(oliver, dave, carter, boyd, stefan, leroi, alicia));
  }
View Full Code Here

    assertThat(result, hasSize(all.size()));
  }
 
  @Test
  public void findOneFromCustomCollectionName() {
    Person result = repository.findOne(dave.getId());
    assertThat(result, is(dave));
  }
View Full Code Here

  Person person;

  @Before
  public void setUp() {
    operations.remove(new Query(), Person.class);
    person = new Person("Dave", "Matthews");
    operations.save(person);
  }
View Full Code Here

public class AbstractMongoEventListenerUnitTests {

  @Test
  public void invokesCallbackForEventForPerson() {

    MongoMappingEvent<Person> event = new BeforeConvertEvent<Person>(new Person("Dave", "Matthews"));
    SamplePersonEventListener listener = new SamplePersonEventListener();
    listener.onApplicationEvent(event);
    assertThat(listener.invokedOnBeforeConvert, is(true));
  }
View Full Code Here

    context.refresh();

    SamplePersonEventListener listener = new SamplePersonEventListener();
    context.addApplicationListener(listener);

    context.publishEvent(new BeforeConvertEvent<Person>(new Person("Dave", "Matthews")));
    assertThat(listener.invokedOnBeforeConvert, is(true));

    listener.invokedOnBeforeConvert = false;
    context.publishEvent(new BeforeConvertEvent<String>("Test"));
    assertThat(listener.invokedOnBeforeConvert, is(false));
View Full Code Here

TOP

Related Classes of org.springframework.data.mongodb.repository.Person

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.