From b7cf478c99c548e49d977f450eaab98887d45f4a Mon Sep 17 00:00:00 2001 From: Eric Lim Date: Thu, 5 Dec 2024 16:34:08 +0100 Subject: [PATCH] refactor(api): migrate certification-point-of-contact repository in identity-access-management --- api/lib/domain/usecases/index.js | 2 -- ...t-certification-point-of-contact.usecase.js | 2 +- .../domain/usecases/index.js | 2 +- ...rtification-point-of-contact.repository.js} | 8 ++++---- ...cation-point-of-contact.repository.test.js} | 18 +++++++++--------- 5 files changed, 15 insertions(+), 17 deletions(-) rename api/{lib/infrastructure/repositories/certification-point-of-contact-repository.js => src/identity-access-management/infrastructure/repositories/certification-point-of-contact.repository.js} (94%) rename api/tests/integration/infrastructure/repositories/{certification-point-of-contact-repository_test.js => certification-point-of-contact.repository.test.js} (97%) diff --git a/api/lib/domain/usecases/index.js b/api/lib/domain/usecases/index.js index e24c9174683..452565ec867 100644 --- a/api/lib/domain/usecases/index.js +++ b/api/lib/domain/usecases/index.js @@ -131,7 +131,6 @@ import * as campaignParticipationRepository from '../../infrastructure/repositor import { campaignParticipationResultRepository } from '../../infrastructure/repositories/campaign-participation-result-repository.js'; import * as campaignRepository from '../../infrastructure/repositories/campaign-repository.js'; import * as certifiableProfileForLearningContentRepository from '../../infrastructure/repositories/certifiable-profile-for-learning-content-repository.js'; -import * as certificationPointOfContactRepository from '../../infrastructure/repositories/certification-point-of-contact-repository.js'; import * as certificationRepository from '../../infrastructure/repositories/certification-repository.js'; import * as complementaryCertificationCourseResultRepository from '../../infrastructure/repositories/complementary-certification-course-result-repository.js'; import * as flashAssessmentResultRepository from '../../infrastructure/repositories/flash-assessment-result-repository.js'; @@ -237,7 +236,6 @@ const dependencies = { certificationCourseRepository, certificationCpfCityRepository, certificationOfficerRepository, - certificationPointOfContactRepository, certificationRepository, challengeRepository, codeGenerator, diff --git a/api/src/identity-access-management/domain/usecases/get-certification-point-of-contact.usecase.js b/api/src/identity-access-management/domain/usecases/get-certification-point-of-contact.usecase.js index 3dc851f0518..187248e0a14 100644 --- a/api/src/identity-access-management/domain/usecases/get-certification-point-of-contact.usecase.js +++ b/api/src/identity-access-management/domain/usecases/get-certification-point-of-contact.usecase.js @@ -1,6 +1,6 @@ /** * @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('../../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 '../../../shared/infrastructure/constants.js'; diff --git a/api/src/identity-access-management/domain/usecases/index.js b/api/src/identity-access-management/domain/usecases/index.js index 4b64cc83ec7..f7da4613718 100644 --- a/api/src/identity-access-management/domain/usecases/index.js +++ b/api/src/identity-access-management/domain/usecases/index.js @@ -7,7 +7,6 @@ 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'; @@ -28,6 +27,7 @@ import { certificationCenterMembershipRepository } from '../../../team/infrastru import * as membershipRepository from '../../../team/infrastructure/repositories/membership.repository.js'; import { accountRecoveryDemandRepository } from '../../infrastructure/repositories/account-recovery-demand.repository.js'; import * as authenticationMethodRepository from '../../infrastructure/repositories/authentication-method.repository.js'; +import * as certificationPointOfContactRepository from '../../infrastructure/repositories/certification-point-of-contact.repository.js'; import { emailValidationDemandRepository } from '../../infrastructure/repositories/email-validation-demand.repository.js'; import { eventLoggingJobRepository } from '../../infrastructure/repositories/jobs/event-logging-job.repository.js'; import { garAnonymizedBatchEventsLoggingJobRepository } from '../../infrastructure/repositories/jobs/gar-anonymized-batch-events-logging-job-repository.js'; diff --git a/api/lib/infrastructure/repositories/certification-point-of-contact-repository.js b/api/src/identity-access-management/infrastructure/repositories/certification-point-of-contact.repository.js similarity index 94% rename from api/lib/infrastructure/repositories/certification-point-of-contact-repository.js rename to api/src/identity-access-management/infrastructure/repositories/certification-point-of-contact.repository.js index 5ab94ec6dc9..d76f0612f3c 100644 --- a/api/lib/infrastructure/repositories/certification-point-of-contact-repository.js +++ b/api/src/identity-access-management/infrastructure/repositories/certification-point-of-contact.repository.js @@ -1,9 +1,9 @@ import _ from 'lodash'; -import { knex } from '../../../db/knex-database-connection.js'; -import { NotFoundError } from '../../../src/shared/domain/errors.js'; -import { AllowedCertificationCenterAccess } from '../../../src/shared/domain/read-models/AllowedCertificationCenterAccess.js'; -import { CertificationPointOfContact } from '../../../src/shared/domain/read-models/CertificationPointOfContact.js'; +import { knex } from '../../../../db/knex-database-connection.js'; +import { NotFoundError } from '../../../shared/domain/errors.js'; +import { AllowedCertificationCenterAccess } from '../../../shared/domain/read-models/AllowedCertificationCenterAccess.js'; +import { CertificationPointOfContact } from '../../../shared/domain/read-models/CertificationPointOfContact.js'; const CERTIFICATION_CENTER_MEMBERSHIPS_TABLE_NAME = 'certification-center-memberships'; diff --git a/api/tests/integration/infrastructure/repositories/certification-point-of-contact-repository_test.js b/api/tests/integration/infrastructure/repositories/certification-point-of-contact.repository.test.js similarity index 97% rename from api/tests/integration/infrastructure/repositories/certification-point-of-contact-repository_test.js rename to api/tests/integration/infrastructure/repositories/certification-point-of-contact.repository.test.js index 4e1443f26b6..d9b0addaae1 100644 --- a/api/tests/integration/infrastructure/repositories/certification-point-of-contact-repository_test.js +++ b/api/tests/integration/infrastructure/repositories/certification-point-of-contact.repository.test.js @@ -1,13 +1,13 @@ -import * as certificationPointOfContactRepository from '../../../../lib/infrastructure/repositories/certification-point-of-contact-repository.js'; import * as centerRepository from '../../../../src/certification/enrolment/infrastructure/repositories/center-repository.js'; import { CERTIFICATION_FEATURES } from '../../../../src/certification/shared/domain/constants.js'; +import * as certificationPointOfContactRepository from '../../../../src/identity-access-management/infrastructure/repositories/certification-point-of-contact.repository.js'; import { Organization } from '../../../../src/organizational-entities/domain/models/Organization.js'; import { NotFoundError } from '../../../../src/shared/domain/errors.js'; import { CertificationCenter } from '../../../../src/shared/domain/models/CertificationCenter.js'; import { AllowedCertificationCenterAccess } from '../../../../src/shared/domain/read-models/AllowedCertificationCenterAccess.js'; import { catchErr, databaseBuilder, domainBuilder, expect } from '../../../test-helper.js'; -describe('Integration | Repository | CertificationPointOfContact', function () { +describe('Integration | Identity Access Management | Repository | CertificationPointOfContact', function () { let userWithoutMembership; let userWithMembership; let certificationCenter; @@ -50,7 +50,7 @@ describe('Integration | Repository | CertificationPointOfContact', function () { }); describe('#getAuthorizedCenterIds', function () { - it('should throw NotFoundError when point of contact does not exist', async function () { + it('throws a NotFoundError when point of contact does not exist', async function () { // given const unexistingUserId = 999999; @@ -62,7 +62,7 @@ describe('Integration | Repository | CertificationPointOfContact', function () { expect(error.message).to.equal(`Le référent de certification ${unexistingUserId} n'existe pas.`); }); - it('should return a list of authorized centers', async function () { + it('returns a list of authorized centers', async function () { // given databaseBuilder.factory.buildUser(); await databaseBuilder.commit(); @@ -89,7 +89,7 @@ describe('Integration | Repository | CertificationPointOfContact', function () { }); describe('#getAllowedCenterAccesses', function () { - it('should return a list of access allowed center', async function () { + it('returns a list of access allowed center', async function () { // when const { authorizedCenterIds } = await certificationPointOfContactRepository.getAuthorizedCenterIds( userWithMembership.id, @@ -124,7 +124,7 @@ describe('Integration | Repository | CertificationPointOfContact', function () { }); describe('#getPointOfContact', function () { - it('should return a point of contact', async function () { + it('returns a point of contact', async function () { // when const { authorizedCenterIds, certificationPointOfContactDTO } = await certificationPointOfContactRepository.getAuthorizedCenterIds(userWithMembership.id); @@ -164,7 +164,7 @@ describe('Integration | Repository | CertificationPointOfContact', function () { context( 'when the certification center is related to an organization of the same type that manages students', function () { - it('should return CertificationPointOfContact with isRelatedOrganizationManagingStudents as true', async function () { + it('returns a CertificationPointOfContact with isRelatedOrganizationManagingStudents as true', async function () { // given databaseBuilder.factory.buildOrganization({ id: 333, @@ -283,7 +283,7 @@ describe('Integration | Repository | CertificationPointOfContact', function () { await databaseBuilder.commit(); }); - it('should return actives and allowed certification center accesses of the CertificationPointOfContact', async function () { + it('return actives and allowed certification center accesses of the CertificationPointOfContact', async function () { // given const now = new Date(); @@ -511,7 +511,7 @@ describe('Integration | Repository | CertificationPointOfContact', function () { context( 'when user is linked to a certification center that has habilitations and is associated with an organization with tags', function () { - it('should return the certification point of contact with tags and habilitations', async function () { + it('returns the certification point of contact with tags and habilitations', async function () { // given const firstComplementaryCertification = { id: 1,