-
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.
test(dsl): for Trim(Leading, Trailing, Both)Dsl
- Loading branch information
Showing
4 changed files
with
518 additions
and
0 deletions.
There are no files selected for viewing
121 changes: 121 additions & 0 deletions
121
dsl/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/expression/TrimBothDslTest.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,121 @@ | ||
package com.linecorp.kotlinjdsl.dsl.jpql.expression | ||
|
||
import com.linecorp.kotlinjdsl.dsl.jpql.queryPart | ||
import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expression | ||
import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expressions | ||
import org.assertj.core.api.WithAssertions | ||
import org.junit.jupiter.api.Test | ||
|
||
class TrimBothDslTest : WithAssertions { | ||
private val char1 = 'c' | ||
private val string1 = "string1" | ||
|
||
private val charExpression1 = Expressions.value(char1) | ||
private val stringExpression1 = Expressions.value(string1) | ||
|
||
@Test | ||
fun `trimBoth() without a char, from() with a string`() { | ||
// when | ||
val expression = queryPart { | ||
trimBoth().from(string1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trimBoth( | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trimBoth() without a char, from() with a string expression`() { | ||
// when | ||
val expression = queryPart { | ||
trimBoth().from(stringExpression1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trimBoth( | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trimBoth() with a char, from() with a string`() { | ||
// when | ||
val expression = queryPart { | ||
trimBoth(char1).from(string1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trimBoth( | ||
character = charExpression1, | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trimBoth() with a char, from() with a string expression`() { | ||
// when | ||
val expression = queryPart { | ||
trimBoth(char1).from(stringExpression1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trimBoth( | ||
character = charExpression1, | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trimBoth() with a char expression, from() with a string`() { | ||
// when | ||
val expression = queryPart { | ||
trimBoth(charExpression1).from(string1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trimBoth( | ||
character = charExpression1, | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trimBoth() with a char expression, from() with a string expression`() { | ||
// when | ||
val expression = queryPart { | ||
trimBoth(charExpression1).from(stringExpression1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trimBoth( | ||
character = charExpression1, | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
} |
155 changes: 155 additions & 0 deletions
155
dsl/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/expression/TrimDslTest.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,155 @@ | ||
package com.linecorp.kotlinjdsl.dsl.jpql.expression | ||
|
||
import com.linecorp.kotlinjdsl.dsl.jpql.queryPart | ||
import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expression | ||
import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expressions | ||
import org.assertj.core.api.WithAssertions | ||
import org.junit.jupiter.api.Test | ||
|
||
class TrimDslTest : WithAssertions { | ||
private val char1 = 'c' | ||
private val string1 = "string1" | ||
|
||
private val charExpression1 = Expressions.value(char1) | ||
private val stringExpression1 = Expressions.value(string1) | ||
|
||
@Test | ||
fun `trim() with a string`() { | ||
// when | ||
val expression = queryPart { | ||
trim(string1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trim( | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trim() with a string expression`() { | ||
// when | ||
val expression = queryPart { | ||
trim(stringExpression1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trim( | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trim() without a char, from() with a string`() { | ||
// when | ||
val expression = queryPart { | ||
trim().from(string1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trim( | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trim() without a char, from() with a string expression`() { | ||
// when | ||
val expression = queryPart { | ||
trim().from(stringExpression1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trim( | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trim() with a char, from() with a string`() { | ||
// when | ||
val expression = queryPart { | ||
trim(char1).from(string1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trim( | ||
character = charExpression1, | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trim() with a char, from() with a string expression`() { | ||
// when | ||
val expression = queryPart { | ||
trim(char1).from(stringExpression1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trim( | ||
character = charExpression1, | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trim() with a char expression, from() with a string`() { | ||
// when | ||
val expression = queryPart { | ||
trim(charExpression1).from(string1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trim( | ||
character = charExpression1, | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trim() with a char expression, from() with a string expression`() { | ||
// when | ||
val expression = queryPart { | ||
trim(charExpression1).from(stringExpression1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trim( | ||
character = charExpression1, | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
} |
121 changes: 121 additions & 0 deletions
121
dsl/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/expression/TrimLeadingDslTest.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,121 @@ | ||
package com.linecorp.kotlinjdsl.dsl.jpql.expression | ||
|
||
import com.linecorp.kotlinjdsl.dsl.jpql.queryPart | ||
import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expression | ||
import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expressions | ||
import org.assertj.core.api.WithAssertions | ||
import org.junit.jupiter.api.Test | ||
|
||
class TrimLeadingDslTest : WithAssertions { | ||
private val char1 = 'c' | ||
private val string1 = "string1" | ||
|
||
private val charExpression1 = Expressions.value(char1) | ||
private val stringExpression1 = Expressions.value(string1) | ||
|
||
@Test | ||
fun `trimLeading() without a char, from() with a string`() { | ||
// when | ||
val expression = queryPart { | ||
trimLeading().from(string1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trimLeading( | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trimLeading() without a char, from() with a string expression`() { | ||
// when | ||
val expression = queryPart { | ||
trimLeading().from(stringExpression1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trimLeading( | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trimLeading() with a char, from() with a string`() { | ||
// when | ||
val expression = queryPart { | ||
trimLeading(char1).from(string1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trimLeading( | ||
character = charExpression1, | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trimLeading() with a char, from() with a string expression`() { | ||
// when | ||
val expression = queryPart { | ||
trimLeading(char1).from(stringExpression1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trimLeading( | ||
character = charExpression1, | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trimLeading() with a char expression, from() with a string`() { | ||
// when | ||
val expression = queryPart { | ||
trimLeading(charExpression1).from(string1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trimLeading( | ||
character = charExpression1, | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun `trimLeading() with a char expression, from() with a string expression`() { | ||
// when | ||
val expression = queryPart { | ||
trimLeading(charExpression1).from(stringExpression1) | ||
}.toExpression() | ||
|
||
val actual: Expression<String> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.trimLeading( | ||
character = charExpression1, | ||
value = stringExpression1, | ||
) | ||
|
||
assertThat(actual.toExpression()).isEqualTo(expected) | ||
} | ||
} |
Oops, something went wrong.