@mindconnect/mindconnect-nodejs
Version:
NodeJS Library for Siemens Insights Hub Connectivity - TypeScript SDK for Insights Hub and Industrial IoT - Command Line Interface - Insights Hub Development Proxy (Siemens Insights Hub was formerly known as MindSphere)
180 lines (166 loc) • 8.53 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const chai = require("chai");
require("url-search-params-polyfill");
const src_1 = require("../src");
const utils_1 = require("../src/api/utils");
const test_device_setup_utils_1 = require("./test-device-setup-utils");
const test_utils_1 = require("./test-utils");
chai.should();
describe.skip("[SDK] DeviceManagementClient.Status", () => {
const auth = (0, utils_1.loadAuth)();
const sdk = new src_1.MindSphereSdk(Object.assign(Object.assign({}, auth), { basicAuth: (0, utils_1.decrypt)(auth, (0, test_utils_1.getPasskeyForUnitTest)()) }));
const deviceStatusManagement = sdk.GetDeviceStatusManagementClient();
const tenant = sdk.GetTenant();
let deviceTypeId = "aee2e37f-f562-4ed6-b90a-c43208dc054a";
let assetTypeId = `${tenant}.UnitTestDeviceAssetType`;
let assetId = "";
let deviceId = "";
let gFolderid = "";
before(() => __awaiter(void 0, void 0, void 0, function* () {
// Setup the testing architecture
const { device, deviceAsset, deviceType, deviceAssetType, folderid } = yield (0, test_device_setup_utils_1.setupDeviceTestStructure)(sdk);
assetTypeId = `${deviceAssetType.id}`;
deviceTypeId = `${deviceType.id}`;
assetId = `${deviceAsset.assetId}`;
deviceId = `${device.id}`;
gFolderid = `${folderid}`;
// report device health status
// await deviceStatusManagement.PatchDeviceHealth(deviceId, reportTemplate);
// Sends a device heartbeat
// await deviceStatusManagement.PostDeviceHeartbeat(`${deviceId}`);
}));
after(() => __awaiter(void 0, void 0, void 0, function* () {
// tear Down test infrastructure
yield (0, test_device_setup_utils_1.tearDownDeviceTestStructure)(sdk);
}));
it("SDK should not be undefined", () => __awaiter(void 0, void 0, void 0, function* () {
sdk.should.not.be.undefined;
}));
it("standard properties should be defined", () => __awaiter(void 0, void 0, void 0, function* () {
deviceStatusManagement.should.not.be.undefined;
deviceStatusManagement.GetGateway().should.be.equal(auth.gateway);
(yield deviceStatusManagement.GetToken()).length.should.be.greaterThan(200);
(yield deviceStatusManagement.GetToken()).length.should.be.greaterThan(200);
}));
/*it("should PATCH data configuration health status", async () => {
deviceStatusManagement.should.not.be.undefined;
const now = new Date();
heathStatusConfigTemplate.lastUpdate = now;
const config = await deviceStatusManagement.PatchDeviceHealthDataConfig(deviceId, heathStatusConfigTemplate);
config.should.not.be.undefined;
config.should.not.be.null;
(config as any).lastUpdate.should.be.eq(now);
});
it("should GET data configuration health status", async () => {
deviceStatusManagement.should.not.be.undefined;
const now = new Date();
const config = await deviceStatusManagement.GetDeviceHealthDataConfig(deviceId);
config.should.not.be.undefined;
config.should.not.be.null;
(config as any).lastUpdate.should.be.eq(now);
});
it("should PATCH device health status", async () => {
deviceStatusManagement.should.not.be.undefined;
reportTemplate.overall.health = DeviceStatusModels.HealthStatus.WARNING;
reportTemplate.overall.lastUpdate = new Date();
const status = await deviceStatusManagement.PatchDeviceHealth(deviceId, reportTemplate);
status.should.not.be.undefined;
status.should.not.be.null;
(status as any).overall.health.should.not.be.eq(DeviceStatusModels.HealthStatus.WARNING);
});
it("should GET device device health status", async () => {
deviceStatusManagement.should.not.be.undefined;
const status = await deviceStatusManagement.GetDeviceHealth(`${deviceId}`);
status.should.not.be.undefined;
status.should.not.be.null;
(status as any).heartbeat.should.not.be.undefined;
(status as any).heartbeat.should.not.be.null;
});
it("should POST device health beat", async () => {
deviceStatusManagement.should.not.be.undefined;
const resp = await deviceStatusManagement.PostDeviceHeartbeat(`${deviceId}`);
resp.should.not.be.undefined;
resp.should.not.be.null;
(resp as any).response.status.should.be.gte(200).and.be.lte(300);
});
it("should GET device connection status", async () => {
deviceStatusManagement.should.not.be.undefined;
const status = await deviceStatusManagement.GetDeviceConnectionStatus(`${deviceId}`);
status.should.not.be.undefined;
status.should.not.be.null;
(status as any).heartbeat.should.not.be.undefined;
(status as any).heartbeat.should.not.be.null;
});*/
it("should GET list software installed on device", () => __awaiter(void 0, void 0, void 0, function* () {
deviceStatusManagement.should.not.be.undefined;
const softwareList = yield deviceStatusManagement.GetDeviceSoftwares(`${deviceId}`);
softwareList.should.not.be.undefined;
softwareList.should.not.be.null;
softwareList.content.length.should.be.gte(0);
}));
/*it("should GET list device inventory", async () => {
deviceStatusManagement.should.not.be.undefined;
const inventory = await deviceStatusManagement.GetDeviceInventory(`${deviceId}`);
inventory.should.not.be.undefined;
inventory.should.not.be.null;
console.log(inventory);
});
it("should PATCH device inventory", async () => {
deviceStatusManagement.should.not.be.undefined;
const now = new Date();
const inventoryEntry = {
softwareId: "a7d6da...",
version: "1.3",
type: DeviceStatusModels.SoftwareType.FIRMWARE,
description: "MyDevice Firmware 1.3 debug build",
installedAt: now
};
const inventory = await deviceStatusManagement.PatchDeviceSoftwareInventory(deviceId, [inventoryEntry]);
inventory.should.not.be.undefined;
inventory.should.not.be.null;
(inventory as any).installedAt.should.be.eq(now);
});
it("should PATCH device firmware inventory", async () => {
deviceStatusManagement.should.not.be.undefined;
const now = new Date();
const firmwareEntry = {
softwareId: "7e7ee7e...",
version: "2.0",
type: DeviceStatusModels.SoftwareTypeFirmware.FIRMWARE,
description: "MyDevice Firmware 2.0 debug build",
installedAt: now
};
const inventory = await deviceStatusManagement.PatchDeviceFirmwareInventory(deviceId, [firmwareEntry]);
inventory.should.not.be.undefined;
inventory.should.not.be.null;
(inventory as any).installedAt.should.be.eq(now);
(inventory as any).version.should.be.contain("2.0");
});
it("should PATCH device app inventory", async () => {
deviceStatusManagement.should.not.be.undefined;
const now = new Date();
const appEntry = {
softwareId: "4a4a4a44",
version: "3.0",
type: DeviceStatusModels.SoftwareTypeApplication.APP,
description: "MyDevice Firmware 3.0 debug build",
installedAt: now
};
const inventory = await deviceStatusManagement.PatchDeviceApplicationInventory(deviceId, [appEntry]);
inventory.should.not.be.undefined;
inventory.should.not.be.null;
(inventory as any).installedAt.should.be.eq(now);
(inventory as any).version.should.be.contain("3.0");
});*/
});
//# sourceMappingURL=oe-device-status-management.spec.js.map