-
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.
[FEATURE] Modifier l'appel Pix Orga qui récupère le status des CGU (P…
- Loading branch information
Showing
18 changed files
with
202 additions
and
45 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
16 changes: 16 additions & 0 deletions
16
api/src/legal-documents/application/http-error-mapper-configuration.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,16 @@ | ||
import { HttpErrors } from '../../shared/application/http-errors.js'; | ||
import { DomainErrorMappingConfiguration } from '../../shared/application/models/domain-error-mapping-configuration.js'; | ||
import { LegalDocumentInvalidDateError, LegalDocumentVersionNotFoundError } from '../domain/errors.js'; | ||
|
||
const legalDocumentsDomainErrorMappingConfiguration = [ | ||
{ | ||
name: LegalDocumentInvalidDateError.name, | ||
httpErrorFn: (error) => new HttpErrors.UnprocessableEntityError(error.message, error.code, error.meta), | ||
}, | ||
{ | ||
name: LegalDocumentVersionNotFoundError.name, | ||
httpErrorFn: (error) => new HttpErrors.NotFoundError(error.message, error.code, error.meta), | ||
}, | ||
].map((domainErrorMappingConfiguration) => new DomainErrorMappingConfiguration(domainErrorMappingConfiguration)); | ||
|
||
export { legalDocumentsDomainErrorMappingConfiguration }; |
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
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 { injectDependencies } from '../../../../src/shared/infrastructure/utils/dependency-injection.js'; | ||
import * as legalDocumentApi from '../../../legal-documents/application/api/legal-documents-api.js'; | ||
import { prescriberRepository } from './prescriber-repository.js'; | ||
|
||
const repositoriesWithoutInjectedDependencies = { | ||
prescriberRepository, | ||
}; | ||
|
||
const dependencies = { | ||
legalDocumentApi, | ||
}; | ||
|
||
const repositories = injectDependencies(repositoriesWithoutInjectedDependencies, dependencies); | ||
|
||
export { repositories }; |
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
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
49 changes: 49 additions & 0 deletions
49
api/tests/legal-documents/unit/domain/application/http-error-mapper-configuration_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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { legalDocumentsDomainErrorMappingConfiguration } from '../../../../../src/legal-documents/application/http-error-mapper-configuration.js'; | ||
import { | ||
LegalDocumentInvalidDateError, | ||
LegalDocumentVersionNotFoundError, | ||
} from '../../../../../src/legal-documents/domain/errors.js'; | ||
import { HttpErrors } from '../../../../../src/shared/application/http-errors.js'; | ||
import { DomainErrorMappingConfiguration } from '../../../../../src/shared/application/models/domain-error-mapping-configuration.js'; | ||
import { expect } from '../../../../test-helper.js'; | ||
|
||
describe('Unit | Legal Documents | Application | HttpErrorMapperConfiguration', function () { | ||
it('contains a list of HttpErrorMapper instances', function () { | ||
// given | ||
// when | ||
// then | ||
legalDocumentsDomainErrorMappingConfiguration.forEach((domainErrorMappingConfiguration) => | ||
expect(domainErrorMappingConfiguration).to.be.instanceOf(DomainErrorMappingConfiguration), | ||
); | ||
}); | ||
|
||
context('when mapping "LegalDocumentInvalidDateError"', function () { | ||
it('returns an UnprocessableEntity Http Error', function () { | ||
//given | ||
const httpErrorMapper = legalDocumentsDomainErrorMappingConfiguration.find( | ||
(httpErrorMapper) => httpErrorMapper.name === LegalDocumentInvalidDateError.name, | ||
); | ||
|
||
//when | ||
const error = httpErrorMapper.httpErrorFn(new LegalDocumentInvalidDateError()); | ||
|
||
//then | ||
expect(error).to.be.instanceOf(HttpErrors.UnprocessableEntityError); | ||
}); | ||
}); | ||
|
||
context('when mapping "LegalDocumentVersionNotFoundError"', function () { | ||
it('returns an NotFound Http Error', function () { | ||
//given | ||
const httpErrorMapper = legalDocumentsDomainErrorMappingConfiguration.find( | ||
(httpErrorMapper) => httpErrorMapper.name === LegalDocumentVersionNotFoundError.name, | ||
); | ||
|
||
//when | ||
const error = httpErrorMapper.httpErrorFn(new LegalDocumentVersionNotFoundError()); | ||
|
||
//then | ||
expect(error).to.be.instanceOf(HttpErrors.NotFoundError); | ||
}); | ||
}); | ||
}); |
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: 5 additions & 2 deletions
7
api/tests/team/integration/domain/usecases/get-prescriber_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
Oops, something went wrong.