Skip to content

Commit

Permalink
allow the alwaysPresentElementIds to have different fed guids
Browse files Browse the repository at this point in the history
  • Loading branch information
nick4598 committed Jan 22, 2024
1 parent 7882d7b commit 2495920
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/transformer/src/test/IModelTransformerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,18 @@ export async function assertIdentityTransformation(
// [IModelTransformerOptions.includeSourceProvenance]$(transformer) is set to true
classesToIgnoreMissingEntitiesOfInTarget = [...IModelTransformer.provenanceElementClasses, ...IModelTransformer.provenanceElementAspectClasses],
compareElemGeom = false,
ignoreFedGuidsOnAlwaysPresentElementIds = true,
}: {
expectedElemsOnlyInSource?: Partial<ElementProps>[];
/** before checking elements that are only in the source are correct, filter out elements of these classes */
classesToIgnoreMissingEntitiesOfInTarget?: typeof Entity[];
compareElemGeom?: boolean;
/** if true, ignores the fed guids present on always present elements (present even in an empty iModel!).
* That list includes the root subject (0x1), dictionaryModel (0x10) and the realityDataSourcesModel (0xe) */
ignoreFedGuidsOnAlwaysPresentElementIds?: boolean;
} = {}
) {
const alwaysPresentElementIds = new Set<Id64String>(["0x1", "0x10", "0xe"]);
const [remapElem, remapCodeSpec, remapAspect]
= remapper instanceof IModelTransformer
? [remapper.context.findTargetElementId.bind(remapper.context),
Expand Down Expand Up @@ -274,7 +279,8 @@ export async function assertIdentityTransformation(
// known cases for the prop expecting to have been changed by the transformation under normal circumstances
// - federation guid will be generated if it didn't exist
// - jsonProperties may include remapped ids
const propChangesAllowed = sourceElem.federationGuid === undefined || propName === "jsonProperties";
const propChangesAllowed = ((propName === "federationGuid" && (sourceElem.federationGuid === undefined || (ignoreFedGuidsOnAlwaysPresentElementIds && alwaysPresentElementIds.has(sourceElemId))))
|| propName === "jsonProperties");
if (prop.isNavigation) {
expect(sourceElem.classFullName).to.equal(targetElem.classFullName);
// some custom handled classes make it difficult to inspect the element props directly with the metadata prop name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1135,11 +1135,19 @@ describe("IModelTransformer", () => {

/** gets a mapping of element ids to their invariant content */
async function getAllElementsInvariants(db: IModelDb, filterPredicate?: (element: Element) => boolean) {
// The set of element Ids where the fed guid should be ignored (since it can change between transforms).
const ignoreFedGuidElementIds = new Set<Id64String>([
IModel.rootSubjectId,
IModel.dictionaryId,
"0xe", // id of realityDataSourcesModel
]);
const result: Record<Id64String, any> = {};
// eslint-disable-next-line deprecation/deprecation
for await (const row of db.query("SELECT * FROM bis.Element", undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames })) {
if (!filterPredicate || filterPredicate(db.elements.getElement(row.id))) {
const { lastMod: _lastMod, ...invariantPortion } = row;
if (ignoreFedGuidElementIds.has(row.id))
delete invariantPortion.federationGuid;
result[row.id] = invariantPortion;
}
}
Expand Down

0 comments on commit 2495920

Please sign in to comment.