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.
FMWK-546 Refactor repository query tests (#783)
* refactor repository query tests, align reactive tests structure with the blocking * update documentation
- Loading branch information
Showing
64 changed files
with
1,160 additions
and
891 deletions.
There are no files selected for viewing
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
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
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
2 changes: 2 additions & 0 deletions
2
src/main/asciidoc/reference/query-methods-simple-property.adoc
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
2 changes: 1 addition & 1 deletion
2
...g/noindex/PersonRepositoryQueryTests.java → .../blocking/PersonRepositoryQueryTests.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
4 changes: 2 additions & 2 deletions
4
.../blocking/noindex/countBy/AfterTests.java → ...tory/query/blocking/count/AfterTests.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
4 changes: 2 additions & 2 deletions
4
...locking/noindex/countBy/BetweenTests.java → ...ry/query/blocking/count/BetweenTests.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
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
4 changes: 2 additions & 2 deletions
4
...blocking/noindex/deleteBy/AfterTests.java → ...ory/query/blocking/delete/AfterTests.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
4 changes: 2 additions & 2 deletions
4
...ocking/noindex/deleteBy/BetweenTests.java → ...y/query/blocking/delete/BetweenTests.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
99 changes: 99 additions & 0 deletions
99
...java/org/springframework/data/aerospike/repository/query/blocking/delete/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,99 @@ | ||
package org.springframework.data.aerospike.repository.query.blocking.delete; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.data.aerospike.query.QueryParam; | ||
import org.springframework.data.aerospike.repository.query.blocking.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 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(); | ||
// cleanup | ||
repository.save(leroi); | ||
} | ||
|
||
@Test | ||
void deleteById() { | ||
assertThat(repository.existsById(dave.getId())).isTrue(); | ||
repository.deleteById(dave.getId()); | ||
assertThat(repository.existsById(dave.getId())).isFalse(); | ||
// cleanup | ||
repository.save(dave); | ||
} | ||
|
||
@Test | ||
void deleteById_AND_simpleProperty() { | ||
assertThat(repository.existsById(leroi.getId())).isTrue(); | ||
assertThat(repository.existsById(dave.getId())).isTrue(); | ||
assertThat(repository.existsById(carter.getId())).isTrue(); | ||
|
||
QueryParam id = of(leroi.getId()); | ||
QueryParam name = of(leroi.getFirstName()); | ||
assertThat(repository.existsByIdAndFirstName(id, name)).isTrue(); | ||
repository.deleteByIdAndFirstName(id, name); | ||
assertThat(repository.existsByIdAndFirstName(id, name)).isFalse(); | ||
|
||
QueryParam id2 = of(dave.getId()); | ||
QueryParam name2 = of(carter.getFirstName()); | ||
// there is no record with Dave's id and Carter's first name | ||
assertThat(repository.existsByIdAndFirstName(id2, name2)).isFalse(); | ||
// delete using id and first name of different records must not change anything | ||
repository.deleteByIdAndFirstName(id2, name2); | ||
assertThat(repository.existsById(dave.getId())).isTrue(); | ||
assertThat(repository.existsById(carter.getId())).isTrue(); | ||
|
||
repository.deleteAllById(List.of(dave.getId(), carter.getId())); | ||
assertThat(repository.existsById(dave.getId())).isFalse(); | ||
assertThat(repository.existsById(carter.getId())).isFalse(); | ||
|
||
// cleanup | ||
repository.save(leroi); | ||
repository.save(dave); | ||
repository.save(carter); | ||
} | ||
|
||
@Test | ||
void deleteAllByIds() { | ||
assertThat(repository.existsById(dave.getId())).isTrue(); | ||
assertThat(repository.existsById(carter.getId())).isTrue(); | ||
|
||
repository.deleteAllById(List.of(dave.getId(), carter.getId())); | ||
|
||
assertThat(repository.existsById(dave.getId())).isFalse(); | ||
assertThat(repository.existsById(carter.getId())).isFalse(); | ||
|
||
// cleanup | ||
repository.save(dave); | ||
repository.save(carter); | ||
} | ||
|
||
@Test | ||
void deleteAll() { | ||
if (serverVersionSupport.isBatchWriteSupported()) { | ||
// batch delete requires server ver. >= 6.0.0 | ||
repository.deleteAll(List.of(dave, carter)); | ||
} else { | ||
List.of(dave, carter).forEach(repository::delete); | ||
} | ||
assertThat(repository.findAllById(List.of(dave.getId(), carter.getId()))).isEmpty(); | ||
// cleanup | ||
repository.save(dave); | ||
repository.save(carter); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...ng/noindex/deleteBy/GreaterThanTests.java → ...ery/blocking/delete/GreaterThanTests.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
4 changes: 2 additions & 2 deletions
4
...blocking/noindex/existsBy/AfterTests.java → ...ory/query/blocking/exists/AfterTests.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
4 changes: 2 additions & 2 deletions
4
...ocking/noindex/existsBy/BetweenTests.java → ...y/query/blocking/exists/BetweenTests.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
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
4 changes: 2 additions & 2 deletions
4
...y/blocking/noindex/findBy/AfterTests.java → ...itory/query/blocking/find/AfterTests.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
4 changes: 2 additions & 2 deletions
4
.../blocking/noindex/findBy/BeforeTests.java → ...tory/query/blocking/find/BeforeTests.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
4 changes: 2 additions & 2 deletions
4
...blocking/noindex/findBy/BetweenTests.java → ...ory/query/blocking/find/BetweenTests.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
4 changes: 2 additions & 2 deletions
4
...cking/noindex/findBy/ContainingTests.java → .../query/blocking/find/ContainingTests.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
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.