Skip to content

Commit

Permalink
Merge branch 'release-0101' into SPSH-1583
Browse files Browse the repository at this point in the history
  • Loading branch information
DPDS93CT committed Dec 12, 2024
2 parents ca6dec3 + ae19e32 commit c4a8330
Show file tree
Hide file tree
Showing 15 changed files with 551 additions and 290 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,18 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.createKlasseEventHandler(event);

expect(itslearningGroupRepoMock.createOrUpdateGroup).toHaveBeenLastCalledWith<[CreateGroupParams]>({
id: event.id,
name: event.name!,
parentId: event.administriertVon!,
type: 'Unspecified',
});
expect(loggerMock.info).toHaveBeenLastCalledWith(`Klasse with ID ${event.id} created.`);
expect(itslearningGroupRepoMock.createOrUpdateGroup).toHaveBeenLastCalledWith<[CreateGroupParams, string]>(
{
id: event.id,
name: event.name!,
parentId: event.administriertVon!,
type: 'Unspecified',
},
`${event.eventID}-KLASSE-CREATED`,
);
expect(loggerMock.info).toHaveBeenLastCalledWith(
`[EventID: ${event.eventID}] Klasse with ID ${event.id} created.`,
);
});

it('should skip event, if not enabled', async () => {
Expand All @@ -87,7 +92,7 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.createKlasseEventHandler(event);

expect(loggerMock.info).toHaveBeenCalledWith('Not enabled, ignoring event.');
expect(loggerMock.info).toHaveBeenCalledWith(`[EventID: ${event.eventID}] Not enabled, ignoring event.`);
expect(itslearningGroupRepoMock.createOrUpdateGroup).not.toHaveBeenCalled();
});

Expand All @@ -100,7 +105,9 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.createKlasseEventHandler(event);

expect(loggerMock.error).toHaveBeenCalledWith('Klasse has no parent organisation. Aborting.');
expect(loggerMock.error).toHaveBeenCalledWith(
`[EventID: ${event.eventID}] Klasse has no parent organisation. Aborting.`,
);
});

it('should log error, if the klasse has no name', async () => {
Expand All @@ -112,7 +119,7 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.createKlasseEventHandler(event);

expect(loggerMock.error).toHaveBeenCalledWith('Klasse has no name. Aborting.');
expect(loggerMock.error).toHaveBeenCalledWith(`[EventID: ${event.eventID}] Klasse has no name. Aborting.`);
});

it('should log info, if the parent school is not itslearning enabled', async () => {
Expand All @@ -126,7 +133,7 @@ describe('ItsLearning Organisations Event Handler', () => {
await sut.createKlasseEventHandler(event);

expect(loggerMock.info).toHaveBeenCalledWith(
`Parent Organisation (${event.administriertVon}) is not an itslearning schule.`,
`[EventID: ${event.eventID}] Parent Organisation (${event.administriertVon}) is not an itslearning schule.`,
);
});

Expand All @@ -142,7 +149,9 @@ describe('ItsLearning Organisations Event Handler', () => {
); // CreateGroupAction

await sut.createKlasseEventHandler(event);
expect(loggerMock.error).toHaveBeenLastCalledWith('Could not create Klasse in itsLearning: Error');
expect(loggerMock.error).toHaveBeenLastCalledWith(
`[EventID: ${event.eventID}] Could not create Klasse in itsLearning: Error`,
);
});
});

Expand All @@ -157,13 +166,18 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.updatedKlasseEventHandler(event);

expect(itslearningGroupRepoMock.createOrUpdateGroup).toHaveBeenLastCalledWith<[CreateGroupParams]>({
id: event.organisationId,
name: event.name,
parentId: event.administriertVon!,
type: 'Unspecified',
});
expect(loggerMock.info).toHaveBeenLastCalledWith(`Klasse with ID ${event.organisationId} was updated.`);
expect(itslearningGroupRepoMock.createOrUpdateGroup).toHaveBeenLastCalledWith<[CreateGroupParams, string]>(
{
id: event.organisationId,
name: event.name,
parentId: event.administriertVon!,
type: 'Unspecified',
},
`${event.eventID}-KLASSE-UPDATED`,
);
expect(loggerMock.info).toHaveBeenLastCalledWith(
`[EventID: ${event.eventID}] Klasse with ID ${event.organisationId} was updated.`,
);
});

it('should skip event, if not enabled', async () => {
Expand All @@ -176,7 +190,7 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.updatedKlasseEventHandler(event);

expect(loggerMock.info).toHaveBeenCalledWith('Not enabled, ignoring event.');
expect(loggerMock.info).toHaveBeenCalledWith(`[EventID: ${event.eventID}] Not enabled, ignoring event.`);
expect(itslearningGroupRepoMock.createOrUpdateGroup).not.toHaveBeenCalled();
});

Expand All @@ -189,7 +203,9 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.updatedKlasseEventHandler(event);

expect(loggerMock.error).toHaveBeenCalledWith('Klasse has no parent organisation. Aborting.');
expect(loggerMock.error).toHaveBeenCalledWith(
`[EventID: ${event.eventID}] Klasse has no parent organisation. Aborting.`,
);
expect(itslearningGroupRepoMock.createOrUpdateGroup).not.toHaveBeenCalled();
});

Expand All @@ -198,7 +214,7 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.updatedKlasseEventHandler(event);

expect(loggerMock.error).toHaveBeenCalledWith('Klasse has no name. Aborting.');
expect(loggerMock.error).toHaveBeenCalledWith(`[EventID: ${event.eventID}] Klasse has no name. Aborting.`);
expect(itslearningGroupRepoMock.createOrUpdateGroup).not.toHaveBeenCalled();
});

Expand All @@ -213,7 +229,7 @@ describe('ItsLearning Organisations Event Handler', () => {
await sut.updatedKlasseEventHandler(event);

expect(loggerMock.info).toHaveBeenCalledWith(
`Parent Organisation (${event.administriertVon}) is not an itslearning schule.`,
`[EventID: ${event.eventID}] Parent Organisation (${event.administriertVon}) is not an itslearning schule.`,
);
});

Expand All @@ -230,7 +246,9 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.updatedKlasseEventHandler(event);

expect(loggerMock.error).toHaveBeenLastCalledWith('Could not update Klasse in itsLearning: Error');
expect(loggerMock.error).toHaveBeenLastCalledWith(
`[EventID: ${event.eventID}] Could not update Klasse in itsLearning: Error`,
);
});
});

Expand All @@ -241,8 +259,13 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.deletedKlasseEventHandler(event);

expect(itslearningGroupRepoMock.deleteGroup).toHaveBeenLastCalledWith(event.organisationId);
expect(loggerMock.info).toHaveBeenLastCalledWith(`Klasse with ID ${event.organisationId} was deleted.`);
expect(itslearningGroupRepoMock.deleteGroup).toHaveBeenLastCalledWith(
event.organisationId,
`${event.eventID}-KLASSE-DELETED`,
);
expect(loggerMock.info).toHaveBeenLastCalledWith(
`[EventID: ${event.eventID}] Klasse with ID ${event.organisationId} was deleted.`,
);
});

it('should skip event, if not enabled', async () => {
Expand All @@ -251,7 +274,7 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.deletedKlasseEventHandler(event);

expect(loggerMock.info).toHaveBeenCalledWith('Not enabled, ignoring event.');
expect(loggerMock.info).toHaveBeenCalledWith(`[EventID: ${event.eventID}] Not enabled, ignoring event.`);
expect(itslearningGroupRepoMock.deleteGroup).not.toHaveBeenCalled();
});

Expand All @@ -261,7 +284,9 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.deletedKlasseEventHandler(event);

expect(loggerMock.error).toHaveBeenLastCalledWith('Could not delete Klasse in itsLearning: Error');
expect(loggerMock.error).toHaveBeenLastCalledWith(
`[EventID: ${event.eventID}] Could not delete Klasse in itsLearning: Error`,
);
});
});

Expand All @@ -277,7 +302,7 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.schuleItslearningEnabledEventHandler(event);

expect(loggerMock.info).toHaveBeenCalledWith('Not enabled, ignoring event.');
expect(loggerMock.info).toHaveBeenCalledWith(`[EventID: ${event.eventID}] Not enabled, ignoring event.`);
expect(itslearningGroupRepoMock.createOrUpdateGroups).not.toHaveBeenCalled();
});

Expand All @@ -292,7 +317,7 @@ describe('ItsLearning Organisations Event Handler', () => {
await sut.schuleItslearningEnabledEventHandler(event);

expect(loggerMock.error).toHaveBeenCalledWith(
`The organisation with ID ${event.organisationId} is not of type "SCHULE"!`,
`[EventID: ${event.eventID}] The organisation with ID ${event.organisationId} is not of type "SCHULE"!`,
);
expect(itslearningGroupRepoMock.createOrUpdateGroups).not.toHaveBeenCalled();
});
Expand All @@ -310,7 +335,7 @@ describe('ItsLearning Organisations Event Handler', () => {

await sut.schuleItslearningEnabledEventHandler(event);

expect(loggerMock.error).toHaveBeenCalledWith('Ersatzschule, ignoring.');
expect(loggerMock.error).toHaveBeenCalledWith(`[EventID: ${event.eventID}] Ersatzschule, ignoring.`);
expect(itslearningGroupRepoMock.createOrUpdateGroups).not.toHaveBeenCalled();
});

Expand All @@ -332,7 +357,7 @@ describe('ItsLearning Organisations Event Handler', () => {
await sut.schuleItslearningEnabledEventHandler(event);

expect(loggerMock.error).toHaveBeenLastCalledWith(
`Could not create Schule (ID ${event.organisationId}) and its Klassen in itsLearning: Error`,
`[EventID: ${event.eventID}] Could not create Schule (ID ${event.organisationId}) and its Klassen in itsLearning: Error`,
);
});

Expand Down Expand Up @@ -360,28 +385,31 @@ describe('ItsLearning Organisations Event Handler', () => {
await sut.schuleItslearningEnabledEventHandler(event);

expect(loggerMock.info).toHaveBeenLastCalledWith(
`Schule with ID ${event.organisationId} and its 2 Klassen were created.`,
`[EventID: ${event.eventID}] Schule with ID ${event.organisationId} and its 2 Klassen were created.`,
);
expect(itslearningGroupRepoMock.createOrUpdateGroups).toHaveBeenCalledWith<[CreateGroupParams[], string]>(
[
{
id: event.organisationId,
name: `${event.kennung} (${event.name})`,
type: 'School',
parentId: sut.ROOT_OEFFENTLICH,
},
{
id: klasse1.id,
name: `${klasse1.name}`,
type: 'Unspecified',
parentId: event.organisationId,
},
{
id: klasse2.id,
name: `Unbenannte Klasse`,
type: 'Unspecified',
parentId: event.organisationId,
},
],
`${event.eventID}-SCHULE-SYNC`,
);
expect(itslearningGroupRepoMock.createOrUpdateGroups).toHaveBeenCalledWith<[CreateGroupParams[]]>([
{
id: event.organisationId,
name: `${event.kennung} (${event.name})`,
type: 'School',
parentId: sut.ROOT_OEFFENTLICH,
},
{
id: klasse1.id,
name: `${klasse1.name}`,
type: 'Unspecified',
parentId: event.organisationId,
},
{
id: klasse2.id,
name: `Unbenannte Klasse`,
type: 'Unspecified',
parentId: event.organisationId,
},
]);
});

it('should set default name for schule', async () => {
Expand All @@ -400,16 +428,19 @@ describe('ItsLearning Organisations Event Handler', () => {
await sut.schuleItslearningEnabledEventHandler(event);

expect(loggerMock.info).toHaveBeenLastCalledWith(
`Schule with ID ${event.organisationId} and its 0 Klassen were created.`,
`[EventID: ${event.eventID}] Schule with ID ${event.organisationId} and its 0 Klassen were created.`,
);
expect(itslearningGroupRepoMock.createOrUpdateGroups).toHaveBeenCalledWith<[CreateGroupParams[], string]>(
[
{
id: event.organisationId,
name: `${event.kennung} (Unbenannte Schule)`,
type: 'School',
parentId: sut.ROOT_OEFFENTLICH,
},
],
`${event.eventID}-SCHULE-SYNC`,
);
expect(itslearningGroupRepoMock.createOrUpdateGroups).toHaveBeenCalledWith<[CreateGroupParams[]]>([
{
id: event.organisationId,
name: `${event.kennung} (Unbenannte Schule)`,
type: 'School',
parentId: sut.ROOT_OEFFENTLICH,
},
]);
});
});
});
Loading

0 comments on commit c4a8330

Please sign in to comment.