Search in sources :

Example 1 with Person

use of org.springframework.data.mongodb.repository.Person in project spring-data-mongodb by spring-projects.

the class AggregationTests method createUsersWithReferencedPersons.

private void createUsersWithReferencedPersons() {
    mongoTemplate.dropCollection(User.class);
    mongoTemplate.dropCollection(Person.class);
    User user1 = new User("u1");
    User user2 = new User("u2");
    User user3 = new User("u3");
    mongoTemplate.save(user1);
    mongoTemplate.save(user2);
    mongoTemplate.save(user3);
    Person person1 = new Person("u1", "User 1");
    Person person2 = new Person("u2", "User 2");
    mongoTemplate.save(person1);
    mongoTemplate.save(person2);
    mongoTemplate.save(user3);
}
Also used : Person(org.springframework.data.mongodb.repository.Person)

Example 2 with Person

use of org.springframework.data.mongodb.repository.Person in project spring-data-mongodb by spring-projects.

the class QuerydslRepositorySupportTests method shouldAllowAny.

// DATAMONGO-1063
@Test
public void shouldAllowAny() {
    person.setSkills(Arrays.asList("vocalist", "songwriter", "guitarist"));
    operations.save(person);
    QPerson p = QPerson.person;
    SpringDataMongodbQuery<Person> query = repoSupport.from(p).where(p.skills.any().in("guitarist"));
    assertThat(query.fetchOne(), is(person));
}
Also used : QPerson(org.springframework.data.mongodb.repository.QPerson) Person(org.springframework.data.mongodb.repository.Person) QPerson(org.springframework.data.mongodb.repository.QPerson) Test(org.junit.Test)

Example 3 with Person

use of org.springframework.data.mongodb.repository.Person in project spring-data-mongodb by spring-projects.

the class QuerydslRepositorySupportTests method setUp.

@Before
public void setUp() {
    operations.remove(new Query(), Person.class);
    person = new Person("Dave", "Matthews");
    operations.save(person);
    repoSupport = new QuerydslRepositorySupport(operations) {
    };
}
Also used : Query(org.springframework.data.mongodb.core.query.Query) Person(org.springframework.data.mongodb.repository.Person) QPerson(org.springframework.data.mongodb.repository.QPerson) Before(org.junit.Before)

Example 4 with Person

use of org.springframework.data.mongodb.repository.Person in project spring-data-mongodb by spring-projects.

the class SimpleMongoRepositoryTests method countByExampleShouldLookUpEntriesCorrectly.

// DATAMONGO-1245
@Test
public void countByExampleShouldLookUpEntriesCorrectly() {
    Person sample = new Person();
    sample.setLastname("Matthews");
    trimDomainType(sample, "id", "createdAt", "email");
    assertThat(repository.count(Example.of(sample))).isEqualTo(2L);
}
Also used : Person(org.springframework.data.mongodb.repository.Person) Test(org.junit.Test)

Example 5 with Person

use of org.springframework.data.mongodb.repository.Person in project spring-data-mongodb by spring-projects.

the class SimpleMongoRepositoryTests method findAllByExampleShouldLookUpEntriesCorrectly.

// DATAMONGO-1245
@Test
public void findAllByExampleShouldLookUpEntriesCorrectly() {
    Person sample = new Person();
    sample.setLastname("Matthews");
    trimDomainType(sample, "id", "createdAt", "email");
    assertThat(repository.findAll(Example.of(sample))).hasSize(2).contains(dave, oliver);
}
Also used : Person(org.springframework.data.mongodb.repository.Person) Test(org.junit.Test)

Aggregations

Person (org.springframework.data.mongodb.repository.Person)35 Test (org.junit.Test)29 Point (org.springframework.data.geo.Point)5 Query (org.springframework.data.mongodb.core.query.Query)5 QPerson (org.springframework.data.mongodb.repository.QPerson)5 GeoJsonPoint (org.springframework.data.mongodb.core.geo.GeoJsonPoint)4 NearQuery (org.springframework.data.mongodb.core.query.NearQuery)4 Address (org.springframework.data.mongodb.repository.Address)4 Before (org.junit.Before)3 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 FindWithQuery (org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithQuery)2 User (org.springframework.data.mongodb.repository.User)2 GeoNearExecution (org.springframework.data.mongodb.repository.query.ReactiveMongoQueryExecution.GeoNearExecution)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Document (org.bson.Document)1 AbstractApplicationContext (org.springframework.context.support.AbstractApplicationContext)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1 Distance (org.springframework.data.geo.Distance)1