Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions node/aas-aid/test/asset-interfaces-description-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Member

Choose a reason for hiding this comment

The 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",
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Member Author

Choose a reason for hiding this comment

The 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);
Copy link
Member

Choose a reason for hiding this comment

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

Remove console log and commented code?

Copy link
Member Author

Choose a reason for hiding this comment

The 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);
}
}