@ -34,6 +34,7 @@ import java.util.List;
@@ -34,6 +34,7 @@ import java.util.List;
import java.util.Objects ;
import java.util.Optional ;
import java.util.Set ;
import java.util.function.Consumer ;
import java.util.stream.Stream ;
import org.junit.jupiter.api.BeforeEach ;
@ -41,6 +42,7 @@ import org.junit.jupiter.api.Test;
@@ -41,6 +42,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest ;
import org.junit.jupiter.params.provider.Arguments ;
import org.junit.jupiter.params.provider.MethodSource ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.config.PropertiesFactoryBean ;
import org.springframework.context.ApplicationListener ;
@ -50,7 +52,16 @@ import org.springframework.context.annotation.Import;
@@ -50,7 +52,16 @@ import org.springframework.context.annotation.Import;
import org.springframework.core.io.ClassPathResource ;
import org.springframework.dao.IncorrectResultSizeDataAccessException ;
import org.springframework.data.annotation.Id ;
import org.springframework.data.domain.* ;
import org.springframework.data.domain.Example ;
import org.springframework.data.domain.ExampleMatcher ;
import org.springframework.data.domain.Limit ;
import org.springframework.data.domain.Page ;
import org.springframework.data.domain.PageRequest ;
import org.springframework.data.domain.Pageable ;
import org.springframework.data.domain.ScrollPosition ;
import org.springframework.data.domain.Slice ;
import org.springframework.data.domain.Sort ;
import org.springframework.data.domain.Window ;
import org.springframework.data.jdbc.core.mapping.AggregateReference ;
import org.springframework.data.jdbc.repository.query.Modifying ;
import org.springframework.data.jdbc.repository.query.Query ;
@ -107,18 +118,6 @@ public class JdbcRepositoryIntegrationTests {
@@ -107,18 +118,6 @@ public class JdbcRepositoryIntegrationTests {
@Autowired WithDelimitedColumnRepository withDelimitedColumnRepository ;
private static DummyEntity createDummyEntity ( ) {
return createDummyEntity ( "Entity Name" ) ;
}
private static DummyEntity createDummyEntity ( String entityName ) {
DummyEntity entity = new DummyEntity ( ) ;
entity . setName ( entityName ) ;
return entity ;
}
@BeforeEach
public void before ( ) {
@ -130,7 +129,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -130,7 +129,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-95
public void savesAnEntity ( ) {
DummyEntity entity = repository . save ( createDummy Entity ( ) ) ;
DummyEntity entity = repository . save ( createEntity ( ) ) ;
assertThat ( JdbcTestUtils . countRowsInTableWhere ( template . getJdbcOperations ( ) , "dummy_entity" ,
"id_Prop = " + entity . getIdProp ( ) ) ) . isEqualTo ( 1 ) ;
@ -139,7 +138,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -139,7 +138,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-95
public void saveAndLoadAnEntity ( ) {
DummyEntity entity = repository . save ( createDummy Entity ( ) ) ;
DummyEntity entity = repository . save ( createEntity ( ) ) ;
assertThat ( repository . findById ( entity . getIdProp ( ) ) ) . hasValueSatisfying ( it - > {
@ -151,8 +150,8 @@ public class JdbcRepositoryIntegrationTests {
@@ -151,8 +150,8 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-97
public void insertsManyEntities ( ) {
DummyEntity entity = createDummy Entity ( ) ;
DummyEntity other = createDummy Entity ( ) ;
DummyEntity entity = createEntity ( ) ;
DummyEntity other = createEntity ( ) ;
repository . saveAll ( asList ( entity , other ) ) ;
@ -164,7 +163,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -164,7 +163,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-97
public void existsReturnsTrueIffEntityExists ( ) {
DummyEntity entity = repository . save ( createDummy Entity ( ) ) ;
DummyEntity entity = repository . save ( createEntity ( ) ) ;
assertThat ( repository . existsById ( entity . getIdProp ( ) ) ) . isTrue ( ) ;
assertThat ( repository . existsById ( entity . getIdProp ( ) + 1 ) ) . isFalse ( ) ;
@ -173,8 +172,8 @@ public class JdbcRepositoryIntegrationTests {
@@ -173,8 +172,8 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-97
public void findAllFindsAllEntities ( ) {
DummyEntity entity = repository . save ( createDummy Entity ( ) ) ;
DummyEntity other = repository . save ( createDummy Entity ( ) ) ;
DummyEntity entity = repository . save ( createEntity ( ) ) ;
DummyEntity other = repository . save ( createEntity ( ) ) ;
Iterable < DummyEntity > all = repository . findAll ( ) ;
@ -186,8 +185,8 @@ public class JdbcRepositoryIntegrationTests {
@@ -186,8 +185,8 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-97
public void findAllFindsAllSpecifiedEntities ( ) {
DummyEntity entity = repository . save ( createDummy Entity ( ) ) ;
DummyEntity other = repository . save ( createDummy Entity ( ) ) ;
DummyEntity entity = repository . save ( createEntity ( ) ) ;
DummyEntity other = repository . save ( createEntity ( ) ) ;
assertThat ( repository . findAllById ( asList ( entity . getIdProp ( ) , other . getIdProp ( ) ) ) ) //
. extracting ( DummyEntity : : getIdProp ) //
@ -197,9 +196,9 @@ public class JdbcRepositoryIntegrationTests {
@@ -197,9 +196,9 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-97
public void countsEntities ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
repository . save ( createEntity ( ) ) ;
repository . save ( createEntity ( ) ) ;
assertThat ( repository . count ( ) ) . isEqualTo ( 3L ) ;
}
@ -207,9 +206,9 @@ public class JdbcRepositoryIntegrationTests {
@@ -207,9 +206,9 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-97
public void deleteById ( ) {
DummyEntity one = repository . save ( createDummy Entity ( ) ) ;
DummyEntity two = repository . save ( createDummy Entity ( ) ) ;
DummyEntity three = repository . save ( createDummy Entity ( ) ) ;
DummyEntity one = repository . save ( createEntity ( ) ) ;
DummyEntity two = repository . save ( createEntity ( ) ) ;
DummyEntity three = repository . save ( createEntity ( ) ) ;
repository . deleteById ( two . getIdProp ( ) ) ;
@ -221,9 +220,9 @@ public class JdbcRepositoryIntegrationTests {
@@ -221,9 +220,9 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-97
public void deleteByEntity ( ) {
DummyEntity one = repository . save ( createDummy Entity ( ) ) ;
DummyEntity two = repository . save ( createDummy Entity ( ) ) ;
DummyEntity three = repository . save ( createDummy Entity ( ) ) ;
DummyEntity one = repository . save ( createEntity ( ) ) ;
DummyEntity two = repository . save ( createEntity ( ) ) ;
DummyEntity three = repository . save ( createEntity ( ) ) ;
repository . delete ( one ) ;
@ -235,9 +234,9 @@ public class JdbcRepositoryIntegrationTests {
@@ -235,9 +234,9 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-97
public void deleteByList ( ) {
DummyEntity one = repository . save ( createDummy Entity ( ) ) ;
DummyEntity two = repository . save ( createDummy Entity ( ) ) ;
DummyEntity three = repository . save ( createDummy Entity ( ) ) ;
DummyEntity one = repository . save ( createEntity ( ) ) ;
DummyEntity two = repository . save ( createEntity ( ) ) ;
DummyEntity three = repository . save ( createEntity ( ) ) ;
repository . deleteAll ( asList ( one , three ) ) ;
@ -249,9 +248,9 @@ public class JdbcRepositoryIntegrationTests {
@@ -249,9 +248,9 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-629
public void deleteByIdList ( ) {
DummyEntity one = repository . save ( createDummy Entity ( ) ) ;
DummyEntity two = repository . save ( createDummy Entity ( ) ) ;
DummyEntity three = repository . save ( createDummy Entity ( ) ) ;
DummyEntity one = repository . save ( createEntity ( ) ) ;
DummyEntity two = repository . save ( createEntity ( ) ) ;
DummyEntity three = repository . save ( createEntity ( ) ) ;
repository . deleteAllById ( asList ( one . idProp , three . idProp ) ) ;
@ -263,9 +262,9 @@ public class JdbcRepositoryIntegrationTests {
@@ -263,9 +262,9 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-97
public void deleteAll ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
repository . save ( createEntity ( ) ) ;
repository . save ( createEntity ( ) ) ;
assertThat ( repository . findAll ( ) ) . isNotEmpty ( ) ;
@ -277,7 +276,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -277,7 +276,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-98
public void update ( ) {
DummyEntity entity = repository . save ( createDummy Entity ( ) ) ;
DummyEntity entity = repository . save ( createEntity ( ) ) ;
entity . setName ( "something else" ) ;
DummyEntity saved = repository . save ( entity ) ;
@ -290,8 +289,8 @@ public class JdbcRepositoryIntegrationTests {
@@ -290,8 +289,8 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-98
public void updateMany ( ) {
DummyEntity entity = repository . save ( createDummy Entity ( ) ) ;
DummyEntity other = repository . save ( createDummy Entity ( ) ) ;
DummyEntity entity = repository . save ( createEntity ( ) ) ;
DummyEntity other = repository . save ( createEntity ( ) ) ;
entity . setName ( "something else" ) ;
other . setName ( "others Name" ) ;
@ -306,9 +305,9 @@ public class JdbcRepositoryIntegrationTests {
@@ -306,9 +305,9 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-537
void insertsOrUpdatesManyEntities ( ) {
DummyEntity entity = repository . save ( createDummy Entity ( ) ) ;
DummyEntity entity = repository . save ( createEntity ( ) ) ;
entity . setName ( "something else" ) ;
DummyEntity other = createDummy Entity ( ) ;
DummyEntity other = createEntity ( ) ;
other . setName ( "others name" ) ;
repository . saveAll ( asList ( other , entity ) ) ;
@ -342,7 +341,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -342,7 +341,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-318
public void queryMethodShouldEmitEvents ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
eventListener . events . clear ( ) ;
repository . findAllWithSql ( ) ;
@ -353,7 +352,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -353,7 +352,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-318
public void queryMethodWithCustomRowMapperDoesNotEmitEvents ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
eventListener . events . clear ( ) ;
repository . findAllWithCustomMapper ( ) ;
@ -364,14 +363,14 @@ public class JdbcRepositoryIntegrationTests {
@@ -364,14 +363,14 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-234
public void findAllByQueryName ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
assertThat ( repository . findAllByNamedQuery ( ) ) . hasSize ( 1 ) ;
}
@Test
void findAllByFirstnameWithLock ( ) {
DummyEntity dummyEntity = createDummy Entity ( ) ;
DummyEntity dummyEntity = createEntity ( ) ;
repository . save ( dummyEntity ) ;
assertThat ( repository . findAllByName ( dummyEntity . getName ( ) ) ) . hasSize ( 1 ) ;
}
@ -379,14 +378,14 @@ public class JdbcRepositoryIntegrationTests {
@@ -379,14 +378,14 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1022
public void findAllByCustomQueryName ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
assertThat ( repository . findAllByCustomNamedQuery ( ) ) . hasSize ( 1 ) ;
}
@Test // DATAJDBC-341
public void findWithMissingQuery ( ) {
DummyEntity dummy = repository . save ( createDummy Entity ( ) ) ;
DummyEntity dummy = repository . save ( createEntity ( ) ) ;
DummyEntity loaded = repository . withMissingColumn ( dummy . idProp ) ;
@ -398,7 +397,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -398,7 +397,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-529
public void existsWorksAsExpected ( ) {
DummyEntity dummy = repository . save ( createDummy Entity ( ) ) ;
DummyEntity dummy = repository . save ( createEntity ( ) ) ;
assertSoftly ( softly - > {
@ -414,7 +413,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -414,7 +413,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-604
public void existsInWorksAsExpected ( ) {
DummyEntity dummy = repository . save ( createDummy Entity ( ) ) ;
DummyEntity dummy = repository . save ( createEntity ( ) ) ;
assertSoftly ( softly - > {
@ -430,7 +429,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -430,7 +429,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-604
public void existsNotInWorksAsExpected ( ) {
DummyEntity dummy = repository . save ( createDummy Entity ( ) ) ;
DummyEntity dummy = repository . save ( createEntity ( ) ) ;
assertSoftly ( softly - > {
@ -446,10 +445,10 @@ public class JdbcRepositoryIntegrationTests {
@@ -446,10 +445,10 @@ public class JdbcRepositoryIntegrationTests {
@Test // DATAJDBC-534
public void countByQueryDerivation ( ) {
DummyEntity one = createDummy Entity ( ) ;
DummyEntity two = createDummy Entity ( ) ;
DummyEntity one = createEntity ( ) ;
DummyEntity two = createEntity ( ) ;
two . name = "other" ;
DummyEntity three = createDummy Entity ( ) ;
DummyEntity three = createEntity ( ) ;
repository . saveAll ( asList ( one , two , three ) ) ;
@ -458,7 +457,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -458,7 +457,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-619
public void findBySpElWorksAsExpected ( ) {
DummyEntity r = repository . save ( createDummy Entity ( ) ) ;
DummyEntity r = repository . save ( createEntity ( ) ) ;
// assign the new id to the global ID provider holder; this is similar to Spring Security's SecurityContextHolder
MyIdContextProvider . ExtensionRoot . ID = r . getIdProp ( ) ;
@ -530,7 +529,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -530,7 +529,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-971
public void stringQueryProjectionShouldReturnProjectedEntities ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
List < DummyProjection > result = repository . findProjectedWithSql ( DummyProjection . class ) ;
@ -541,7 +540,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -541,7 +540,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-971
public void stringQueryProjectionShouldReturnDtoProjectedEntities ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
List < DtoProjection > result = repository . findProjectedWithSql ( DtoProjection . class ) ;
@ -552,7 +551,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -552,7 +551,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-971
public void partTreeQueryProjectionShouldReturnProjectedEntities ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
List < DummyProjection > result = repository . findProjectedByName ( "Entity Name" ) ;
@ -563,7 +562,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -563,7 +562,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-971
public void pageQueryProjectionShouldReturnProjectedEntities ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
Page < DummyProjection > result = repository . findPageProjectionByName ( "Entity Name" , PageRequest . ofSize ( 10 ) ) ;
@ -581,8 +580,8 @@ public class JdbcRepositoryIntegrationTests {
@@ -581,8 +580,8 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-908
void derivedQueryWithBooleanLiteralFindsCorrectValues ( ) {
repository . save ( createDummy Entity ( ) ) ;
DummyEntity entity = createDummy Entity ( ) ;
repository . save ( createEntity ( ) ) ;
DummyEntity entity = createEntity ( ) ;
entity . flag = true ;
entity = repository . save ( entity ) ;
@ -594,8 +593,8 @@ public class JdbcRepositoryIntegrationTests {
@@ -594,8 +593,8 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-987
void queryBySimpleReference ( ) {
DummyEntity one = repository . save ( createDummy Entity ( ) ) ;
DummyEntity two = createDummy Entity ( ) ;
DummyEntity one = repository . save ( createEntity ( ) ) ;
DummyEntity two = createEntity ( ) ;
two . ref = AggregateReference . to ( one . idProp ) ;
two = repository . save ( two ) ;
@ -607,8 +606,8 @@ public class JdbcRepositoryIntegrationTests {
@@ -607,8 +606,8 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-987
void queryByAggregateReference ( ) {
DummyEntity one = repository . save ( createDummy Entity ( ) ) ;
DummyEntity two = createDummy Entity ( ) ;
DummyEntity one = repository . save ( createEntity ( ) ) ;
DummyEntity two = createEntity ( ) ;
two . ref = AggregateReference . to ( one . idProp ) ;
two = repository . save ( two ) ;
@ -620,7 +619,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -620,7 +619,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1167
void stringResult ( ) {
repository . save ( createDummy Entity ( ) ) ; // just ensure we have data in the table
repository . save ( createEntity ( ) ) ; // just ensure we have data in the table
assertThat ( repository . returnInput ( "HELLO" ) ) . isEqualTo ( "HELLO" ) ;
}
@ -628,7 +627,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -628,7 +627,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1167
void nullStringResult ( ) {
repository . save ( createDummy Entity ( ) ) ; // just ensure we have data in the table
repository . save ( createEntity ( ) ) ; // just ensure we have data in the table
assertThat ( repository . returnInput ( null ) ) . isNull ( ) ;
}
@ -726,11 +725,11 @@ public class JdbcRepositoryIntegrationTests {
@@ -726,11 +725,11 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void findOneByExampleShouldGetOne ( ) {
DummyEntity dummyEntity1 = createDummy Entity ( ) ;
DummyEntity dummyEntity1 = createEntity ( ) ;
dummyEntity1 . setFlag ( true ) ;
repository . save ( dummyEntity1 ) ;
DummyEntity dummyEntity2 = createDummy Entity ( ) ;
DummyEntity dummyEntity2 = createEntity ( ) ;
dummyEntity2 . setName ( "Diego" ) ;
repository . save ( dummyEntity2 ) ;
@ -743,10 +742,10 @@ public class JdbcRepositoryIntegrationTests {
@@ -743,10 +742,10 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void findOneByExampleMultipleMatchShouldGetOne ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
repository . save ( createEntity ( ) ) ;
Example < DummyEntity > example = Example . of ( createDummy Entity ( ) ) ;
Example < DummyEntity > example = Example . of ( createEntity ( ) ) ;
assertThatThrownBy ( ( ) - > repository . findOne ( example ) ) . isInstanceOf ( IncorrectResultSizeDataAccessException . class )
. hasMessageContaining ( "expected 1, actual 2" ) ;
@ -755,7 +754,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -755,7 +754,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void findOneByExampleShouldGetNone ( ) {
DummyEntity dummyEntity1 = createDummy Entity ( ) ;
DummyEntity dummyEntity1 = createEntity ( ) ;
dummyEntity1 . setFlag ( true ) ;
repository . save ( dummyEntity1 ) ;
@ -769,11 +768,11 @@ public class JdbcRepositoryIntegrationTests {
@@ -769,11 +768,11 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void findAllByExampleShouldGetOne ( ) {
DummyEntity dummyEntity1 = createDummy Entity ( ) ;
DummyEntity dummyEntity1 = createEntity ( ) ;
dummyEntity1 . setFlag ( true ) ;
repository . save ( dummyEntity1 ) ;
DummyEntity dummyEntity2 = createDummy Entity ( ) ;
DummyEntity dummyEntity2 = createEntity ( ) ;
dummyEntity2 . setName ( "Diego" ) ;
repository . save ( dummyEntity2 ) ;
@ -788,10 +787,10 @@ public class JdbcRepositoryIntegrationTests {
@@ -788,10 +787,10 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void findAllByExampleMultipleMatchShouldGetOne ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
repository . save ( createEntity ( ) ) ;
Example < DummyEntity > example = Example . of ( createDummy Entity ( ) ) ;
Example < DummyEntity > example = Example . of ( createEntity ( ) ) ;
Iterable < DummyEntity > allFound = repository . findAll ( example ) ;
@ -804,7 +803,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -804,7 +803,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void findAllByExampleShouldGetNone ( ) {
DummyEntity dummyEntity1 = createDummy Entity ( ) ;
DummyEntity dummyEntity1 = createEntity ( ) ;
dummyEntity1 . setFlag ( true ) ;
repository . save ( dummyEntity1 ) ;
@ -819,12 +818,12 @@ public class JdbcRepositoryIntegrationTests {
@@ -819,12 +818,12 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void findAllByExamplePageableShouldGetOne ( ) {
DummyEntity dummyEntity1 = createDummy Entity ( ) ;
DummyEntity dummyEntity1 = createEntity ( ) ;
dummyEntity1 . setFlag ( true ) ;
repository . save ( dummyEntity1 ) ;
DummyEntity dummyEntity2 = createDummy Entity ( ) ;
DummyEntity dummyEntity2 = createEntity ( ) ;
dummyEntity2 . setName ( "Diego" ) ;
repository . save ( dummyEntity2 ) ;
@ -841,10 +840,10 @@ public class JdbcRepositoryIntegrationTests {
@@ -841,10 +840,10 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void findAllByExamplePageableMultipleMatchShouldGetOne ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
repository . save ( createEntity ( ) ) ;
Example < DummyEntity > example = Example . of ( createDummy Entity ( ) ) ;
Example < DummyEntity > example = Example . of ( createEntity ( ) ) ;
Pageable pageRequest = PageRequest . of ( 0 , 10 ) ;
Iterable < DummyEntity > allFound = repository . findAll ( example , pageRequest ) ;
@ -858,7 +857,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -858,7 +857,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void findAllByExamplePageableShouldGetNone ( ) {
DummyEntity dummyEntity1 = createDummy Entity ( ) ;
DummyEntity dummyEntity1 = createEntity ( ) ;
dummyEntity1 . setFlag ( true ) ;
repository . save ( dummyEntity1 ) ;
@ -874,10 +873,10 @@ public class JdbcRepositoryIntegrationTests {
@@ -874,10 +873,10 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void findAllByExamplePageableOutsidePageShouldGetNone ( ) {
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
repository . save ( createEntity ( ) ) ;
Example < DummyEntity > example = Example . of ( createDummy Entity ( ) ) ;
Example < DummyEntity > example = Example . of ( createEntity ( ) ) ;
Pageable pageRequest = PageRequest . of ( 10 , 10 ) ;
Iterable < DummyEntity > allFound = repository . findAll ( example , pageRequest ) ;
@ -892,14 +891,14 @@ public class JdbcRepositoryIntegrationTests {
@@ -892,14 +891,14 @@ public class JdbcRepositoryIntegrationTests {
void findAllByExamplePageable ( Pageable pageRequest , int size , int totalPages , List < String > notContains ) {
for ( int i = 0 ; i < 100 ; i + + ) {
DummyEntity dummyEntity = createDummy Entity ( ) ;
DummyEntity dummyEntity = createEntity ( ) ;
dummyEntity . setFlag ( true ) ;
dummyEntity . setName ( "" + i ) ;
repository . save ( dummyEntity ) ;
}
DummyEntity dummyEntityExample = createDummy Entity ( ) ;
DummyEntity dummyEntityExample = createEntity ( ) ;
dummyEntityExample . setName ( null ) ;
dummyEntityExample . setFlag ( true ) ;
@ -939,11 +938,11 @@ public class JdbcRepositoryIntegrationTests {
@@ -939,11 +938,11 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void existsByExampleShouldGetOne ( ) {
DummyEntity dummyEntity1 = createDummy Entity ( ) ;
DummyEntity dummyEntity1 = createEntity ( ) ;
dummyEntity1 . setFlag ( true ) ;
repository . save ( dummyEntity1 ) ;
DummyEntity dummyEntity2 = createDummy Entity ( ) ;
DummyEntity dummyEntity2 = createEntity ( ) ;
dummyEntity2 . setName ( "Diego" ) ;
repository . save ( dummyEntity2 ) ;
@ -957,13 +956,13 @@ public class JdbcRepositoryIntegrationTests {
@@ -957,13 +956,13 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void existsByExampleMultipleMatchShouldGetOne ( ) {
DummyEntity dummyEntity1 = createDummy Entity ( ) ;
DummyEntity dummyEntity1 = createEntity ( ) ;
repository . save ( dummyEntity1 ) ;
DummyEntity dummyEntity2 = createDummy Entity ( ) ;
DummyEntity dummyEntity2 = createEntity ( ) ;
repository . save ( dummyEntity2 ) ;
Example < DummyEntity > example = Example . of ( createDummy Entity ( ) ) ;
Example < DummyEntity > example = Example . of ( createEntity ( ) ) ;
boolean exists = repository . exists ( example ) ;
assertThat ( exists ) . isTrue ( ) ;
@ -972,7 +971,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -972,7 +971,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void existsByExampleShouldGetNone ( ) {
DummyEntity dummyEntity1 = createDummy Entity ( ) ;
DummyEntity dummyEntity1 = createEntity ( ) ;
dummyEntity1 . setFlag ( true ) ;
repository . save ( dummyEntity1 ) ;
@ -989,14 +988,14 @@ public class JdbcRepositoryIntegrationTests {
@@ -989,14 +988,14 @@ public class JdbcRepositoryIntegrationTests {
Instant pointInTime = Instant . now ( ) . truncatedTo ( ChronoUnit . MILLIS ) . minusSeconds ( 10000 ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
DummyEntity two = createDummy Entity ( ) ;
DummyEntity two = createEntity ( ) ;
two . setName ( "Diego" ) ;
two . setPointInTime ( pointInTime ) ;
repository . save ( two ) ;
DummyEntity exampleEntitiy = createDummy Entity ( ) ;
DummyEntity exampleEntitiy = createEntity ( ) ;
exampleEntitiy . setName ( "Diego" ) ;
exampleEntitiy . setPointInTime ( pointInTime ) ;
@ -1009,12 +1008,12 @@ public class JdbcRepositoryIntegrationTests {
@@ -1009,12 +1008,12 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void countByExampleShouldGetOne ( ) {
DummyEntity dummyEntity1 = createDummy Entity ( ) ;
DummyEntity dummyEntity1 = createEntity ( ) ;
dummyEntity1 . setFlag ( true ) ;
repository . save ( dummyEntity1 ) ;
DummyEntity dummyEntity2 = createDummy Entity ( ) ;
DummyEntity dummyEntity2 = createEntity ( ) ;
dummyEntity2 . setName ( "Diego" ) ;
repository . save ( dummyEntity2 ) ;
@ -1029,13 +1028,13 @@ public class JdbcRepositoryIntegrationTests {
@@ -1029,13 +1028,13 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void countByExampleMultipleMatchShouldGetOne ( ) {
DummyEntity dummyEntity1 = createDummy Entity ( ) ;
DummyEntity dummyEntity1 = createEntity ( ) ;
repository . save ( dummyEntity1 ) ;
DummyEntity dummyEntity2 = createDummy Entity ( ) ;
DummyEntity dummyEntity2 = createEntity ( ) ;
repository . save ( dummyEntity2 ) ;
Example < DummyEntity > example = Example . of ( createDummy Entity ( ) ) ;
Example < DummyEntity > example = Example . of ( createEntity ( ) ) ;
long count = repository . count ( example ) ;
assertThat ( count ) . isEqualTo ( 2 ) ;
@ -1044,7 +1043,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -1044,7 +1043,7 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1192
void countByExampleShouldGetNone ( ) {
DummyEntity dummyEntity1 = createDummy Entity ( ) ;
DummyEntity dummyEntity1 = createEntity ( ) ;
dummyEntity1 . setFlag ( true ) ;
repository . save ( dummyEntity1 ) ;
@ -1060,14 +1059,14 @@ public class JdbcRepositoryIntegrationTests {
@@ -1060,14 +1059,14 @@ public class JdbcRepositoryIntegrationTests {
void countByExampleComplex ( ) {
Instant pointInTime = Instant . now ( ) . minusSeconds ( 10000 ) . truncatedTo ( ChronoUnit . MILLIS ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
DummyEntity two = createDummy Entity ( ) ;
DummyEntity two = createEntity ( ) ;
two . setName ( "Diego" ) ;
two . setPointInTime ( pointInTime ) ;
repository . save ( two ) ;
DummyEntity exampleEntitiy = createDummy Entity ( ) ;
DummyEntity exampleEntitiy = createEntity ( ) ;
exampleEntitiy . setName ( "Diego" ) ;
exampleEntitiy . setPointInTime ( pointInTime ) ;
@ -1083,7 +1082,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -1083,7 +1082,7 @@ public class JdbcRepositoryIntegrationTests {
String searchName = "Diego" ;
Instant now = Instant . now ( ) . truncatedTo ( ChronoUnit . MILLIS ) ;
DummyEntity two = createDummy Entity ( ) ;
DummyEntity two = createEntity ( ) ;
two . setName ( searchName ) ;
two . setPointInTime ( now . minusSeconds ( 10000 ) ) ;
@ -1092,7 +1091,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -1092,7 +1091,7 @@ public class JdbcRepositoryIntegrationTests {
// I'm looking at you MariaDb.
two = repository . findById ( two . idProp ) . orElseThrow ( ) ;
DummyEntity third = createDummy Entity ( ) ;
DummyEntity third = createEntity ( ) ;
third . setName ( searchName ) ;
third . setPointInTime ( now . minusSeconds ( 200000 ) ) ;
third = repository . save ( third ) ;
@ -1100,7 +1099,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -1100,7 +1099,7 @@ public class JdbcRepositoryIntegrationTests {
// I'm looking at you MariaDb.
third = repository . findById ( third . idProp ) . orElseThrow ( ) ;
DummyEntity exampleEntitiy = createDummy Entity ( ) ;
DummyEntity exampleEntitiy = createEntity ( ) ;
exampleEntitiy . setName ( searchName ) ;
Example < DummyEntity > example = Example . of ( exampleEntitiy ) ;
@ -1151,20 +1150,20 @@ public class JdbcRepositoryIntegrationTests {
@@ -1151,20 +1150,20 @@ public class JdbcRepositoryIntegrationTests {
String searchName = "Diego" ;
Instant now = Instant . now ( ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
DummyEntity two = createDummy Entity ( ) ;
DummyEntity two = createEntity ( ) ;
two . setName ( searchName ) ;
two . setPointInTime ( now . minusSeconds ( 10000 ) ) ;
repository . save ( two ) ;
DummyEntity third = createDummy Entity ( ) ;
DummyEntity third = createEntity ( ) ;
third . setName ( searchName ) ;
third . setPointInTime ( now . minusSeconds ( 200000 ) ) ;
repository . save ( third ) ;
DummyEntity exampleEntitiy = createDummy Entity ( ) ;
DummyEntity exampleEntitiy = createEntity ( ) ;
exampleEntitiy . setName ( searchName ) ;
Example < DummyEntity > example = Example . of ( exampleEntitiy ) ;
@ -1179,9 +1178,9 @@ public class JdbcRepositoryIntegrationTests {
@@ -1179,9 +1178,9 @@ public class JdbcRepositoryIntegrationTests {
String searchName = "Diego" ;
Instant now = Instant . now ( ) . truncatedTo ( ChronoUnit . MILLIS ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
DummyEntity two = createDummy Entity ( ) ;
DummyEntity two = createEntity ( ) ;
two . setName ( searchName ) ;
two . setPointInTime ( now . minusSeconds ( 10000 ) ) ;
@ -1190,12 +1189,12 @@ public class JdbcRepositoryIntegrationTests {
@@ -1190,12 +1189,12 @@ public class JdbcRepositoryIntegrationTests {
// I'm looking at you MariaDb.
two = repository . findById ( two . idProp ) . orElseThrow ( ) ;
DummyEntity third = createDummy Entity ( ) ;
DummyEntity third = createEntity ( ) ;
third . setName ( searchName ) ;
third . setPointInTime ( now . minusSeconds ( 200000 ) ) ;
repository . save ( third ) ;
DummyEntity exampleEntity = createDummy Entity ( ) ;
DummyEntity exampleEntity = createEntity ( ) ;
exampleEntity . setName ( searchName ) ;
Example < DummyEntity > example = Example . of ( exampleEntity ) ;
@ -1212,19 +1211,19 @@ public class JdbcRepositoryIntegrationTests {
@@ -1212,19 +1211,19 @@ public class JdbcRepositoryIntegrationTests {
String searchName = "Diego" ;
Instant now = Instant . now ( ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
DummyEntity two = createDummy Entity ( ) ;
DummyEntity two = createEntity ( ) ;
two . setName ( searchName ) ;
two . setPointInTime ( now . minusSeconds ( 10000 ) ) ;
repository . save ( two ) ;
DummyEntity third = createDummy Entity ( ) ;
DummyEntity third = createEntity ( ) ;
third . setName ( searchName ) ;
third . setPointInTime ( now . minusSeconds ( 200000 ) ) ;
repository . save ( third ) ;
DummyEntity exampleEntitiy = createDummy Entity ( ) ;
DummyEntity exampleEntitiy = createEntity ( ) ;
exampleEntitiy . setName ( searchName ) ;
Example < DummyEntity > example = Example . of ( exampleEntitiy ) ;
@ -1239,9 +1238,9 @@ public class JdbcRepositoryIntegrationTests {
@@ -1239,9 +1238,9 @@ public class JdbcRepositoryIntegrationTests {
String searchName = "Diego" ;
Instant now = Instant . now ( ) . truncatedTo ( ChronoUnit . MILLIS ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
DummyEntity two = createDummy Entity ( ) ;
DummyEntity two = createEntity ( ) ;
two . setName ( searchName ) ;
two . setPointInTime ( now . minusSeconds ( 10000 ) ) ;
two = repository . save ( two ) ;
@ -1249,7 +1248,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -1249,7 +1248,7 @@ public class JdbcRepositoryIntegrationTests {
// I'm looking at you MariaDb.
two = repository . findById ( two . idProp ) . orElseThrow ( ) ;
DummyEntity exampleEntitiy = createDummy Entity ( ) ;
DummyEntity exampleEntitiy = createEntity ( ) ;
exampleEntitiy . setName ( searchName ) ;
Example < DummyEntity > example = Example . of ( exampleEntitiy ) ;
@ -1265,14 +1264,14 @@ public class JdbcRepositoryIntegrationTests {
@@ -1265,14 +1264,14 @@ public class JdbcRepositoryIntegrationTests {
String searchName = "Diego" ;
Instant now = Instant . now ( ) ;
repository . save ( createDummy Entity ( ) ) ;
repository . save ( createEntity ( ) ) ;
DummyEntity two = createDummy Entity ( ) ;
DummyEntity two = createEntity ( ) ;
two . setName ( searchName ) ;
two . setPointInTime ( now . minusSeconds ( 10000 ) ) ;
two = repository . save ( two ) ;
DummyEntity exampleEntity = createDummy Entity ( ) ;
DummyEntity exampleEntity = createEntity ( ) ;
exampleEntity . setName ( searchName ) ;
Example < DummyEntity > example = Example . of ( exampleEntity ) ;
@ -1333,9 +1332,9 @@ public class JdbcRepositoryIntegrationTests {
@@ -1333,9 +1332,9 @@ public class JdbcRepositoryIntegrationTests {
@EnabledOnFeature ( TestDatabaseFeatures . Feature . WHERE_IN_TUPLE )
void queryWithTupleIn ( ) {
DummyEntity one = repository . save ( createDummy Entity ( "one" ) ) ;
DummyEntity two = repository . save ( createDummy Entity ( "two" ) ) ;
DummyEntity three = repository . save ( createDummy Entity ( "three" ) ) ;
DummyEntity one = repository . save ( createEntity ( "one" ) ) ;
DummyEntity two = repository . save ( createEntity ( "two" ) ) ;
DummyEntity three = repository . save ( createEntity ( "three" ) ) ;
List < Object [ ] > tuples = List . of ( new Object [ ] { two . idProp , "two" } , // matches "two"
new Object [ ] { three . idProp , "two" } // matches nothing
@ -1349,22 +1348,12 @@ public class JdbcRepositoryIntegrationTests {
@@ -1349,22 +1348,12 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1900
void queryByListOfByteArray ( ) {
byte [ ] oneBytes = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } ;
DummyEntity one = createDummyEntity ( "one" ) ;
one . setBytes ( oneBytes ) ;
one = repository . save ( one ) ;
byte [ ] twoBytes = { 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 } ;
DummyEntity two = createDummyEntity ( "two" ) ;
two . setBytes ( twoBytes ) ;
two = repository . save ( two ) ;
DummyEntity one = repository . save ( createEntity ( "one" , it - > it . setBytes ( new byte [ ] { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } ) ) ) ;
DummyEntity two = repository . save ( createEntity ( "two" , it - > it . setBytes ( new byte [ ] { 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 } ) ) ) ;
DummyEntity three = repository
. save ( createEntity ( "three" , it - > it . setBytes ( new byte [ ] { 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 } ) ) ) ;
byte [ ] threeBytes = { 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 } ;
DummyEntity three = createDummyEntity ( "three" ) ;
three . setBytes ( threeBytes ) ;
three = repository . save ( three ) ;
List < DummyEntity > result = repository . findByBytesIn ( List . of ( threeBytes , oneBytes ) ) ;
List < DummyEntity > result = repository . findByBytesIn ( List . of ( three . getBytes ( ) , one . getBytes ( ) ) ) ;
assertThat ( result ) . extracting ( "idProp" ) . containsExactlyInAnyOrder ( one . idProp , three . idProp ) ;
}
@ -1372,22 +1361,12 @@ public class JdbcRepositoryIntegrationTests {
@@ -1372,22 +1361,12 @@ public class JdbcRepositoryIntegrationTests {
@Test // GH-1900
void queryByByteArray ( ) {
byte [ ] oneBytes = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } ;
DummyEntity one = createDummyEntity ( "one" ) ;
one . setBytes ( oneBytes ) ;
one = repository . save ( one ) ;
byte [ ] twoBytes = { 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 } ;
DummyEntity two = createDummyEntity ( "two" ) ;
two . setBytes ( twoBytes ) ;
two = repository . save ( two ) ;
byte [ ] threeBytes = { 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 } ;
DummyEntity three = createDummyEntity ( "three" ) ;
three . setBytes ( threeBytes ) ;
three = repository . save ( three ) ;
DummyEntity one = repository . save ( createEntity ( "one" , it - > it . setBytes ( new byte [ ] { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } ) ) ) ;
DummyEntity two = repository . save ( createEntity ( "two" , it - > it . setBytes ( new byte [ ] { 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 } ) ) ) ;
DummyEntity three = repository
. save ( createEntity ( "three" , it - > it . setBytes ( new byte [ ] { 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 } ) ) ) ;
List < DummyEntity > result = repository . findByBytes ( twoBytes ) ;
List < DummyEntity > result = repository . findByBytes ( two . getBytes ( ) ) ;
assertThat ( result ) . extracting ( "idProp" ) . containsExactly ( two . idProp ) ;
}
@ -1419,7 +1398,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -1419,7 +1398,7 @@ public class JdbcRepositoryIntegrationTests {
Instant now = Instant . now ( ) ;
DummyEntity first = createDummy Entity ( ) ;
DummyEntity first = createEntity ( ) ;
Instant earlier = now . minusSeconds ( 1000L ) ;
OffsetDateTime earlierPlus3 = earlier . atOffset ( ZoneOffset . ofHours ( 3 ) ) ;
first . setPointInTime ( earlier ) ;
@ -1427,7 +1406,7 @@ public class JdbcRepositoryIntegrationTests {
@@ -1427,7 +1406,7 @@ public class JdbcRepositoryIntegrationTests {
first . setName ( "first" ) ;
DummyEntity second = createDummy Entity ( ) ;
DummyEntity second = createEntity ( ) ;
Instant later = now . plusSeconds ( 1000L ) ;
OffsetDateTime laterPlus3 = later . atOffset ( ZoneOffset . ofHours ( 3 ) ) ;
second . setPointInTime ( later ) ;
@ -1842,6 +1821,24 @@ public class JdbcRepositoryIntegrationTests {
@@ -1842,6 +1821,24 @@ public class JdbcRepositoryIntegrationTests {
}
}
private static DummyEntity createEntity ( ) {
return createEntity ( "Entity Name" ) ;
}
private static DummyEntity createEntity ( String entityName ) {
return createEntity ( entityName , it - > { } ) ;
}
private static DummyEntity createEntity ( String entityName , Consumer < DummyEntity > customizer ) {
DummyEntity entity = new DummyEntity ( ) ;
entity . setName ( entityName ) ;
customizer . accept ( entity ) ;
return entity ;
}
static class DummyEntity {
String name ;
@ -1936,6 +1933,10 @@ public class JdbcRepositoryIntegrationTests {
@@ -1936,6 +1933,10 @@ public class JdbcRepositoryIntegrationTests {
this . bytes = bytes ;
}
public byte [ ] getBytes ( ) {
return bytes ;
}
@Override
public String toString ( ) {
return "DummyEntity{" + "name='" + name + '\'' + ", idProp=" + idProp + '}' ;