Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): align behavior for update entity attributes (1.6+ compliance) #1146

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

bobeal
Copy link
Member

@bobeal bobeal commented Apr 27, 2024

No description provided.

@bobeal bobeal requested a review from ranim-n April 27, 2024 13:45
@github-actions github-actions bot added the feature New feature or request label Apr 27, 2024
@bobeal bobeal self-assigned this Apr 27, 2024
@bobeal bobeal added core Relates to core API ngsild-1.6.1 labels Apr 27, 2024
@bobeal bobeal linked an issue Apr 27, 2024 that may be closed by this pull request
Copy link
Contributor

Test Results

 58 files  ±0   58 suites  ±0   1m 24s ⏱️ -2s
953 tests ±0  953 ✅ ±0  0 💤 ±0  0 ❌ ±0 
992 runs  ±0  992 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 9f62d9c. ± Comparison against base commit 3c80bbc.

This pull request removes 170 and adds 30 tests. Note that renamed tests count towards both.
                         …, withTemporalValues=true, withAudit=false, expectation={
                      "@type": "@json",
                      …
                    "@value": "/A/B"
                    "@value": "/C/D"
                    "@value": 20
                    "…
                    {
                  "@type": "https://uri.etsi.org/ngsi-ld/DateTime",
                  "@value": "2020-03-25T08:29:17.965206Z"
…
com.egm.stellio.search.util.PatchAttributeTests ‑ [1] source={
    "attribute": {
        "type": "Property",
        "value": 12.0,
        "observedAt": "2024-04-14T12:34:56Z"
    }
}, target={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM"
    }
}, expected={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM",
        "observedAt": "2024-04-14T12:34:56Z"
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [1] source={
    "attribute": {
        "type": "Property",
        "value": 12.0,
        "observedAt": "2024-04-14T12:34:56Z",
        "subAttribute": {
            "type": "Property",
            "value": "subAttribute"
        }
    }
}, target={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM",
        "subAttribute": {
            "type": "Property",
            "value": "newSubAttributeValue"
        }
    }
}, expected={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM",
        "observedAt": "2024-04-14T12:34:56Z",
        "subAttribute": {
            "type": "Property",
            "value": "newSubAttributeValue"
        }
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [2] source={
    "attribute": {
        "type": "Property",
        "value": { "en": "car", "fr": "voiture" }
    }
}, target={
    "attribute": {
        "type": "Property",
        "value": { "fr": "vélo", "es": "bicicleta" }
    }
}, expected={
    "attribute": {
        "type": "Property",
        "value": { "en": "car", "fr": "vélo", "es": "bicicleta" }
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [2] source={
    "incoming": {
        "type": "JsonProperty",
        "json": { "id": 1, "b": null, "c": 12.4 },
        "observedAt": "2022-12-24T14:01:22.066Z",
        "subAttribute": {
            "type": "Property",
            "value": "subAttribute"
        }
    }
}, target={
    "incoming": {
        "type": "JsonProperty",
        "json": { "id": 2, "b": "something" },
        "observedAt": "2023-12-24T14:01:22.066Z"
    }
}, expected={
    "incoming": {
        "type": "JsonProperty",
        "json": { "id": 2, "b": "something" },
        "observedAt": "2023-12-24T14:01:22.066Z",
        "subAttribute": {
            "type": "Property",
            "value": "subAttribute"
        }
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [3] source={
    "attribute": {
        "type": "Property",
        "value": [ "car", "voiture" ]
    }
}, target={
    "attribute": {
        "type": "Property",
        "value": [ "vélo", "bicicleta" ]
    }
}, expected={
    "attribute": {
        "type": "Property",
        "value": [ "vélo", "bicicleta" ]
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [4] source={
    "attribute": {
        "type": "Relationship",
        "object": "urn:ngsi-ld:Entity:01"
    }
}, target={
    "attribute": {
        "type": "Relationship",
        "object": "urn:ngsi-ld:Entity:02"
    }
}, expected={
    "attribute": {
        "type": "Relationship",
        "object": "urn:ngsi-ld:Entity:02"
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [5] source={
    "attribute": {
        "type": "LanguageProperty",
        "languageMap": { "en": "train", "fr": "train" }
    }
}, target={
    "attribute": {
        "type": "LanguageProperty",
        "languageMap": { "fr": "TGV", "es": "tren" }
    }
}, expected={
    "attribute": {
        "type": "LanguageProperty",
        "languageMap": { "en": "train", "fr": "TGV", "es": "tren" }
    }
}
com.egm.stellio.search.util.PatchAttributeTests ‑ [6] source={
    "incoming": {
        "type": "JsonProperty",
        "json": { "a": 1, "b": "thing" }
    }
}, target={
    "incoming": {
        "type": "JsonProperty",
        "json": { "a": 2, "c": "other thing" }
    }
}, expected={
    "incoming": {
        "type": "JsonProperty",
        "json": { "a": 2, "b": "thing", "c": "other thing" }
    }
}
com.egm.stellio.search.util.TemporalEntityBuilderTests ‑ [10] scopeHistory=[], attributeAndResultsMap={TemporalEntityAttribute(id=2b3bff51-346c-4cd8-856d-d6022a88d620, entityId=urn:ngsi-ld:BeeHive:TESTC, attributeName=https://ontology.eglobalmark.com/apic#incoming, attributeType=Property, attributeValueType=STRING, datasetId=null, createdAt=2024-04-27T13:51:02.489587426Z, modifiedAt=null, payload=JsonByteArrayInput{{}})=[SimplifiedAttributeInstanceResult(temporalEntityAttribute=bf419487-bdb9-43fe-acde-aaea9616099d, value=Beehive_incoming_123, time=2020-03-25T08:29:17.965206Z), SimplifiedAttributeInstanceRe…, withTemporalValues=true, withAudit=false, expectation={
  "@id": "urn:ngsi-ld:BeeHive:TESTC",
  "@type": [
    "https://ontology.eglobalmark.com/apic#BeeHive"
  ],
  "https://ontology.eglobalmark.com/apic#incoming": [
    {
      "@type": [
        "https://uri.etsi.org/ngsi-ld/Property"
      ],
      "https://uri.etsi.org/ngsi-ld/hasValues": [
        {
          "@list": [
            {
              "@list": [
                {
                  "@value": "Beehive_incoming_123"
                },
                {
                  "@value": "2020-03-25T0…
com.egm.stellio.search.util.TemporalEntityBuilderTests ‑ [11] scopeHistory=[], attributeAndResultsMap={TemporalEntityAttribute(id=1e1df749-3e58-40af-adb2-81eae39685b4, entityId=urn:ngsi-ld:BeeHive:TESTC, attributeName=https://ontology.eglobalmark.com/apic#incoming, attributeType=Relationship, attributeValueType=STRING, datasetId=urn:ngsi-ld:Dataset:45678, createdAt=2024-04-27T13:51:02.489587426Z, modifiedAt=null, payload=JsonByteArrayInput{{}})=[SimplifiedAttributeInstanceResult(temporalEntityAttribute=3f2d28a5-1e96-47e2-bddd-8eeee61e7562, value=urn:ngsi-ld:Entity:1234, time=2020-03-25T08:29:17.965206Z), S…, withTemporalValues=true, withAudit=false, expectation={
  "@id": "urn:ngsi-ld:BeeHive:TESTC",
  "@type": [
    "https://ontology.eglobalmark.com/apic#BeeHive"
  ],
  "https://ontology.eglobalmark.com/apic#incoming": [
    {
      "@type": [
        "https://uri.etsi.org/ngsi-ld/Relationship"
      ],
      "https://uri.etsi.org/ngsi-ld/datasetId": [
        {
          "@id": "urn:ngsi-ld:Dataset:45678"
        }
      ],
      "https://uri.etsi.org/ngsi-ld/hasObjects": [
        {
          "@list": [
            {
              "@list": [
                {
…
…

Copy link

val attributePayload = expandedAttributes.getAttributeFromExpandedAttributes(
ngsiLdAttribute.name,
ngsiLdAttributeInstance.datasetId
)!!
if (currentTea != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you place them outside the if clause ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I need them in both clauses

logger.info(message)
UpdateAttributeResult(
addAttribute(
entityUri,
ngsiLdAttribute.name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this to treate the case where a temporal entity doesn't have any instances of this attribute yet ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in 1.6, new behavior states that if the attribute does not exist, it has to be added (before it had to be ignored)

@bobeal bobeal merged commit ab9b404 into develop Apr 29, 2024
11 checks passed
@bobeal bobeal deleted the feature/1064-align-update-attributes-behavior branch April 29, 2024 07:53
@github-actions github-actions bot locked and limited conversation to collaborators Apr 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core Relates to core API feature New feature or request ngsild-1.6.1
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Align Append and Update Entity Attributes to last expected behaviour
2 participants