diff --git a/pom.xml b/pom.xml
index d320b6d..be0ccda 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,13 +9,13 @@
com.sipios
spring-search
- 0.2.4
+ 0.2.5
spring-search
API for generating spring boot database queries
1.8
- 1.4.10
+ 1.6.20
4.9
com.sipios.springsearch.grammar
com/sipios/springsearch/grammar
diff --git a/src/main/kotlin/com/sipios/springsearch/strategies/InstantStrategy.kt b/src/main/kotlin/com/sipios/springsearch/strategies/InstantStrategy.kt
new file mode 100644
index 0000000..5010a40
--- /dev/null
+++ b/src/main/kotlin/com/sipios/springsearch/strategies/InstantStrategy.kt
@@ -0,0 +1,28 @@
+package com.sipios.springsearch.strategies
+
+import com.sipios.springsearch.SearchOperation
+import java.time.Instant
+import javax.persistence.criteria.CriteriaBuilder
+import javax.persistence.criteria.Path
+import javax.persistence.criteria.Predicate
+import kotlin.reflect.KClass
+
+class InstantStrategy : ParsingStrategy {
+ override fun buildPredicate(
+ builder: CriteriaBuilder,
+ path: Path<*>,
+ fieldName: String,
+ ops: SearchOperation?,
+ value: Any?
+ ): Predicate? {
+ return when (ops) {
+ SearchOperation.GREATER_THAN -> builder.greaterThan(path.get(fieldName), value as Instant)
+ SearchOperation.LESS_THAN -> builder.lessThan(path.get(fieldName), value as Instant)
+ else -> super.buildPredicate(builder, path, fieldName, ops, value)
+ }
+ }
+
+ override fun parse(value: String?, fieldClass: KClass): Any? {
+ return Instant.parse(value)
+ }
+}
diff --git a/src/main/kotlin/com/sipios/springsearch/strategies/ParsingStrategy.kt b/src/main/kotlin/com/sipios/springsearch/strategies/ParsingStrategy.kt
index 28aedf7..739adb9 100644
--- a/src/main/kotlin/com/sipios/springsearch/strategies/ParsingStrategy.kt
+++ b/src/main/kotlin/com/sipios/springsearch/strategies/ParsingStrategy.kt
@@ -3,6 +3,7 @@ package com.sipios.springsearch.strategies
import com.sipios.springsearch.SearchOperation
import com.sipios.springsearch.anotation.SearchSpec
import java.time.Duration
+import java.time.Instant
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
@@ -72,6 +73,7 @@ interface ParsingStrategy {
fieldClass == LocalDate::class -> LocalDateStrategy()
fieldClass == LocalTime::class -> LocalTimeStrategy()
fieldClass == LocalDateTime::class -> LocalDateTimeStrategy()
+ fieldClass == Instant::class -> InstantStrategy()
fieldClass == UUID::class -> UUIDStrategy()
else -> StringStrategy(searchSpecAnnotation)
}
diff --git a/src/test/kotlin/com/sipios/springsearch/SpringSearchApplicationTest.kt b/src/test/kotlin/com/sipios/springsearch/SpringSearchApplicationTest.kt
index e0d0df4..44adefb 100644
--- a/src/test/kotlin/com/sipios/springsearch/SpringSearchApplicationTest.kt
+++ b/src/test/kotlin/com/sipios/springsearch/SpringSearchApplicationTest.kt
@@ -3,6 +3,7 @@ package com.sipios.springsearch
import com.fasterxml.jackson.databind.util.StdDateFormat
import com.sipios.springsearch.anotation.SearchSpec
import java.time.Duration
+import java.time.Instant
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
@@ -20,7 +21,8 @@ class SpringSearchApplicationTest {
lateinit var userRepository: UsersRepository
@Test
- fun run() {}
+ fun run() {
+ }
@Test
fun canAddUsers() {
@@ -34,7 +36,9 @@ class SpringSearchApplicationTest {
val userId = userRepository.save(Users()).userId
userRepository.save(Users())
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userId:$userId").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userId:$userId").build()
Assertions.assertEquals(userId, userRepository.findAll(specification).get(0).userId)
}
@@ -43,7 +47,9 @@ class SpringSearchApplicationTest {
val aliceId = userRepository.save(Users(userFirstName = "Alice")).userId
userRepository.save(Users(userFirstName = "Bob"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:Alice").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:Alice").build()
Assertions.assertEquals(aliceId, userRepository.findAll(specification).get(0).userId)
}
@@ -54,7 +60,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "Bob", userLastName = "One"))
userRepository.save(Users(userFirstName = "Bob", userLastName = "Two"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:Alice AND userLastName:One").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:Alice AND userLastName:One").build()
Assertions.assertEquals(aliceId, userRepository.findAll(specification).get(0).userId)
}
@@ -62,7 +70,9 @@ class SpringSearchApplicationTest {
fun canGetUserWithFrenchName() {
val edouardProstId = userRepository.save(Users(userFirstName = "Édouard", userLastName = "Pröst")).userId
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:Édouard AND userLastName:Pröst").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:Édouard AND userLastName:Pröst").build()
Assertions.assertEquals(edouardProstId, userRepository.findAll(specification).get(0).userId)
}
@@ -70,7 +80,9 @@ class SpringSearchApplicationTest {
fun canGetUserWithChineseName() {
val sunDemingId = userRepository.save(Users(userFirstName = "孫德明")).userId
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:孫德明").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:孫德明").build()
Assertions.assertEquals(sunDemingId, userRepository.findAll(specification).get(0).userId)
}
@@ -78,7 +90,9 @@ class SpringSearchApplicationTest {
fun canGetUserWithChineseNameNoEncoding() {
val sunDemingId = userRepository.save(Users(userFirstName = "孫德明")).userId
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:孫德明").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:孫德明").build()
Assertions.assertEquals(sunDemingId, userRepository.findAll(specification).get(0).userId)
}
@@ -86,7 +100,9 @@ class SpringSearchApplicationTest {
fun canGetUserWithSpecialCharactersName() {
val hackermanId = userRepository.save(Users(userFirstName = "&@#*\"''^^^\$``%=+§__hack3rman__")).userId
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:&@#*\"''^^^\$``%=+§__hack3rman__").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:&@#*\"''^^^\$``%=+§__hack3rman__").build()
Assertions.assertEquals(hackermanId, userRepository.findAll(specification).get(0).userId)
}
@@ -94,7 +110,9 @@ class SpringSearchApplicationTest {
fun canGetUserWithSpaceInNameWithString() {
val robertJuniorId = userRepository.save(Users(userFirstName = "robert junior")).userId
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:'robert junior'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:'robert junior'").build()
Assertions.assertEquals(robertJuniorId, userRepository.findAll(specification).get(0).userId)
}
@@ -105,7 +123,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "robot"))
userRepository.save(Users(userFirstName = "röbert"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:robe*").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:robe*").build()
val robeUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(robertId, robertaId) == robeUsers.map { user -> user.userId }.toSet())
}
@@ -117,7 +137,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "robot"))
userRepository.save(Users(userFirstName = "röbęrt"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:*ert").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:*ert").build()
val robeUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(robertId, robertaId) == robeUsers.map { user -> user.userId }.toSet())
}
@@ -129,7 +151,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "robot"))
userRepository.save(Users(userFirstName = "röb*rt"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:rob**").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:rob**").build()
val robeUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(robertId, robertaId) == robeUsers.map { user -> user.userId }.toSet())
}
@@ -143,9 +167,18 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "Robot"))
userRepository.save(Users(userFirstName = "Röbert"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:*obe*").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:*obe*").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(robertId, robertaId, toborobeId, obertaId) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ robertId,
+ robertaId,
+ toborobeId,
+ obertaId
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -157,9 +190,18 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "robot"))
userRepository.save(Users(userFirstName = "röb*rt"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:*ob**").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:*ob**").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(robertId, robertaId, lobertaId, tobertaId) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ robertId,
+ robertaId,
+ lobertaId,
+ tobertaId
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -171,9 +213,18 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "robot"))
userRepository.save(Users(userFirstName = "röb*rt"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:'*ob**'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:'*ob**'").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(robertId, robertaId, lobertaId, tobertaId) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ robertId,
+ robertaId,
+ lobertaId,
+ tobertaId
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -185,9 +236,18 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "robot"))
userRepository.save(Users(userFirstName = "röb*rt"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName:\"*ob**\"").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName:\"*ob**\"").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(robertId, robertaId, lobertaId, tobertaId) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ robertId,
+ robertaId,
+ lobertaId,
+ tobertaId
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -199,9 +259,18 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "Robèrt")).userId
userRepository.save(Users(userFirstName = "robèrta")).userId
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName!*è*").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName!*è*").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(lobertaId, tobertaId, robotId, roobertId) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ lobertaId,
+ tobertaId,
+ robotId,
+ roobertId
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -211,7 +280,9 @@ class SpringSearchApplicationTest {
val bobId = userRepository.save(Users(userFirstName = "bob")).userId
userRepository.save(Users(userFirstName = "Bob"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName!B*").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName!B*").build()
val specificationUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(aliceId, aliceId2, bobId) == specificationUsers.map { user -> user.userId }.toSet())
}
@@ -223,7 +294,9 @@ class SpringSearchApplicationTest {
val boBId = userRepository.save(Users(userFirstName = "boB")).userId
userRepository.save(Users(userFirstName = "alice"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userFirstName!*e").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userFirstName!*e").build()
val specificationUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(boBId, alicEId, bobId) == specificationUsers.map { user -> user.userId }.toSet())
}
@@ -238,9 +311,17 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userChildrenNumber = 4))
userRepository.save(Users(userChildrenNumber = 2))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userChildrenNumber>4").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userChildrenNumber>4").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(user2With5ChildrenId, userWith5ChildrenId, userWith6ChildrenId) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ user2With5ChildrenId,
+ userWith5ChildrenId,
+ userWith6ChildrenId
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -253,9 +334,17 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userChildrenNumber = 4))
val user2With2ChildrenId = userRepository.save(Users(userChildrenNumber = 2)).userId
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userChildrenNumber<4").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userChildrenNumber<4").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(user2With2ChildrenId, userWith1ChildrenId, userWith2ChildrenId) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ user2With2ChildrenId,
+ userWith1ChildrenId,
+ userWith2ChildrenId
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -270,9 +359,17 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userChildrenNumber = 2))
userRepository.save(Users(userChildrenNumber = 5))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userChildrenNumber:4").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userChildrenNumber:4").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(user1With4ChildrenId, user2With4ChildrenId, user3With4ChildrenId) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ user1With4ChildrenId,
+ user2With4ChildrenId,
+ user3With4ChildrenId
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -283,9 +380,17 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userChildrenNumber = 2))
userRepository.save(Users(userChildrenNumber = 2))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userChildrenNumber!2").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userChildrenNumber!2").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(userWith1ChildId, userWith5ChildrenId, userWith6ChildrenId) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ userWith1ChildId,
+ userWith5ChildrenId,
+ userWith6ChildrenId
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -296,9 +401,16 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userSalary = 2550.7F))
userRepository.save(Users(userSalary = 2300.0F))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userSalary<2300").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userSalary<2300").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(smallerSalaryUserId, smallerSalaryUser2Id) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ smallerSalaryUserId,
+ smallerSalaryUser2Id
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -308,9 +420,16 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userSalary = 2323.3F))
userRepository.save(Users(userSalary = 1500.2F))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userSalary>4000.001").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userSalary>4000.001").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(higherSalaryUserId, higherSalaryUser2Id) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ higherSalaryUserId,
+ higherSalaryUser2Id
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -320,7 +439,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userSalary = 4000.1F))
userRepository.save(Users(userSalary = 5350.7F))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userSalary<4000.1 AND userSalary>1500.2").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userSalary<4000.1 AND userSalary>1500.2").build()
val specificationUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(medianUserId) == specificationUsers.map { user -> user.userId }.toSet())
}
@@ -331,7 +452,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userAgeInSeconds = 23222223.2))
userRepository.save(Users(userAgeInSeconds = 23222223.0))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userAgeInSeconds>23222223.2").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userAgeInSeconds>23222223.2").build()
val specificationUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(olderUserId) == specificationUsers.map { user -> user.userId }.toSet())
}
@@ -342,7 +465,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userAgeInSeconds = 23222223.2))
userRepository.save(Users(userAgeInSeconds = 23222223.3))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userAgeInSeconds<23222223.2").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userAgeInSeconds<23222223.2").build()
val specificationUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(youngerUserId) == specificationUsers.map { user -> user.userId }.toSet())
}
@@ -353,7 +478,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userAgeInSeconds = 23222223.3))
userRepository.save(Users(userAgeInSeconds = 23222223.0))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userAgeInSeconds:23222223.2").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userAgeInSeconds:23222223.2").build()
val specificationUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(middleUserId) == specificationUsers.map { user -> user.userId }.toSet())
}
@@ -367,9 +494,16 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userSalary = 1500.1F, userLastName = "Three"))
userRepository.save(Users(userSalary = 1500.2F, userLastName = "Three"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userSalary>1500.1 AND ( userLastName:One OR userLastName:Two )").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userSalary>1500.1 AND ( userLastName:One OR userLastName:Two )").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(userOneWithHigherSalaryId, userTwoWithHigherSalaryId) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ userOneWithHigherSalaryId,
+ userTwoWithHigherSalaryId
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -381,9 +515,16 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userSalary = 1501F, userLastName = "O n e"))
userRepository.save(Users(userSalary = 1502F, userLastName = "One"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userSalary<1502 AND ( ( userLastName:One OR userLastName:one ) OR userLastName!*n* )").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userSalary<1502 AND ( ( userLastName:One OR userLastName:one ) OR userLastName!*n* )").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(userOneWithSmallerSalaryId, userOeId) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ userOneWithSmallerSalaryId,
+ userOeId
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -395,9 +536,16 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userSalary = 1501F, userLastName = "O n e"))
userRepository.save(Users(userSalary = 1502F, userLastName = "One"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("userSalary<1502 AND ((userLastName:One OR userLastName:one) OR userLastName!*n*)").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("userSalary<1502 AND ((userLastName:One OR userLastName:one) OR userLastName!*n*)").build()
val specificationUsers = userRepository.findAll(specification)
- Assertions.assertTrue(setOf(userOneWithSmallerSalaryId, userOeId) == specificationUsers.map { user -> user.userId }.toSet())
+ Assertions.assertTrue(
+ setOf(
+ userOneWithSmallerSalaryId,
+ userOeId
+ ) == specificationUsers.map { user -> user.userId }.toSet()
+ )
}
@Test
@@ -405,7 +553,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(isAdmin = true))
userRepository.save(Users(isAdmin = false))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("isAdmin:true").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("isAdmin:true").build()
val specificationUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, specificationUsers.size)
}
@@ -416,7 +566,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(createdAt = sdf.parse("2019-01-01")))
userRepository.save(Users(createdAt = sdf.parse("2019-01-03")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("createdAt<'2019-01-02'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("createdAt<'2019-01-02'").build()
val specificationUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, specificationUsers.size)
}
@@ -427,11 +579,15 @@ class SpringSearchApplicationTest {
userRepository.save(Users(createdAt = sdf.parse("2019-01-01")))
userRepository.save(Users(createdAt = sdf.parse("2019-01-03")))
- var specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("createdAt>'2019-01-02'").build()
+ var specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("createdAt>'2019-01-02'").build()
var specificationUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, specificationUsers.size)
- specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("createdAt>'2019-01-04'").build()
+ specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("createdAt>'2019-01-04'").build()
specificationUsers = userRepository.findAll(specification)
Assertions.assertEquals(0, specificationUsers.size)
}
@@ -442,7 +598,9 @@ class SpringSearchApplicationTest {
val date = sdf.parse("2019-01-01")
userRepository.save(Users(createdAt = date))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("createdAt:'${sdf.format(date)}'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("createdAt:'${sdf.format(date)}'").build()
val specificationUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, specificationUsers.size)
}
@@ -453,7 +611,9 @@ class SpringSearchApplicationTest {
val date = sdf.parse("2019-01-01")
userRepository.save(Users(createdAt = date))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", true)).withSearch("createdAt!'2019-01-02'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", true)
+ ).withSearch("createdAt!'2019-01-02'").build()
val specificationUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, specificationUsers.size)
}
@@ -465,7 +625,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "robot"))
userRepository.save(Users(userFirstName = "röbęrt"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("userFirstName:robe*").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("userFirstName:robe*").build()
val robeUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(robertId, robertaId) == robeUsers.map { user -> user.userId }.toSet())
}
@@ -477,7 +639,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "robot"))
userRepository.save(Users(userFirstName = "röbęrt"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("userFirstName:*ert").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("userFirstName:*ert").build()
val robeUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(robertId, roubertId) == robeUsers.map { user -> user.userId }.toSet())
}
@@ -489,7 +653,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "robot"))
userRepository.save(Users(userFirstName = "röbęrt"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("userFirstName:*er*").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("userFirstName:*er*").build()
val robeUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(robertId, roubertId) == robeUsers.map { user -> user.userId }.toSet())
}
@@ -500,7 +666,9 @@ class SpringSearchApplicationTest {
val roubertId = userRepository.save(Users(userFirstName = "roubert")).userId
userRepository.save(Users(userFirstName = "robot"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("userFirstName!*rob*").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("userFirstName!*rob*").build()
val robeUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(roubertId) == robeUsers.map { user -> user.userId }.toSet())
}
@@ -511,7 +679,9 @@ class SpringSearchApplicationTest {
val roubertId = userRepository.save(Users(userFirstName = "roubert")).userId
userRepository.save(Users(userFirstName = "robot"))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("userFirstName!rob*").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("userFirstName!rob*").build()
val robeUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(roubertId) == robeUsers.map { user -> user.userId }.toSet())
}
@@ -522,7 +692,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "roubert"))
val robotId = userRepository.save(Users(userFirstName = "robot")).userId
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("userFirstName!*rt").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("userFirstName!*rt").build()
val robotUsers = userRepository.findAll(specification)
Assertions.assertTrue(setOf(robotId) == robotUsers.map { user -> user.userId }.toSet())
}
@@ -534,7 +706,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "Ireh", type = UserType.TEAM_MEMBER))
userRepository.save(Users(userFirstName = "robot", type = UserType.ADMINISTRATOR))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("type:ADMINISTRATOR").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("type:ADMINISTRATOR").build()
val robeUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, robeUsers.size)
Assertions.assertEquals("robot", robeUsers[0].userFirstName)
@@ -546,7 +720,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "Ireh", type = UserType.ADMINISTRATOR))
userRepository.save(Users(userFirstName = "robot", type = UserType.TEAM_MEMBER))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("type!TEAM_MEMBER").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("type!TEAM_MEMBER").build()
val irehUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, irehUsers.size)
Assertions.assertEquals("Ireh", irehUsers[0].userFirstName)
@@ -557,7 +733,27 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", updatedAt = LocalDateTime.parse("2020-01-10T10:15:30")))
userRepository.save(Users(userFirstName = "robot", updatedAt = LocalDateTime.parse("2020-01-11T10:20:30")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("updatedAt>'2020-01-11T09:20:30'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("updatedAt>'2020-01-11T09:20:30'").build()
+ val robotUsers = userRepository.findAll(specification)
+ Assertions.assertEquals(1, robotUsers.size)
+ Assertions.assertEquals("robot", robotUsers[0].userFirstName)
+ }
+
+ @Test
+ fun canGetUsersWithUpdateInstantAtGreaterSearch() {
+ userRepository.save(
+ Users(
+ userFirstName = "HamidReza",
+ updatedInstantAt = Instant.parse("2020-01-10T10:15:30Z")
+ )
+ )
+ userRepository.save(Users(userFirstName = "robot", updatedInstantAt = Instant.parse("2020-01-11T10:20:30Z")))
+
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("updatedInstantAt>'2020-01-11T09:20:30Z'").build()
val robotUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, robotUsers.size)
Assertions.assertEquals("robot", robotUsers[0].userFirstName)
@@ -568,7 +764,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", updatedAt = LocalDateTime.parse("2020-01-10T10:15:30")))
userRepository.save(Users(userFirstName = "robot", updatedAt = LocalDateTime.parse("2020-01-11T10:20:30")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("updatedAt<'2020-01-11T09:20:30'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("updatedAt<'2020-01-11T09:20:30'").build()
val hamidrezaUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, hamidrezaUsers.size)
Assertions.assertEquals("HamidReza", hamidrezaUsers[0].userFirstName)
@@ -579,7 +777,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", updatedAt = LocalDateTime.parse("2020-01-10T10:15:30")))
userRepository.save(Users(userFirstName = "robot", updatedAt = LocalDateTime.parse("2020-01-11T10:20:30")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("updatedAt:'2020-01-10T10:15:30'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("updatedAt:'2020-01-10T10:15:30'").build()
val hamidrezaUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, hamidrezaUsers.size)
Assertions.assertEquals("HamidReza", hamidrezaUsers[0].userFirstName)
@@ -590,7 +790,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", updatedAt = LocalDateTime.parse("2020-01-10T10:15:30")))
userRepository.save(Users(userFirstName = "robot", updatedAt = LocalDateTime.parse("2020-01-11T10:20:30")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("updatedAt!'2020-01-11T10:20:30'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("updatedAt!'2020-01-11T10:20:30'").build()
val hamidrezaUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, hamidrezaUsers.size)
Assertions.assertEquals("HamidReza", hamidrezaUsers[0].userFirstName)
@@ -601,7 +803,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", updatedDateAt = LocalDate.parse("2020-01-10")))
userRepository.save(Users(userFirstName = "robot", updatedDateAt = LocalDate.parse("2020-01-11")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("updatedDateAt>'2020-01-10'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("updatedDateAt>'2020-01-10'").build()
val robotUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, robotUsers.size)
Assertions.assertEquals("robot", robotUsers[0].userFirstName)
@@ -612,7 +816,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", updatedDateAt = LocalDate.parse("2020-01-10")))
userRepository.save(Users(userFirstName = "robot", updatedDateAt = LocalDate.parse("2020-01-11")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("updatedDateAt<'2020-01-11'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("updatedDateAt<'2020-01-11'").build()
val hamidrezaUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, hamidrezaUsers.size)
Assertions.assertEquals("HamidReza", hamidrezaUsers[0].userFirstName)
@@ -623,7 +829,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", updatedDateAt = LocalDate.parse("2020-01-10")))
userRepository.save(Users(userFirstName = "robot", updatedDateAt = LocalDate.parse("2020-01-11")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("updatedDateAt:'2020-01-10'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("updatedDateAt:'2020-01-10'").build()
val hamidrezaUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, hamidrezaUsers.size)
Assertions.assertEquals("HamidReza", hamidrezaUsers[0].userFirstName)
@@ -634,7 +842,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", updatedDateAt = LocalDate.parse("2020-01-10")))
userRepository.save(Users(userFirstName = "robot", updatedDateAt = LocalDate.parse("2020-01-11")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("updatedDateAt!'2020-01-11'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("updatedDateAt!'2020-01-11'").build()
val hamidrezaUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, hamidrezaUsers.size)
Assertions.assertEquals("HamidReza", hamidrezaUsers[0].userFirstName)
@@ -645,7 +855,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", updatedTimeAt = LocalTime.parse("10:15:30")))
userRepository.save(Users(userFirstName = "robot", updatedTimeAt = LocalTime.parse("10:20:30")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("updatedTimeAt>'10:15:30'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("updatedTimeAt>'10:15:30'").build()
val robotUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, robotUsers.size)
Assertions.assertEquals("robot", robotUsers[0].userFirstName)
@@ -656,7 +868,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", updatedTimeAt = LocalTime.parse("10:15:30")))
userRepository.save(Users(userFirstName = "robot", updatedTimeAt = LocalTime.parse("10:20:30")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("updatedTimeAt<'10:16:30'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("updatedTimeAt<'10:16:30'").build()
val hamidrezaUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, hamidrezaUsers.size)
Assertions.assertEquals("HamidReza", hamidrezaUsers[0].userFirstName)
@@ -667,7 +881,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", updatedTimeAt = LocalTime.parse("10:15:30")))
userRepository.save(Users(userFirstName = "robot", updatedTimeAt = LocalTime.parse("10:20:30")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("updatedTimeAt:'10:15:30'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("updatedTimeAt:'10:15:30'").build()
val hamidrezaUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, hamidrezaUsers.size)
Assertions.assertEquals("HamidReza", hamidrezaUsers[0].userFirstName)
@@ -678,7 +894,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", updatedTimeAt = LocalTime.parse("10:15:30")))
userRepository.save(Users(userFirstName = "robot", updatedTimeAt = LocalTime.parse("10:20:30")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("updatedTimeAt!'10:20:30'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("updatedTimeAt!'10:20:30'").build()
val hamidrezaUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, hamidrezaUsers.size)
Assertions.assertEquals("HamidReza", hamidrezaUsers[0].userFirstName)
@@ -689,7 +907,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", validityDuration = Duration.parse("PT10H")))
userRepository.save(Users(userFirstName = "robot", validityDuration = Duration.parse("PT15H")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("validityDuration>'PT10H'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("validityDuration>'PT10H'").build()
val robotUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, robotUsers.size)
Assertions.assertEquals("robot", robotUsers[0].userFirstName)
@@ -700,7 +920,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", validityDuration = Duration.parse("PT10H")))
userRepository.save(Users(userFirstName = "robot", validityDuration = Duration.parse("PT15H")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("validityDuration<'PT11H'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("validityDuration<'PT11H'").build()
val hamidrezaUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, hamidrezaUsers.size)
Assertions.assertEquals("HamidReza", hamidrezaUsers[0].userFirstName)
@@ -711,7 +933,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", validityDuration = Duration.parse("PT10H")))
userRepository.save(Users(userFirstName = "robot", validityDuration = Duration.parse("PT15H")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("validityDuration:'PT10H'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("validityDuration:'PT10H'").build()
val hamidrezaUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, hamidrezaUsers.size)
Assertions.assertEquals("HamidReza", hamidrezaUsers[0].userFirstName)
@@ -722,7 +946,9 @@ class SpringSearchApplicationTest {
userRepository.save(Users(userFirstName = "HamidReza", validityDuration = Duration.parse("PT10H")))
userRepository.save(Users(userFirstName = "robot", validityDuration = Duration.parse("PT15H")))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("validityDuration!'PT10H'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("validityDuration!'PT10H'").build()
val robotUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, robotUsers.size)
Assertions.assertEquals("robot", robotUsers[0].userFirstName)
@@ -732,7 +958,9 @@ class SpringSearchApplicationTest {
fun canGetUsersWithUUIDEqualSearch() {
val userUUID = UUID.randomUUID()
userRepository.save(Users(userFirstName = "Diego", uuid = userUUID))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("uuid:'$userUUID'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("uuid:'$userUUID'").build()
val robotUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, robotUsers.size)
Assertions.assertEquals(userUUID, robotUsers[0].uuid)
@@ -744,7 +972,9 @@ class SpringSearchApplicationTest {
val user2UUID = UUID.randomUUID()
userRepository.save(Users(userFirstName = "Diego", uuid = userUUID))
userRepository.save(Users(userFirstName = "Diego two", uuid = user2UUID))
- val specification = SpecificationsBuilder(SearchSpec::class.constructors.first().call("", false)).withSearch("uuid!'$userUUID'").build()
+ val specification = SpecificationsBuilder(
+ SearchSpec::class.constructors.first().call("", false)
+ ).withSearch("uuid!'$userUUID'").build()
val robotUsers = userRepository.findAll(specification)
Assertions.assertEquals(1, robotUsers.size)
Assertions.assertEquals(user2UUID, robotUsers[0].uuid)
diff --git a/src/test/kotlin/com/sipios/springsearch/Users.kt b/src/test/kotlin/com/sipios/springsearch/Users.kt
index 02ff06c..fb6610a 100644
--- a/src/test/kotlin/com/sipios/springsearch/Users.kt
+++ b/src/test/kotlin/com/sipios/springsearch/Users.kt
@@ -1,6 +1,7 @@
package com.sipios.springsearch
import java.time.Duration
+import java.time.Instant
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
@@ -56,6 +57,9 @@ data class Users(
@Column
var updatedDateAt: LocalDate = LocalDate.now(),
+ @Column
+ var updatedInstantAt: Instant = Instant.now(),
+
@Column
var validityDuration: Duration = Duration.ofDays(30),