@itwin/insights-client
Version:
Insights client for the iTwin platform
55 lines • 3.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
const chai_1 = require("chai");
const Extraction_1 = require("../../../grouping-and-mapping/interfaces/Extraction");
const GlobalSetup_1 = require("../../utils/GlobalSetup");
const CommonTestUtils_1 = require("../../utils/imodels-client-test-utils/CommonTestUtils");
describe("CDM Client Integration Tests", () => {
let mappingOne;
let groupOne;
let extraction;
before(async () => {
mappingOne = await GlobalSetup_1.mappingsClient.createMapping(GlobalSetup_1.accessToken, {
iModelId: GlobalSetup_1.testIModel.id,
mappingName: "mappingOne",
});
groupOne = await GlobalSetup_1.groupsClient.createGroup(GlobalSetup_1.accessToken, mappingOne.id, {
groupName: "GroupOne",
description: "Group number one",
query: "SELECT * FROM bis.Element limit 10",
});
});
after(async () => {
await GlobalSetup_1.groupsClient.deleteGroup(GlobalSetup_1.accessToken, mappingOne.id, groupOne.id);
await GlobalSetup_1.mappingsClient.deleteMapping(GlobalSetup_1.accessToken, mappingOne.id);
});
it("CDM Client - Get CDM and Get CDM partition", async () => {
extraction = await GlobalSetup_1.extractionClient.runExtraction(GlobalSetup_1.accessToken, {
iModelId: GlobalSetup_1.testIModel.id,
mappings: [
{ id: mappingOne.id },
],
});
let state = Extraction_1.ExtractionState.Queued;
let status;
for (const start = performance.now(); performance.now() - start < 6 * 60 * 1000; await (0, CommonTestUtils_1.sleep)(3000)) {
status = await GlobalSetup_1.extractionClient.getExtractionStatus(GlobalSetup_1.accessToken, extraction.id);
state = status.state;
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
if (state !== Extraction_1.ExtractionState.Queued && state.valueOf() !== Extraction_1.ExtractionState.Running)
break;
}
(0, chai_1.expect)(state).to.be.eq(Extraction_1.ExtractionState.Succeeded);
const cdm = await GlobalSetup_1.cdmClient.getCDM(GlobalSetup_1.accessToken, mappingOne.id, extraction.id);
(0, chai_1.expect)(cdm).not.be.undefined;
const entity = cdm.entities[0];
const cdmPartitionLocation = entity.partitions[0].location;
const cdmPartition = await GlobalSetup_1.cdmClient.getCDMPartition(GlobalSetup_1.accessToken, mappingOne.id, extraction.id, cdmPartitionLocation);
(0, chai_1.expect)(cdmPartition.status).to.be.equal(200);
});
});
//# sourceMappingURL=CDMClient.test.js.map