Don't spam regular log with json test fails
This commit is contained in:
parent
21fcad14b3
commit
9644eda14c
@ -21,15 +21,15 @@ enum class JsonPatch(val key: String) {
|
|||||||
|
|
||||||
if (inverse) {
|
if (inverse) {
|
||||||
if (value == JsonNull.INSTANCE && get != JsonNull.INSTANCE) {
|
if (value == JsonNull.INSTANCE && get != JsonNull.INSTANCE) {
|
||||||
throw IllegalStateException("Expected $path to not contain anything")
|
throw JsonTestException("Expected $path to not contain anything")
|
||||||
} else if (value != JsonNull.INSTANCE && value == get) {
|
} else if (value != JsonNull.INSTANCE && value == get) {
|
||||||
throw IllegalStateException("Expected $path to not contain $value")
|
throw JsonTestException("Expected $path to not contain $value")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (value == JsonNull.INSTANCE && get == JsonNull.INSTANCE) {
|
if (value == JsonNull.INSTANCE && get == JsonNull.INSTANCE) {
|
||||||
throw IllegalStateException("Expected $path to contain anything")
|
throw JsonTestException("Expected $path to contain anything")
|
||||||
} else if (value != JsonNull.INSTANCE && get == JsonNull.INSTANCE) {
|
} else if (value != JsonNull.INSTANCE && get == JsonNull.INSTANCE) {
|
||||||
throw IllegalStateException("Expected $path to contain '$value', but found nothing")
|
throw JsonTestException("Expected $path to contain '$value', but found nothing")
|
||||||
} else if (value != JsonNull.INSTANCE && get != JsonNull.INSTANCE && value != get) {
|
} else if (value != JsonNull.INSTANCE && get != JsonNull.INSTANCE && value != get) {
|
||||||
var text = get.toString()
|
var text = get.toString()
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ enum class JsonPatch(val key: String) {
|
|||||||
text = text.substring(0, 40) + "..."
|
text = text.substring(0, 40) + "..."
|
||||||
}
|
}
|
||||||
|
|
||||||
throw IllegalStateException("Expected $path to contain $value, but found $text")
|
throw JsonTestException("Expected $path to contain $value, but found $text")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +80,8 @@ enum class JsonPatch(val key: String) {
|
|||||||
|
|
||||||
abstract fun apply(base: JsonElement, data: JsonObject): JsonElement
|
abstract fun apply(base: JsonElement, data: JsonObject): JsonElement
|
||||||
|
|
||||||
|
class JsonTestException(message: String) : IllegalStateException(message)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val LOGGER = LogManager.getLogger()
|
private val LOGGER = LogManager.getLogger()
|
||||||
|
|
||||||
@ -99,6 +101,8 @@ enum class JsonPatch(val key: String) {
|
|||||||
if (element is JsonObject) {
|
if (element is JsonObject) {
|
||||||
try {
|
try {
|
||||||
base = apply(base, element)
|
base = apply(base, element)
|
||||||
|
} catch (err: JsonTestException) {
|
||||||
|
LOGGER.debug("Test condition failed in {} at index {}: {}", source, i, err.message)
|
||||||
} catch (err: Throwable) {
|
} catch (err: Throwable) {
|
||||||
LOGGER.error("Error while applying JSON patch from $source at index $i: ${err.message}")
|
LOGGER.error("Error while applying JSON patch from $source at index $i: ${err.message}")
|
||||||
}
|
}
|
||||||
@ -109,6 +113,9 @@ enum class JsonPatch(val key: String) {
|
|||||||
throw JsonSyntaxException("Expected JSON Object as patch data, got $sub")
|
throw JsonSyntaxException("Expected JSON Object as patch data, got $sub")
|
||||||
|
|
||||||
base = apply(base, sub)
|
base = apply(base, sub)
|
||||||
|
} catch (err: JsonTestException) {
|
||||||
|
LOGGER.debug("Test condition failed in {} at index {} -> {}: {}", source, i, i2, err.message)
|
||||||
|
break
|
||||||
} catch (err: Throwable) {
|
} catch (err: Throwable) {
|
||||||
LOGGER.error("Error while applying JSON patch from $source at index $i -> $i2: ${err.message}")
|
LOGGER.error("Error while applying JSON patch from $source at index $i -> $i2: ${err.message}")
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user