-
Notifications
You must be signed in to change notification settings - Fork 0
remove toggle from PS and generate UntoggleReport #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
laura-murat
merged 4 commits into
main
from
feature/30_handle_deletion_toggled_ps_ref_id
Sep 5, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
735de2c
remove toggle from PS and generate UntoggleReport
f195d2f
Merge remote-tracking branch 'refs/remotes/origin/main' into feature/…
74fb45a
bump psc-api-client version to 2.3.2-snapshot
laura-murat c0e5609
bump psc-api-client version to 2.3.2
laura-murat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
47 changes: 47 additions & 0 deletions
47
psc-toggle-manager/src/main/java/fr/ans/psc/toggle/model/Report.java
This file contains hidden or 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,47 @@ | ||
| /* | ||
| * Copyright © 2022-2024 Agence du Numérique en Santé (ANS) (https://esante.gouv.fr) | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package fr.ans.psc.toggle.model; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| public class Report { | ||
| protected int successful; | ||
| protected int failed; | ||
| protected int submitted; | ||
|
|
||
| public void setReportCounters(Map<String, TogglePsRef> psRefMap) { | ||
| submitted = psRefMap.size(); | ||
| successful = (int) psRefMap.values().stream().filter(psRef -> psRef.getReturnStatus() == HttpStatus.OK.value()).count(); | ||
| failed = submitted - successful; | ||
| } | ||
|
|
||
| public String generateReportSummary() { | ||
| return String.format("Opérations terminées.\n\n" + | ||
| "%s soumis.\n" + | ||
| "%s en succès.\n" + | ||
| "%s en échec.\n\n" + | ||
| "Vous trouverez la liste des opérations en pièce jointe.\n\n" + | ||
| "Les erreurs possibles sont les suivantes :\n" + | ||
| "- 500 : Erreur côté serveur, veuillez vous rapprocher de l'administrateur.", | ||
| submitted, successful, failed); | ||
| } | ||
| } |
This file contains hidden or 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
38 changes: 38 additions & 0 deletions
38
psc-toggle-manager/src/main/java/fr/ans/psc/toggle/model/UntoggleReport.java
This file contains hidden or 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,38 @@ | ||
| /* | ||
| * Copyright © 2022-2024 Agence du Numérique en Santé (ANS) (https://esante.gouv.fr) | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package fr.ans.psc.toggle.model; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| public class UntoggleReport extends Report { | ||
|
|
||
| @Override | ||
| public String generateReportSummary() { | ||
| return String.format("Opérations terminées.\n\n" + | ||
| "%s PsRefs soumis pour déréférencement.\n" + | ||
| "%s PsRefs retirés avec succès.\n" + | ||
| "%s PsRefs n'ont pas pu être retirés.\n\n" + | ||
| "Vous trouverez la liste des opérations en pièce jointe.\n\n" + | ||
| "Les erreurs possibles sont les suivantes :\n" + | ||
| "- 404 : Le PsRef proposé n'est pas lié au Ps, n'a pas pu être retiré.\n" + | ||
| "- 410 : Le Ps proposé n'est pas présent en base, le PsRef n'a pas été rétiré.\n" + | ||
| "- 500 : Erreur côté serveur, veuillez vous rapprocher de l'administrateur.", | ||
| submitted, successful, failed); | ||
| } | ||
| } |
This file contains hidden or 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
65 changes: 65 additions & 0 deletions
65
psc-toggle-manager/src/test/java/fr/ans/psc/toggle/model/ReportTest.java
This file contains hidden or 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,65 @@ | ||
| /* | ||
| * Copyright © 2022-2024 Agence du Numérique en Santé (ANS) (https://esante.gouv.fr) | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package fr.ans.psc.toggle.model; | ||
|
|
||
| import fr.ans.psc.toggle.ToggleManagerApplication; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.test.context.ActiveProfiles; | ||
| import org.springframework.test.context.ContextConfiguration; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| @SpringBootTest | ||
| @ActiveProfiles("test") | ||
| @ContextConfiguration(classes = ToggleManagerApplication.class) | ||
| public class ReportTest { | ||
|
|
||
| @Test | ||
| @DisplayName("tata") | ||
| void setCounters() { | ||
| Map<String, TogglePsRef> psRefMap = TestUtil.createTestPsRefMap(); | ||
|
|
||
| Report report = new Report(); | ||
| report.setReportCounters(psRefMap); | ||
|
|
||
| assertEquals(3, report.getSubmitted()); | ||
| assertEquals(1, report.getFailed()); | ||
| assertEquals(2, report.getSuccessful()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("tutu") | ||
| void generateReport() { | ||
| Map<String, TogglePsRef> psRefMap = TestUtil.createTestPsRefMap(); | ||
|
|
||
| String expected = "Opérations terminées.\n\n" + | ||
| "3 soumis.\n" + | ||
| "2 en succès.\n" + | ||
| "1 en échec.\n\n" + | ||
| "Vous trouverez la liste des opérations en pièce jointe.\n\n" + | ||
| "Les erreurs possibles sont les suivantes :\n" + | ||
| "- 500 : Erreur côté serveur, veuillez vous rapprocher de l'administrateur."; | ||
|
|
||
| Report report = new Report(); | ||
| report.setReportCounters(psRefMap); | ||
| String actual = report.generateReportSummary(); | ||
| assertEquals(expected, actual); | ||
| } | ||
| } |
37 changes: 37 additions & 0 deletions
37
psc-toggle-manager/src/test/java/fr/ans/psc/toggle/model/TestUtil.java
This file contains hidden or 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,37 @@ | ||
| /* | ||
| * Copyright © 2022-2024 Agence du Numérique en Santé (ANS) (https://esante.gouv.fr) | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package fr.ans.psc.toggle.model; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
|
|
||
| public class TestUtil { | ||
| public static Map<String, TogglePsRef> createTestPsRefMap() { | ||
| TogglePsRef psRef1 = new TogglePsRef(new String[]{"123", "823"}, PsIdType.ADELI, PsIdType.RPPS); | ||
| psRef1.setReturnStatus(200); | ||
| TogglePsRef psRef2 = new TogglePsRef(new String[]{"055", "855"}, PsIdType.ADELI, PsIdType.RPPS); | ||
| psRef2.setReturnStatus(200); | ||
| TogglePsRef psRef3 = new TogglePsRef(new String[]{"089","889"}, PsIdType.ADELI, PsIdType.RPPS); | ||
| psRef3.setReturnStatus(409); | ||
|
|
||
| Map<String, TogglePsRef> psRefMap = new ConcurrentHashMap<>(); | ||
| psRefMap.put(psRef1.getNationalIdRef(), psRef1); | ||
| psRefMap.put(psRef2.getNationalIdRef(), psRef2); | ||
| psRefMap.put(psRef3.getNationalIdRef(), psRef3); | ||
|
|
||
| return psRefMap; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.