forked from spring-attic/spring-data-aerospike
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
407 additions
and
31 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...springframework/data/aerospike/repository/query/blocking/noindex/countBy/EqualsTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.springframework.data.aerospike.repository.query.blocking.noindex.countBy; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.data.aerospike.query.QueryParam; | ||
import org.springframework.data.aerospike.repository.query.blocking.noindex.PersonRepositoryQueryTests; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.springframework.data.aerospike.query.QueryParam.of; | ||
|
||
/** | ||
* Tests for the "Equals" repository query. Keywords: Is, Equals (or no keyword). | ||
*/ | ||
public class EqualsTests extends PersonRepositoryQueryTests { | ||
|
||
@Test | ||
void countBySimplePropertyEquals_String() { | ||
long result = repository.countByFirstName("Leroi"); | ||
assertThat(result).isEqualTo(2); | ||
|
||
long result1 = repository.countByFirstNameIgnoreCase("lEroi"); | ||
assertThat(result1).isEqualTo(2); | ||
|
||
long result2 = repository.countByFirstNameIs("lEroi"); // another way to call the query method | ||
assertThat(result2).isZero(); | ||
} | ||
|
||
@Test | ||
void countPersonById_AND_simpleProperty() { | ||
QueryParam ids = of(dave.getId()); | ||
QueryParam name = of(carter.getFirstName()); | ||
long persons = repository.countByIdAndFirstName(ids, name); | ||
assertThat(persons).isZero(); | ||
|
||
ids = of(dave.getId()); | ||
name = of(dave.getFirstName()); | ||
persons = repository.countByIdAndFirstName(ids, name); | ||
assertThat(persons).isEqualTo(1); | ||
|
||
ids = of(List.of(leroi.getId(), leroi2.getId(), carter.getId())); | ||
QueryParam firstName = of(leroi.getFirstName()); | ||
QueryParam age = of(stefan.getAge()); | ||
long persons4 = repository.countByIdAndFirstNameOrAge(ids, firstName, age); | ||
assertThat(persons4).isEqualTo(2); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...pringframework/data/aerospike/repository/query/blocking/noindex/deleteBy/EqualsTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.springframework.data.aerospike.repository.query.blocking.noindex.deleteBy; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.data.aerospike.query.QueryParam; | ||
import org.springframework.data.aerospike.repository.query.blocking.noindex.PersonRepositoryQueryTests; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.springframework.data.aerospike.query.QueryParam.of; | ||
|
||
/** | ||
* Tests for the "Equals" repository query. Keywords: Is, Equals (or no keyword). | ||
*/ | ||
public class EqualsTests extends PersonRepositoryQueryTests { | ||
|
||
@Test | ||
void deleteBySimplePropertyEquals_String() { | ||
assertThat(repository.findByFirstName("Leroi")).isNotEmpty(); | ||
repository.deleteByFirstName("Leroi"); | ||
assertThat(repository.findByFirstName("Leroi")).isEmpty(); | ||
|
||
repository.save(leroi); | ||
assertThat(repository.findByFirstNameIgnoreCase("lEroi")).isNotEmpty(); | ||
repository.deleteByFirstNameIgnoreCase("lEroi"); | ||
assertThat(repository.findByFirstNameIgnoreCase("lEroi")).isEmpty(); | ||
} | ||
|
||
@Test | ||
void deletePersonById_AND_simpleProperty() { | ||
QueryParam ids = of(dave.getId()); | ||
QueryParam name = of(carter.getFirstName()); | ||
repository.deleteByIdAndFirstName(ids, name); | ||
assertThat(repository.findByIdAndFirstName(ids, name)).isEmpty(); | ||
|
||
ids = of(dave.getId()); | ||
name = of(dave.getFirstName()); | ||
assertThat(repository.findByIdAndFirstName(ids, name)).isNotEmpty(); | ||
repository.deleteByIdAndFirstName(ids, name); | ||
assertThat(repository.findByIdAndFirstName(ids, name)).isEmpty(); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...pringframework/data/aerospike/repository/query/blocking/noindex/existsBy/EqualsTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.springframework.data.aerospike.repository.query.blocking.noindex.existsBy; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.data.aerospike.query.QueryParam; | ||
import org.springframework.data.aerospike.repository.query.blocking.noindex.PersonRepositoryQueryTests; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.springframework.data.aerospike.query.QueryParam.of; | ||
|
||
/** | ||
* Tests for the "Equals" repository query. Keywords: Is, Equals (or no keyword). | ||
*/ | ||
public class EqualsTests extends PersonRepositoryQueryTests { | ||
|
||
@Test | ||
void existsBySimplePropertyEquals_String() { | ||
boolean result = repository.existsByFirstName("Leroi"); | ||
assertThat(result).isTrue(); | ||
|
||
boolean result1 = repository.existsByFirstNameIgnoreCase("lEroi"); | ||
assertThat(result1).isTrue(); | ||
|
||
boolean result2 = repository.existsByFirstNameIs("lEroi"); // another way to call the query method | ||
assertThat(result2).isFalse(); | ||
} | ||
|
||
@Test | ||
void existsPersonById_AND_simpleProperty() { | ||
QueryParam ids = of(dave.getId()); | ||
QueryParam name = of(carter.getFirstName()); | ||
boolean result = repository.existsByIdAndFirstName(ids, name); | ||
assertThat(result).isFalse(); | ||
|
||
ids = of(dave.getId()); | ||
name = of(dave.getFirstName()); | ||
result = repository.existsByIdAndFirstName(ids, name); | ||
assertThat(result).isTrue(); | ||
|
||
ids = of(List.of(leroi.getId(), leroi2.getId(), carter.getId())); | ||
QueryParam firstName = of(leroi.getFirstName()); | ||
QueryParam age = of(stefan.getAge()); | ||
boolean result2 = repository.existsByIdAndFirstNameOrAge(ids, firstName, age); | ||
assertThat(result2).isTrue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...work/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryCountRelatedTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.springframework.data.aerospike.repository.reactive; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.aerospike.BaseReactiveIntegrationTests; | ||
import org.springframework.data.aerospike.query.QueryParam; | ||
import org.springframework.data.aerospike.sample.Customer; | ||
import org.springframework.data.aerospike.sample.ReactiveCustomerRepository; | ||
import reactor.core.publisher.Flux; | ||
import reactor.test.StepVerifier; | ||
|
||
import java.util.List; | ||
|
||
public class ReactiveAerospikeRepositoryCountRelatedTests extends BaseReactiveIntegrationTests { | ||
|
||
@Autowired | ||
ReactiveCustomerRepository customerRepo; | ||
|
||
private Customer customer1, customer2; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
customer1 = Customer.builder().id(nextId()).firstName("Philip J.").lastName("Fry").age(1029).build(); | ||
customer2 = Customer.builder().id(nextId()).firstName("Leela").lastName("Turanga").age(29).build(); | ||
StepVerifier.create(customerRepo.saveAll(Flux.just(customer1, customer2))).expectNextCount(2).verifyComplete(); | ||
} | ||
|
||
@Test | ||
public void countByAgeBetween() { | ||
StepVerifier.create(customerRepo.countByAgeBetween(20, 1100)) | ||
.expectNext(2L) | ||
.verifyComplete(); | ||
} | ||
|
||
@Test | ||
public void countByIdAndFirstNameIn() { | ||
QueryParam ids = QueryParam.of(List.of(customer1.getId(), customer2.getId())); | ||
QueryParam firstNames = QueryParam.of(List.of(customer1.getFirstName(), customer2.getFirstName(), "FirstName")); | ||
StepVerifier.create(customerRepo.countByIdAndFirstNameIn(ids, firstNames)) | ||
.expectNext(2L) | ||
.verifyComplete(); | ||
|
||
firstNames = QueryParam.of(List.of("FirstName")); | ||
StepVerifier.create(customerRepo.countByIdAndFirstNameIn(ids, firstNames)) | ||
.expectNext(0L) | ||
.verifyComplete(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.