From 4d8cac4b3f54568173a5ebd5f49f01a67f1943da Mon Sep 17 00:00:00 2001 From: Daniel Erbynn Date: Wed, 4 Sep 2024 13:20:22 -0400 Subject: [PATCH 1/6] add init unit test --- .../test/standalone/IModelTransformer.test.ts | 132 +++++++++++++++--- 1 file changed, 109 insertions(+), 23 deletions(-) diff --git a/packages/transformer/src/test/standalone/IModelTransformer.test.ts b/packages/transformer/src/test/standalone/IModelTransformer.test.ts index 9389d8e1..9cb85fe5 100644 --- a/packages/transformer/src/test/standalone/IModelTransformer.test.ts +++ b/packages/transformer/src/test/standalone/IModelTransformer.test.ts @@ -1363,24 +1363,70 @@ describe("IModelTransformer", () => { targetIModelDb.close(); }); - it.skip("should log unresolved references", async () => { + it.only("should log unresolved references", async () => { const iModelShared: SnapshotDb = IModelTransformerTestUtils.createSharedIModel(outputDir, ["A", "B"]); - const iModelA: SnapshotDb = IModelTransformerTestUtils.createTeamIModel( - outputDir, - "A", - Point3d.create(0, 0, 0), - ColorDef.green - ); - IModelTransformerTestUtils.assertTeamIModelContents(iModelA, "A"); - const iModelExporterA = new IModelExporter(iModelA); + const teamFile: string = path.join(outputDir, "TeamA.bim"); + if (IModelJsFs.existsSync(teamFile)) { + IModelJsFs.removeSync(teamFile); + } + const iModelA: SnapshotDb = SnapshotDb.createEmpty(teamFile, { + rootSubject: { name: "A" }, + createClassViews: true, + }); + assert.exists(iModelA); + iModelA.saveChanges(); - // Exclude element - const excludedId = iModelA.elements.queryElementIdByCode( - Subject.createCode(iModelA, IModel.rootSubjectId, "Context") + const sourceCategoryId = SpatialCategory.insert( + iModelA, + IModel.dictionaryId, + "SpatialCategory", + { color: ColorDef.green.toJSON() } + ); + const sourceModelId = PhysicalModel.insert( + iModelA, + IModel.rootSubjectId, + "Physical" + ); + const myPhysObjCodeSpec = CodeSpec.create( + iModelA, + "myPhysicalObjects", + CodeScopeSpec.Type.ParentElement + ); + const myPhysObjCodeSpecId = iModelA.codeSpecs.insert(myPhysObjCodeSpec); + const physicalObjects = [1, 2].map((x) => { + const code = new Code({ + spec: myPhysObjCodeSpecId, + scope: sourceModelId, + value: `PhysicalObject(${x})`, + }); + const props: PhysicalElementProps = { + classFullName: PhysicalObject.classFullName, + model: sourceModelId, + category: sourceCategoryId, + code, + userLabel: `PhysicalObject(${x})`, + geom: IModelTransformerTestUtils.createBox(Point3d.create(1, 1, 1)), + placement: Placement3d.fromJSON({ origin: { x }, angles: {} }), + }; + const id = iModelA.elements.insertElement(props); + return { code, id }; + }); + const displayStyleId = DisplayStyle3d.insert( + iModelA, + IModel.dictionaryId, + "MyDisplayStyle", + { + excludedElements: physicalObjects.map((o) => o.id), + } ); - assert.isDefined(excludedId); - iModelExporterA.excludeElement(excludedId!); + const displayStyleElement = iModelA.elements.getElement(displayStyleId); + assert.isDefined(displayStyleElement); + const physObjId1 = physicalObjects[0].id; + const physObjId2 = physicalObjects[1].id; + + iModelA.saveChanges(); + const iModelExporterA = new IModelExporter(iModelA); const subjectId: Id64String = IModelTransformerTestUtils.querySubjectId( iModelShared, @@ -1392,12 +1438,10 @@ describe("IModelTransformer", () => { { targetScopeElementId: subjectId, danglingReferencesBehavior: "ignore" } ); transformerA2S.context.remapElement(IModel.rootSubjectId, subjectId); - // Configure logger to capture warning message about unresolved references const messageStart = "The following elements were never fully resolved:\n"; const messageEnd = "\nThis indicates that either some references were excluded from the transformation\nor the source has dangling references."; - let unresolvedElementMessage: string | undefined; const logWarning = ( _category: string, @@ -1414,25 +1458,67 @@ describe("IModelTransformer", () => { // Act await transformerA2S.process(); + // Get target physical obj Ids + const targetPhysObjId1 = + transformerA2S.context.findTargetElementId(physObjId1); + const targetPhysObjId2 = + transformerA2S.context.findTargetElementId(physObjId2); + + // Get elements to verify if they we are getting the correct phys objs when debugging + const targetPhysObj1 = iModelShared.elements.getElement(targetPhysObjId1); + const targetPhysObj2 = iModelShared.elements.getElement(targetPhysObjId2); + + assert.isDefined(targetPhysObj1); + assert.isDefined(targetPhysObj2); + + // delete referenced in target + iModelShared.elements.deleteElement(targetPhysObjId1); + iModelShared.elements.deleteElement(targetPhysObjId2); + + // update referencer in source + const sourceDisplayStyleElementProps = iModelA.elements.getElementProps( + displayStyleElement.id + ); + iModelA.elements.updateElement({ + ...sourceDisplayStyleElementProps, + userLabel: "DisplayStyleSourceElement", + }); + + // for debugging + const sourceDisplayStyleElementNew = iModelA.elements.getElement( + displayStyleElement.id + ); + assert.isDefined(sourceDisplayStyleElementNew); + + iModelShared.saveChanges(); + iModelA.saveChanges(); + + // Act + const transformer2S = new IModelTransformer(iModelExporterA, iModelShared, { + targetScopeElementId: subjectId, + danglingReferencesBehavior: "ignore", + }); + await transformer2S.process(); + // Collect expected ids const result = iModelA.queryEntityIds({ from: "BisCore.Element", - where: "Model.Id = :rootId AND ECInstanceId NOT IN (:excludedId)", - bindings: { rootId: IModel.rootSubjectId, excludedId }, + where: + "Model.Id = :rootId AND ECInstanceId NOT IN (:physObjId2,:physObjId1)", + bindings: { rootId: IModel.rootSubjectId, physObjId2, physObjId1 }, }); const expectedIds = [...result].map((x) => `e${x}`); - // Collect actual ids assert.isDefined(unresolvedElementMessage); const actualIds = unresolvedElementMessage! .split(messageStart)[1] .split(messageEnd)[0] .split(","); - // Assert - assert.equal(actualIds.length, 5); - assert.sameMembers(actualIds, expectedIds); - + // assert.equal(actualIds.length, 5); + // assert.sameMembers(actualIds, expectedIds); + assert.isDefined(actualIds); + assert.isDefined(expectedIds); transformerA2S.dispose(); iModelA.close(); iModelShared.close(); From e97b77f693e661ec5d647a40c5259d7c800696ec Mon Sep 17 00:00:00 2001 From: Daniel Erbynn Date: Thu, 5 Sep 2024 09:07:01 -0400 Subject: [PATCH 2/6] add unresolved reference unit test to IModelTransformerHub tests --- .../test/standalone/IModelTransformer.test.ts | 2 +- .../standalone/IModelTransformerHub.test.ts | 251 ++++++++++++++++++ 2 files changed, 252 insertions(+), 1 deletion(-) diff --git a/packages/transformer/src/test/standalone/IModelTransformer.test.ts b/packages/transformer/src/test/standalone/IModelTransformer.test.ts index 9cb85fe5..5a14c8ca 100644 --- a/packages/transformer/src/test/standalone/IModelTransformer.test.ts +++ b/packages/transformer/src/test/standalone/IModelTransformer.test.ts @@ -1363,7 +1363,7 @@ describe("IModelTransformer", () => { targetIModelDb.close(); }); - it.only("should log unresolved references", async () => { + it.skip("should log unresolved references", async () => { const iModelShared: SnapshotDb = IModelTransformerTestUtils.createSharedIModel(outputDir, ["A", "B"]); const teamFile: string = path.join(outputDir, "TeamA.bim"); diff --git a/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts b/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts index 2fac5c3f..df087bcd 100644 --- a/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts +++ b/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts @@ -54,10 +54,13 @@ import { Id64Array, Id64String, Logger, + LoggingMetaData, LogLevel, } from "@itwin/core-bentley"; import { Code, + CodeScopeSpec, + CodeSpec, ColorDef, DefinitionElementProps, ElementProps, @@ -496,6 +499,254 @@ describe("IModelTransformerHub", () => { } }); + it.only("should log unresolved references", async () => { + const sourceIModelId = await HubWrappers.createIModel( + accessToken, + iTwinId, + "source" + ); + + const targetIModelId = await HubWrappers.createIModel( + accessToken, + iTwinId, + "target" + ); + + try { + // download and open briefcase on source imodel + const sourceBriefcase = await HubWrappers.downloadAndOpenBriefcase({ + accessToken: await IModelHost.getAccessToken(), + iTwinId, + iModelId: sourceIModelId, + asOf: IModelVersion.latest().toJSON(), + }); + + await sourceBriefcase.locks.acquireLocks({ + shared: "0x10", + exclusive: "0x1", + }); + + // download and open briefcase on target imodel + const targetBriefcase = await HubWrappers.downloadAndOpenBriefcase({ + accessToken: await IModelHost.getAccessToken(), + iTwinId, + iModelId: targetIModelId, + asOf: IModelVersion.latest().toJSON(), + }); + + await targetBriefcase.locks.acquireLocks({ + shared: "0x10", + exclusive: "0x1", + }); + + assert.isTrue(sourceBriefcase.isBriefcaseDb()); + assert.isTrue(targetBriefcase.isBriefcaseDb()); + assert.isFalse(sourceBriefcase.isSnapshot); + assert.isFalse(targetBriefcase.isSnapshot); + + // set up physical models + const sourceCategoryId = SpatialCategory.insert( + sourceBriefcase, + IModel.dictionaryId, + "SpatialCategory", + { color: ColorDef.green.toJSON() } + ); + + const sourceModelId = PhysicalModel.insert( + sourceBriefcase, + IModel.rootSubjectId, + "Physical" + ); + + const myPhysObjCodeSpec = CodeSpec.create( + sourceBriefcase, + "myPhysicalObjects", + CodeScopeSpec.Type.ParentElement + ); + + const myPhysObjCodeSpecId = + sourceBriefcase.codeSpecs.insert(myPhysObjCodeSpec); + const physicalObjects = [1, 2].map((x) => { + const code = new Code({ + spec: myPhysObjCodeSpecId, + scope: sourceModelId, + value: `PhysicalObject(${x})`, + }); + const props: PhysicalElementProps = { + classFullName: PhysicalObject.classFullName, + model: sourceModelId, + category: sourceCategoryId, + code, + userLabel: `PhysicalObject(${x})`, + geom: IModelTransformerTestUtils.createBox(Point3d.create(1, 1, 1)), + placement: Placement3d.fromJSON({ origin: { x }, angles: {} }), + }; + const id = sourceBriefcase.elements.insertElement(props); + return { code, id }; + }); + const displayStyleId = DisplayStyle3d.insert( + sourceBriefcase, + IModel.dictionaryId, + "MyDisplayStyle", + { + excludedElements: physicalObjects.map((o) => o.id), + } + ); + + const displayStyleElement = + sourceBriefcase.elements.getElement(displayStyleId); + assert.isDefined(displayStyleElement); + const physObjId1 = physicalObjects[0].id; + const physObjId2 = physicalObjects[1].id; + + sourceBriefcase.saveChanges(); + await sourceBriefcase.pushChanges({ + description: "source changes for inserting physical elements", + retainLocks: true, + }); + + const iModelExporterA = new IModelExporter(sourceBriefcase); + const transformer1 = new IModelTransformer( + iModelExporterA, + targetBriefcase, + { danglingReferencesBehavior: "ignore" } + ); + + // Configure logger to capture warning message about unresolved references + const messageStart = + "The following elements were never fully resolved:\n"; + const messageEnd = + "\nThis indicates that either some references were excluded from the transformation\nor the source has dangling references."; + let unresolvedElementMessage: string | undefined; + const logWarning = ( + _category: string, + message: string, + _metaData: LoggingMetaData + ) => { + if (message.startsWith(messageStart)) { + unresolvedElementMessage = message; + } + }; + Logger.initialize(undefined, logWarning); + Logger.setLevelDefault(LogLevel.Warning); + + // Act + await transformer1.process(); + targetBriefcase.saveChanges(); + await targetBriefcase.pushChanges({ + description: "target changes for transformation", + retainLocks: true, + }); + + // Get target physical obj Ids + const targetPhysObjId1 = + transformer1.context.findTargetElementId(physObjId1); + const targetPhysObjId2 = + transformer1.context.findTargetElementId(physObjId2); + + // Get elements to verify if they we are getting the correct phys objs when debugging + const targetPhysObj1 = + targetBriefcase.elements.getElement(targetPhysObjId1); + const targetPhysObj2 = + targetBriefcase.elements.getElement(targetPhysObjId2); + + assert.isDefined(targetPhysObj1); + assert.isDefined(targetPhysObj2); + + // delete referenced in target + targetBriefcase.elements.deleteElement(targetPhysObjId1); + targetBriefcase.elements.deleteElement(targetPhysObjId2); + + // update referencer in source + const sourceDisplayStyleElementProps = + sourceBriefcase.elements.getElementProps(displayStyleElement.id); + sourceBriefcase.elements.updateElement({ + ...sourceDisplayStyleElementProps, + userLabel: "DisplayStyleSourceElement", + }); + + targetBriefcase.saveChanges(); + sourceBriefcase.saveChanges(); + await sourceBriefcase.pushChanges({ + description: "source changes for updating referencer", + retainLocks: true, + }); + await targetBriefcase.pushChanges({ + description: "target changes for deleting referenced elements", + retainLocks: true, + }); + + const transformer2 = new IModelTransformer( + iModelExporterA, + targetBriefcase, + { + danglingReferencesBehavior: "ignore", + argsForProcessChanges: { startChangeset: sourceBriefcase.changeset }, + } + ); + + // Act + await transformer2.process(); + + // sourceCatergory element is needed to create physical elements and it is inserted in dictionary model + const sourceCategoryElement = + sourceBriefcase.elements.getElement(sourceCategoryId); + assert.isDefined(sourceCategoryElement); + + // when sourceCategory element is created (which is also a spatial element), it creates a spatial element child + const sourceCategoryChild = sourceBriefcase.elements.queryChildren( + sourceCategoryElement.id + )[0]; + const sourceCategoryChildElement = + sourceBriefcase.elements.getElement(sourceCategoryChild); + assert.isDefined(sourceCategoryChild); + assert.isDefined(sourceCategoryChildElement); + + // Collect expected ids + const result = sourceBriefcase.queryEntityIds({ + from: "BisCore.Element", + where: + "Model.Id = :dictionaryId AND ECInstanceId NOT IN (:sourceCategoryId,:sourceCategoryChild)", + bindings: { + dictionaryId: IModel.dictionaryId, + sourceCategoryId, + sourceCategoryChild, + }, + }); + const expectedIds = [...result].map((x) => `e${x}`); + // Collect actual ids + assert.isDefined(unresolvedElementMessage); + const actualIds = unresolvedElementMessage! + .split(messageStart)[1] + .split(messageEnd)[0] + .split(","); + // Assert + assert.equal(actualIds.length, 1); + assert.sameMembers(actualIds, expectedIds); + assert.isDefined(actualIds); + assert.isDefined(expectedIds); + transformer1.dispose(); + transformer2.dispose(); + + await HubWrappers.closeAndDeleteBriefcaseDb(accessToken, sourceBriefcase); + await HubWrappers.closeAndDeleteBriefcaseDb(accessToken, targetBriefcase); + } finally { + try { + await IModelHost.hubAccess.deleteIModel({ + iTwinId, + iModelId: sourceIModelId, + }); + await IModelHost.hubAccess.deleteIModel({ + iTwinId, + iModelId: targetIModelId, + }); + } catch (err) { + // eslint-disable-next-line no-console + console.log("can't destroy", err); + } + } + }); + it("should consolidate PhysicalModels", async () => { const sourceIModelName: string = IModelTransformerTestUtils.generateUniqueName("ConsolidateModelsSource"); From 5989094817755f3ed6ff21c5e4795e0796809af8 Mon Sep 17 00:00:00 2001 From: Daniel Erbynn Date: Thu, 5 Sep 2024 10:44:04 -0400 Subject: [PATCH 3/6] use sourceImodel as seed --- .../standalone/IModelTransformerHub.test.ts | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts b/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts index df087bcd..5b6c4acd 100644 --- a/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts +++ b/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts @@ -505,12 +505,8 @@ describe("IModelTransformerHub", () => { iTwinId, "source" ); - - const targetIModelId = await HubWrappers.createIModel( - accessToken, - iTwinId, - "target" - ); + let targetIModelId!: GuidString; + assert.isTrue(Guid.isGuid(sourceIModelId)); try { // download and open briefcase on source imodel @@ -520,29 +516,12 @@ describe("IModelTransformerHub", () => { iModelId: sourceIModelId, asOf: IModelVersion.latest().toJSON(), }); - await sourceBriefcase.locks.acquireLocks({ shared: "0x10", exclusive: "0x1", }); - - // download and open briefcase on target imodel - const targetBriefcase = await HubWrappers.downloadAndOpenBriefcase({ - accessToken: await IModelHost.getAccessToken(), - iTwinId, - iModelId: targetIModelId, - asOf: IModelVersion.latest().toJSON(), - }); - - await targetBriefcase.locks.acquireLocks({ - shared: "0x10", - exclusive: "0x1", - }); - assert.isTrue(sourceBriefcase.isBriefcaseDb()); - assert.isTrue(targetBriefcase.isBriefcaseDb()); assert.isFalse(sourceBriefcase.isSnapshot); - assert.isFalse(targetBriefcase.isSnapshot); // set up physical models const sourceCategoryId = SpatialCategory.insert( @@ -605,11 +584,39 @@ describe("IModelTransformerHub", () => { retainLocks: true, }); + sourceBriefcase.performCheckpoint(); // so we can use as a seed + + targetIModelId = await HubWrappers.recreateIModel({ + accessToken, + iTwinId, + iModelName: "target", + version0: sourceBriefcase.pathName, + }); + assert.isTrue(Guid.isGuid(targetIModelId)); + + // download and open briefcase on target imodel + const targetBriefcase = await HubWrappers.downloadAndOpenBriefcase({ + accessToken: await IModelHost.getAccessToken(), + iTwinId, + iModelId: targetIModelId, + asOf: IModelVersion.latest().toJSON(), + }); + assert.isTrue(targetBriefcase.isBriefcaseDb()); + assert.isFalse(targetBriefcase.isSnapshot); + + await targetBriefcase.locks.acquireLocks({ + shared: "0x10", + exclusive: "0x1", + }); + const iModelExporterA = new IModelExporter(sourceBriefcase); const transformer1 = new IModelTransformer( iModelExporterA, targetBriefcase, - { danglingReferencesBehavior: "ignore" } + { + danglingReferencesBehavior: "ignore", + wasSourceIModelCopiedToTarget: true, + } ); // Configure logger to capture warning message about unresolved references @@ -681,7 +688,7 @@ describe("IModelTransformerHub", () => { targetBriefcase, { danglingReferencesBehavior: "ignore", - argsForProcessChanges: { startChangeset: sourceBriefcase.changeset }, + argsForProcessChanges: {}, } ); From b83d93af78a2487b13283a7209917fa39490b253 Mon Sep 17 00:00:00 2001 From: Daniel Erbynn Date: Thu, 5 Sep 2024 10:46:23 -0400 Subject: [PATCH 4/6] remove unresolved test from transformer test file --- .../test/standalone/IModelTransformer.test.ts | 161 ------------------ .../standalone/IModelTransformerHub.test.ts | 2 +- 2 files changed, 1 insertion(+), 162 deletions(-) diff --git a/packages/transformer/src/test/standalone/IModelTransformer.test.ts b/packages/transformer/src/test/standalone/IModelTransformer.test.ts index 5a14c8ca..c4d18c0d 100644 --- a/packages/transformer/src/test/standalone/IModelTransformer.test.ts +++ b/packages/transformer/src/test/standalone/IModelTransformer.test.ts @@ -1363,167 +1363,6 @@ describe("IModelTransformer", () => { targetIModelDb.close(); }); - it.skip("should log unresolved references", async () => { - const iModelShared: SnapshotDb = - IModelTransformerTestUtils.createSharedIModel(outputDir, ["A", "B"]); - const teamFile: string = path.join(outputDir, "TeamA.bim"); - if (IModelJsFs.existsSync(teamFile)) { - IModelJsFs.removeSync(teamFile); - } - const iModelA: SnapshotDb = SnapshotDb.createEmpty(teamFile, { - rootSubject: { name: "A" }, - createClassViews: true, - }); - assert.exists(iModelA); - iModelA.saveChanges(); - - const sourceCategoryId = SpatialCategory.insert( - iModelA, - IModel.dictionaryId, - "SpatialCategory", - { color: ColorDef.green.toJSON() } - ); - const sourceModelId = PhysicalModel.insert( - iModelA, - IModel.rootSubjectId, - "Physical" - ); - const myPhysObjCodeSpec = CodeSpec.create( - iModelA, - "myPhysicalObjects", - CodeScopeSpec.Type.ParentElement - ); - const myPhysObjCodeSpecId = iModelA.codeSpecs.insert(myPhysObjCodeSpec); - const physicalObjects = [1, 2].map((x) => { - const code = new Code({ - spec: myPhysObjCodeSpecId, - scope: sourceModelId, - value: `PhysicalObject(${x})`, - }); - const props: PhysicalElementProps = { - classFullName: PhysicalObject.classFullName, - model: sourceModelId, - category: sourceCategoryId, - code, - userLabel: `PhysicalObject(${x})`, - geom: IModelTransformerTestUtils.createBox(Point3d.create(1, 1, 1)), - placement: Placement3d.fromJSON({ origin: { x }, angles: {} }), - }; - const id = iModelA.elements.insertElement(props); - return { code, id }; - }); - const displayStyleId = DisplayStyle3d.insert( - iModelA, - IModel.dictionaryId, - "MyDisplayStyle", - { - excludedElements: physicalObjects.map((o) => o.id), - } - ); - const displayStyleElement = iModelA.elements.getElement(displayStyleId); - assert.isDefined(displayStyleElement); - const physObjId1 = physicalObjects[0].id; - const physObjId2 = physicalObjects[1].id; - - iModelA.saveChanges(); - const iModelExporterA = new IModelExporter(iModelA); - - const subjectId: Id64String = IModelTransformerTestUtils.querySubjectId( - iModelShared, - "A" - ); - const transformerA2S = new IModelTransformer( - iModelExporterA, - iModelShared, - { targetScopeElementId: subjectId, danglingReferencesBehavior: "ignore" } - ); - transformerA2S.context.remapElement(IModel.rootSubjectId, subjectId); - // Configure logger to capture warning message about unresolved references - const messageStart = "The following elements were never fully resolved:\n"; - const messageEnd = - "\nThis indicates that either some references were excluded from the transformation\nor the source has dangling references."; - let unresolvedElementMessage: string | undefined; - const logWarning = ( - _category: string, - message: string, - _metaData: LoggingMetaData - ) => { - if (message.startsWith(messageStart)) { - unresolvedElementMessage = message; - } - }; - Logger.initialize(undefined, logWarning); - Logger.setLevelDefault(LogLevel.Warning); - - // Act - await transformerA2S.process(); - - // Get target physical obj Ids - const targetPhysObjId1 = - transformerA2S.context.findTargetElementId(physObjId1); - const targetPhysObjId2 = - transformerA2S.context.findTargetElementId(physObjId2); - - // Get elements to verify if they we are getting the correct phys objs when debugging - const targetPhysObj1 = iModelShared.elements.getElement(targetPhysObjId1); - const targetPhysObj2 = iModelShared.elements.getElement(targetPhysObjId2); - - assert.isDefined(targetPhysObj1); - assert.isDefined(targetPhysObj2); - - // delete referenced in target - iModelShared.elements.deleteElement(targetPhysObjId1); - iModelShared.elements.deleteElement(targetPhysObjId2); - - // update referencer in source - const sourceDisplayStyleElementProps = iModelA.elements.getElementProps( - displayStyleElement.id - ); - iModelA.elements.updateElement({ - ...sourceDisplayStyleElementProps, - userLabel: "DisplayStyleSourceElement", - }); - - // for debugging - const sourceDisplayStyleElementNew = iModelA.elements.getElement( - displayStyleElement.id - ); - assert.isDefined(sourceDisplayStyleElementNew); - - iModelShared.saveChanges(); - iModelA.saveChanges(); - - // Act - const transformer2S = new IModelTransformer(iModelExporterA, iModelShared, { - targetScopeElementId: subjectId, - danglingReferencesBehavior: "ignore", - }); - await transformer2S.process(); - - // Collect expected ids - const result = iModelA.queryEntityIds({ - from: "BisCore.Element", - where: - "Model.Id = :rootId AND ECInstanceId NOT IN (:physObjId2,:physObjId1)", - bindings: { rootId: IModel.rootSubjectId, physObjId2, physObjId1 }, - }); - const expectedIds = [...result].map((x) => `e${x}`); - // Collect actual ids - assert.isDefined(unresolvedElementMessage); - const actualIds = unresolvedElementMessage! - .split(messageStart)[1] - .split(messageEnd)[0] - .split(","); - // Assert - // assert.equal(actualIds.length, 5); - // assert.sameMembers(actualIds, expectedIds); - assert.isDefined(actualIds); - assert.isDefined(expectedIds); - transformerA2S.dispose(); - iModelA.close(); - iModelShared.close(); - }); - it("should detect conflicting provenance scopes", async () => { const sourceDb1 = IModelTransformerTestUtils.createTeamIModel( outputDir, diff --git a/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts b/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts index 5b6c4acd..b3f38a22 100644 --- a/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts +++ b/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts @@ -499,7 +499,7 @@ describe("IModelTransformerHub", () => { } }); - it.only("should log unresolved references", async () => { + it("should log unresolved references", async () => { const sourceIModelId = await HubWrappers.createIModel( accessToken, iTwinId, From 83f41b231058066b914d3273087fe6569c679d77 Mon Sep 17 00:00:00 2001 From: Daniel Erbynn Date: Thu, 5 Sep 2024 11:29:12 -0400 Subject: [PATCH 5/6] lint fix --- .../transformer/src/test/standalone/IModelTransformer.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/transformer/src/test/standalone/IModelTransformer.test.ts b/packages/transformer/src/test/standalone/IModelTransformer.test.ts index c4d18c0d..60fa9a1d 100644 --- a/packages/transformer/src/test/standalone/IModelTransformer.test.ts +++ b/packages/transformer/src/test/standalone/IModelTransformer.test.ts @@ -64,7 +64,6 @@ import { Id64, Id64String, Logger, - LoggingMetaData, LogLevel, OpenMode, } from "@itwin/core-bentley"; From 529382b427fbc7866b2cb7488597a17b3a2335a0 Mon Sep 17 00:00:00 2001 From: Daniel Erbynn Date: Thu, 5 Sep 2024 11:42:59 -0400 Subject: [PATCH 6/6] remove debugging variables --- .../src/test/standalone/IModelTransformerHub.test.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts b/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts index b3f38a22..c40eb393 100644 --- a/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts +++ b/packages/transformer/src/test/standalone/IModelTransformerHub.test.ts @@ -651,15 +651,6 @@ describe("IModelTransformerHub", () => { const targetPhysObjId2 = transformer1.context.findTargetElementId(physObjId2); - // Get elements to verify if they we are getting the correct phys objs when debugging - const targetPhysObj1 = - targetBriefcase.elements.getElement(targetPhysObjId1); - const targetPhysObj2 = - targetBriefcase.elements.getElement(targetPhysObjId2); - - assert.isDefined(targetPhysObj1); - assert.isDefined(targetPhysObj2); - // delete referenced in target targetBriefcase.elements.deleteElement(targetPhysObjId1); targetBriefcase.elements.deleteElement(targetPhysObjId2);