-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
169 additions
and
13 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...login-migration/loggable/identical-user-login-migration-system.loggable-exception.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { IdenticalUserLoginMigrationSystemLoggableException } from '@modules/user-login-migration/loggable/identical-user-login-migration-system.loggable-exception'; | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
|
||
describe(IdenticalUserLoginMigrationSystemLoggableException.name, () => { | ||
describe('getLogMessage', () => { | ||
const setup = () => { | ||
const schoolId = new ObjectId().toHexString(); | ||
const targetSystemId = new ObjectId().toHexString(); | ||
|
||
const exception: IdenticalUserLoginMigrationSystemLoggableException = | ||
new IdenticalUserLoginMigrationSystemLoggableException(schoolId, targetSystemId); | ||
|
||
return { | ||
schoolId, | ||
targetSystemId, | ||
exception, | ||
}; | ||
}; | ||
|
||
it('should return log message', () => { | ||
const { exception, schoolId, targetSystemId } = setup(); | ||
|
||
const result = exception.getLogMessage(); | ||
|
||
expect(result).toEqual({ | ||
type: 'IDENTICAL_USER_LOGIN_MIGRATION_SYSTEM', | ||
message: | ||
'The migration cannot be started, because the target system and current schools login system are the same.', | ||
stack: exception.stack, | ||
data: { | ||
schoolId, | ||
targetSystemId, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
...user-login-migration/loggable/identical-user-login-migration-system.loggable-exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from '@src/core/logger'; | ||
import { BusinessError } from '@shared/common'; | ||
import { EntityId } from '@shared/domain/types'; | ||
import { HttpStatus } from '@nestjs/common'; | ||
|
||
export class IdenticalUserLoginMigrationSystemLoggableException extends BusinessError implements Loggable { | ||
constructor(private readonly schoolId: string | undefined, private readonly targetSystemId: EntityId | undefined) { | ||
super( | ||
{ | ||
type: 'IDENTICAL_USER_LOGIN_MIGRATION_SYSTEM', | ||
title: 'Identical user login migration system', | ||
defaultMessage: | ||
'The migration cannot be started, because the target system and current schools login system are the same.', | ||
}, | ||
HttpStatus.INTERNAL_SERVER_ERROR, | ||
{ | ||
schoolId, | ||
targetSystemId, | ||
} | ||
); | ||
} | ||
|
||
getLogMessage(): LogMessage | ErrorLogMessage | ValidationErrorLogMessage { | ||
return { | ||
type: this.type, | ||
message: this.message, | ||
stack: this.stack, | ||
data: { | ||
schoolId: this.schoolId, | ||
targetSystemId: this.targetSystemId, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...les/user-login-migration/loggable/moin-schule-system-not-found.loggable-exception.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { MoinSchuleSystemNotFoundLoggableException } from '@modules/user-login-migration/loggable/moin-schule-system-not-found.loggable-exception'; | ||
|
||
describe(MoinSchuleSystemNotFoundLoggableException.name, () => { | ||
describe('getLogMessage', () => { | ||
const setup = () => { | ||
const exception: MoinSchuleSystemNotFoundLoggableException = new MoinSchuleSystemNotFoundLoggableException(); | ||
|
||
return { | ||
exception, | ||
}; | ||
}; | ||
|
||
it('should return log message', () => { | ||
const { exception } = setup(); | ||
|
||
const result = exception.getLogMessage(); | ||
|
||
expect(result).toEqual({ | ||
type: 'MOIN_SCHULE_SYSTEM_NOT_FOUND', | ||
message: 'Cannot find moin.schule system', | ||
stack: exception.stack, | ||
}); | ||
}); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
.../modules/user-login-migration/loggable/moin-schule-system-not-found.loggable-exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from '@src/core/logger'; | ||
import { BusinessError } from '@shared/common'; | ||
import { HttpStatus } from '@nestjs/common'; | ||
|
||
export class MoinSchuleSystemNotFoundLoggableException extends BusinessError implements Loggable { | ||
constructor() { | ||
super( | ||
{ | ||
type: 'MOIN_SCHULE_SYSTEM_NOT_FOUND', | ||
title: 'moin.schule system not found', | ||
defaultMessage: 'Cannot find moin.schule system', | ||
}, | ||
HttpStatus.INTERNAL_SERVER_ERROR | ||
); | ||
} | ||
|
||
getLogMessage(): LogMessage | ErrorLogMessage | ValidationErrorLogMessage { | ||
return { | ||
type: this.type, | ||
message: this.message, | ||
stack: this.stack, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters