@itwin/insights-client
Version:
Insights client for the iTwin platform
99 lines • 5.33 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");
describe("Extraction Client", () => {
let mappingIds = [];
let mappingOne;
let mappingTwo;
let mappingThree;
let extraction;
const validExtractionStates = Object.values(Extraction_1.ExtractionState);
before(async () => {
mappingOne = await GlobalSetup_1.mappingsClient.createMapping(GlobalSetup_1.accessToken, {
iModelId: GlobalSetup_1.testIModel.id,
mappingName: "mappingOne",
});
mappingIds.push(mappingOne.id);
mappingTwo = await GlobalSetup_1.mappingsClient.createMapping(GlobalSetup_1.accessToken, {
iModelId: GlobalSetup_1.testIModel.id,
mappingName: "mappingTwo",
});
mappingIds.push(mappingTwo.id);
mappingThree = await GlobalSetup_1.mappingsClient.createMapping(GlobalSetup_1.accessToken, {
iModelId: GlobalSetup_1.testIModel.id,
mappingName: "mappingThree",
});
mappingIds.push(mappingThree.id);
extraction = await GlobalSetup_1.extractionClient.runExtraction(GlobalSetup_1.accessToken, {
iModelId: GlobalSetup_1.testIModel.id,
mappings: [
{ id: mappingOne.id },
{ id: mappingTwo.id },
{ id: mappingThree.id },
],
});
});
after(async () => {
for (const id of mappingIds) {
await GlobalSetup_1.mappingsClient.deleteMapping(GlobalSetup_1.accessToken, id);
}
mappingIds = [];
});
it("Extraction Client - Run extraction", async () => {
const extractionRequestDetails = {
iModelId: GlobalSetup_1.testIModel.id,
mappings: [
{ id: mappingThree.id },
],
};
const anotherExtraction = await GlobalSetup_1.extractionClient.runExtraction(GlobalSetup_1.accessToken, extractionRequestDetails);
(0, chai_1.expect)(anotherExtraction).to.not.be.undefined;
(0, chai_1.expect)(anotherExtraction.state).to.be.equal(Extraction_1.ExtractionState.Queued);
});
it("Extraction Client - Get extraction status", async () => {
const getStatus = await GlobalSetup_1.extractionClient.getExtractionStatus(GlobalSetup_1.accessToken, extraction.id);
(0, chai_1.expect)(getStatus).not.be.undefined;
(0, chai_1.expect)(getStatus.id).to.deep.equal(extraction.id);
(0, chai_1.expect)(validExtractionStates).includes(getStatus.state);
});
it("Extraction Client - Get iModel extractions", async () => {
const iModelExtractions = await GlobalSetup_1.extractionClient.getIModelExtractions(GlobalSetup_1.accessToken, GlobalSetup_1.testIModel.id);
(0, chai_1.expect)(iModelExtractions).to.not.be.undefined;
(0, chai_1.expect)(iModelExtractions.extractions.length).to.be.greaterThan(0);
(0, chai_1.expect)(validExtractionStates).includes(iModelExtractions.extractions[0].state);
});
it("Extraction Client - Get iModel extractions iterator", async () => {
const iModelExtractionsIt = GlobalSetup_1.extractionClient.getIModelExtractionsIterator(GlobalSetup_1.accessToken, GlobalSetup_1.testIModel.id, 2);
const pages = iModelExtractionsIt.byPage();
for await (const page of pages) {
(0, chai_1.expect)(page).to.not.be.empty;
}
(0, chai_1.expect)(iModelExtractionsIt).not.be.undefined;
});
it("Extraction Client - Get max iModel extractions using top parameter", async () => {
const iModelExtractions = await GlobalSetup_1.extractionClient.getIModelExtractions(GlobalSetup_1.accessToken, GlobalSetup_1.testIModel.id, 2);
(0, chai_1.expect)(iModelExtractions).to.not.be.undefined;
(0, chai_1.expect)(iModelExtractions.extractions.length).to.be.equal(2);
(0, chai_1.expect)(validExtractionStates).includes(iModelExtractions.extractions[0].state);
});
it("Extraction Client - Get extraction logs", async () => {
const extractionLogs = await GlobalSetup_1.extractionClient.getExtractionLogs(GlobalSetup_1.accessToken, extraction.id);
(0, chai_1.expect)(extractionLogs).not.be.undefined;
(0, chai_1.expect)(extractionLogs.logs.length).to.be.greaterThan(0);
});
it("Extraction Client - Get extraction logs iterator", async () => {
const extractionLogsIt = GlobalSetup_1.extractionClient.getExtractionLogsIterator(GlobalSetup_1.accessToken, extraction.id, 1);
const pages = extractionLogsIt.byPage();
for await (const page of pages) {
(0, chai_1.expect)(page).not.be.empty;
}
(0, chai_1.expect)(extractionLogsIt).not.be.undefined;
});
});
//# sourceMappingURL=ExtractionClient.test.js.map