Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
hofstef committed Jan 29, 2025
1 parent d97e1c0 commit 75545ff
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 135 deletions.
2 changes: 1 addition & 1 deletion src/app/tools/autosave/services/autosave.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class AutosaveService {
workObjectIcons,
config,
);
this.rendererService.importStory(story, true, config, false);
this.rendererService.importStory(story, config, false);
}

removeAllDrafts() {
Expand Down
77 changes: 0 additions & 77 deletions src/app/tools/import/services/import-domain-story.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,83 +68,6 @@ describe('ImportDomainStoryService', () => {
expect(service).toBeTruthy();
});

describe('checkConfigForChanges', () => {
const actorsDict = new Dictionary();
const workObjectsDict = new Dictionary();

actorsDict.add('', 'actor');
workObjectsDict.add('', 'workObject');

const testDomainCofiguration: IconSet = {
name: INITIAL_ICON_SET_NAME,
actors: actorsDict,
workObjects: workObjectsDict,
};

it('should find changes, more actors', () => {
iconDictionarySpy.getNamesOfIconsAssignedAs
.withArgs(ElementTypes.ACTOR)
.and.returnValue(['test']);
iconDictionarySpy.getNamesOfIconsAssignedAs
.withArgs(ElementTypes.WORKOBJECT)
.and.returnValue(['workObject']);

expect(
service.checkConfigForChanges(testDomainCofiguration),
).toBeTruthy();
});

it('should find changes, different actors', () => {
iconDictionarySpy.getNamesOfIconsAssignedAs
.withArgs(ElementTypes.ACTOR)
.and.returnValue(['actor', 'test']);
iconDictionarySpy.getNamesOfIconsAssignedAs
.withArgs(ElementTypes.WORKOBJECT)
.and.returnValue(['workObject']);

expect(
service.checkConfigForChanges(testDomainCofiguration),
).toBeTruthy();
});

it('should find changes, different workobjects', () => {
iconDictionarySpy.getNamesOfIconsAssignedAs
.withArgs(ElementTypes.ACTOR)
.and.returnValue(['actor']);
iconDictionarySpy.getNamesOfIconsAssignedAs
.withArgs(ElementTypes.WORKOBJECT)
.and.returnValue(['workObject', 'test']);

expect(
service.checkConfigForChanges(testDomainCofiguration),
).toBeTruthy();
});

it('should find changes, different workobjects', () => {
iconDictionarySpy.getNamesOfIconsAssignedAs
.withArgs(ElementTypes.ACTOR)
.and.returnValue(['actor']);
iconDictionarySpy.getNamesOfIconsAssignedAs
.withArgs(ElementTypes.WORKOBJECT)
.and.returnValue(['test']);

expect(
service.checkConfigForChanges(testDomainCofiguration),
).toBeTruthy();
});

it('should not find changes', () => {
iconDictionarySpy.getNamesOfIconsAssignedAs
.withArgs(ElementTypes.ACTOR)
.and.returnValue(['actor']);
iconDictionarySpy.getNamesOfIconsAssignedAs
.withArgs(ElementTypes.WORKOBJECT)
.and.returnValue(['workObject']);

expect(service.checkConfigForChanges(testDomainCofiguration)).toBeFalsy();
});
});

describe('should process title of story correctly', () => {
const input: Blob = new File([], '');
let filename: string;
Expand Down
51 changes: 1 addition & 50 deletions src/app/tools/import/services/import-domain-story.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,6 @@ export class ImportDomainStoryService
this.importRepairService.removeWhitespacesFromIcons(elements);
this.importRepairService.removeUnnecessaryBpmnProperties(elements);

const configChanged = this.checkConfigForChanges(iconSetConfig);

let lastElement = elements[elements.length - 1];
if (!lastElement.id) {
lastElement = elements.pop();
Expand Down Expand Up @@ -333,7 +331,7 @@ export class ImportDomainStoryService
);

this.updateIconRegistries(elements, iconSetConfig);
this.rendererService.importStory(elements, configChanged, iconSetConfig);
this.rendererService.importStory(elements, iconSetConfig);
}
}

Expand Down Expand Up @@ -387,53 +385,6 @@ export class ImportDomainStoryService
return xmlText;
}

checkConfigForChanges(iconSetConfiguration: IconSet): boolean {
const newActorKeys = iconSetConfiguration.actors.keysArray();
const newWorkObjectKeys = iconSetConfiguration.workObjects.keysArray();

const currentActorKeys =
this.iconDictionaryService.getNamesOfIconsAssignedAs(ElementTypes.ACTOR);
const currentWorkobjectKeys =
this.iconDictionaryService.getNamesOfIconsAssignedAs(
ElementTypes.WORKOBJECT,
);

let changed = false;

if (
newActorKeys.length !== currentActorKeys.length ||
newWorkObjectKeys.length !== currentWorkobjectKeys.length
) {
return true;
}

for (let i = 0; i < newActorKeys.length; i++) {
changed =
this.clearName(currentActorKeys[i]) !== this.clearName(newActorKeys[i]);
if (changed) {
i = newActorKeys.length;
}
}
if (changed) {
return changed;
}
for (let i = 0; i < newWorkObjectKeys.length; i++) {
changed =
this.clearName(currentWorkobjectKeys[i]) !==
this.clearName(newWorkObjectKeys[i]);
if (changed) {
i = newWorkObjectKeys.length;
}
}
return changed;
}

private clearName(name: string): string {
return name
.replace(ElementTypes.ACTOR, '')
.replace(ElementTypes.WORKOBJECT, '');
}

private updateIconRegistries(
elements: BusinessObject[],
config: IconSet,
Expand Down
12 changes: 6 additions & 6 deletions src/app/tools/modeler/services/renderer.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ describe('RendererService', () => {
dirtyFlagServiceSpy.makeClean.and.returnValue();
});

it('should call correct functions - configHasChanged and makeClean', () => {
service.importStory([], true, iconSetConfig);
it('should call correct functions - makeClean', () => {
service.importStory([], iconSetConfig);

expect(modelerServiceSpy.restart).toHaveBeenCalled();
expect(elementRegistryServiceSpy.correctInitialize).toHaveBeenCalledTimes(
Expand All @@ -108,8 +108,8 @@ describe('RendererService', () => {
expect(dirtyFlagServiceSpy.makeClean).toHaveBeenCalled();
});

it('should call correct functions - configHasChanged and not makeClean', () => {
service.importStory([], true, iconSetConfig, false);
it('should call correct functions - not makeClean', () => {
service.importStory([], iconSetConfig, false);

expect(modelerServiceSpy.restart).toHaveBeenCalled();
expect(elementRegistryServiceSpy.correctInitialize).toHaveBeenCalledTimes(
Expand All @@ -120,8 +120,8 @@ describe('RendererService', () => {
expect(dirtyFlagServiceSpy.makeClean).toHaveBeenCalledTimes(0);
});

it('should call correct functions - not configHasChanged and makeClean', () => {
service.importStory([], false);
it('should call correct functions - makeClean', () => {
service.importStory([]);

expect(modelerServiceSpy.getModeler).toHaveBeenCalled();
expect(modelerServiceSpy.restart).toHaveBeenCalledTimes(1);
Expand Down
1 change: 0 additions & 1 deletion src/app/tools/modeler/services/renderer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export class RendererService {

importStory(
domainStory: BusinessObject[],
configurationChange: boolean,
config?: IconSet,
makeClean = true,
): void {
Expand Down

0 comments on commit 75545ff

Please sign in to comment.