diff --git a/common/api/core-backend.api.md b/common/api/core-backend.api.md index 6be7580546ee..f0de8e9e3922 100644 --- a/common/api/core-backend.api.md +++ b/common/api/core-backend.api.md @@ -2188,6 +2188,69 @@ export class GroupModel extends GroupInformationModel { static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String; } +// @internal +export class HubMock { + // (undocumented) + static acquireLocks(arg: BriefcaseDbArg, locks: LockMap): Promise; + // (undocumented) + static acquireNewBriefcaseId(arg: AcquireNewBriefcaseIdArg): Promise; + static createNewIModel(arg: CreateNewIModelProps): Promise; + // (undocumented) + static deleteIModel(arg: IModelIdArg & { + iTwinId: GuidString; + }): Promise; + static destroy(iModelId: GuidString): void; + // (undocumented) + static downloadChangeset(arg: ChangesetArg & { + targetDir: LocalDirName; + }): Promise; + // (undocumented) + static downloadChangesets(arg: ChangesetRangeArg & { + targetDir: LocalDirName; + }): Promise; + // (undocumented) + static downloadV1Checkpoint(arg: CheckpointArg): Promise; + // (undocumented) + static downloadV2Checkpoint(arg: CheckpointArg): Promise; + // (undocumented) + static findLocalHub(iModelId: GuidString): LocalHub; + static getChangesetFromNamedVersion(arg: IModelIdArg & { + versionName: string; + }): Promise; + // (undocumented) + static getChangesetFromVersion(arg: IModelIdArg & { + version: IModelVersion; + }): Promise; + // (undocumented) + static getLatestChangeset(arg: IModelIdArg): Promise; + // (undocumented) + static getMyBriefcaseIds(arg: IModelIdArg): Promise; + static get isValid(): boolean; + // (undocumented) + static get iTwinId(): string; + // (undocumented) + static pushChangeset(arg: IModelIdArg & { + changesetProps: ChangesetFileProps; + }): Promise; + // (undocumented) + static queryAllLocks(_arg: BriefcaseDbArg): Promise; + // (undocumented) + static queryChangeset(arg: ChangesetArg): Promise; + // (undocumented) + static queryChangesets(arg: IModelIdArg & { + range?: ChangesetRange; + }): Promise; + // (undocumented) + static queryIModelByName(arg: IModelNameArg): Promise; + // (undocumented) + static queryV2Checkpoint(_arg: CheckpointProps): Promise; + // (undocumented) + static releaseAllLocks(arg: BriefcaseDbArg): Promise; + static releaseBriefcase(arg: BriefcaseIdArg): Promise; + static shutdown(): void; + static startup(mockName: LocalDirName, outputDir: string): void; +} + // @beta export class IModelCloneContext { constructor(sourceDb: IModelDb, targetDb?: IModelDb); @@ -3024,6 +3087,111 @@ export interface LocalhostIpcHostOpts { socketPort?: number; } +// @internal +export class LocalHub { + constructor(rootDir: LocalDirName, arg: LocalHubProps); + // (undocumented) + acquireLock(props: LockProps, briefcase: BriefcaseIdAndChangeset): void; + acquireLocks(locks: LockMap, briefcase: BriefcaseIdAndChangeset): void; + acquireNewBriefcaseId(user: string, alias?: string): BriefcaseId; + addChangeset(changeset: ChangesetFileProps): ChangesetIndex; + addNamedVersion(arg: { + versionName: string; + csIndex: ChangesetIndex; + }): void; + // (undocumented) + get changesetDir(): string; + // (undocumented) + get checkpointDir(): string; + // (undocumented) + checkpointNameFromIndex(csIndex: ChangesetIndex): string; + // (undocumented) + cleanup(): void; + // (undocumented) + countLocks(): number; + // (undocumented) + countSharedLocks(): number; + deleteNamedVersion(versionName: string): void; + // (undocumented) + readonly description?: string; + downloadChangeset(arg: { + index: ChangesetIndex; + targetDir: LocalDirName; + }): ChangesetFileProps; + downloadChangesets(arg: { + range?: ChangesetRange; + targetDir: LocalDirName; + }): ChangesetFileProps[]; + downloadCheckpoint(arg: { + changeset: ChangesetIndexOrId; + targetFile: LocalFileName; + }): { + index: number; + id: string; + }; + findNamedVersion(versionName: string): ChangesetProps; + // (undocumented) + getBriefcase(id: BriefcaseId): MockBriefcaseIdProps; + getBriefcaseIds(user: string): BriefcaseId[]; + getBriefcases(onlyAssigned?: boolean): MockBriefcaseIdProps[]; + getChangesetById(id: ChangesetId): ChangesetProps; + getChangesetByIndex(index: ChangesetIndex): ChangesetProps; + // (undocumented) + getChangesetId(index: ChangesetIndex): ChangesetId; + getChangesetIndex(id: ChangesetId): ChangesetIndex; + getCheckpoints(range?: ChangesetRange): ChangesetIndex[]; + // (undocumented) + getIndexFromChangeset(changeset: ChangesetIndexOrId): ChangesetIndex; + // (undocumented) + getLatestChangeset(): ChangesetProps; + // (undocumented) + getParentId(index: ChangesetIndex): ChangesetId; + // (undocumented) + getPreviousIndex(index: ChangesetIndex): number; + // (undocumented) + readonly iModelId: GuidString; + // (undocumented) + readonly iModelName: string; + // (undocumented) + readonly iTwinId: GuidString; + // (undocumented) + get latestChangesetIndex(): number; + // (undocumented) + get mockDbName(): string; + // (undocumented) + queryAllLocks(briefcaseId: BriefcaseId): LockProps[]; + // (undocumented) + queryAllSharedLocks(): { + id: Id64String; + briefcaseId: BriefcaseId; + }[]; + queryChangesets(range?: ChangesetRange): ChangesetProps[]; + // (undocumented) + queryLocks(): LocksEntry[]; + // (undocumented) + queryLockStatus(elementId: Id64String): LockStatus; + queryPreviousCheckpoint(changesetIndex: ChangesetIndex): ChangesetIndex; + // (undocumented) + releaseAllLocks(arg: { + briefcaseId: BriefcaseId; + changesetIndex: ChangesetIndex; + }): void; + releaseBriefcaseId(id: BriefcaseId): void; + // (undocumented) + releaseLocks(locks: LockProps[], arg: { + briefcaseId: BriefcaseId; + changesetIndex: ChangesetIndex; + }): void; + // (undocumented) + removeDir(dirName: string): void; + // (undocumented) + readonly rootDir: LocalDirName; + uploadCheckpoint(arg: { + changesetIndex: ChangesetIndex; + localFile: LocalFileName; + }): string; +} + // @beta export class LockConflict extends IModelError { constructor( @@ -3069,6 +3237,26 @@ export enum LockState { Shared = 1 } +// @internal (undocumented) +export interface LockStatusExclusive { + // (undocumented) + briefcaseId: BriefcaseId; + // (undocumented) + lastCsIndex?: ChangesetIndex; + // (undocumented) + state: LockState.Exclusive; +} + +// @internal (undocumented) +export interface LockStatusShared { + // (undocumented) + lastCsIndex?: ChangesetIndex; + // (undocumented) + sharedBy: Set; + // (undocumented) + state: LockState.Shared; +} + // @internal export class MetaDataRegistry { add(classFullName: string, metaData: EntityMetaData): void; diff --git a/common/api/summary/core-backend.exports.csv b/common/api/summary/core-backend.exports.csv index bf890d0b831e..f5a5cb763283 100644 --- a/common/api/summary/core-backend.exports.csv +++ b/common/api/summary/core-backend.exports.csv @@ -179,6 +179,7 @@ public;class GroupInformationElement public;class GroupInformationModel public;GroupInformationPartition public;GroupModel +internal;HubMock beta;IModelCloneContext public;class IModelDb public;IModelDb @@ -216,11 +217,14 @@ public;LinkModel public;LinkPartition internal;LocalhostIpcHost internal;LocalhostIpcHostOpts +internal;LocalHub beta;LockConflict beta;LockControl internal;LockMap = Map beta;LockProps public;LockState +internal;LockStatusExclusive +internal;LockStatusShared internal;MetaDataRegistry public;Model public;ModelSelector diff --git a/common/changes/@itwin/core-backend/move-HubMock_2022-06-09-17-40.json b/common/changes/@itwin/core-backend/move-HubMock_2022-06-09-17-40.json new file mode 100644 index 000000000000..efb2a363f0a2 --- /dev/null +++ b/common/changes/@itwin/core-backend/move-HubMock_2022-06-09-17-40.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@itwin/core-backend", + "comment": "move HubMock to core-backend", + "type": "none" + } + ], + "packageName": "@itwin/core-backend" +} \ No newline at end of file diff --git a/common/changes/@itwin/core-transformer/move-HubMock_2022-06-09-17-40.json b/common/changes/@itwin/core-transformer/move-HubMock_2022-06-09-17-40.json new file mode 100644 index 000000000000..074ff572455b --- /dev/null +++ b/common/changes/@itwin/core-transformer/move-HubMock_2022-06-09-17-40.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@itwin/core-transformer", + "comment": "move HubMock to core-backend", + "type": "none" + } + ], + "packageName": "@itwin/core-transformer" +} \ No newline at end of file diff --git a/core/backend/src/test/HubMock.ts b/core/backend/src/HubMock.ts similarity index 94% rename from core/backend/src/test/HubMock.ts rename to core/backend/src/HubMock.ts index 4d67146d1247..60f09ce504d5 100644 --- a/core/backend/src/test/HubMock.ts +++ b/core/backend/src/HubMock.ts @@ -10,15 +10,15 @@ import { ChangesetFileProps, ChangesetIndex, ChangesetIndexAndId, ChangesetProps, ChangesetRange, IModelVersion, LocalDirName, } from "@itwin/core-common"; import { + AcquireNewBriefcaseIdArg, BackendHubAccess, BriefcaseDbArg, BriefcaseIdArg, ChangesetArg, ChangesetRangeArg, CheckpointArg, CreateNewIModelProps, IModelIdArg, IModelNameArg, LockMap, LockProps, V2CheckpointAccessProps, -} from "../BackendHubAccess"; -import { CheckpointProps } from "../CheckpointManager"; -import { AcquireNewBriefcaseIdArg, TokenArg } from "../core-backend"; -import { IModelHost } from "../IModelHost"; -import { IModelJsFs } from "../IModelJsFs"; -import { LocalHub } from "../LocalHub"; -import { KnownTestLocations } from "./KnownTestLocations"; +} from "./BackendHubAccess"; +import { CheckpointProps } from "./CheckpointManager"; +import { IModelHost } from "./IModelHost"; +import { IModelJsFs } from "./IModelJsFs"; +import { LocalHub } from "./LocalHub"; +import { TokenArg } from "./IModelDb"; /** * Mocks iModelHub for testing creating Briefcases, downloading checkpoints, and simulating multiple users pushing and pulling changesets, etc. @@ -67,19 +67,17 @@ export class HubMock { return this._iTwinId; } - protected static get knownTestLocations(): { outputDir: string, assetsDir: string } { return KnownTestLocations; } - /** * Begin mocking IModelHub access. After this call, all access to IModelHub will be directed to a [[LocalHub]]. * @param mockName a unique name (e.g. "MyTest") for this HubMock to disambiguate tests when more than one is simultaneously active. * It is used to create a private directory used by the HubMock for a test. That directory is removed when [[shutdown]] is called. */ - public static startup(mockName: LocalDirName) { + public static startup(mockName: LocalDirName, outputDir: string) { if (this.isValid) throw new Error("Either a previous test did not call HubMock.shutdown() properly, or more than one test is simultaneously attempting to use HubMock, which is not allowed"); this.hubs.clear(); - this.mockRoot = join(this.knownTestLocations.outputDir, "HubMock", mockName); + this.mockRoot = join(outputDir, "HubMock", mockName); IModelJsFs.recursiveMkDirSync(this.mockRoot); IModelJsFs.purgeDirSync(this.mockRoot); this._saveHubAccess = IModelHost.getHubAccess(); @@ -100,7 +98,9 @@ export class HubMock { hub[1].cleanup(); this.hubs.clear(); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion IModelJsFs.purgeDirSync(this.mockRoot!); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion IModelJsFs.removeSync(this.mockRoot!); sinon.restore(); IModelHost.setHubAccess(this._saveHubAccess); diff --git a/core/backend/src/core-backend.ts b/core/backend/src/core-backend.ts index 953ea0b40c98..5d1d03114167 100644 --- a/core/backend/src/core-backend.ts +++ b/core/backend/src/core-backend.ts @@ -17,6 +17,8 @@ export * from "./ElementAspect"; export * from "./Entity"; export * from "./ExportGraphics"; export * from "./ExternalSource"; +export * from "./LocalHub"; +export * from "./HubMock"; export * from "./IModelJsFs"; export * from "./BackendHubAccess"; export * from "./Relationship"; diff --git a/core/backend/src/test/IModelTestUtils.ts b/core/backend/src/test/IModelTestUtils.ts index 11c651251227..b5618b837e4b 100644 --- a/core/backend/src/test/IModelTestUtils.ts +++ b/core/backend/src/test/IModelTestUtils.ts @@ -31,7 +31,7 @@ import { DefinitionModel, DocumentListModel, DrawingModel, InformationRecordMode import { DrawingGraphicRepresentsElement, ElementDrivesElement, Relationship, RelationshipProps } from "../Relationship"; import { DownloadAndOpenArgs, RpcBriefcaseUtility } from "../rpc-impl/RpcBriefcaseUtility"; import { Schema, Schemas } from "../Schema"; -import { HubMock } from "./HubMock"; +import { HubMock } from "../HubMock"; import { KnownTestLocations } from "./KnownTestLocations"; import { BackendHubAccess } from "../BackendHubAccess"; diff --git a/core/backend/src/test/TestChangeSetUtility.ts b/core/backend/src/test/TestChangeSetUtility.ts index b622ef4fdf79..af04e2f73e62 100644 --- a/core/backend/src/test/TestChangeSetUtility.ts +++ b/core/backend/src/test/TestChangeSetUtility.ts @@ -6,8 +6,8 @@ import { AccessToken, GuidString } from "@itwin/core-bentley"; import { ColorDef, IModel, SubCategoryAppearance } from "@itwin/core-common"; import { BriefcaseDb, IModelHost, SpatialCategory } from "../core-backend"; -import { HubWrappers } from "./IModelTestUtils"; -import { HubMock, IModelTestUtils } from "./index"; +import { HubMock } from "../HubMock"; +import { HubWrappers, IModelTestUtils } from "./IModelTestUtils"; /** Test utility to push an iModel and ChangeSets */ export class TestChangeSetUtility { diff --git a/core/backend/src/test/hubaccess/BriefcaseManager.test.ts b/core/backend/src/test/hubaccess/BriefcaseManager.test.ts index f34c0b34a0e6..fe2c6d0b7ef8 100644 --- a/core/backend/src/test/hubaccess/BriefcaseManager.test.ts +++ b/core/backend/src/test/hubaccess/BriefcaseManager.test.ts @@ -6,10 +6,11 @@ import { assert } from "chai"; import { Guid } from "@itwin/core-bentley"; import { BriefcaseIdValue } from "@itwin/core-common"; -import { HubWrappers, TestChangeSetUtility } from ".."; import { Element } from "../../Element"; -import { HubMock } from "../HubMock"; -import { IModelTestUtils } from "../IModelTestUtils"; +import { HubWrappers, IModelTestUtils } from "../IModelTestUtils"; +import { KnownTestLocations } from "../KnownTestLocations"; +import { HubMock } from "../../HubMock"; +import { TestChangeSetUtility } from "../TestChangeSetUtility"; describe("BriefcaseManager", async () => { const testITwinId: string = Guid.createValue(); @@ -20,7 +21,7 @@ describe("BriefcaseManager", async () => { afterEach(() => HubMock.shutdown()); it("Open iModels with various names causing potential issues on Windows/Unix", async () => { - HubMock.startup("bad names"); + HubMock.startup("bad names", KnownTestLocations.outputDir); let iModelName = "iModel Name With Spaces"; let iModelId = await HubWrappers.createIModel(managerAccessToken, testITwinId, iModelName); const args = { accessToken, iTwinId: testITwinId, iModelId }; @@ -49,7 +50,7 @@ describe("BriefcaseManager", async () => { }); it("should set appropriate briefcase ids for FixedVersion, PullOnly and PullAndPush workflows", async () => { - HubMock.startup("briefcaseIds"); + HubMock.startup("briefcaseIds", KnownTestLocations.outputDir); const iModelId = await HubWrappers.createIModel(accessToken, testITwinId, "imodel1"); const args = { accessToken, iTwinId: testITwinId, iModelId, deleteFirst: true }; const iModel1 = await HubWrappers.openCheckpointUsingRpc(args); @@ -68,7 +69,7 @@ describe("BriefcaseManager", async () => { }); it("should reuse a briefcaseId when re-opening iModels for pullAndPush workflows", async () => { - HubMock.startup("briefcaseIdsReopen"); + HubMock.startup("briefcaseIdsReopen", KnownTestLocations.outputDir); const iModelId = await HubWrappers.createIModel(accessToken, testITwinId, "imodel1"); const args = { accessToken, iTwinId: testITwinId, iModelId, deleteFirst: false }; @@ -85,7 +86,7 @@ describe("BriefcaseManager", async () => { }); it("should reuse a briefcaseId when re-opening iModels of different versions for pullAndPush and pullOnly workflows", async () => { - HubMock.startup("workflow"); + HubMock.startup("workflow", KnownTestLocations.outputDir); const userToken1 = "manager token"; const userToken2 = "super manager token"; @@ -129,7 +130,7 @@ describe("BriefcaseManager", async () => { }); it("should be able to edit a PullAndPush briefcase, reopen it as of a new version, and then push changes", async () => { - HubMock.startup("pullPush"); + HubMock.startup("pullPush", KnownTestLocations.outputDir); const userToken1 = "manager token"; // User1 is just used to create and update the iModel const userToken2 = "super manager token"; // User2 is used for the test diff --git a/core/backend/src/test/hubaccess/CheckpointManager.test.ts b/core/backend/src/test/hubaccess/CheckpointManager.test.ts index eaab12d4132e..c82f745ff2de 100644 --- a/core/backend/src/test/hubaccess/CheckpointManager.test.ts +++ b/core/backend/src/test/hubaccess/CheckpointManager.test.ts @@ -8,12 +8,12 @@ import * as path from "path"; import * as sinon from "sinon"; import { Guid, IModelStatus } from "@itwin/core-bentley"; import { IModelError } from "@itwin/core-common"; -import { HubMock } from "../"; import { CheckpointManager, V1CheckpointManager, V2CheckpointManager } from "../../CheckpointManager"; import { IModelHost } from "../../core-backend"; import { SnapshotDb } from "../../IModelDb"; import { IModelJsFs } from "../../IModelJsFs"; import { IModelTestUtils } from "../IModelTestUtils"; +import { HubMock } from "../../HubMock"; describe("V1 Checkpoint Manager", () => { it("empty props", async () => { diff --git a/core/backend/src/test/imodel/IModel.test.ts b/core/backend/src/test/imodel/IModel.test.ts index 923dabbf09db..ca2366409bc9 100644 --- a/core/backend/src/test/imodel/IModel.test.ts +++ b/core/backend/src/test/imodel/IModel.test.ts @@ -32,7 +32,7 @@ import { SqliteValue, SqliteValueType, StandaloneDb, SubCategory, Subject, Texture, ViewDefinition, } from "../../core-backend"; import { BriefcaseDb } from "../../IModelDb"; -import { HubMock } from "../HubMock"; +import { HubMock } from "../../HubMock"; import { DisableNativeAssertions, IModelTestUtils } from "../index"; import { KnownTestLocations } from "../KnownTestLocations"; diff --git a/core/backend/src/test/index.ts b/core/backend/src/test/index.ts index 88807590c607..818c0d1c45a9 100644 --- a/core/backend/src/test/index.ts +++ b/core/backend/src/test/index.ts @@ -2,7 +2,6 @@ * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -export * from "./HubMock"; export * from "./IModelTestUtils"; export * from "./KnownTestLocations"; export * from "./RevisionUtility"; diff --git a/core/backend/src/test/standalone/HubMock.test.ts b/core/backend/src/test/standalone/HubMock.test.ts index c6d60eb1ef91..d55ededc2834 100644 --- a/core/backend/src/test/standalone/HubMock.test.ts +++ b/core/backend/src/test/standalone/HubMock.test.ts @@ -11,7 +11,7 @@ import { LockProps, LockState } from "../../BackendHubAccess"; import { BriefcaseManager } from "../../BriefcaseManager"; import { IModelHost } from "../../IModelHost"; import { IModelJsFs } from "../../IModelJsFs"; -import { HubMock } from "../HubMock"; +import { HubMock } from "../../HubMock"; import { IModelTestUtils } from "../IModelTestUtils"; import { KnownTestLocations } from "../KnownTestLocations"; import { LockStatusExclusive, LockStatusShared } from "../../LocalHub"; @@ -22,8 +22,8 @@ describe("HubMock", () => { const version0 = IModelTestUtils.resolveAssetFile("test.bim"); const accessToken: AccessToken = "fake token"; - before(async () => { - HubMock.startup("HubMockTest"); + before(() => { + HubMock.startup("HubMockTest", KnownTestLocations.outputDir); }); after(() => { HubMock.shutdown(); diff --git a/core/backend/src/test/standalone/IModelWrite.test.ts b/core/backend/src/test/standalone/IModelWrite.test.ts index 395722e6fff0..a94aa902b2e9 100644 --- a/core/backend/src/test/standalone/IModelWrite.test.ts +++ b/core/backend/src/test/standalone/IModelWrite.test.ts @@ -10,14 +10,14 @@ import { Code, ColorDef, GeometryStreamProps, IModel, QueryRowFormat, RequestNewBriefcaseProps, SchemaState, SubCategoryAppearance, } from "@itwin/core-common"; import { Arc3d, IModelJson, Point3d } from "@itwin/core-geometry"; +import { HubWrappers, KnownTestLocations } from "../"; import { DrawingCategory } from "../../Category"; import { BriefcaseDb, BriefcaseManager, DictionaryModel, IModelHost, IModelJsFs, SpatialCategory, SqliteStatement, SqliteValue, SqliteValueType, } from "../../core-backend"; import { ECSqlStatement } from "../../ECSqlStatement"; -import { HubMock } from "../HubMock"; +import { HubMock } from "../../HubMock"; import { IModelTestUtils, TestUserType } from "../IModelTestUtils"; -import { HubWrappers } from ".."; export async function createNewModelAndCategory(rwIModel: BriefcaseDb, parent?: Id64String) { // Create a new physical model. @@ -44,7 +44,7 @@ describe("IModelWriteTest", () => { before(async () => { // IModelTestUtils.setupDebugLogLevels(); - HubMock.startup("IModelWriteTest"); + HubMock.startup("IModelWriteTest", KnownTestLocations.outputDir); testITwinId = HubMock.iTwinId; readWriteTestIModelName = IModelTestUtils.generateUniqueName("ReadWriteTest"); diff --git a/core/backend/src/test/standalone/PushChanges.test.ts b/core/backend/src/test/standalone/PushChanges.test.ts index f5c5a49699ce..60fa44272150 100644 --- a/core/backend/src/test/standalone/PushChanges.test.ts +++ b/core/backend/src/test/standalone/PushChanges.test.ts @@ -3,16 +3,18 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ import { AccessToken, GuidString, Id64String } from "@itwin/core-bentley"; -import { Box, Point3d, Range3d, Vector3d, YawPitchRollAngles } from "@itwin/core-geometry"; import { - Code, ColorDef, GeometryParams, GeometryPartProps, - GeometryStreamBuilder, GeometryStreamProps, IModel, PhysicalElementProps, SubCategoryAppearance, + Code, ColorDef, GeometryParams, GeometryPartProps, GeometryStreamBuilder, GeometryStreamProps, IModel, PhysicalElementProps, SubCategoryAppearance, } from "@itwin/core-common"; +import { Box, Point3d, Range3d, Vector3d, YawPitchRollAngles } from "@itwin/core-geometry"; +import { + BriefcaseDb, BriefcaseManager, DefinitionModel, GeometryPart, IModelDb, PhysicalModel, PhysicalObject, RenderMaterialElement, SpatialCategory, + SubCategory, Subject, +} from "../../core-backend"; import { IModelHost } from "../../IModelHost"; -import { BriefcaseDb, BriefcaseManager, DefinitionModel, GeometryPart, IModelDb, PhysicalModel, PhysicalObject, RenderMaterialElement, SpatialCategory, SubCategory, Subject } from "../../core-backend"; -import { HubMock } from "../HubMock"; -import { IModelTestUtils } from "../IModelTestUtils"; -import { HubWrappers } from ".."; +import { HubMock } from "../../HubMock"; +import { HubWrappers, IModelTestUtils } from "../IModelTestUtils"; +import { KnownTestLocations } from "../KnownTestLocations"; class TestIModelWriter { public static insertGeometryPart(iModel: IModelDb, definitionModelId: Id64String): Id64String { @@ -80,7 +82,7 @@ describe("PushChangesTest (#integration)", () => { before(async () => { // IModelTestUtils.setupDebugLogLevels(); - HubMock.startup("PushChangesTest"); + HubMock.startup("PushChangesTest", KnownTestLocations.outputDir); accessToken = "manager token"; iTwinId = HubMock.iTwinId; diff --git a/core/backend/src/test/standalone/ServerBasedLocks.test.ts b/core/backend/src/test/standalone/ServerBasedLocks.test.ts index b10632088107..94b1a8b6127b 100644 --- a/core/backend/src/test/standalone/ServerBasedLocks.test.ts +++ b/core/backend/src/test/standalone/ServerBasedLocks.test.ts @@ -15,8 +15,9 @@ import { BriefcaseDb, SnapshotDb } from "../../IModelDb"; import { IModelHost } from "../../IModelHost"; import { ElementOwnsChildElements } from "../../NavigationRelationship"; import { ServerBasedLocks } from "../../ServerBasedLocks"; -import { HubMock } from "../HubMock"; +import { HubMock } from "../../HubMock"; import { ExtensiveTestScenario, IModelTestUtils } from "../IModelTestUtils"; +import { KnownTestLocations } from "../KnownTestLocations"; describe("Server-based locks", () => { const createVersion0 = async () => { @@ -37,7 +38,7 @@ describe("Server-based locks", () => { afterEach(() => sinonRestore()); before(async () => { - HubMock.startup("ServerBasedLocks"); + HubMock.startup("ServerBasedLocks", KnownTestLocations.outputDir); const iModelProps = { iModelName: "server locks test", diff --git a/core/backend/src/test/standalone/TileCache.test.ts b/core/backend/src/test/standalone/TileCache.test.ts index 86860b0b1371..9e03f487f38e 100644 --- a/core/backend/src/test/standalone/TileCache.test.ts +++ b/core/backend/src/test/standalone/TileCache.test.ts @@ -16,9 +16,8 @@ import { IModelDb, SnapshotDb } from "../../IModelDb"; import { RpcTrace } from "../../RpcBackend"; import { IModelTestUtils, TestUtils } from "../index"; import { IModelJsFs } from "../../IModelJsFs"; - -import { HubMock } from ".."; import { GeometricModel3d } from "../../Model"; +import { HubMock } from "../../HubMock"; const fakeRpc: RpcActivity = { accessToken: "dummy", diff --git a/core/transformer/src/test/HubMock.ts b/core/transformer/src/test/HubMock.ts deleted file mode 100644 index 90c063ed56d8..000000000000 --- a/core/transformer/src/test/HubMock.ts +++ /dev/null @@ -1,10 +0,0 @@ -/*--------------------------------------------------------------------------------------------- -* Copyright (c) Bentley Systems, Incorporated. All rights reserved. -* See LICENSE.md in the project root for license terms and full copyright notice. -*--------------------------------------------------------------------------------------------*/ -import { HubMock as BackendHubMock } from "@itwin/core-backend/lib/cjs/test/HubMock"; -import { KnownTestLocations } from "./KnownTestLocations"; - -export class HubMock extends BackendHubMock { - protected static override get knownTestLocations() { return KnownTestLocations; } -} diff --git a/core/transformer/src/test/IModelTransformerUtils.ts b/core/transformer/src/test/IModelTransformerUtils.ts index f3b12f9cf63c..26d5243bdfb2 100644 --- a/core/transformer/src/test/IModelTransformerUtils.ts +++ b/core/transformer/src/test/IModelTransformerUtils.ts @@ -11,7 +11,7 @@ import { Geometry, Point3d, Transform, YawPitchRollAngles } from "@itwin/core-ge import { AuxCoordSystem, AuxCoordSystem2d, CategorySelector, DefinitionModel, DisplayStyle3d, DrawingCategory, DrawingGraphicRepresentsElement, ECSqlStatement, Element, ElementAspect, ElementMultiAspect, ElementRefersToElements, ElementUniqueAspect, Entity, ExternalSourceAspect, FunctionalSchema, - GeometricElement3d, GeometryPart, IModelDb, IModelJsFs, InformationPartitionElement, InformationRecordModel, Model, ModelSelector, + GeometricElement3d, GeometryPart, HubMock, IModelDb, IModelJsFs, InformationPartitionElement, InformationRecordModel, Model, ModelSelector, OrthographicViewDefinition, PhysicalElement, PhysicalModel, PhysicalObject, PhysicalPartition, Relationship, RelationshipProps, RenderMaterialElement, SnapshotDb, SpatialCategory, SpatialLocationModel, SpatialViewDefinition, SubCategory, Subject, Texture, } from "@itwin/core-backend"; @@ -23,7 +23,6 @@ import { } from "@itwin/core-common"; import { IModelExporter, IModelExportHandler, IModelImporter, IModelTransformer } from "../core-transformer"; import { KnownTestLocations } from "./KnownTestLocations"; -import { HubMock } from "./HubMock"; interface DeepEqualWithFpToleranceOpts { tolerance?: number; @@ -86,11 +85,9 @@ Assertion.addMethod( isDeep ? deepEqualWithFpTolerance(expected, actual, options) : isAlmostEqualNumber(expected, actual, options.tolerance), - `expected ${ - isDeep ? "deep equality of " : " " + `expected ${isDeep ? "deep equality of " : " " }#{exp} and #{act} with a tolerance of ${options.tolerance}`, - `expected ${ - isDeep ? "deep inequality of " : " " + `expected ${isDeep ? "deep inequality of " : " " }#{exp} and #{act} with a tolerance of ${options.tolerance}`, expected, actual @@ -282,17 +279,14 @@ function getAllElemMetaDataProperties(elem: Element) { /** * Assert that an identity (no changes) transformation has occurred between two IModelDbs - * @note If you do not pass a transformer or custom implemention of an id remapping context, it defaults to assuming + * @note If you do not pass a transformer or custom implementation of an id remapping context, it defaults to assuming * no remapping occurred and therefore can be used as a general db-content-equivalence check */ export async function assertIdentityTransformation( sourceDb: IModelDb, targetDb: IModelDb, /** either an IModelTransformer instance or a function mapping source element ids to target elements */ - remapper: - | IModelTransformer - | ((id: Id64String) => Id64String) - | { + remapper: IModelTransformer | ((id: Id64String) => Id64String) | { findTargetCodeSpecId: (id: Id64String) => Id64String; findTargetElementId: (id: Id64String) => Id64String; } = (id: Id64String) => id, @@ -551,7 +545,7 @@ export async function assertIdentityTransformation( const relInTarget = targetRelationshipsToFind.get(relInTargetKey); const relClassName = sourceDb.withPreparedStatement( "SELECT Name FROM meta.ECClassDef WHERE ECInstanceId=?", - (s) => { s.bindId(1,relInSource.ECClassId); s.step(); return s.getValue(0).getString(); } + (s) => { s.bindId(1, relInSource.ECClassId); s.step(); return s.getValue(0).getString(); } ); expect(relInTarget, `rel ${relClassName}:${relInSource.SourceECInstanceId}->${relInSource.TargetECInstanceId} was missing`).not.to.be.undefined; // this won't work if the relationship instance has navigation properties (or any property that was changed by the transformer) diff --git a/core/transformer/src/test/standalone/IModelTransformerHub.test.ts b/core/transformer/src/test/standalone/IModelTransformerHub.test.ts index 51c129f77480..7c6173afce2f 100644 --- a/core/transformer/src/test/standalone/IModelTransformerHub.test.ts +++ b/core/transformer/src/test/standalone/IModelTransformerHub.test.ts @@ -7,9 +7,11 @@ import { assert, expect } from "chai"; import { join } from "path"; import * as semver from "semver"; import { - BisCoreSchema, BriefcaseDb, BriefcaseManager, ECSqlStatement, Element, ElementRefersToElements, ExternalSourceAspect, GenericSchema, IModelDb, - IModelHost, IModelJsFs, IModelJsNative, ModelSelector, NativeLoggerCategory, PhysicalModel, PhysicalObject, PhysicalPartition, SnapshotDb, SpatialCategory, + BisCoreSchema, BriefcaseDb, BriefcaseManager, ECSqlStatement, Element, ElementRefersToElements, ExternalSourceAspect, GenericSchema, HubMock, IModelDb, + IModelHost, IModelJsFs, IModelJsNative, ModelSelector, NativeLoggerCategory, PhysicalModel, PhysicalObject, PhysicalPartition, SnapshotDb, + SpatialCategory, } from "@itwin/core-backend"; + import * as BackendTestUtils from "@itwin/core-backend/lib/cjs/test"; import { AccessToken, DbResult, Guid, GuidString, Id64, Id64String, Logger, LogLevel } from "@itwin/core-bentley"; import { Code, ColorDef, ElementProps, IModel, IModelVersion, PhysicalElementProps, SubCategoryAppearance } from "@itwin/core-common"; @@ -20,7 +22,6 @@ import { TransformerExtensiveTestScenario as TransformerExtensiveTestScenario, } from "../IModelTransformerUtils"; import { KnownTestLocations } from "../KnownTestLocations"; -import { HubMock } from "../HubMock"; describe("IModelTransformerHub", () => { const outputDir = join(KnownTestLocations.outputDir, "IModelTransformerHub"); @@ -28,7 +29,7 @@ describe("IModelTransformerHub", () => { let accessToken: AccessToken; before(async () => { - HubMock.startup("IModelTransformerHub"); + HubMock.startup("IModelTransformerHub", KnownTestLocations.outputDir); iTwinId = HubMock.iTwinId; IModelJsFs.recursiveMkDirSync(outputDir); @@ -640,7 +641,7 @@ describe("IModelTransformerHub", () => { return super.onExportElement(sourceElement); } } - const synchronizer = new IModelTransformerInjected (sourceDb, new IModelImporterInjected(targetDb)); + const synchronizer = new IModelTransformerInjected(sourceDb, new IModelImporterInjected(targetDb)); await synchronizer.processChanges(accessToken); expect(didExportModelSelector).to.be.true; expect(didImportModelSelector).to.be.true; diff --git a/core/transformer/src/test/standalone/IModelTransformerResumption.test.ts b/core/transformer/src/test/standalone/IModelTransformerResumption.test.ts index 5cfa2a2c3acd..79a798709999 100644 --- a/core/transformer/src/test/standalone/IModelTransformerResumption.test.ts +++ b/core/transformer/src/test/standalone/IModelTransformerResumption.test.ts @@ -3,7 +3,7 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { BriefcaseDb, Element, IModelDb, IModelHost, IModelJsNative, Relationship, SnapshotDb, SQLiteDb } from "@itwin/core-backend"; +import { BriefcaseDb, Element, HubMock, IModelDb, IModelHost, IModelJsNative, Relationship, SnapshotDb, SQLiteDb } from "@itwin/core-backend"; import * as BackendTestUtils from "@itwin/core-backend/lib/cjs/test"; import { AccessToken, DbResult, GuidString, Id64, Id64String, StopWatch } from "@itwin/core-bentley"; import { ChangesetId, ElementProps } from "@itwin/core-common"; @@ -13,7 +13,7 @@ import { IModelImporter } from "../../IModelImporter"; import { IModelExporter } from "../../IModelExporter"; import { IModelTransformer, IModelTransformOptions } from "../../IModelTransformer"; import { assertIdentityTransformation, HubWrappers, IModelTransformerTestUtils } from "../IModelTransformerUtils"; -import { HubMock } from "../HubMock"; +import { KnownTestLocations } from "../KnownTestLocations"; const formatter = new Intl.NumberFormat("en-US", { maximumFractionDigits: 2, @@ -226,17 +226,17 @@ describe("test resuming transformations", () => { let seedDb: BriefcaseDb; before(async () => { - HubMock.startup("IModelTransformerResumption"); + HubMock.startup("IModelTransformerResumption", KnownTestLocations.outputDir); iTwinId = HubMock.iTwinId; accessToken = await HubWrappers.getAccessToken(BackendTestUtils.TestUserType.Regular); const seedPath = IModelTransformerTestUtils.prepareOutputFile("IModelTransformerResumption", "seed.bim"); - SnapshotDb.createEmpty(seedPath, { rootSubject: { name: "resumption-tests-seed" }}); + SnapshotDb.createEmpty(seedPath, { rootSubject: { name: "resumption-tests-seed" } }); seedDbId = await IModelHost.hubAccess.createNewIModel({ iTwinId, iModelName: "ResumeTestsSeed", description: "seed for resumption tests", version0: seedPath, noLocks: true }); seedDb = await HubWrappers.downloadAndOpenBriefcase({ accessToken, iTwinId, iModelId: seedDbId }); await BackendTestUtils.ExtensiveTestScenario.prepareDb(seedDb); BackendTestUtils.ExtensiveTestScenario.populateDb(seedDb); seedDb.saveChanges(); - await seedDb.pushChanges({accessToken, description: "populated seed db"}); + await seedDb.pushChanges({ accessToken, description: "populated seed db" }); }); after(async () => { @@ -251,7 +251,7 @@ describe("test resuming transformations", () => { const targetDbId = await IModelHost.hubAccess.createNewIModel({ iTwinId, iModelName: "targetDb2", description: "non crashing target", noLocks: true }); const targetDb = await HubWrappers.downloadAndOpenBriefcase({ accessToken, iTwinId, iModelId: targetDbId }); const transformer = new IModelTransformer(sourceDb, targetDb); - await transformNoCrash({sourceDb, targetDb, transformer}); + await transformNoCrash({ sourceDb, targetDb, transformer }); targetDb.saveChanges(); return [transformer, targetDb] as const; })(); @@ -266,7 +266,7 @@ describe("test resuming transformations", () => { transformer.elementExportsUntilCall = 10; transformer.callback = async () => { targetDb.saveChanges(); - await targetDb.pushChanges({accessToken, description: "early state save"}); + await targetDb.pushChanges({ accessToken, description: "early state save" }); transformer.saveStateToFile(dumpPath); changesetId = targetDb.changeset.id; // now after another 10 exported elements, interrupt for resumption @@ -330,9 +330,11 @@ describe("test resuming transformations", () => { const targetDb = await HubWrappers.downloadAndOpenBriefcase({ accessToken, iTwinId, iModelId: targetDbId }); const transformer = new CountdownToCrashTransformer(sourceDb, targetDb); transformer.elementExportsUntilCall = 10; - await transformWithCrashAndRecover({sourceDb, targetDb, transformer, disableCrashing(t) { - t.elementExportsUntilCall = undefined; - }}); + await transformWithCrashAndRecover({ + sourceDb, targetDb, transformer, disableCrashing(t) { + t.elementExportsUntilCall = undefined; + }, + }); targetDb.saveChanges(); transformer.dispose(); return targetDb; @@ -342,7 +344,7 @@ describe("test resuming transformations", () => { const targetDbId = await IModelHost.hubAccess.createNewIModel({ iTwinId, iModelName: "targetDb2", description: "non crashing target", noLocks: true }); const targetDb = await HubWrappers.downloadAndOpenBriefcase({ accessToken, iTwinId, iModelId: targetDbId }); const transformer = new IModelTransformer(sourceDb, targetDb); - await transformNoCrash({sourceDb, targetDb, transformer}); + await transformNoCrash({ sourceDb, targetDb, transformer }); targetDb.saveChanges(); transformer.dispose(); return targetDb; @@ -457,9 +459,9 @@ describe("test resuming transformations", () => { } } - class DifferentTransformerClass extends CrashOn2Transformer {} - class DifferentImporterClass extends IModelImporter {} - class DifferentExporterClass extends IModelExporter {} + class DifferentTransformerClass extends CrashOn2Transformer { } + class DifferentImporterClass extends IModelImporter { } + class DifferentExporterClass extends IModelExporter { } await testResumeCrashTransformerWithClasses({ StartTransformerClass: CrashOn2Transformer, ResumeTransformerClass: DifferentTransformerClass }); await testResumeCrashTransformerWithClasses({ StartTransformerClass: CrashOn2Transformer, ResumeImporterClass: DifferentImporterClass }); @@ -474,7 +476,7 @@ describe("test resuming transformations", () => { protected override loadAdditionalStateJson(additionalState: any) { this.state1 = additionalState.state1; } } class AdditionalStateExporter extends IModelExporter { - public state1 = "exporter"; + public state1 = "exporter"; protected override getAdditionalStateJson() { return { state1: this.state1 }; } protected override loadAdditionalStateJson(additionalState: any) { this.state1 = additionalState.state1; } } @@ -607,7 +609,7 @@ describe("test resuming transformations", () => { const targetDbId = await IModelHost.hubAccess.createNewIModel({ iTwinId, iModelName: "targetDb2", description: "non crashing target", noLocks: true }); const targetDb = await HubWrappers.downloadAndOpenBriefcase({ accessToken, iTwinId, iModelId: targetDbId }); const transformer = new IModelTransformer(sourceDb, targetDb); - await transformNoCrash({sourceDb, targetDb, transformer}); + await transformNoCrash({ sourceDb, targetDb, transformer }); targetDb.saveChanges(); transformer.dispose(); return targetDb; @@ -629,7 +631,7 @@ describe("test resuming transformations", () => { await BackendTestUtils.ExtensiveTestScenario.prepareDb(sourceDb); BackendTestUtils.ExtensiveTestScenario.populateDb(sourceDb); sourceDb.saveChanges(); - await sourceDb.pushChanges({accessToken, description: "populated source db"}); + await sourceDb.pushChanges({ accessToken, description: "populated source db" }); const targetDbRev0Path = IModelTransformerTestUtils.prepareOutputFile("IModelTransformerResumption", "processChanges-targetDbRev0.bim"); const targetDbRev0 = SnapshotDb.createFrom(sourceDb, targetDbRev0Path); @@ -640,7 +642,7 @@ describe("test resuming transformations", () => { BackendTestUtils.ExtensiveTestScenario.updateDb(sourceDb); sourceDb.saveChanges(); - await sourceDb.pushChanges({accessToken, description: "updated source db"}); + await sourceDb.pushChanges({ accessToken, description: "updated source db" }); const regularTarget = await (async () => { const targetDbId = await IModelHost.hubAccess.createNewIModel({ @@ -674,13 +676,15 @@ describe("test resuming transformations", () => { const targetDb = await HubWrappers.downloadAndOpenBriefcase({ accessToken, iTwinId, iModelId: targetDbId }); const transformer = new CountdownToCrashTransformer(sourceDb, targetDb); transformer.elementExportsUntilCall = 10; - await transformWithCrashAndRecover({sourceDb, targetDb, transformer, disableCrashing(t) { - t.elementExportsUntilCall = undefined; - }, async transformerProcessing(t) { - await t.processChanges(accessToken); - }}); + await transformWithCrashAndRecover({ + sourceDb, targetDb, transformer, disableCrashing(t) { + t.elementExportsUntilCall = undefined; + }, async transformerProcessing(t) { + await t.processChanges(accessToken); + }, + }); targetDb.saveChanges(); - await targetDb.pushChanges({accessToken, description: "completed transformation that crashed"}); + await targetDb.pushChanges({ accessToken, description: "completed transformation that crashed" }); transformer.dispose(); return targetDb; })(); @@ -702,9 +706,11 @@ describe("test resuming transformations", () => { const targetDb = SnapshotDb.createEmpty(targetDbPath, sourceDb); const transformer = new CountdownToCrashTransformer(sourceDb, targetDb); transformer.elementExportsUntilCall = Number(process.env.TRANSFORMER_RESUMPTION_TEST_SINGLE_MODEL_ELEMENTS_BEFORE_CRASH) || 2_500_000; - await transformWithCrashAndRecover({sourceDb, targetDb, transformer, disableCrashing(t) { - t.elementExportsUntilCall = undefined; - }}); + await transformWithCrashAndRecover({ + sourceDb, targetDb, transformer, disableCrashing(t) { + t.elementExportsUntilCall = undefined; + }, + }); targetDb.saveChanges(); transformer.dispose(); return targetDb; @@ -714,7 +720,7 @@ describe("test resuming transformations", () => { const targetDbPath = "/tmp/huge-model-out.bim"; const targetDb = SnapshotDb.createEmpty(targetDbPath, sourceDb); const transformer = new IModelTransformer(sourceDb, targetDb); - await transformNoCrash({sourceDb, targetDb, transformer}); + await transformNoCrash({ sourceDb, targetDb, transformer }); targetDb.saveChanges(); transformer.dispose(); return targetDb; @@ -790,7 +796,7 @@ describe("test resuming transformations", () => { const targetDb = SnapshotDb.createEmpty(targetDbPath, sourceDb); const transformer = new IModelTransformer(sourceDb, targetDb); enableCrashes(false); - return transformNoCrash({sourceDb, targetDb, transformer}); + return transformNoCrash({ sourceDb, targetDb, transformer }); })(); await assertIdentityTransformation(regularTarget, crashingTarget); @@ -818,11 +824,7 @@ describe("test resuming transformations", () => { const avgExportedEntityCount = totalExportedEntities / totalNonCrashingTransformations; // eslint-disable-next-line no-console - console.log(`the average non crashing transformation took ${ - formatter.format(avgNonCrashingTransformationsTime) - } and made ${ - formatter.format(avgCrashableCallsMade) - } native calls.`); + console.log(`the average non crashing transformation took ${formatter.format(avgNonCrashingTransformationsTime)} and made ${formatter.format(avgCrashableCallsMade)} native calls.`); let totalCrashingTransformationsTime = 0.0; const targetTotalCrashingTransformations = Number(process.env.TRANSFORMER_RESUMPTION_TEST_TARGET_TOTAL_CRASHING_TRANSFORMATIONS) || 50; @@ -836,17 +838,11 @@ describe("test resuming transformations", () => { const proportionOfNonCrashingTransformTime = result.finalTransformationTime / avgNonCrashingTransformationsTime; const proportionOfNonCrashingTransformCalls = result.finalTransformationCallsMade / avgCrashableCallsMade; const proportionOfNonCrashingEntityImports = result.importedEntityCount / avgImportedEntityCount; - expect(result.exportedEntityCount ).to.equal(avgExportedEntityCount); + expect(result.exportedEntityCount).to.equal(avgExportedEntityCount); const _ratioOfCallsToTime = proportionOfNonCrashingTransformCalls / proportionOfNonCrashingTransformTime; const _ratioOfImportsToTime = proportionOfNonCrashingEntityImports / proportionOfNonCrashingTransformTime; /* eslint-disable no-console */ - console.log(`final resuming transformation took | ${ - percent(proportionOfNonCrashingTransformTime) - } time | ${ - percent(proportionOfNonCrashingTransformCalls) - } calls | ${ - percent(proportionOfNonCrashingEntityImports) - } element imports |`); + console.log(`final resuming transformation took | ${percent(proportionOfNonCrashingTransformTime)} time | ${percent(proportionOfNonCrashingTransformCalls)} calls | ${percent(proportionOfNonCrashingEntityImports)} element imports |`); /* eslint-enable no-console */ totalCrashingTransformationsTime += result.finalTransformationTime; } diff --git a/example-code/snippets/src/backend/IModelBranchingOperations.test.ts b/example-code/snippets/src/backend/IModelBranchingOperations.test.ts index 01f4ddd73f80..7eaa10218109 100644 --- a/example-code/snippets/src/backend/IModelBranchingOperations.test.ts +++ b/example-code/snippets/src/backend/IModelBranchingOperations.test.ts @@ -3,15 +3,17 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { BriefcaseDb, BriefcaseManager, ExternalSource, ExternalSourceIsInRepository, IModelDb, IModelHost, PhysicalModel, PhysicalObject, PhysicalPartition, RepositoryLink, SnapshotDb, SpatialCategory } from "@itwin/core-backend"; -import * as path from "path"; import * as fs from "fs"; +import * as path from "path"; +import { + BriefcaseDb, BriefcaseManager, ExternalSource, ExternalSourceIsInRepository, HubMock, IModelDb, IModelHost, PhysicalModel, PhysicalObject, + PhysicalPartition, RepositoryLink, SnapshotDb, SpatialCategory, +} from "@itwin/core-backend"; +import { IModelTestUtils as BackendTestUtils, HubWrappers, TestUserType } from "@itwin/core-backend/lib/cjs/test/IModelTestUtils"; import { AccessToken } from "@itwin/core-bentley"; import { Code, IModel, PhysicalElementProps, SubCategoryAppearance } from "@itwin/core-common"; -import { IModelTransformer } from "@itwin/core-transformer"; -import { HubMock } from "@itwin/core-backend/lib/cjs/test/HubMock"; -import { IModelTestUtils as BackendTestUtils, HubWrappers, TestUserType } from "@itwin/core-backend/lib/cjs/test/IModelTestUtils"; import { Point3d, YawPitchRollAngles } from "@itwin/core-geometry"; +import { IModelTransformer } from "@itwin/core-transformer"; import { KnownTestLocations } from "./IModelTestUtils"; // some json will be required later, but we don't want an eslint-disable line in the example code, so just disable for the file @@ -174,9 +176,9 @@ describe("IModelBranchingOperations", () => { const version0Path = path.join(KnownTestLocations.outputDir, "branching-ops.bim"); before(async () => { - HubMock.startup("IModelBranchingOperations"); + HubMock.startup("IModelBranchingOperations", KnownTestLocations.outputDir); if (!fs.existsSync(version0Path)) - SnapshotDb.createEmpty(version0Path, { rootSubject: { name: "branching-ops" }}); + SnapshotDb.createEmpty(version0Path, { rootSubject: { name: "branching-ops" } }); }); after(() => {