DATAMONGO-1677 - Adds a test to confirm a query with more than 10 arguments works just fine.
Original Pull Request: #849
This commit is contained in:
committed by
Christoph Strobl
parent
4bbf4cd5cf
commit
28510de6c8
@@ -36,7 +36,6 @@ import org.bson.Document;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
||||
@@ -1338,4 +1337,23 @@ public abstract class AbstractPersonRepositoryIntegrationTests {
|
||||
assertThat(repository.findDocumentById(dave.getId()).get()).containsEntry("firstname", dave.getFirstname())
|
||||
.containsEntry("lastname", dave.getLastname());
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1677
|
||||
public void findWithMoreThan10Arguments() {
|
||||
|
||||
alicia.setSkills(Arrays.asList("musician", "singer", "composer", "actress", "pianist"));
|
||||
alicia.setAddress(new Address("street", "zipCode", "city"));
|
||||
alicia.setUniqueId(UUID.randomUUID());
|
||||
UsernameAndPassword credentials = new UsernameAndPassword();
|
||||
credentials.password = "keys";
|
||||
credentials.username = "alicia";
|
||||
alicia.credentials = credentials;
|
||||
|
||||
alicia = repository.save(this.alicia);
|
||||
|
||||
assertThat(repository.findPersonByManyArguments(this.alicia.getFirstname(), this.alicia.getLastname(), this.alicia.getEmail(),
|
||||
this.alicia.getAge(), Sex.FEMALE, this.alicia.createdAt, alicia.getSkills(), "street", "zipCode", "city",
|
||||
alicia.getUniqueId(), credentials.username, credentials.password)
|
||||
).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ public class Address {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @param string2
|
||||
* @param string3
|
||||
* @param street
|
||||
* @param zipcode
|
||||
* @param city
|
||||
*/
|
||||
public Address(String street, String zipcode, String city) {
|
||||
this.street = street;
|
||||
|
||||
@@ -394,4 +394,10 @@ public interface PersonRepository extends MongoRepository<Person, String>, Query
|
||||
|
||||
@Query(value = "{_id:?0}")
|
||||
Optional<org.bson.Document> findDocumentById(String id);
|
||||
|
||||
@Query(
|
||||
value = "{ 'firstname' : ?0, 'lastname' : ?1, 'email' : ?2 , 'age' : ?3, 'sex' : ?4, 'createdAt' : ?5, 'skills' : ?6, 'address.street' : ?7, 'address.zipCode' : ?8, 'address.city' : ?9, 'uniqueId' : ?10, 'credentials.username' : ?11, 'credentials.password' : ?12 }")
|
||||
Person findPersonByManyArguments(String firstname, String lastname, String email, Integer age, Sex sex,
|
||||
Date createdAt, List<String> skills, String street, String zipCode, String city, UUID uniqueId, String username,
|
||||
String password);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user