diff --git a/search-service/src/test/kotlin/com/egm/stellio/search/service/AttributeInstanceServiceTests.kt b/search-service/src/test/kotlin/com/egm/stellio/search/service/AttributeInstanceServiceTests.kt index 69f4cb661..62efd15b3 100644 --- a/search-service/src/test/kotlin/com/egm/stellio/search/service/AttributeInstanceServiceTests.kt +++ b/search-service/src/test/kotlin/com/egm/stellio/search/service/AttributeInstanceServiceTests.kt @@ -7,16 +7,19 @@ import com.egm.stellio.shared.model.ResourceNotFoundException import com.egm.stellio.shared.model.addNonReifiedTemporalProperty import com.egm.stellio.shared.model.getSingleEntry import com.egm.stellio.shared.util.* +import com.egm.stellio.shared.util.JsonLdUtils.JSONLD_ID import com.egm.stellio.shared.util.JsonLdUtils.JSONLD_LANGUAGE import com.egm.stellio.shared.util.JsonLdUtils.JSONLD_TYPE import com.egm.stellio.shared.util.JsonLdUtils.JSONLD_VALUE import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_DATE_TIME_TYPE +import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_DEFAULT_VOCAB import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_INSTANCE_ID_PROPERTY import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_JSONPROPERTY_VALUE import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_LANGUAGEPROPERTY_VALUE import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_MODIFIED_AT_PROPERTY import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_OBSERVED_AT_PROPERTY import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_PROPERTY_VALUE +import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_VOCABPROPERTY_VALUE import com.egm.stellio.shared.util.JsonLdUtils.buildExpandedPropertyValue import com.egm.stellio.shared.util.JsonUtils.deserializeAsMap import io.mockk.spyk @@ -60,6 +63,7 @@ class AttributeInstanceServiceTests : WithTimescaleContainer, WithKafkaContainer private lateinit var outgoingTemporalEntityAttribute: TemporalEntityAttribute private lateinit var jsonTemporalEntityAttribute: TemporalEntityAttribute private lateinit var languageTemporalEntityAttribute: TemporalEntityAttribute + private lateinit var vocabTemporalEntityAttribute: TemporalEntityAttribute val entityId = "urn:ngsi-ld:BeeHive:TESTC".toUri() @@ -112,6 +116,18 @@ class AttributeInstanceServiceTests : WithTimescaleContainer, WithKafkaContainer runBlocking { temporalEntityAttributeService.create(languageTemporalEntityAttribute) } + + vocabTemporalEntityAttribute = TemporalEntityAttribute( + entityId = entityId, + attributeName = CATEGORY_VOCAPPROPERTY, + attributeValueType = TemporalEntityAttribute.AttributeValueType.ARRAY, + createdAt = now, + payload = SAMPLE_VOCAB_PROPERTY_PAYLOAD + ) + + runBlocking { + temporalEntityAttributeService.create(vocabTemporalEntityAttribute) + } } @AfterEach @@ -689,6 +705,51 @@ class AttributeInstanceServiceTests : WithTimescaleContainer, WithKafkaContainer } } + @Test + fun `it should modify attribute instance for a VocabProperty property`() = runTest { + val attributeInstance = gimmeVocabPropertyAttributeInstance(vocabTemporalEntityAttribute.id) + attributeInstanceService.create(attributeInstance) + + val instanceTemporalFragment = + loadSampleData("fragments/temporal_instance_vocab_fragment.jsonld") + val attributeInstancePayload = + mapOf(CATEGORY_COMPACT_VOCABPROPERTY to instanceTemporalFragment.deserializeAsMap()) + val jsonLdAttribute = JsonLdUtils.expandJsonLdFragment( + attributeInstancePayload, + APIC_COMPOUND_CONTEXTS + ) as ExpandedAttributes + + val temporalEntitiesQuery = gimmeTemporalEntitiesQuery( + TemporalQuery( + timerel = TemporalQuery.Timerel.AFTER, + timeAt = ZonedDateTime.parse("1970-01-01T00:00:00Z") + ) + ) + + attributeInstanceService.modifyAttributeInstance( + entityId, + CATEGORY_VOCAPPROPERTY, + attributeInstance.instanceId, + jsonLdAttribute.entries.first().value + ).shouldSucceed() + + attributeInstanceService.search(temporalEntitiesQuery, vocabTemporalEntityAttribute) + .shouldSucceedWith { + (it as List).single { result -> + val deserializedPayload = result.payload.deserializeAsMap() + result.time == ZonedDateTime.parse("2023-03-13T12:33:06Z") && + deserializedPayload.containsKey(NGSILD_MODIFIED_AT_PROPERTY) && + deserializedPayload.containsKey(NGSILD_INSTANCE_ID_PROPERTY) && + deserializedPayload.containsKey(NGSILD_VOCABPROPERTY_VALUE) && + (deserializedPayload[NGSILD_VOCABPROPERTY_VALUE] as List>) + .all { entry -> + entry[JSONLD_ID] == "${NGSILD_DEFAULT_VOCAB}stellio" || + entry[JSONLD_ID] == "${NGSILD_DEFAULT_VOCAB}egm" + } + } + } + } + @Test fun `it should delete attribute instance`() = runTest { val attributeInstance = gimmeNumericPropertyAttributeInstance(incomingTemporalEntityAttribute.id) diff --git a/search-service/src/test/kotlin/com/egm/stellio/search/service/EntityTypeServiceTests.kt b/search-service/src/test/kotlin/com/egm/stellio/search/service/EntityTypeServiceTests.kt index 7628e3002..7e1adb21e 100644 --- a/search-service/src/test/kotlin/com/egm/stellio/search/service/EntityTypeServiceTests.kt +++ b/search-service/src/test/kotlin/com/egm/stellio/search/service/EntityTypeServiceTests.kt @@ -81,6 +81,12 @@ class EntityTypeServiceTests : WithTimescaleContainer, WithKafkaContainer { TemporalEntityAttribute.AttributeType.LanguageProperty, TemporalEntityAttribute.AttributeValueType.OBJECT ) + private val categoryVocabProperty = newTemporalEntityAttribute( + "urn:ngsi-ld:Apiary:TESTC", + CATEGORY_VOCAPPROPERTY, + TemporalEntityAttribute.AttributeType.VocabProperty, + TemporalEntityAttribute.AttributeValueType.ARRAY + ) @AfterEach fun clearPreviousTemporalEntityAttributesAndObservations() { @@ -103,6 +109,7 @@ class EntityTypeServiceTests : WithTimescaleContainer, WithKafkaContainer { createTemporalEntityAttribute(outgoingProperty) createTemporalEntityAttribute(luminosityJsonProperty) createTemporalEntityAttribute(friendlyNameLanguageProperty) + createTemporalEntityAttribute(categoryVocabProperty) } @Test @@ -131,7 +138,10 @@ class EntityTypeServiceTests : WithTimescaleContainer, WithKafkaContainer { EntityType( id = toUri(APIARY_TYPE), typeName = APIARY_COMPACT_TYPE, - attributeNames = listOf(NGSILD_LOCATION_TERM) + attributeNames = listOf( + CATEGORY_COMPACT_VOCABPROPERTY, + NGSILD_LOCATION_TERM + ) ), EntityType( id = toUri(BEEHIVE_TYPE), diff --git a/search-service/src/test/kotlin/com/egm/stellio/search/support/BusinessObjectsFactory.kt b/search-service/src/test/kotlin/com/egm/stellio/search/support/BusinessObjectsFactory.kt index 9c1496407..508c350f6 100644 --- a/search-service/src/test/kotlin/com/egm/stellio/search/support/BusinessObjectsFactory.kt +++ b/search-service/src/test/kotlin/com/egm/stellio/search/support/BusinessObjectsFactory.kt @@ -108,6 +108,32 @@ fun gimmeLanguagePropertyAttributeInstance( ) } +fun gimmeVocabPropertyAttributeInstance( + teaUuid: UUID, + timeProperty: AttributeInstance.TemporalProperty = AttributeInstance.TemporalProperty.OBSERVED_AT +): AttributeInstance { + val attributeMetadata = AttributeMetadata( + measuredValue = null, + value = SAMPLE_VOCAB_PROPERTY_PAYLOAD.asString(), + geoValue = null, + valueType = TemporalEntityAttribute.AttributeValueType.ARRAY, + datasetId = null, + type = TemporalEntityAttribute.AttributeType.VocabProperty, + observedAt = ngsiLdDateTime() + ) + val payload = JsonLdUtils.buildExpandedPropertyValue(attributeMetadata.value!!) + .addNonReifiedTemporalProperty(JsonLdUtils.NGSILD_OBSERVED_AT_PROPERTY, attributeMetadata.observedAt!!) + .getSingleEntry() + + return AttributeInstance( + temporalEntityAttribute = teaUuid, + time = attributeMetadata.observedAt!!, + attributeMetadata = attributeMetadata, + timeProperty = timeProperty, + payload = payload + ) +} + fun gimmeTemporalEntitiesQuery( temporalQuery: TemporalQuery, withTemporalValues: Boolean = false, diff --git a/search-service/src/test/kotlin/com/egm/stellio/search/support/TestUtils.kt b/search-service/src/test/kotlin/com/egm/stellio/search/support/TestUtils.kt index 7d7ef1043..2b381827d 100644 --- a/search-service/src/test/kotlin/com/egm/stellio/search/support/TestUtils.kt +++ b/search-service/src/test/kotlin/com/egm/stellio/search/support/TestUtils.kt @@ -52,7 +52,11 @@ const val EMPTY_PAYLOAD = "{}" val EMPTY_JSON_PAYLOAD = Json.of(EMPTY_PAYLOAD) val SAMPLE_JSON_PROPERTY_PAYLOAD = Json.of( """ - { "id": "123", "stringValue": "value", "nullValue": null } + { + "id": "123", + "stringValue": "value", + "nullValue": null + } """.trimIndent() ) val SAMPLE_LANGUAGE_PROPERTY_PAYLOAD = Json.of( @@ -74,3 +78,20 @@ val SAMPLE_LANGUAGE_PROPERTY_PAYLOAD = Json.of( } """.trimIndent() ) +val SAMPLE_VOCAB_PROPERTY_PAYLOAD = Json.of( + """ + { + "https://uri.etsi.org/ngsi-ld/hasVocab": [ + { + "@id": "https://uri.etsi.org/ngsi-ld/default-context/stellio" + }, + { + "@id": "https://uri.etsi.org/ngsi-ld/default-context/egm" + } + ], + "@type": [ + "https://uri.etsi.org/ngsi-ld/VocabProperty" + ] + } + """.trimIndent() +) diff --git a/search-service/src/test/kotlin/com/egm/stellio/search/util/PatchAttributeTests.kt b/search-service/src/test/kotlin/com/egm/stellio/search/util/PatchAttributeTests.kt index 96c00ebd3..acb08d941 100644 --- a/search-service/src/test/kotlin/com/egm/stellio/search/util/PatchAttributeTests.kt +++ b/search-service/src/test/kotlin/com/egm/stellio/search/util/PatchAttributeTests.kt @@ -83,6 +83,32 @@ class PatchAttributeTests { } } """.trimIndent() + ), + Arguments.of( + """ + { + "attribute": { + "type": "VocabProperty", + "vocab": "stellio" + } + } + """.trimIndent(), + """ + { + "attribute": { + "type": "VocabProperty", + "vocab": "egm" + } + } + """.trimIndent(), + """ + { + "attribute": { + "type": "VocabProperty", + "vocab": "egm" + } + } + """.trimIndent() ) ) } @@ -261,6 +287,32 @@ class PatchAttributeTests { } } """.trimIndent() + ), + Arguments.of( + """ + { + "attribute": { + "type": "VocabProperty", + "vocab": "stellio" + } + } + """.trimIndent(), + """ + { + "attribute": { + "type": "VocabProperty", + "vocab": "egm" + } + } + """.trimIndent(), + """ + { + "attribute": { + "type": "VocabProperty", + "vocab": "egm" + } + } + """.trimIndent() ) ) } diff --git a/search-service/src/test/kotlin/com/egm/stellio/search/util/TemporalEntityParameterizedSource.kt b/search-service/src/test/kotlin/com/egm/stellio/search/util/TemporalEntityParameterizedSource.kt index ecde867a3..a6c2d87d0 100644 --- a/search-service/src/test/kotlin/com/egm/stellio/search/util/TemporalEntityParameterizedSource.kt +++ b/search-service/src/test/kotlin/com/egm/stellio/search/util/TemporalEntityParameterizedSource.kt @@ -4,10 +4,7 @@ import com.egm.stellio.search.model.* import com.egm.stellio.search.scope.FullScopeInstanceResult import com.egm.stellio.search.scope.ScopeInstanceResult import com.egm.stellio.search.scope.SimplifiedScopeInstanceResult -import com.egm.stellio.search.support.EMPTY_JSON_PAYLOAD -import com.egm.stellio.search.support.SAMPLE_JSON_PROPERTY_PAYLOAD -import com.egm.stellio.search.support.SAMPLE_LANGUAGE_PROPERTY_PAYLOAD -import com.egm.stellio.search.support.buildAttributeInstancePayload +import com.egm.stellio.search.support.* import com.egm.stellio.shared.util.JsonLdUtils import com.egm.stellio.shared.util.loadSampleData import com.egm.stellio.shared.util.toUri @@ -625,6 +622,48 @@ class TemporalEntityParameterizedSource { loadSampleData("expectations/beehive_language_property_temporal_values.jsonld") ) + private val beehiveVocabPropertyTemporalValues = + Arguments.arguments( + emptyList(), + mapOf( + TemporalEntityAttribute( + entityId = entityId, + attributeName = "https://ontology.eglobalmark.com/apic#category", + attributeType = TemporalEntityAttribute.AttributeType.VocabProperty, + attributeValueType = TemporalEntityAttribute.AttributeValueType.ARRAY, + datasetId = null, + createdAt = now, + payload = SAMPLE_VOCAB_PROPERTY_PAYLOAD + ) to + listOf( + SimplifiedAttributeInstanceResult( + temporalEntityAttribute = UUID.randomUUID(), + value = """ + [{ + "@id": "https://uri.etsi.org/ngsi-ld/default-context/stellio" + }, + { + "@id": "https://uri.etsi.org/ngsi-ld/default-context/egm" + }] + """, + time = ZonedDateTime.parse("2020-03-25T08:29:17.965206Z") + ), + SimplifiedAttributeInstanceResult( + temporalEntityAttribute = UUID.randomUUID(), + value = """ + [{ + "@id": "https://uri.etsi.org/ngsi-ld/default-context/stellio" + }] + """, + time = ZonedDateTime.parse("2020-03-25T08:33:17.965206Z") + ) + ) + ), + true, + false, + loadSampleData("expectations/beehive_vocab_property_temporal_values.jsonld") + ) + @JvmStatic fun rawResultsProvider(): Stream { return Stream.of( @@ -642,7 +681,8 @@ class TemporalEntityParameterizedSource { beehiveScopeMultiInstancesTemporalValues, beehiveScopeMultiInstances, beehiveJsonPropertyTemporalValues, - beehiveLanguagePropertyTemporalValues + beehiveLanguagePropertyTemporalValues, + beehiveVocabPropertyTemporalValues ) } } diff --git a/search-service/src/test/resources/ngsild/expectations/beehive_vocab_property_temporal_values.jsonld b/search-service/src/test/resources/ngsild/expectations/beehive_vocab_property_temporal_values.jsonld index 4f3939cc6..dbaecc31a 100644 --- a/search-service/src/test/resources/ngsild/expectations/beehive_vocab_property_temporal_values.jsonld +++ b/search-service/src/test/resources/ngsild/expectations/beehive_vocab_property_temporal_values.jsonld @@ -3,25 +3,23 @@ "@type": [ "https://ontology.eglobalmark.com/apic#BeeHive" ], - "https://ontology.eglobalmark.com/apic#friendlyName": [ + "https://ontology.eglobalmark.com/apic#category": [ { "@type": [ - "https://uri.etsi.org/ngsi-ld/LanguageProperty" + "https://uri.etsi.org/ngsi-ld/VocabProperty" ], - "https://uri.etsi.org/ngsi-ld/hasLanguageMaps": [ + "https://uri.etsi.org/ngsi-ld/hasVocabs": [ { "@list": [ { "@list": [ { - "https://uri.etsi.org/ngsi-ld/hasLanguageMap": [ + "https://uri.etsi.org/ngsi-ld/hasVocab": [ { - "@value": "One beautiful beehive", - "@language": "en" + "@id": "https://uri.etsi.org/ngsi-ld/default-context/stellio" }, { - "@value": "Une belle ruche", - "@language": "fr" + "@id": "https://uri.etsi.org/ngsi-ld/default-context/egm" } ] }, @@ -33,14 +31,9 @@ { "@list": [ { - "https://uri.etsi.org/ngsi-ld/hasLanguageMap": [ + "https://uri.etsi.org/ngsi-ld/hasVocab": [ { - "@value": "My beautiful beehive", - "@language": "en" - }, - { - "@value": "Ma belle ruche", - "@language": "fr" + "@id": "https://uri.etsi.org/ngsi-ld/default-context/stellio" } ] }, diff --git a/search-service/src/test/resources/ngsild/fragments/temporal_instance_vocab_fragment.jsonld b/search-service/src/test/resources/ngsild/fragments/temporal_instance_vocab_fragment.jsonld index e964936ea..052f42c0b 100644 --- a/search-service/src/test/resources/ngsild/fragments/temporal_instance_vocab_fragment.jsonld +++ b/search-service/src/test/resources/ngsild/fragments/temporal_instance_vocab_fragment.jsonld @@ -1,8 +1,5 @@ { - "type": "LanguageProperty", - "languageMap": { - "fr": "Ma belle ruche", - "it": "Il mio bellissimo alveare" - }, + "type": "VocabProperty", + "vocab": "stellio", "observedAt": "2023-03-13T12:33:06Z" } diff --git a/shared/src/test/kotlin/com/egm/stellio/shared/model/CompactedEntityTests.kt b/shared/src/test/kotlin/com/egm/stellio/shared/model/CompactedEntityTests.kt index c0fe63663..c623dd6fc 100644 --- a/shared/src/test/kotlin/com/egm/stellio/shared/model/CompactedEntityTests.kt +++ b/shared/src/test/kotlin/com/egm/stellio/shared/model/CompactedEntityTests.kt @@ -785,4 +785,62 @@ class CompactedEntityTests { assertJsonPayloadsAreEqual(expectedSimplifiedRepresentation, serializeObject(simplifiedRepresentation)) } + + @Test + fun `it should return the simplified representation of a VocabProperty - string value`() { + val compactedEntity = """ + { + "id": "urn:ngsi-ld:Entity:01", + "type": "Entity", + "vocabProperty": { + "type": "VocabProperty", + "vocab": "stellio" + } + } + """.trimIndent() + .deserializeAsMap() + + val simplifiedRepresentation = compactedEntity.toSimplifiedAttributes() + + val expectedSimplifiedRepresentation = """ + { + "id": "urn:ngsi-ld:Entity:01", + "type": "Entity", + "vocabProperty": { + "vocab": "stellio" + } + } + """.trimIndent() + + assertJsonPayloadsAreEqual(expectedSimplifiedRepresentation, serializeObject(simplifiedRepresentation)) + } + + @Test + fun `it should return the simplified representation of a VocabProperty - array of strings value`() { + val compactedEntity = """ + { + "id": "urn:ngsi-ld:Entity:01", + "type": "Entity", + "vocabProperty": { + "type": "VocabProperty", + "vocab": ["stellio", "egm"] + } + } + """.trimIndent() + .deserializeAsMap() + + val simplifiedRepresentation = compactedEntity.toSimplifiedAttributes() + + val expectedSimplifiedRepresentation = """ + { + "id": "urn:ngsi-ld:Entity:01", + "type": "Entity", + "vocabProperty": { + "vocab": ["stellio", "egm"] + } + } + """.trimIndent() + + assertJsonPayloadsAreEqual(expectedSimplifiedRepresentation, serializeObject(simplifiedRepresentation)) + } } diff --git a/shared/src/test/kotlin/com/egm/stellio/shared/model/NgsiLdEntityTests.kt b/shared/src/test/kotlin/com/egm/stellio/shared/model/NgsiLdEntityTests.kt index a9bfaf748..93db489ce 100644 --- a/shared/src/test/kotlin/com/egm/stellio/shared/model/NgsiLdEntityTests.kt +++ b/shared/src/test/kotlin/com/egm/stellio/shared/model/NgsiLdEntityTests.kt @@ -1,5 +1,6 @@ package com.egm.stellio.shared.model +import com.egm.stellio.shared.util.JsonLdUtils.JSONLD_ID import com.egm.stellio.shared.util.JsonLdUtils.JSONLD_VALUE import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_DEFAULT_VOCAB import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_LOCATION_PROPERTY @@ -1010,4 +1011,118 @@ class NgsiLdEntityTests { expandJsonLdEntity(rawEntity, NGSILD_TEST_CORE_CONTEXTS) } } + + @Test + fun `it should parse an entity with a VocabProperty - array of strings value`() = runTest { + val rawEntity = + """ + { + "id":"urn:ngsi-ld:Device:01234", + "type":"Device", + "vocabProperty": { + "type": "VocabProperty", + "vocab": ["stellio", "egm"] + } + } + """.trimIndent() + + val ngsiLdEntity = expandJsonLdEntity(rawEntity, NGSILD_TEST_CORE_CONTEXTS).toNgsiLdEntity() + .shouldSucceedAndResult() + + val vocabProperty = ngsiLdEntity.vocabProperties.first() + assertNotNull(vocabProperty) + assertEquals("${NGSILD_DEFAULT_VOCAB}vocabProperty", vocabProperty.name) + assertEquals(1, vocabProperty.instances.size) + val vocabPropertyInstance = vocabProperty.instances[0] + assertEquals( + listOf( + mapOf(JSONLD_ID to "${NGSILD_DEFAULT_VOCAB}stellio"), + mapOf(JSONLD_ID to "${NGSILD_DEFAULT_VOCAB}egm") + ), + vocabPropertyInstance.vocab + ) + } + + @Test + fun `it should parse an entity with a VocabProperty - string value`() = runTest { + val rawEntity = + """ + { + "id":"urn:ngsi-ld:Device:01234", + "type":"Device", + "vocabProperty": { + "type": "VocabProperty", + "vocab": "stellio" + } + } + """.trimIndent() + + val ngsiLdEntity = expandJsonLdEntity(rawEntity, NGSILD_TEST_CORE_CONTEXTS).toNgsiLdEntity() + .shouldSucceedAndResult() + + val vocabProperty = ngsiLdEntity.vocabProperties.first() + assertNotNull(vocabProperty) + assertEquals("${NGSILD_DEFAULT_VOCAB}vocabProperty", vocabProperty.name) + assertEquals(1, vocabProperty.instances.size) + val vocabPropertyInstance = vocabProperty.instances[0] + assertEquals( + listOf( + mapOf(JSONLD_ID to "${NGSILD_DEFAULT_VOCAB}stellio") + ), + vocabPropertyInstance.vocab + ) + } + + @Test + fun `it should not parse an entity with a VocabProperty without a vocab member`() = runTest { + val rawEntity = + """ + { + "id":"urn:ngsi-ld:Device:01234", + "type":"Device", + "vocabProperty": { + "type": "VocabProperty", + "value": "stellio" + } + } + """.trimIndent() + + expandJsonLdEntity(rawEntity, NGSILD_TEST_CORE_CONTEXTS).toNgsiLdEntity() + .shouldFail { + assertInstanceOf(BadRequestDataException::class.java, it) + assertEquals( + "VocabProperty ${NGSILD_DEFAULT_VOCAB}vocabProperty has an instance " + + "without a vocab member", + it.message + ) + } + } + + @Test + fun `it should not parse an entity with a VocabProperty with an invalid vocab member`() = runTest { + val rawEntity = + """ + { + "id":"urn:ngsi-ld:Device:01234", + "type":"Device", + "vocabProperty": { + "type": "VocabProperty", + "vocab": { + "name": "stellio", + "company": "EGM" + } + } + } + """.trimIndent() + + expandJsonLdEntity(rawEntity, NGSILD_TEST_CORE_CONTEXTS).toNgsiLdEntity() + .shouldFail { + assertInstanceOf(BadRequestDataException::class.java, it) + assertEquals( + "VocabProperty ${NGSILD_DEFAULT_VOCAB}vocabProperty has a vocab member " + + "that is not a string, nor an array of string", + it.message + ) + } + } } diff --git a/shared/src/testFixtures/kotlin/com/egm/stellio/shared/util/JsonLdContextUtils.kt b/shared/src/testFixtures/kotlin/com/egm/stellio/shared/util/JsonLdContextUtils.kt index b021d45ff..1fae07482 100644 --- a/shared/src/testFixtures/kotlin/com/egm/stellio/shared/util/JsonLdContextUtils.kt +++ b/shared/src/testFixtures/kotlin/com/egm/stellio/shared/util/JsonLdContextUtils.kt @@ -37,6 +37,8 @@ const val LUMINOSITY_COMPACT_JSONPROPERTY = "luminosity" const val LUMINOSITY_JSONPROPERTY = "https://ontology.eglobalmark.com/apic#$LUMINOSITY_COMPACT_JSONPROPERTY" const val FRIENDLYNAME_COMPACT_LANGUAGEPROPERTY = "friendlyName" const val FRIENDLYNAME_LANGUAGEPROPERTY = "https://ontology.eglobalmark.com/apic#$FRIENDLYNAME_COMPACT_LANGUAGEPROPERTY" +const val CATEGORY_COMPACT_VOCABPROPERTY = "category" +const val CATEGORY_VOCAPPROPERTY = "https://ontology.eglobalmark.com/apic#$CATEGORY_COMPACT_VOCABPROPERTY" const val MANAGED_BY_COMPACT_RELATIONSHIP = "managedBy" const val MANAGED_BY_RELATIONSHIP = "https://ontology.eglobalmark.com/egm#$MANAGED_BY_COMPACT_RELATIONSHIP" diff --git a/shared/src/testFixtures/resources/jsonld-contexts/apic.jsonld b/shared/src/testFixtures/resources/jsonld-contexts/apic.jsonld index 0b79db69e..e439e5257 100644 --- a/shared/src/testFixtures/resources/jsonld-contexts/apic.jsonld +++ b/shared/src/testFixtures/resources/jsonld-contexts/apic.jsonld @@ -34,6 +34,7 @@ "movementCount": "https://ontology.eglobalmark.com/apic#movementCount", "hornetCount": "https://ontology.eglobalmark.com/apic#hornetCount", "dateOfFirstBee": "https://ontology.eglobalmark.com/apic#dateOfFirstBee", - "friendlyName": "https://ontology.eglobalmark.com/apic#friendlyName" + "friendlyName": "https://ontology.eglobalmark.com/apic#friendlyName", + "category": "https://ontology.eglobalmark.com/apic#category" } }