-
Notifications
You must be signed in to change notification settings - Fork 56
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
1 parent
370f587
commit e405c81
Showing
10 changed files
with
84 additions
and
23 deletions.
There are no files selected for viewing
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
7 changes: 0 additions & 7 deletions
7
api/src/certification/session-management/domain/usecases/uncancel-certification-course.js
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
api/src/certification/session-management/domain/usecases/uncancel.js
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,33 @@ | ||
/** | ||
* @typedef {import('./index.js'.CertificationCourseRepository} CertificationCourseRepository | ||
* @typedef {import('./index.js'.CertificationRescoringRepository} CertificationRescoringRepository | ||
*/ | ||
|
||
import CertificationUncancelled from '../../../../shared/domain/events/CertificationUncancelled.js'; | ||
|
||
/** | ||
* @param {Object} params | ||
* @param {number} params.certificationCourseId | ||
* @param {number} params.juryId | ||
* @param {CertificationCourseRepository} params.certificationCourseRepository | ||
* @param {CertificationRescoringRepository} params.certificationRescoringRepository | ||
*/ | ||
const uncancel = async function ({ | ||
certificationCourseId, | ||
juryId, | ||
certificationCourseRepository, | ||
certificationRescoringRepository, | ||
}) { | ||
const certificationCourse = await certificationCourseRepository.get({ id: certificationCourseId }); | ||
certificationCourse.uncancel(); | ||
await certificationCourseRepository.update({ certificationCourse }); | ||
|
||
const certificationUncancelledEvent = new CertificationUncancelled({ | ||
certificationCourseId: certificationCourse.getId(), | ||
juryId, | ||
}); | ||
|
||
return certificationRescoringRepository.execute({ event: certificationUncancelledEvent }); | ||
}; | ||
|
||
export { uncancel }; |
7 changes: 3 additions & 4 deletions
7
...tion/session-management/infrastructure/repositories/certification-rescoring-repository.js
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 |
---|---|---|
@@ -1,15 +1,14 @@ | ||
/** | ||
* @typedef {import('../../../../../src/shared/domain/events/CertificationCancelled.js'} CertificationCancelled | ||
* @typedef {import('./index.js'.LibServices} LibServices | ||
*/ | ||
|
||
/** | ||
* @param {Object} params | ||
* @param {CertificationCancelled} params.certificationCancelledEvent | ||
* @param {??} params.event | ||
* @param {LibServices} params.libServices | ||
*/ | ||
export const execute = async ({ certificationCancelledEvent, libServices }) => { | ||
export const execute = async ({ event, libServices }) => { | ||
return libServices.handleCertificationRescoring({ | ||
event: certificationCancelledEvent, | ||
event, | ||
}); | ||
}; |
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,15 @@ | ||
import { assertNotNullOrUndefined } from '../models/asserts.js'; | ||
|
||
export default class CertificationUncancelled { | ||
/** | ||
* @param {Object} params | ||
* @param {number} params.certificationCourseId - certification course that will be rescored | ||
* @param {number} params.juryId - Id of the jury member who uncancelled the certification | ||
*/ | ||
constructor({ certificationCourseId, juryId }) { | ||
assertNotNullOrUndefined(certificationCourseId); | ||
this.certificationCourseId = certificationCourseId; | ||
assertNotNullOrUndefined(juryId); | ||
this.juryId = juryId; | ||
} | ||
} |
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
20 changes: 17 additions & 3 deletions
20
...ses/uncancel-certification-course_test.js → ...ent/unit/domain/usecases/uncancel_test.js
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 |
---|---|---|
@@ -1,26 +1,40 @@ | ||
import { uncancelCertificationCourse } from '../../../../../../src/certification/session-management/domain/usecases/uncancel-certification-course.js'; | ||
import { uncancel } from '../../../../../../src/certification/session-management/domain/usecases/uncancel.js'; | ||
import CertificationUncancelled from '../../../../../../src/shared/domain/events/CertificationUncancelled.js'; | ||
import { domainBuilder, expect, sinon } from '../../../../../test-helper.js'; | ||
|
||
describe('Certification | Session-management | Unit | Domain | UseCases | uncancel-certification-course', function () { | ||
describe('Certification | Session-management | Unit | Domain | UseCases | uncancel', function () { | ||
it('should uncancel the certification course', async function () { | ||
// given | ||
const juryId = 123; | ||
const certificationCourse = domainBuilder.buildCertificationCourse({ id: 123 }); | ||
sinon.spy(certificationCourse, 'uncancel'); | ||
const certificationCourseRepository = { | ||
update: sinon.stub(), | ||
get: sinon.stub(), | ||
}; | ||
const certificationRescoringRepository = { | ||
execute: sinon.stub(), | ||
}; | ||
certificationCourseRepository.get.withArgs({ id: 123 }).resolves(certificationCourse); | ||
certificationCourseRepository.update.resolves(); | ||
certificationRescoringRepository.execute.resolves(); | ||
|
||
// when | ||
await uncancelCertificationCourse({ | ||
await uncancel({ | ||
certificationCourseId: 123, | ||
juryId, | ||
certificationCourseRepository, | ||
certificationRescoringRepository, | ||
}); | ||
|
||
// then | ||
expect(certificationCourse.uncancel).to.have.been.calledOnce; | ||
expect(certificationCourseRepository.update).to.have.been.calledWithExactly({ certificationCourse }); | ||
expect(certificationRescoringRepository.execute).to.have.been.calledWithExactly({ | ||
event: new CertificationUncancelled({ | ||
certificationCourseId: certificationCourse.getId(), | ||
juryId, | ||
}), | ||
}); | ||
}); | ||
}); |