-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update embedded measure slots when updating models
- Loading branch information
Showing
7 changed files
with
368 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
166 changes: 166 additions & 0 deletions
166
tests/scenario/modules/models/asset-model-measure-slots-propagation.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
import { | ||
ApiAssetCreateRequest, | ||
ApiAssetCreateResult, | ||
} from "../../../../lib/modules/asset"; | ||
import { | ||
ApiModelUpdateAssetRequest, | ||
ApiModelUpdateAssetResult, | ||
ApiModelWriteAssetRequest, | ||
ApiModelWriteAssetResult, | ||
} from "../../../../lib/modules/model"; | ||
import { setupHooks } from "../../../helpers"; | ||
|
||
jest.setTimeout(10000); | ||
|
||
describe("Asset model measure slots propagation", () => { | ||
const sdk = setupHooks(); | ||
|
||
it("should update the embedded measure slots of existing assets with writeAsset", async () => { | ||
await sdk.query<ApiModelWriteAssetRequest, ApiModelWriteAssetResult>({ | ||
controller: "device-manager/models", | ||
action: "writeAsset", | ||
body: { | ||
engineGroup: "commons", | ||
model: "Plane", | ||
metadataMappings: { size: { type: "integer" } }, | ||
measures: [{ name: "temperatureExt", type: "temperature" }], | ||
}, | ||
}); | ||
|
||
const { result } = await sdk.query< | ||
ApiAssetCreateRequest, | ||
ApiAssetCreateResult | ||
>({ | ||
controller: "device-manager/assets", | ||
action: "create", | ||
engineId: "engine-kuzzle", | ||
body: { | ||
model: "Plane", | ||
reference: "Technoplane", | ||
metadata: { size: 8311 }, | ||
}, | ||
}); | ||
|
||
expect(result).toMatchObject({ | ||
_source: { | ||
measureSlots: [ | ||
{ | ||
name: "temperatureExt", | ||
type: "temperature", | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
await sdk.query<ApiModelWriteAssetRequest, ApiModelWriteAssetResult>({ | ||
controller: "device-manager/models", | ||
action: "writeAsset", | ||
body: { | ||
engineGroup: "commons", | ||
model: "Plane", | ||
metadataMappings: { size: { type: "integer" } }, | ||
measures: [ | ||
{ | ||
name: "temperatureExt", | ||
type: "temperature", | ||
}, | ||
{ | ||
name: "temperatureInt", | ||
type: "temperature", | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
await expect( | ||
sdk.document.get("engine-kuzzle", "assets", "Plane-Technoplane"), | ||
).resolves.toMatchObject({ | ||
_source: { | ||
measureSlots: [ | ||
{ | ||
name: "temperatureExt", | ||
type: "temperature", | ||
}, | ||
{ | ||
name: "temperatureInt", | ||
type: "temperature", | ||
}, | ||
], | ||
}, | ||
}); | ||
}); | ||
|
||
it("should update the embedded measure slots of existing assets with updateAsset", async () => { | ||
await sdk.query<ApiModelWriteAssetRequest, ApiModelWriteAssetResult>({ | ||
controller: "device-manager/models", | ||
action: "writeAsset", | ||
body: { | ||
engineGroup: "commons", | ||
model: "Plane", | ||
metadataMappings: { size: { type: "integer" } }, | ||
measures: [{ name: "temperatureExt", type: "temperature" }], | ||
}, | ||
}); | ||
|
||
const { result } = await sdk.query< | ||
ApiAssetCreateRequest, | ||
ApiAssetCreateResult | ||
>({ | ||
controller: "device-manager/assets", | ||
action: "create", | ||
engineId: "engine-kuzzle", | ||
body: { | ||
model: "Plane", | ||
reference: "Technoplane", | ||
metadata: { size: 8311 }, | ||
}, | ||
}); | ||
|
||
expect(result).toMatchObject({ | ||
_source: { | ||
measureSlots: [ | ||
{ | ||
name: "temperatureExt", | ||
type: "temperature", | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
await sdk.query<ApiModelUpdateAssetRequest, ApiModelUpdateAssetResult>({ | ||
controller: "device-manager/models", | ||
action: "updateAsset", | ||
engineGroup: "commons", | ||
model: "Plane", | ||
body: { | ||
measures: [ | ||
{ | ||
name: "temperatureExt", | ||
type: "temperature", | ||
}, | ||
{ | ||
name: "temperatureInt", | ||
type: "temperature", | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
await expect( | ||
sdk.document.get("engine-kuzzle", "assets", "Plane-Technoplane"), | ||
).resolves.toMatchObject({ | ||
_source: { | ||
measureSlots: [ | ||
{ | ||
name: "temperatureExt", | ||
type: "temperature", | ||
}, | ||
{ | ||
name: "temperatureInt", | ||
type: "temperature", | ||
}, | ||
], | ||
}, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.