-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
852 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...jpql/src/test/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/predicate/CustomPredicateDslTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.linecorp.kotlinjdsl.dsl.jpql.predicate | ||
|
||
import com.linecorp.kotlinjdsl.dsl.jpql.queryPart | ||
import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expressions | ||
import com.linecorp.kotlinjdsl.querymodel.jpql.predicate.Predicate | ||
import com.linecorp.kotlinjdsl.querymodel.jpql.predicate.Predicates | ||
import org.assertj.core.api.WithAssertions | ||
import org.junit.jupiter.api.Test | ||
|
||
class CustomPredicateDslTest : WithAssertions { | ||
private val template1: String = "template1" | ||
|
||
private val stringExpression1 = Expressions.value("string1") | ||
private val stringExpression2 = Expressions.value("string2") | ||
|
||
private val string1 = "string1" | ||
private val string2 = "string2" | ||
|
||
@Test | ||
fun `customPredicate() with strings`() { | ||
// when | ||
val predicate = queryPart { | ||
customPredicate(template1, string1, string2) | ||
} | ||
|
||
val actual: Predicate = predicate // for type check | ||
|
||
// then | ||
val expected = Predicates.customPredicate( | ||
template1, | ||
listOf( | ||
Expressions.value(string1), | ||
Expressions.value(string2), | ||
), | ||
) | ||
|
||
assertThat(actual).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `customPredicate() with string expressions`() { | ||
// when | ||
val predicate = queryPart { | ||
customPredicate(template1, stringExpression1, stringExpression2) | ||
} | ||
|
||
val actual: Predicate = predicate // for type check | ||
|
||
// then | ||
val expected = Predicates.customPredicate( | ||
template1, | ||
listOf( | ||
stringExpression1, | ||
stringExpression2, | ||
), | ||
) | ||
|
||
assertThat(actual).isEqualTo(expected) | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
dsl/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/predicate/FunctionDslTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.linecorp.kotlinjdsl.dsl.jpql.predicate | ||
|
||
import com.linecorp.kotlinjdsl.dsl.jpql.queryPart | ||
import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expressions | ||
import com.linecorp.kotlinjdsl.querymodel.jpql.predicate.Predicate | ||
import com.linecorp.kotlinjdsl.querymodel.jpql.predicate.Predicates | ||
import org.assertj.core.api.WithAssertions | ||
import org.junit.jupiter.api.Test | ||
|
||
class FunctionDslTest : WithAssertions { | ||
private val name1: String = "name1" | ||
|
||
private val stringExpression1 = Expressions.value("string1") | ||
private val stringExpression2 = Expressions.value("string2") | ||
|
||
private val string1 = "string1" | ||
private val string2 = "string2" | ||
|
||
@Test | ||
fun `function() with strings`() { | ||
// when | ||
val predicate = queryPart { | ||
function(Boolean::class, name1, string1, string2) | ||
} | ||
|
||
val actual: Predicate = predicate // for type check | ||
|
||
// then | ||
val expected = Predicates.function( | ||
name1, | ||
listOf( | ||
Expressions.value(string1), | ||
Expressions.value(string2), | ||
), | ||
) | ||
|
||
assertThat(actual).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `function() with string expressions`() { | ||
// when | ||
val predicate = queryPart { | ||
function(Boolean::class, name1, stringExpression1, stringExpression2) | ||
} | ||
|
||
val actual: Predicate = predicate // for type check | ||
|
||
// then | ||
val expected = Predicates.function( | ||
name1, | ||
listOf( | ||
stringExpression1, | ||
stringExpression2, | ||
), | ||
) | ||
|
||
assertThat(actual).isEqualTo(expected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.