-
Notifications
You must be signed in to change notification settings - Fork 9
[AID] Handling of semantic annotations #54
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
e88207d
6e909fd
e557ca1
a753e0e
7370556
9aabeda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1327,4 +1327,90 @@ class AssetInterfaceDescriptionTest { | |
| expect(isValid.valid, isValid.errors).to.equal(true); | ||
| expect(submodel).to.have.property("submodelElements").to.be.an("array").to.have.lengthOf(1); | ||
| } | ||
|
|
||
| td4: ThingDescription = { | ||
| "@context": [ | ||
| "https://www.w3.org/2022/wot/td/v1.1", | ||
| { | ||
| myPrefix1: "https://example.com/myContext1", | ||
| myPrefix2: "https://example.com/myContext2", | ||
| }, | ||
| ], | ||
| title: "test thing", | ||
| "@type": ["myPrefix1:suffix1", "myPrefix2:suffix2"], | ||
| securityDefinitions: { | ||
| nosec_sc: { | ||
| scheme: "nosec", | ||
| }, | ||
| }, | ||
| base: "http://example.com:3003", | ||
| security: ["nosec_sc"], | ||
| "myPrefix2:suffix3": "value1", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not part of the test? |
||
| properties: { | ||
| myProperty1: { | ||
| type: "number", | ||
| title: "Property Title", | ||
| "myPrefix1:suffix4": "myPrefix2:value4", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really understand the idea/system/schema behind the attached numbers but it is fine by me
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was just to make sure I create new terms in the AID to make it easier to search where they end up at |
||
| unit: "myPrefix2:value2", | ||
| forms: [ | ||
| { | ||
| href: "relative/value", | ||
| contentType: "application/json", | ||
| "htv:methodName": "GET", | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| @test async "should correctly include semantic annotations into AAS from TD"() { | ||
| const sm = this.assetInterfacesDescription.transformTD2AID(JSON.stringify(this.td4)); | ||
|
|
||
| const smObj = JSON.parse(sm); | ||
| console.log("###\n\n" + JSON.stringify(smObj) + "\n\n###"); | ||
| // const isValid = this.validateAID(smObj); | ||
| // expect(isValid.valid, isValid.errors).to.equal(true); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove console log and commented code?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| expect(smObj).to.have.property("idShort").that.equals("AssetInterfacesDescription"); | ||
| const smInterface = smObj.submodelElements[0]; | ||
|
|
||
| // InteractionMetadata with properties etc | ||
| let hasInteractionMetadata = false; | ||
| for (const smValue of smInterface.value) { | ||
| if (smValue.idShort === "InteractionMetadata") { | ||
| hasInteractionMetadata = true; | ||
| expect(smValue).to.have.property("value").to.be.an("array").to.have.lengthOf.greaterThan(0); | ||
| let hasProperties = false; | ||
| for (const interactionValues of smValue.value) { | ||
| if (interactionValues.idShort === "properties") { | ||
| hasProperties = true; | ||
| expect(interactionValues) | ||
| .to.have.property("value") | ||
| .to.be.an("array") | ||
| .to.have.lengthOf.greaterThan(0); | ||
| let hasProperty1 = false; | ||
| for (const propertyValue of interactionValues.value) { | ||
| if (propertyValue.idShort === "myProperty1") { | ||
| hasProperty1 = true; | ||
| expect(propertyValue) | ||
| .to.have.property("value") | ||
| .to.be.an("array") | ||
| .to.have.lengthOf.greaterThan(0); | ||
| let hasMyPrefix1_suffix4 = false; | ||
| for (const propProperty of propertyValue.value) { | ||
| if (propProperty.idShort === "myPrefix1_suffix4") { | ||
| hasMyPrefix1_suffix4 = true; | ||
| expect(propProperty.value).to.equal("myPrefix2:value4"); | ||
| } | ||
| } | ||
| expect(hasMyPrefix1_suffix4).to.equal(true); | ||
| } | ||
| } | ||
| expect(hasProperty1).to.equal(true); | ||
| } | ||
| } | ||
| expect(hasProperties).to.equal(true); | ||
| } | ||
| } | ||
| expect(hasInteractionMetadata, "No InteractionMetadata").to.equal(true); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.