Skip to content

Commit

Permalink
feat(api): migrate usecase and use into controller
Browse files Browse the repository at this point in the history
  • Loading branch information
xav-car committed Dec 4, 2024
1 parent 1cf1e60 commit bae8f31
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { usecases } from '../../../../../lib/domain/usecases/index.js';
import { usecases } from '../../../../../src/prescription/learner-management/domain/usecases/index.js';
import { JobController } from '../../../../shared/application/jobs/job-controller.js';
import { ComputeCertificabilityJob } from '../../domain/models/ComputeCertificabilityJob.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const computeOrganizationLearnerCertificability = async function ({
organizationLearnerRepository,
placementProfileService,
}) {
const organizationLearner = await organizationLearnerRepository.get(organizationLearnerId);
const organizationLearner = await organizationLearnerRepository.getLearnerInfo(organizationLearnerId);

const placementProfile = await placementProfileService.getPlacementProfile({
userId: organizationLearner.userId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as campaignRepository from '../../../../../lib/infrastructure/repositor
import * as libOrganizationLearnerRepository from '../../../../../lib/infrastructure/repositories/organization-learner-repository.js';
import * as userRepository from '../../../../identity-access-management/infrastructure/repositories/user.repository.js';
import * as organizationFeatureApi from '../../../../organizational-entities/application/api/organization-features-api.js';
import * as placementProfileService from '../../../../shared/domain/services/placement-profile-service.js';
import { logErrorWithCorrelationIds } from '../../../../shared/infrastructure/monitoring-tools.js';
import * as organizationRepository from '../../../../shared/infrastructure/repositories/organization-repository.js';
import { injectDependencies } from '../../../../shared/infrastructure/utils/dependency-injection.js';
Expand Down Expand Up @@ -46,6 +47,7 @@ import { importStorage } from '../../infrastructure/storage/import-storage.js';
* @typedef {import ('../../infrastructure/repositories/organization-learner-import-format-repository.js')} OrganizationLearnerImportFormatRepository
* @typedef {import ('../../infrastructure/repositories/organization-learner-repository.js')} OrganizationLearnerRepository
* @typedef {import ('../../../../shared/infrastructure/repositories/organization-repository.js')} OrganizationRepository
* @typedef {import ('../../../../shared/domain/services/placement-profile-service.js')} placementProfileService
* @typedef {import('../../../organization-learner/infrastructure/repositories/registration-organization-learner-repository.js')} registrationOrganizationLearnerRepository
* @typedef {import ('../../infrastructure/repositories/student-repository.js')} studentRepository
* @typedef {import ('../../infrastructure/repositories/sup-organization-learner-repository.js')} SupOrganizationLearnerRepository
Expand All @@ -72,6 +74,7 @@ const dependencies = {
organizationLearnerImportFormatRepository,
organizationLearnerRepository,
organizationRepository,
placementProfileService,
registrationOrganizationLearnerRepository,
studentRepository,
supOrganizationLearnerRepository,
Expand All @@ -96,6 +99,7 @@ const usecasesWithoutInjectedDependencies = {

/**
* @typedef PrescriptionLearnerManagementUsecases
* @property {computeOrganizationLearnerCertificability} computeOrganizationLearnerCertificability
* @property {saveOrganizationLearnersFile} saveOrganizationLearnersFile
* @property {sendOrganizationLearnersFile} sendOrganizationLearnersFile
* @property {validateOrganizationLearnersFile} validateOrganizationLearnersFile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { usecases } from '../../../../../../lib/domain/usecases/index.js';
import { ComputeCertificabilityJobController } from '../../../../../../src/prescription/learner-management/application/jobs/compute-certificability-job-controller.js';
import { usecases } from '../../../../../../src/prescription/learner-management/domain/usecases/index.js';
import { expect, sinon } from '../../../../../test-helper.js';

describe('Unit | Prescription | Application | Jobs | computeCertificabilityJobController', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { usecases } from '../../../../lib/domain/usecases/index.js';
import { domainBuilder, expect, sinon } from '../../../test-helper.js';
import { usecases } from '../../../../../../src/prescription/learner-management/domain/usecases/index.js';
import { domainBuilder, expect, sinon } from '../../../../../test-helper.js';

describe('Unit | UseCase | compute-organization-learner-certificabilty', function () {
let clock;
Expand All @@ -18,13 +18,13 @@ describe('Unit | UseCase | compute-organization-learner-certificabilty', functio
it('should update certificability for an organization learner', async function () {
// given
const organizationLearnerRepository = {
get: sinon.stub(),
getLearnerInfo: sinon.stub(),
updateCertificability: sinon.stub(),
};
const organizationLearnerId = 1;
const organizationLearner = domainBuilder.buildOrganizationLearner({ id: organizationLearnerId });
sinon.stub(organizationLearner, 'updateCertificability');
organizationLearnerRepository.get.withArgs(organizationLearner.id).returns(organizationLearner);
organizationLearnerRepository.getLearnerInfo.withArgs(organizationLearner.id).returns(organizationLearner);
const placementProfileService = {
getPlacementProfile: sinon.stub(),
};
Expand Down

0 comments on commit bae8f31

Please sign in to comment.