diff --git a/shared/src/main/kotlin/com/egm/stellio/shared/util/JsonUtils.kt b/shared/src/main/kotlin/com/egm/stellio/shared/util/JsonUtils.kt index da13b8b06..f42c983bd 100644 --- a/shared/src/main/kotlin/com/egm/stellio/shared/util/JsonUtils.kt +++ b/shared/src/main/kotlin/com/egm/stellio/shared/util/JsonUtils.kt @@ -1,6 +1,6 @@ package com.egm.stellio.shared.util -import com.egm.stellio.shared.model.BadRequestDataException +import com.egm.stellio.shared.model.InvalidRequestException import com.egm.stellio.shared.util.JsonLdUtils.JSONLD_JSON_TERM import com.egm.stellio.shared.util.JsonLdUtils.JSONLD_VALUE_TERM import com.fasterxml.jackson.core.JsonProcessingException @@ -31,7 +31,7 @@ object JsonUtils { mapper.typeFactory.constructMapLikeType(Map::class.java, String::class.java, Any::class.java) ) } catch (e: JsonProcessingException) { - throw BadRequestDataException(e.message!!) + throw InvalidRequestException(e.message!!) } fun String.deserializeAsMap(): Map = @@ -49,7 +49,7 @@ object JsonUtils { mapper.typeFactory.constructCollectionType(MutableList::class.java, Map::class.java) ) } catch (e: JsonProcessingException) { - throw BadRequestDataException(e.message!!) + throw InvalidRequestException(e.message!!) } fun String.deserializeAsList(): List> = diff --git a/shared/src/test/kotlin/com/egm/stellio/shared/util/JsonUtilsTests.kt b/shared/src/test/kotlin/com/egm/stellio/shared/util/JsonUtilsTests.kt index 4ed291c30..ddad6db9b 100644 --- a/shared/src/test/kotlin/com/egm/stellio/shared/util/JsonUtilsTests.kt +++ b/shared/src/test/kotlin/com/egm/stellio/shared/util/JsonUtilsTests.kt @@ -4,11 +4,11 @@ import com.egm.stellio.shared.model.AttributeDeleteAllInstancesEvent import com.egm.stellio.shared.model.AttributeDeleteEvent import com.egm.stellio.shared.model.AttributeReplaceEvent import com.egm.stellio.shared.model.AttributeUpdateEvent -import com.egm.stellio.shared.model.BadRequestDataException import com.egm.stellio.shared.model.EntityCreateEvent import com.egm.stellio.shared.model.EntityDeleteEvent import com.egm.stellio.shared.model.EntityEvent import com.egm.stellio.shared.model.EntityReplaceEvent +import com.egm.stellio.shared.model.InvalidRequestException import com.egm.stellio.shared.util.JsonLdUtils.expandJsonLdFragment import com.egm.stellio.shared.util.JsonUtils.deserializeAs import com.egm.stellio.shared.util.JsonUtils.deserializeAsMap @@ -153,7 +153,7 @@ class JsonUtilsTests { } @Test - fun `it should throw an BadRequestDataException exception if the JSON-LD fragment is not a valid JSON document`() { + fun `it should throw an InvalidRequest exception if the JSON-LD fragment is not a valid JSON document`() { val rawEntity = """ { @@ -162,7 +162,7 @@ class JsonUtilsTests { } """.trimIndent() - val exception = assertThrows { + val exception = assertThrows { rawEntity.deserializeAsMap() } assertThat(exception.message) diff --git a/shared/src/test/kotlin/com/egm/stellio/shared/web/ExceptionHandlerTests.kt b/shared/src/test/kotlin/com/egm/stellio/shared/web/ExceptionHandlerTests.kt index a8b05d813..1c010e7d2 100644 --- a/shared/src/test/kotlin/com/egm/stellio/shared/web/ExceptionHandlerTests.kt +++ b/shared/src/test/kotlin/com/egm/stellio/shared/web/ExceptionHandlerTests.kt @@ -31,7 +31,7 @@ class ExceptionHandlerTests { .exchange() .expectStatus().isEqualTo(HttpStatus.BAD_REQUEST) .expectBody() - .jsonPath("$..type").isEqualTo("https://uri.etsi.org/ngsi-ld/errors/BadRequestData") + .jsonPath("$..type").isEqualTo("https://uri.etsi.org/ngsi-ld/errors/InvalidRequest") } @Test