-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
6538be4
commit 32bc14a
Showing
20 changed files
with
222 additions
and
18 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
apps/server/src/infra/schulconnex-client/schulconnex-client-config.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
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
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
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
38 changes: 38 additions & 0 deletions
38
apps/server/src/modules/provisioning/loggable/group-provisioning-info.loggable.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,38 @@ | ||
import { externalGroupDtoFactory, externalGroupUserDtoFactory } from '../testing'; | ||
import { GroupProvisioningInfoLoggable } from './group-provisioning-info.loggable'; | ||
|
||
describe(GroupProvisioningInfoLoggable.name, () => { | ||
describe('getLogMessage', () => { | ||
const setup = () => { | ||
const groupCount = 2; | ||
const otherUserCount = 5; | ||
const totalUserCount = groupCount * otherUserCount + groupCount; | ||
const externalGroups = externalGroupDtoFactory.buildList(groupCount, { | ||
otherUsers: externalGroupUserDtoFactory.buildList(otherUserCount), | ||
}); | ||
|
||
const loggable = new GroupProvisioningInfoLoggable(externalGroups, 100); | ||
|
||
return { | ||
loggable, | ||
totalUserCount, | ||
groupCount, | ||
}; | ||
}; | ||
|
||
it('should return a loggable message', () => { | ||
const { loggable, totalUserCount, groupCount } = setup(); | ||
|
||
const message = loggable.getLogMessage(); | ||
|
||
expect(message).toEqual({ | ||
message: 'Group provisioning has finished.', | ||
data: { | ||
groupCount, | ||
userCount: totalUserCount, | ||
durationMs: 100, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
apps/server/src/modules/provisioning/loggable/group-provisioning-info.loggable.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,22 @@ | ||
import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from '@src/core/logger'; | ||
import { ExternalGroupDto } from '../dto'; | ||
|
||
export class GroupProvisioningInfoLoggable implements Loggable { | ||
constructor(private readonly groups: ExternalGroupDto[], private readonly durationMs: number) {} | ||
|
||
public getLogMessage(): LogMessage | ErrorLogMessage | ValidationErrorLogMessage { | ||
const userCount = this.groups.reduce( | ||
(count: number, group: ExternalGroupDto) => count + (group.otherUsers?.length ?? 0), | ||
this.groups.length | ||
); | ||
|
||
return { | ||
message: 'Group provisioning has finished.', | ||
data: { | ||
groupCount: this.groups.length, | ||
userCount, | ||
durationMs: this.durationMs, | ||
}, | ||
}; | ||
} | ||
} |
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
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
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
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
18 changes: 18 additions & 0 deletions
18
apps/server/src/modules/provisioning/testing/external-group-dto.factory.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,18 @@ | ||
import { UUID } from 'bson'; | ||
import { Factory } from 'fishery'; | ||
import { GroupTypes } from '../../group'; | ||
import { ExternalGroupDto } from '../dto'; | ||
import { externalGroupUserDtoFactory } from './external-group-user-dto.factory'; | ||
|
||
export const externalGroupDtoFactory = Factory.define<ExternalGroupDto>( | ||
({ sequence }) => | ||
new ExternalGroupDto({ | ||
type: GroupTypes.CLASS, | ||
name: `External Group ${sequence}`, | ||
externalId: new UUID().toString(), | ||
user: externalGroupUserDtoFactory.build(), | ||
otherUsers: externalGroupUserDtoFactory.buildList(2), | ||
from: new Date(), | ||
until: new Date(), | ||
}) | ||
); |
12 changes: 12 additions & 0 deletions
12
apps/server/src/modules/provisioning/testing/external-group-user-dto.factory.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,12 @@ | ||
import { RoleName } from '@shared/domain/interface'; | ||
import { UUID } from 'bson'; | ||
import { Factory } from 'fishery'; | ||
import { ExternalGroupUserDto } from '../dto'; | ||
|
||
export const externalGroupUserDtoFactory = Factory.define<ExternalGroupUserDto>( | ||
() => | ||
new ExternalGroupUserDto({ | ||
externalUserId: new UUID().toString(), | ||
roleName: RoleName.TEACHER, | ||
}) | ||
); |
Oops, something went wrong.