Skip to content

Commit

Permalink
reorder test factories to main modules
Browse files Browse the repository at this point in the history
  • Loading branch information
MajedAlaitwniCap committed Dec 19, 2024
1 parent 2d49b6b commit 4e6c0f6
Show file tree
Hide file tree
Showing 24 changed files with 59 additions and 91 deletions.
22 changes: 14 additions & 8 deletions apps/server/src/infra/sync/tsp/tsp-oauth-data.mapper.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { faker } from '@faker-js/faker';
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { ProvisioningSystemDto } from '@modules/provisioning';
import {
externalUserDtoFactory,
oauthDataDtoFactory,
externalClassDtoFactory,
provisioningSystemDtoFactory,
externalSchoolDtoFactory,
} from '@modules/provisioning/testing';
import { Test, TestingModule } from '@nestjs/testing';
import { RoleName } from '@shared/domain/interface';
import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy';
import { externalSchoolDtoFactory } from '@shared/testing';
import { externalClassDtoFactory } from '@shared/testing/factory/external-class-dto.factory';
import { externalUserDtoFactory } from '@shared/testing/factory/external-user-dto.factory';
import { oauthDataDtoFactory } from '@shared/testing/factory/oauth-data-dto.factory';
import { provisioningSystemDtoFactory } from '@shared/testing/factory/provisioning-system-dto.factory';
import { robjExportKlasseFactory } from '@shared/testing/factory/robj-export-klasse.factory';
import { robjExportLehrerFactory } from '@shared/testing/factory/robj-export-lehrer.factory';
import { robjExportSchuelerFactory } from '@shared/testing/factory/robj-export-schueler.factory';
import {
robjExportSchuelerFactory,
robjExportLehrerFactory,
robjExportKlasseFactory,
} from '@src/infra/tsp-client/testing';
import { Logger } from '@src/core/logger';
import { BadDataLoggableException } from '@src/modules/provisioning/loggable';
import { schoolFactory } from '@src/modules/school/testing';
Expand Down Expand Up @@ -104,6 +108,7 @@ describe(TspOauthDataMapper.name, () => {
lastName: tspTeachers[0].lehrerNachname,
roles: [RoleName.TEACHER],
email: undefined,
birthday: undefined,
});

const externalStudentUserDto = externalUserDtoFactory.build({
Expand All @@ -112,6 +117,7 @@ describe(TspOauthDataMapper.name, () => {
lastName: tspStudents[0].schuelerNachname,
roles: [RoleName.STUDENT],
email: undefined,
birthday: undefined,
});

const externalSchoolDto = externalSchoolDtoFactory.build({
Expand Down
17 changes: 11 additions & 6 deletions apps/server/src/infra/sync/tsp/tsp-sync.strategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ import { Test, TestingModule } from '@nestjs/testing';
import { UserDO } from '@shared/domain/domainobject';
import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy';
import { userDoFactory } from '@shared/testing';
import { externalUserDtoFactory } from '@shared/testing/factory/external-user-dto.factory';
import { oauthDataDtoFactory } from '@shared/testing/factory/oauth-data-dto.factory';
import { provisioningSystemDtoFactory } from '@shared/testing/factory/provisioning-system-dto.factory';
import { robjExportLehrerMigrationFactory } from '@shared/testing/factory/robj-export-lehrer-migration.factory';
import { robjExportSchuelerMigrationFactory } from '@shared/testing/factory/robj-export-schueler-migration.factory';
import { robjExportSchuleFactory } from '@shared/testing/factory/robj-export-schule.factory';

import {
externalUserDtoFactory,
oauthDataDtoFactory,
provisioningSystemDtoFactory,
} from '@src/modules/provisioning/testing';
import {
robjExportSchuleFactory,
robjExportLehrerMigrationFactory,
robjExportSchuelerMigrationFactory,
} from '@src/infra/tsp-client/testing';
import { Logger } from '@src/core/logger';
import { Account } from '@src/modules/account';
import { accountDoFactory } from '@src/modules/account/testing';
Expand Down
6 changes: 6 additions & 0 deletions apps/server/src/infra/tsp-client/testing/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export { robjExportSchuleFactory } from './robj-export-schule.factory';
export { robjExportKlasseFactory } from './robj-export-klasse.factory';
export { robjExportLehrerFactory } from './robj-export-lehrer.factory';
export { robjExportSchuelerFactory } from './robj-export-schueler.factory';
export { robjExportLehrerMigrationFactory } from './robj-export-lehrer-migration.factory';
export { robjExportSchuelerMigrationFactory } from './robj-export-schueler-migration.factory';
14 changes: 7 additions & 7 deletions apps/server/src/modules/provisioning/dto/provisioning.dto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export class ProvisioningDto {
externalUserId: string;

constructor(provisioningDto: ProvisioningDto) {
this.externalUserId = provisioningDto.externalUserId;
}
}
export class ProvisioningDto {
externalUserId: string;

constructor(provisioningDto: ProvisioningDto) {
this.externalUserId = provisioningDto.externalUserId;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { externalSchoolDtoFactory } from '@shared/testing';
import { externalGroupDtoFactory } from '@shared/testing/factory/external-group-dto.factory';
import { externalGroupDtoFactory, externalSchoolDtoFactory } from '@modules/provisioning/testing';
import { ExternalGroupDto, ExternalSchoolDto } from '../dto';
import { SchoolForGroupNotFoundLoggable } from './school-for-group-not-found.loggable';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { System, SystemService } from '@modules/system';
import { InternalServerErrorException } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy';
import { oauthDataDtoFactory } from '@shared/testing/factory/oauth-data-dto.factory';
import { provisioningDtoFactory } from '@shared/testing/factory/provisioning-dto.factory';
import { provisioningSystemDtoFactory } from '@shared/testing/factory/provisioning-system-dto.factory';
import { provisioningDtoFactory, oauthDataDtoFactory } from '@modules/provisioning/testing';
import { provisioningSystemDtoFactory } from '@src/modules/provisioning/testing/provisioning-system-dto.factory';
import { systemFactory } from '@src/modules/system/testing';
import { OauthDataDto, OauthDataStrategyInputDto, ProvisioningDto, ProvisioningSystemDto } from '../dto';
import { IservProvisioningStrategy, OidcMockProvisioningStrategy, SanisProvisioningStrategy } from '../strategy';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { Test, TestingModule } from '@nestjs/testing';
import { NotFoundLoggableException } from '@shared/common/loggable-exception';
import { RoleName } from '@shared/domain/interface';
import { externalSchoolDtoFactory, roleDtoFactory, roleFactory, userDoFactory } from '@shared/testing';
import { externalClassDtoFactory } from '@shared/testing/factory/external-class-dto.factory';
import { externalUserDtoFactory } from '@shared/testing/factory/external-user-dto.factory';
import { oauthDataDtoFactory } from '@shared/testing/factory/oauth-data-dto.factory';
import { provisioningSystemDtoFactory } from '@shared/testing/factory/provisioning-system-dto.factory';
import { roleDtoFactory, roleFactory, userDoFactory } from '@shared/testing';
import { AccountService } from '@src/modules/account';
import { ClassService } from '@src/modules/class';
import { classFactory } from '@src/modules/class/domain/testing';
Expand All @@ -17,6 +13,13 @@ import { schoolFactory } from '@src/modules/school/testing';
import { UserService } from '@src/modules/user';
import { BadDataLoggableException } from '../loggable';
import { TspProvisioningService } from './tsp-provisioning.service';
import {
provisioningSystemDtoFactory,
externalClassDtoFactory,
oauthDataDtoFactory,
externalUserDtoFactory,
externalSchoolDtoFactory,
} from '../testing';

describe('TspProvisioningService', () => {
let module: TestingModule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { LegacySchoolDo, UserDO } from '@shared/domain/domainobject';
import { RoleName } from '@shared/domain/interface';
import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy';
import {
externalGroupDtoFactory,
externalSchoolDtoFactory,
groupFactory,
legacySchoolDoFactory,
userDoFactory,
} from '@shared/testing';
import { groupFactory, legacySchoolDoFactory, userDoFactory } from '@shared/testing';
import { Logger } from '@src/core/logger';
import {
ExternalGroupDto,
Expand All @@ -24,7 +18,7 @@ import {
ProvisioningSystemDto,
} from '../../dto';
import { ProvisioningConfig } from '../../provisioning.config';
import { externalUserDtoFactory } from '../../testing';
import { externalGroupDtoFactory, externalSchoolDtoFactory, externalUserDtoFactory } from '../../testing';
import { SchulconnexProvisioningStrategy } from './schulconnex.strategy';
import {
SchulconnexCourseSyncService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,9 @@ import { NotFoundLoggableException } from '@shared/common/loggable-exception';
import { ExternalSource, LegacySchoolDo, Page, RoleReference, UserDO } from '@shared/domain/domainobject';
import { RoleName } from '@shared/domain/interface';
import { EntityId } from '@shared/domain/types';
import {
externalGroupDtoFactory,
externalSchoolDtoFactory,
groupFactory,
legacySchoolDoFactory,
roleDtoFactory,
roleFactory,
userDoFactory,
} from '@shared/testing';
import { groupFactory, legacySchoolDoFactory, roleDtoFactory, roleFactory, userDoFactory } from '@shared/testing';
import { Logger } from '@src/core/logger';
import { externalGroupDtoFactory, externalSchoolDtoFactory } from '@modules/provisioning/testing';
import { ExternalGroupDto, ExternalSchoolDto } from '../../../dto';
import { SchoolForGroupNotFoundLoggable, UserForGroupNotFoundLoggable } from '../../../loggable';
import { SchulconnexGroupProvisioningService } from './schulconnex-group-provisioning.service';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ObjectId } from '@mikro-orm/mongodb';
import { ExternalSchoolDto } from '@modules/provisioning/dto';
import { BaseFactory } from './base.factory';
import { BaseFactory } from '../../../shared/testing/factory/base.factory';

class ExternalSchoolDtoFactory extends BaseFactory<ExternalSchoolDto, Readonly<ExternalSchoolDto>> {}

Expand Down
5 changes: 5 additions & 0 deletions apps/server/src/modules/provisioning/testing/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export { externalUserDtoFactory } from './external-user-dto.factory';
export { externalGroupDtoFactory } from './external-group-dto.factory';
export { externalGroupUserDtoFactory } from './external-group-user-dto.factory';
export { oauthDataDtoFactory } from './oauth-data-dto.factory';
export { externalClassDtoFactory } from './external-class-dto.factory';
export { externalSchoolDtoFactory } from './external-school-dto.factory';
export { provisioningSystemDtoFactory } from './provisioning-system-dto.factory';
export { provisioningDtoFactory } from './provisioning-dto.factory';

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions apps/server/src/shared/testing/factory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export * from './coursegroup.factory';
export * from './currentuser.factory';
export * from './domainobject';
export * from './entity.factory';
export * from './external-group-dto.factory';
export { externalSchoolDtoFactory } from './external-school-dto.factory';
export * from './external-tool-pseudonym.factory';
export * from './federal-state.factory';
export * from './filerecord.factory';
Expand Down

0 comments on commit 4e6c0f6

Please sign in to comment.