Skip to content

Commit

Permalink
feat(openapi): Update ConditionConverter (#924)
Browse files Browse the repository at this point in the history
* feat(openapi): Update ConditionConverter
  • Loading branch information
Ahoo-Wang authored Sep 10, 2024
1 parent c61a7b0 commit 8fa4e5c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ConditionConverter : TargetTypeModifyConverter() {
resolvedSchema.properties[Condition::operator.name]?.setDefault(Operator.ALL.name)
resolvedSchema.properties[Condition::value.name]?.setDefault(EMPTY_VALUE)
resolvedSchema.properties[Condition::children.name]?.setDefault(emptyList<Condition>())
resolvedSchema.properties[Condition::options.name]?.setDefault(emptyMap<String, Any>())
return resolvedSchema
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@ class ConditionDslTest {
"field5" gte 1
"field6" lte 1
"field7" contains "value7"
"field7".contains("value7", false)
"field7".contains("value7", true)
"field8" isIn listOf("value8")
"field9" notIn listOf("value9")
"field10" between (1 to 2)
"field100" between 1 to 2
"field11" all listOf("value11")
"field12" startsWith "value12"
"field12".startsWith("value12", false)
"field12".startsWith("value12", true)
"field12" endsWith "value12"
"field12".endsWith("value12", false)
"field12".endsWith("value12", true)
"field13" elemMatch {
"field14" eq "value14"
Expand Down Expand Up @@ -106,15 +109,18 @@ class ConditionDslTest {
Condition.gte("field5", 1),
Condition.lte("field6", 1),
Condition.contains("field7", "value7"),
Condition.contains("field7", "value7", false),
Condition.contains("field7", "value7", true),
Condition.isIn("field8", listOf("value8")),
Condition.notIn("field9", listOf("value9")),
Condition.between("field10", 1, 2),
Condition.between("field100", 1, 2),
Condition.all("field11", listOf("value11")),
Condition.startsWith("field12", "value12"),
Condition.startsWith("field12", "value12", false),
Condition.startsWith("field12", "value12", true),
Condition.endsWith("field12", "value12"),
Condition.endsWith("field12", "value12", false),
Condition.endsWith("field12", "value12", true),
Condition.elemMatch("field13", Condition.eq("field14", "value14")),
Condition.isNull("field15"),
Expand Down Expand Up @@ -224,6 +230,20 @@ class ConditionDslTest {
)
}

@Test
fun nor() {
val condition = condition {
nor {
}
}
assertThat(
condition,
equalTo(
Condition.ALL
)
)
}

@Test
fun orEmpty() {
val condition = condition {
Expand Down

0 comments on commit 8fa4e5c

Please sign in to comment.