Skip to content

Commit

Permalink
refactor(api): migrate certification-point-of-contact repository
Browse files Browse the repository at this point in the history
in identity-access-management
  • Loading branch information
er-lim committed Dec 5, 2024
1 parent fde9b51 commit b7cf478
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
2 changes: 0 additions & 2 deletions api/lib/domain/usecases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -237,7 +236,6 @@ const dependencies = {
certificationCourseRepository,
certificationCpfCityRepository,
certificationOfficerRepository,
certificationPointOfContactRepository,
certificationRepository,
challengeRepository,
codeGenerator,
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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();
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b7cf478

Please sign in to comment.