diff --git a/api/src/identity-access-management/application/user/user.controller.js b/api/src/identity-access-management/application/user/user.controller.js index 8c689a5b105..cc53ee4a781 100644 --- a/api/src/identity-access-management/application/user/user.controller.js +++ b/api/src/identity-access-management/application/user/user.controller.js @@ -1,4 +1,3 @@ -import { usecases as libUsecases } from '../../../../lib/domain/usecases/index.js'; import * as localeService from '../../../shared/domain/services/locale-service.js'; import * as userSerializer from '../../../shared/infrastructure/serializers/jsonapi/user-serializer.js'; import { requestResponseUtils } from '../../../shared/infrastructure/utils/request-response-utils.js'; @@ -237,7 +236,7 @@ const validateUserAccountEmail = async function (request, h) { const getCertificationPointOfContact = async function (request) { const authenticatedUserId = request.auth.credentials.userId; - const certificationPointOfContact = await libUsecases.getCertificationPointOfContact({ userId: authenticatedUserId }); + const certificationPointOfContact = await usecases.getCertificationPointOfContact({ userId: authenticatedUserId }); return certificationPointOfContactSerializer.serialize(certificationPointOfContact); }; diff --git a/api/lib/domain/usecases/get-certification-point-of-contact.js b/api/src/identity-access-management/domain/usecases/get-certification-point-of-contact.usecase.js similarity index 61% rename from api/lib/domain/usecases/get-certification-point-of-contact.js rename to api/src/identity-access-management/domain/usecases/get-certification-point-of-contact.usecase.js index 33b9e784b33..3dc851f0518 100644 --- a/api/lib/domain/usecases/get-certification-point-of-contact.js +++ b/api/src/identity-access-management/domain/usecases/get-certification-point-of-contact.usecase.js @@ -1,13 +1,16 @@ /** - * @typedef {import('./index.js').CenterRepository} CenterRepository - * @typedef {import('../../../src/certification/enrolment/domain/models/Center.js').Center} Center + * @typedef {import('../../../certification/enrolment/infrastructure/repositories/center-repository.js').CenterRepository} CenterRepository + * @typedef {import('../../../../lib/infrastructure/repositories/certification-point-of-contact-repository.js').CertificationPointOfContactRepository} CertificationPointOfContactRepository + * @typedef {import('../../../certification/enrolment/domain/models/Center.js').Center} Center */ -import { CONCURRENCY_HEAVY_OPERATIONS } from '../../../src/shared/infrastructure/constants.js'; -import { PromiseUtils } from '../../../src/shared/infrastructure/utils/promise-utils.js'; +import { CONCURRENCY_HEAVY_OPERATIONS } from '../../../shared/infrastructure/constants.js'; +import { PromiseUtils } from '../../../shared/infrastructure/utils/promise-utils.js'; /** * @param {Object} params + * @param {string} params.userId * @param {CenterRepository} params.centerRepository + * @param {CertificationPointOfContactRepository} params.certificationPointOfContactRepository */ const getCertificationPointOfContact = async function ({ userId, diff --git a/api/src/identity-access-management/domain/usecases/index.js b/api/src/identity-access-management/domain/usecases/index.js index 480e5bc9670..4b64cc83ec7 100644 --- a/api/src/identity-access-management/domain/usecases/index.js +++ b/api/src/identity-access-management/domain/usecases/index.js @@ -7,7 +7,9 @@ import * as userReconciliationService from '../../../../lib/domain/services/user import { oidcAuthenticationServiceRegistry } from '../../../../lib/domain/usecases/index.js'; import * as campaignParticipationRepository from '../../../../lib/infrastructure/repositories/campaign-participation-repository.js'; import * as campaignRepository from '../../../../lib/infrastructure/repositories/campaign-repository.js'; +import * as certificationPointOfContactRepository from '../../../../lib/infrastructure/repositories/certification-point-of-contact-repository.js'; import * as organizationLearnerRepository from '../../../../lib/infrastructure/repositories/organization-learner-repository.js'; +import * as centerRepository from '../../../certification/enrolment/infrastructure/repositories/center-repository.js'; import * as userRecommendedTrainingRepository from '../../../devcomp/infrastructure/repositories/user-recommended-training-repository.js'; import { repositories as campaignRepositories } from '../../../prescription/campaign/infrastructure/repositories/index.js'; import { config } from '../../../shared/config.js'; @@ -52,7 +54,9 @@ const repositories = { campaignParticipationRepository, campaignRepository, campaignToJoinRepository: campaignRepositories.campaignToJoinRepository, + centerRepository, certificationCenterMembershipRepository, + certificationPointOfContactRepository, emailValidationDemandRepository, emailRepository, eventLoggingJobRepository, diff --git a/api/tests/integration/domain/usecases/get-certification-point-of-contact_test.js b/api/tests/identity-access-management/integration/domain/usecases/get-certification-point-of-contact.usecase.test.js similarity index 81% rename from api/tests/integration/domain/usecases/get-certification-point-of-contact_test.js rename to api/tests/identity-access-management/integration/domain/usecases/get-certification-point-of-contact.usecase.test.js index 2b0be8c63ce..0df8d075f32 100644 --- a/api/tests/integration/domain/usecases/get-certification-point-of-contact_test.js +++ b/api/tests/identity-access-management/integration/domain/usecases/get-certification-point-of-contact.usecase.test.js @@ -1,12 +1,12 @@ -import { usecases } from '../../../../lib/domain/usecases/index.js'; -import { CERTIFICATION_FEATURES } from '../../../../src/certification/shared/domain/constants.js'; -import { CERTIFICATION_CENTER_MEMBERSHIP_ROLES } from '../../../../src/shared/domain/models/CertificationCenterMembership.js'; -import { databaseBuilder, domainBuilder, expect } from '../../../test-helper.js'; +import { CERTIFICATION_FEATURES } from '../../../../../src/certification/shared/domain/constants.js'; +import { usecases } from '../../../../../src/identity-access-management/domain/usecases/index.js'; +import { CERTIFICATION_CENTER_MEMBERSHIP_ROLES } from '../../../../../src/shared/domain/models/CertificationCenterMembership.js'; +import { databaseBuilder, domainBuilder, expect } from '../../../../test-helper.js'; const { getCertificationPointOfContact } = usecases; -describe('Integration | UseCase | get-certification-point-of-contact', function () { - it('should return the CertificationPointOfContact', async function () { +describe('Integration | Identity Access Management | Domain | UseCase | get-certification-point-of-contact', function () { + it('returns the CertificationPointOfContact', async function () { // given const user = databaseBuilder.factory.buildUser(); const certificationCenter = databaseBuilder.factory.buildCertificationCenter(); diff --git a/api/tests/identity-access-management/unit/application/user/user.controller.test.js b/api/tests/identity-access-management/unit/application/user/user.controller.test.js index 9fb2a9196ce..5a7dc7b8771 100644 --- a/api/tests/identity-access-management/unit/application/user/user.controller.test.js +++ b/api/tests/identity-access-management/unit/application/user/user.controller.test.js @@ -1,4 +1,3 @@ -import { usecases as libUsecases } from '../../../../../lib/domain/usecases/index.js'; import { userController } from '../../../../../src/identity-access-management/application/user/user.controller.js'; import { User } from '../../../../../src/identity-access-management/domain/models/User.js'; import { usecases } from '../../../../../src/identity-access-management/domain/usecases/index.js'; @@ -475,7 +474,7 @@ describe('Unit | Identity Access Management | Application | Controller | User', describe('#getCertificationPointOfContact', function () { beforeEach(function () { - sinon.stub(libUsecases, 'getCertificationPointOfContact'); + sinon.stub(usecases, 'getCertificationPointOfContact'); }); it('returns a serialized CertificationPointOfContact', async function () { @@ -514,7 +513,7 @@ describe('Unit | Identity Access Management | Application | Controller | User', }, }; - libUsecases.getCertificationPointOfContact.withArgs({ userId: 123 }).resolves(certificationPointOfContact); + usecases.getCertificationPointOfContact.withArgs({ userId: 123 }).resolves(certificationPointOfContact); // when const response = await userController.getCertificationPointOfContact(request, hFake);