Browse Source

Polishing.

See spring-projects/spring-data-jdbc/issues/1041
Original pull request spring-projects/spring-data-r2dbc/pull/720
pull/1188/head
Jens Schauder 4 years ago
parent
commit
56ece619d2
No known key found for this signature in database
GPG Key ID: 45CC872F17423DBF
  1. 8
      spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/StatementMapper.java
  2. 4
      spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/dialect/H2Dialect.java
  3. 11
      spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryCreator.java
  4. 36
      spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/AbstractR2dbcRepositoryIntegrationTests.java
  5. 92
      spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/query/PartTreeR2dbcQueryUnitTests.java

8
spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/StatementMapper.java

@ -15,7 +15,13 @@
*/ */
package org.springframework.data.r2dbc.core; package org.springframework.data.r2dbc.core;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;

4
spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/dialect/H2Dialect.java

@ -23,10 +23,6 @@ public class H2Dialect extends PostgresDialect {
return identifier.getReference(getIdentifierProcessing()); return identifier.getReference(getIdentifierProcessing());
} }
/*
* (non-Javadoc)
* @see org.springframework.data.relational.core.dialect.Dialect#lock()
*/
@Override @Override
public LockClause lock() { public LockClause lock() {
// H2 Dialect does not support the same lock keywords as PostgreSQL, but it supports the ANSI SQL standard. // H2 Dialect does not support the same lock keywords as PostgreSQL, but it supports the ANSI SQL standard.

11
spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryCreator.java

@ -158,14 +158,16 @@ class R2dbcQueryCreator extends RelationalQueryCreator<PreparedOperation<?>> {
for (String projectedProperty : projectedProperties) { for (String projectedProperty : projectedProperties) {
RelationalPersistentProperty property = entity.getPersistentProperty(projectedProperty); RelationalPersistentProperty property = entity.getPersistentProperty(projectedProperty);
Column column = table Column column = table.column(property != null //
.column(property != null ? property.getColumnName() : SqlIdentifier.unquoted(projectedProperty)); ? property.getColumnName() //
: SqlIdentifier.unquoted(projectedProperty));
expressions.add(column); expressions.add(column);
} }
} else if (tree.isExistsProjection()) { } else if (tree.isExistsProjection()) {
expressions = dataAccessStrategy.getIdentifierColumns(entityToRead).stream().map(table::column) expressions = dataAccessStrategy.getIdentifierColumns(entityToRead).stream() //
.map(table::column) //
.collect(Collectors.toList()); .collect(Collectors.toList());
} else if (tree.isCountProjection()) { } else if (tree.isCountProjection()) {
@ -175,7 +177,8 @@ class R2dbcQueryCreator extends RelationalQueryCreator<PreparedOperation<?>> {
expressions = Collections.singletonList(Functions.count(countExpression)); expressions = Collections.singletonList(Functions.count(countExpression));
} else { } else {
expressions = dataAccessStrategy.getAllColumns(entityToRead).stream().map(table::column) expressions = dataAccessStrategy.getAllColumns(entityToRead).stream() //
.map(table::column) //
.collect(Collectors.toList()); .collect(Collectors.toList());
} }

36
spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/AbstractR2dbcRepositoryIntegrationTests.java

@ -112,7 +112,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
protected abstract Class<? extends LegoSetRepository> getRepositoryInterfaceType(); protected abstract Class<? extends LegoSetRepository> getRepositoryInterfaceType();
@Test @Test // GH-2
void shouldInsertNewItems() { void shouldInsertNewItems() {
LegoSet legoSet1 = new LegoSet(null, "SCHAUFELRADBAGGER", 12, true); LegoSet legoSet1 = new LegoSet(null, "SCHAUFELRADBAGGER", 12, true);
@ -124,7 +124,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete(); .verifyComplete();
} }
@Test @Test // GH-2
void shouldFindItemsByManual() { void shouldFindItemsByManual() {
shouldInsertNewItems(); shouldInsertNewItems();
@ -137,7 +137,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete(); .verifyComplete();
} }
@Test @Test // GH-2
void shouldFindItemsByNameContains() { void shouldFindItemsByNameContains() {
shouldInsertNewItems(); shouldInsertNewItems();
@ -151,7 +151,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
}).verifyComplete(); }).verifyComplete();
} }
@Test // gh-475, gh-607 @Test // GH-475, GH-607
void shouldFindApplyingInterfaceProjection() { void shouldFindApplyingInterfaceProjection() {
shouldInsertNewItems(); shouldInsertNewItems();
@ -173,7 +173,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
}).verifyComplete(); }).verifyComplete();
} }
@Test // gh-475 @Test // GH-475
void shouldByStringQueryApplyingDtoProjection() { void shouldByStringQueryApplyingDtoProjection() {
shouldInsertNewItems(); shouldInsertNewItems();
@ -187,7 +187,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
}).verifyComplete(); }).verifyComplete();
} }
@Test // gh-344 @Test // GH-344
void shouldFindApplyingDistinctProjection() { void shouldFindApplyingDistinctProjection() {
LegoSet legoSet1 = new LegoSet(null, "SCHAUFELRADBAGGER", 12, true); LegoSet legoSet1 = new LegoSet(null, "SCHAUFELRADBAGGER", 12, true);
@ -207,7 +207,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
}).verifyComplete(); }).verifyComplete();
} }
@Test // gh-41 @Test // GH-41
void shouldFindApplyingSimpleTypeProjection() { void shouldFindApplyingSimpleTypeProjection() {
shouldInsertNewItems(); shouldInsertNewItems();
@ -220,7 +220,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
}).verifyComplete(); }).verifyComplete();
} }
@Test // gh-698 @Test // GH-698
void shouldBeTrue() { void shouldBeTrue() {
shouldInsertNewItems(); shouldInsertNewItems();
@ -246,7 +246,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
assertThat(getCount(count)).satisfies(numberOf(1)); assertThat(getCount(count)).satisfies(numberOf(1));
} }
@Test // gh-335 @Test // GH-335
void shouldFindByPageable() { void shouldFindByPageable() {
Flux<LegoSet> sets = Flux.fromStream(IntStream.range(0, 100).mapToObj(value -> { Flux<LegoSet> sets = Flux.fromStream(IntStream.range(0, 100).mapToObj(value -> {
@ -275,7 +275,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
}).verifyComplete(); }).verifyComplete();
} }
@Test // gh-335 @Test // GH-335
void shouldFindTop10() { void shouldFindTop10() {
Flux<LegoSet> sets = Flux Flux<LegoSet> sets = Flux
@ -292,7 +292,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete(); .verifyComplete();
} }
@Test // gh-341 @Test // GH-341
void shouldDeleteAll() { void shouldDeleteAll() {
shouldInsertNewItems(); shouldInsertNewItems();
@ -306,7 +306,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete(); .verifyComplete();
} }
@Test @Test // GH-2
public void shouldInsertItemsTransactional() { public void shouldInsertItemsTransactional() {
R2dbcTransactionManager r2dbcTransactionManager = new R2dbcTransactionManager(connectionFactory); R2dbcTransactionManager r2dbcTransactionManager = new R2dbcTransactionManager(connectionFactory);
@ -330,7 +330,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
assertThat(getCount(map)).satisfies(numberOf(2)); assertThat(getCount(map)).satisfies(numberOf(2));
} }
@Test // gh-363 @Test // GH-363
void derivedQueryWithCountProjection() { void derivedQueryWithCountProjection() {
shouldInsertNewItems(); shouldInsertNewItems();
@ -341,7 +341,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete(); .verifyComplete();
} }
@Test // gh-363 @Test // GH-363
void derivedQueryWithCount() { void derivedQueryWithCount() {
shouldInsertNewItems(); shouldInsertNewItems();
@ -352,7 +352,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete(); .verifyComplete();
} }
@Test // gh-468 @Test // GH-468
void derivedQueryWithExists() { void derivedQueryWithExists() {
shouldInsertNewItems(); shouldInsertNewItems();
@ -368,7 +368,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete(); .verifyComplete();
} }
@Test // gh-421 @Test // GH-421
void shouldDeleteAllAndReturnCount() { void shouldDeleteAllAndReturnCount() {
shouldInsertNewItems(); shouldInsertNewItems();
@ -383,7 +383,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete(); .verifyComplete();
} }
@Test @Test // GH-1041
void getAllByNameWithWriteLock() { void getAllByNameWithWriteLock() {
shouldInsertNewItems(); shouldInsertNewItems();
@ -396,7 +396,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete(); .verifyComplete();
} }
@Test @Test // GH-1041
void findByNameAndFlagWithReadLock() { void findByNameAndFlagWithReadLock() {
shouldInsertNewItems(); shouldInsertNewItems();

92
spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/query/PartTreeR2dbcQueryUnitTests.java

@ -102,7 +102,7 @@ class PartTreeR2dbcQueryUnitTests {
dataAccessStrategy); dataAccessStrategy);
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByStringAttribute() throws Exception { void createsQueryToFindAllEntitiesByStringAttribute() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstName", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstName", String.class);
@ -114,7 +114,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1");
} }
@Test // gh-282 @Test // GH-282
void createsQueryWithIsNullCondition() throws Exception { void createsQueryWithIsNullCondition() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstName", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstName", String.class);
@ -126,7 +126,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name IS NULL"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name IS NULL");
} }
@Test // gh-282 @Test // GH-282
void createsQueryWithLimitForExistsProjection() throws Exception { void createsQueryWithLimitForExistsProjection() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("existsByFirstName", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("existsByFirstName", String.class);
@ -138,7 +138,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + TABLE + ".id FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1 LIMIT 1"); .isEqualTo("SELECT " + TABLE + ".id FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1 LIMIT 1");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByTwoStringAttributes() throws Exception { void createsQueryToFindAllEntitiesByTwoStringAttributes() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByLastNameAndFirstName", String.class, String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByLastNameAndFirstName", String.class, String.class);
@ -151,7 +151,7 @@ class PartTreeR2dbcQueryUnitTests {
+ ".last_name = $1 AND (" + TABLE + ".first_name = $2)"); + ".last_name = $1 AND (" + TABLE + ".first_name = $2)");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByOneOfTwoStringAttributes() throws Exception { void createsQueryToFindAllEntitiesByOneOfTwoStringAttributes() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByLastNameOrFirstName", String.class, String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByLastNameOrFirstName", String.class, String.class);
@ -164,7 +164,7 @@ class PartTreeR2dbcQueryUnitTests {
+ ".last_name = $1 OR (" + TABLE + ".first_name = $2)"); + ".last_name = $1 OR (" + TABLE + ".first_name = $2)");
} }
@Test // gh-282, gh-349 @Test // GH-282, gh-349
void createsQueryToFindAllEntitiesByDateAttributeBetween() throws Exception { void createsQueryToFindAllEntitiesByDateAttributeBetween() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthBetween", Date.class, Date.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthBetween", Date.class, Date.class);
@ -185,7 +185,7 @@ class PartTreeR2dbcQueryUnitTests {
verify(bindTarget, times(1)).bind(1, to); verify(bindTarget, times(1)).bind(1, to);
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeLessThan() throws Exception { void createsQueryToFindAllEntitiesByIntegerAttributeLessThan() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeLessThan", Integer.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeLessThan", Integer.class);
@ -198,7 +198,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age < $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age < $1");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeLessThanEqual() throws Exception { void createsQueryToFindAllEntitiesByIntegerAttributeLessThanEqual() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeLessThanEqual", Integer.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeLessThanEqual", Integer.class);
@ -211,7 +211,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age <= $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age <= $1");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThan() throws Exception { void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThan() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeGreaterThan", Integer.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeGreaterThan", Integer.class);
@ -224,7 +224,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age > $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age > $1");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThanEqual() throws Exception { void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThanEqual() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeGreaterThanEqual", Integer.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeGreaterThanEqual", Integer.class);
@ -237,7 +237,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age >= $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age >= $1");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByDateAttributeAfter() throws Exception { void createsQueryToFindAllEntitiesByDateAttributeAfter() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthAfter", Date.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthAfter", Date.class);
@ -250,7 +250,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".date_of_birth > $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".date_of_birth > $1");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByDateAttributeBefore() throws Exception { void createsQueryToFindAllEntitiesByDateAttributeBefore() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthBefore", Date.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthBefore", Date.class);
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter, PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter,
@ -262,7 +262,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".date_of_birth < $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".date_of_birth < $1");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeIsNull() throws Exception { void createsQueryToFindAllEntitiesByIntegerAttributeIsNull() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeIsNull"); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeIsNull");
@ -275,7 +275,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age IS NULL"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age IS NULL");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeIsNotNull() throws Exception { void createsQueryToFindAllEntitiesByIntegerAttributeIsNotNull() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeIsNotNull"); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeIsNotNull");
@ -288,7 +288,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age IS NOT NULL"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age IS NOT NULL");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeLike() throws Exception { void createsQueryToFindAllEntitiesByStringAttributeLike() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameLike", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameLike", String.class);
@ -301,7 +301,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name LIKE $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name LIKE $1");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeNotLike() throws Exception { void createsQueryToFindAllEntitiesByStringAttributeNotLike() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotLike", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotLike", String.class);
@ -314,7 +314,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name NOT LIKE $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name NOT LIKE $1");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeStartingWith() throws Exception { void createsQueryToFindAllEntitiesByStringAttributeStartingWith() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameStartingWith", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameStartingWith", String.class);
@ -327,7 +327,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name LIKE $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name LIKE $1");
} }
@Test // gh-282 @Test // GH-282
void appendsLikeOperatorParameterWithPercentSymbolForStartingWithQuery() throws Exception { void appendsLikeOperatorParameterWithPercentSymbolForStartingWithQuery() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameStartingWith", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameStartingWith", String.class);
@ -341,7 +341,7 @@ class PartTreeR2dbcQueryUnitTests {
verify(bindTarget, times(1)).bind(0, "Jo%"); verify(bindTarget, times(1)).bind(0, "Jo%");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeEndingWith() throws Exception { void createsQueryToFindAllEntitiesByStringAttributeEndingWith() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameEndingWith", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameEndingWith", String.class);
@ -354,7 +354,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name LIKE $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name LIKE $1");
} }
@Test // gh-282 @Test // GH-282
void prependsLikeOperatorParameterWithPercentSymbolForEndingWithQuery() throws Exception { void prependsLikeOperatorParameterWithPercentSymbolForEndingWithQuery() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameEndingWith", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameEndingWith", String.class);
@ -368,7 +368,7 @@ class PartTreeR2dbcQueryUnitTests {
verify(bindTarget, times(1)).bind(0, "%hn"); verify(bindTarget, times(1)).bind(0, "%hn");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeContaining() throws Exception { void createsQueryToFindAllEntitiesByStringAttributeContaining() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameContaining", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameContaining", String.class);
@ -381,7 +381,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name LIKE $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name LIKE $1");
} }
@Test // gh-282 @Test // GH-282
void wrapsLikeOperatorParameterWithPercentSymbolsForContainingQuery() throws Exception { void wrapsLikeOperatorParameterWithPercentSymbolsForContainingQuery() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameContaining", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameContaining", String.class);
@ -395,7 +395,7 @@ class PartTreeR2dbcQueryUnitTests {
verify(bindTarget, times(1)).bind(0, "%oh%"); verify(bindTarget, times(1)).bind(0, "%oh%");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeNotContaining() throws Exception { void createsQueryToFindAllEntitiesByStringAttributeNotContaining() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotContaining", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotContaining", String.class);
@ -408,7 +408,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name NOT LIKE $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name NOT LIKE $1");
} }
@Test // gh-282 @Test // GH-282
void wrapsLikeOperatorParameterWithPercentSymbolsForNotContainingQuery() throws Exception { void wrapsLikeOperatorParameterWithPercentSymbolsForNotContainingQuery() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotContaining", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotContaining", String.class);
@ -422,7 +422,7 @@ class PartTreeR2dbcQueryUnitTests {
verify(bindTarget, times(1)).bind(0, "%oh%"); verify(bindTarget, times(1)).bind(0, "%oh%");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeWithDescendingOrderingByStringAttribute() void createsQueryToFindAllEntitiesByIntegerAttributeWithDescendingOrderingByStringAttribute()
throws Exception { throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeOrderByLastNameDesc", Integer.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeOrderByLastNameDesc", Integer.class);
@ -436,7 +436,7 @@ class PartTreeR2dbcQueryUnitTests {
"SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age = $1 ORDER BY users.last_name DESC"); "SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age = $1 ORDER BY users.last_name DESC");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeWithAscendingOrderingByStringAttribute() throws Exception { void createsQueryToFindAllEntitiesByIntegerAttributeWithAscendingOrderingByStringAttribute() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeOrderByLastNameAsc", Integer.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeOrderByLastNameAsc", Integer.class);
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter, PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter,
@ -449,7 +449,7 @@ class PartTreeR2dbcQueryUnitTests {
"SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age = $1 ORDER BY users.last_name ASC"); "SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age = $1 ORDER BY users.last_name ASC");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeNot() throws Exception { void createsQueryToFindAllEntitiesByStringAttributeNot() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByLastNameNot", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByLastNameNot", String.class);
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter, PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter,
@ -461,7 +461,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".last_name != $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".last_name != $1");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeIn() throws Exception { void createsQueryToFindAllEntitiesByIntegerAttributeIn() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeIn", Collection.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeIn", Collection.class);
@ -475,7 +475,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age IN ($1)"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age IN ($1)");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeNotIn() throws Exception { void createsQueryToFindAllEntitiesByIntegerAttributeNotIn() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeNotIn", Collection.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeNotIn", Collection.class);
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter, PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter,
@ -488,7 +488,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age NOT IN ($1)"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age NOT IN ($1)");
} }
@Test // gh-282, gh-698 @Test // GH-282, gh-698
void createsQueryToFindAllEntitiesByBooleanAttributeTrue() throws Exception { void createsQueryToFindAllEntitiesByBooleanAttributeTrue() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByActiveTrue"); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByActiveTrue");
@ -501,7 +501,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".active = $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".active = $1");
} }
@Test // gh-282, gh-698 @Test // GH-282, gh-698
void createsQueryToFindAllEntitiesByBooleanAttributeFalse() throws Exception { void createsQueryToFindAllEntitiesByBooleanAttributeFalse() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByActiveFalse"); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByActiveFalse");
@ -514,7 +514,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".active = $1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".active = $1");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeIgnoringCase() throws Exception { void createsQueryToFindAllEntitiesByStringAttributeIgnoringCase() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameIgnoreCase", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameIgnoreCase", String.class);
@ -527,7 +527,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE UPPER(" + TABLE + ".first_name) = UPPER($1)"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE UPPER(" + TABLE + ".first_name) = UPPER($1)");
} }
@Test // gh-282 @Test // GH-282
void throwsExceptionWhenIgnoringCaseIsImpossible() throws Exception { void throwsExceptionWhenIgnoringCaseIsImpossible() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findByIdIgnoringCase", Long.class); R2dbcQueryMethod queryMethod = getQueryMethod("findByIdIgnoringCase", Long.class);
@ -538,7 +538,7 @@ class PartTreeR2dbcQueryUnitTests {
.isThrownBy(() -> createQuery(r2dbcQuery, getAccessor(queryMethod, new Object[] { 1L }))); .isThrownBy(() -> createQuery(r2dbcQuery, getAccessor(queryMethod, new Object[] { 1L })));
} }
@Test // gh-282 @Test // GH-282
void throwsExceptionWhenInPredicateHasNonIterableParameter() throws Exception { void throwsExceptionWhenInPredicateHasNonIterableParameter() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByIdIn", Long.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByIdIn", Long.class);
@ -547,7 +547,7 @@ class PartTreeR2dbcQueryUnitTests {
.isThrownBy(() -> new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter, dataAccessStrategy)); .isThrownBy(() -> new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter, dataAccessStrategy));
} }
@Test // gh-282 @Test // GH-282
void throwsExceptionWhenSimplePropertyPredicateHasIterableParameter() throws Exception { void throwsExceptionWhenSimplePropertyPredicateHasIterableParameter() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllById", Collection.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllById", Collection.class);
@ -556,7 +556,7 @@ class PartTreeR2dbcQueryUnitTests {
.isThrownBy(() -> new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter, dataAccessStrategy)); .isThrownBy(() -> new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter, dataAccessStrategy));
} }
@Test // gh-282 @Test // GH-282
void throwsExceptionWhenConditionKeywordIsUnsupported() throws Exception { void throwsExceptionWhenConditionKeywordIsUnsupported() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByIdIsEmpty"); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByIdIsEmpty");
@ -567,7 +567,7 @@ class PartTreeR2dbcQueryUnitTests {
.isThrownBy(() -> createQuery(r2dbcQuery, getAccessor(queryMethod, new Object[0]))); .isThrownBy(() -> createQuery(r2dbcQuery, getAccessor(queryMethod, new Object[0])));
} }
@Test // gh-282 @Test // GH-282
void throwsExceptionWhenInvalidNumberOfParameterIsGiven() throws Exception { void throwsExceptionWhenInvalidNumberOfParameterIsGiven() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstName", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstName", String.class);
@ -578,7 +578,7 @@ class PartTreeR2dbcQueryUnitTests {
.isThrownBy(() -> createQuery(r2dbcQuery, getAccessor(queryMethod, new Object[0]))); .isThrownBy(() -> createQuery(r2dbcQuery, getAccessor(queryMethod, new Object[0])));
} }
@Test // gh-282 @Test // GH-282
void createsQueryWithLimitToFindEntitiesByStringAttribute() throws Exception { void createsQueryWithLimitToFindEntitiesByStringAttribute() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findTop3ByFirstName", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findTop3ByFirstName", String.class);
@ -591,7 +591,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1 LIMIT 3"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1 LIMIT 3");
} }
@Test // gh-282 @Test // GH-282
void createsQueryToFindFirstEntityByStringAttribute() throws Exception { void createsQueryToFindFirstEntityByStringAttribute() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findFirstByFirstName", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findFirstByFirstName", String.class);
@ -604,7 +604,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1 LIMIT 1"); .isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1 LIMIT 1");
} }
@Test // gh-341 @Test // GH-341
void createsQueryToDeleteByFirstName() throws Exception { void createsQueryToDeleteByFirstName() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("deleteByFirstName", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("deleteByFirstName", String.class);
@ -616,7 +616,7 @@ class PartTreeR2dbcQueryUnitTests {
assertThat(preparedOperation.get()).isEqualTo("DELETE FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1"); assertThat(preparedOperation.get()).isEqualTo("DELETE FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1");
} }
@Test // gh-344 @Test // GH-344
void createsQueryToFindAllEntitiesByStringAttributeWithDistinct() throws Exception { void createsQueryToFindAllEntitiesByStringAttributeWithDistinct() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findDistinctByFirstName", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findDistinctByFirstName", String.class);
@ -628,7 +628,7 @@ class PartTreeR2dbcQueryUnitTests {
+ ".foo FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1"); + ".foo FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1");
} }
@Test // gh-475 @Test // GH-475
void createsQueryToFindByOpenProjection() throws Exception { void createsQueryToFindByOpenProjection() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findOpenProjectionBy"); R2dbcQueryMethod queryMethod = getQueryMethod("findOpenProjectionBy");
@ -641,7 +641,7 @@ class PartTreeR2dbcQueryUnitTests {
+ TABLE); + TABLE);
} }
@Test // gh-475 @Test // GH-475
void createsDtoProjectionQuery() throws Exception { void createsDtoProjectionQuery() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAsDtoProjectionBy"); R2dbcQueryMethod queryMethod = getQueryMethod("findAsDtoProjectionBy");
@ -654,7 +654,7 @@ class PartTreeR2dbcQueryUnitTests {
+ TABLE); + TABLE);
} }
@Test // gh-363 @Test // GH-363
void createsQueryForCountProjection() throws Exception { void createsQueryForCountProjection() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("countByFirstName", String.class); R2dbcQueryMethod queryMethod = getQueryMethod("countByFirstName", String.class);
@ -666,7 +666,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT COUNT(users.id) FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1"); .isEqualTo("SELECT COUNT(users.id) FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1");
} }
@Test // gh-1041 @Test // GH-1041
void createQueryWithPessimisticWriteLock() throws Exception { void createQueryWithPessimisticWriteLock() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameAndLastName", String.class, String.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameAndLastName", String.class, String.class);
@ -681,7 +681,7 @@ class PartTreeR2dbcQueryUnitTests {
"SELECT users.id, users.first_name, users.last_name, users.date_of_birth, users.age, users.active FROM users WHERE users.first_name = $1 AND (users.last_name = $2) FOR UPDATE OF users"); "SELECT users.id, users.first_name, users.last_name, users.date_of_birth, users.age, users.active FROM users WHERE users.first_name = $1 AND (users.last_name = $2) FOR UPDATE OF users");
} }
@Test // gh-1041 @Test // GH-1041
void createQueryWithPessimisticReadLock() throws Exception { void createQueryWithPessimisticReadLock() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameAndAge", String.class, Integer.class); R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameAndAge", String.class, Integer.class);

Loading…
Cancel
Save