Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions src/test/java/fr/ans/psc/pscapimajv2/api/PsOperationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void createNewPs() throws Exception {

ResultActions createdPs2 = mockMvc.perform(post("/api/v2/ps").header("Accept", "application/json")
.contentType("application/json").content("{\"idType\":\"8\",\"id\":\"00000000002\"," +"\"ids\":[\"800000000002\",\"855e8700-e29b-41d4-a716-44665544111\"],"+
"\"alternativeIds\":[{\"identifier\":\"800000000002\",\"origine\":\"RPPS\",\"quality\":1},{\"identifier\":\"855e8700-e29b-41d4-a716-44665544111\",\"origine\":\"PSI\",\"quality\":2}]," + "\"quality\":0," +
"\"alternativeIds\":[{\"identifier\":\"800000000002\",\"origine\":\"RPPS\",\"quality\":1},{\"identifier\":\"855e8700-e29b-41d4-a716-44665544111\",\"origine\":\"PSI\",\"quality\":2}]," + "\"quality\":0," +
"\"nationalId\":\"855e8700-e29b-41d4-a716-44665544111\",\"lastName\":\"DUPONT\",\"firstNames\":[{\"firstName\":\"JIMMY\",\"order\":1}],\"dateOfBirth\":\"17/12/1983\"," +
"\"birthAddressCode\":\"57463\",\"birthCountryCode\":\"99000\",\"birthAddress\":\"METZ\",\"genderCode\":\"M\"," +
"\"phone\":\"0601020304\",\"email\":\"toto57@hotmail.fr\",\"salutationCode\":\"MME\",\"professions\":[{\"exProId\":\"50C\"," +
Expand Down Expand Up @@ -388,38 +388,38 @@ public void deletePsFailed() throws Exception {
@DisplayName(value = "Search a PS by identity")
@MongoDataSet(value = "/dataset/ps_search_by_identity.json", cleanBefore = true, cleanAfter = true)
public void searchPs() throws Exception {
// Only required criterias (and only one firstName)
ResultActions result = mockMvc.perform(
get("/api/v2/ps/search")
// Only required criterias (and only one firstName)
ResultActions result = mockMvc.perform(
get("/api/v2/ps/search")
.header("Accept", "application/json")
.param("lastName", "DUPONT")
.param("firstNames", "JIMMY")
.param("genderCode", "M")
.param("birthdate", "1983-12-17")
)
.andExpect(status().is(200));
String responseBody = result.andReturn().getResponse().getContentAsString();
String responseBody = result.andReturn().getResponse().getContentAsString();

assertTrue(responseBody.contains("800000000001") && responseBody.contains("800000000002"));

// Only required criterias (and all firstnames)
result = mockMvc.perform(
get("/api/v2/ps/search")
result = mockMvc.perform(
get("/api/v2/ps/search")
.header("Accept", "application/json")
.param("lastName", "DUPONT")
.param("firstNames", "JIMMY BOB")
.param("genderCode", "M")
.param("birthdate", "1983-12-17")
)
.andExpect(status().is(200));
responseBody = result.andReturn().getResponse().getContentAsString();
responseBody = result.andReturn().getResponse().getContentAsString();

assertTrue(responseBody.contains("800000000001"));

// Only required criterias + birthCountryCode
result = mockMvc.perform(
get("/api/v2/ps/search")
result = mockMvc.perform(
get("/api/v2/ps/search")
.header("Accept", "application/json")
.param("lastName", "DUPONT")
.param("firstNames", "JIMMY BOB")
Expand All @@ -428,13 +428,13 @@ public void searchPs() throws Exception {
.param("birthCountryCode","99000")
)
.andExpect(status().is(200));
responseBody = result.andReturn().getResponse().getContentAsString();
responseBody = result.andReturn().getResponse().getContentAsString();

assertTrue(responseBody.contains("800000000001"));

// Only required criterias + birthCountryCode + birthAddressCode
result = mockMvc.perform(
get("/api/v2/ps/search")
result = mockMvc.perform(
get("/api/v2/ps/search")
.header("Accept", "application/json")
.param("lastName", "DUPONT")
.param("firstNames", "JIMMY BOB")
Expand All @@ -444,13 +444,13 @@ public void searchPs() throws Exception {
.param("birthTownCode","57463")
)
.andExpect(status().is(200));
responseBody = result.andReturn().getResponse().getContentAsString();
responseBody = result.andReturn().getResponse().getContentAsString();

assertTrue(responseBody.contains("800000000001"));

// All criterias (+ optionals birthCountryCode, birthAddressCode, birthAddress)
result = mockMvc.perform(
get("/api/v2/ps/search")
result = mockMvc.perform(
get("/api/v2/ps/search")
.header("Accept", "application/json")
.param("lastName", "DUPONT")
.param("firstNames", "JIMMY BOB")
Expand All @@ -461,13 +461,13 @@ public void searchPs() throws Exception {
.param("birthplace","METZ")
)
.andExpect(status().is(200));
responseBody = result.andReturn().getResponse().getContentAsString();
responseBody = result.andReturn().getResponse().getContentAsString();

assertTrue(responseBody.contains("800000000001"));

// All criterias, fake firstname
result = mockMvc.perform(
get("/api/v2/ps/search")
result = mockMvc.perform(
get("/api/v2/ps/search")
.header("Accept", "application/json")
.param("lastName", "DUPONT")
.param("firstNames", "JIMMY BOB TOTO")
Expand All @@ -478,13 +478,13 @@ public void searchPs() throws Exception {
.param("birthplace","METZ")
)
.andExpect(status().is(200));
responseBody = result.andReturn().getResponse().getContentAsString();
responseBody = result.andReturn().getResponse().getContentAsString();

assertEquals("[]", responseBody);

// All criterias, fake birthCountryCode
result = mockMvc.perform(
get("/api/v2/ps/search")
result = mockMvc.perform(
get("/api/v2/ps/search")
.header("Accept", "application/json")
.param("lastName", "DUPONT")
.param("firstNames", "JIMMY BOB")
Expand All @@ -495,13 +495,13 @@ public void searchPs() throws Exception {
.param("birthplace","METZ")
)
.andExpect(status().is(200));
responseBody = result.andReturn().getResponse().getContentAsString();
responseBody = result.andReturn().getResponse().getContentAsString();

assertEquals("[]", responseBody);
assertEquals("[]", responseBody);
// All criterias, fake birthCountryCode
result = mockMvc.perform(
get("/api/v2/ps/search")
result = mockMvc.perform(
get("/api/v2/ps/search")
.header("Accept", "application/json")
.param("lastName", "DUPONT")
.param("firstNames", "JIMMY BOB")
Expand All @@ -512,9 +512,9 @@ public void searchPs() throws Exception {
.param("birthplace","METZ")
)
.andExpect(status().is(200));
responseBody = result.andReturn().getResponse().getContentAsString();
responseBody = result.andReturn().getResponse().getContentAsString();

assertEquals("[]", responseBody);
assertEquals("[]", responseBody);
}

@Test
Expand Down Expand Up @@ -910,7 +910,7 @@ public void createNewPsNonPsi_noRppsPractice_fallbackOnLastName() throws Excepti

@Test
@DisplayName(value = "createNewPs: usualLastName fourni explicitement → respecté (pas de fallback)")
public void createNewPs_explicitUsualLastNameIsKept() throws Exception {
void createNewPs_explicitUsualLastNameIsKept() throws Exception {
String json = "{"
+ "\"idType\":\"8\","
+ "\"id\":\"00000000098\","
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void setUp(WebApplicationContext context, RestDocumentationContextProvide
@Test
@DisplayName(value = "should toggle PsRef, PSI_RPPS case")
@MongoDataSet(value = "/dataset/toggle_PSI_RPPS.json", cleanBefore = true, cleanAfter = true)
public void PSIandRPPStogglePsRef() throws Exception {
void PSIandRPPStogglePsRef() throws Exception {

Ps ps1 = psRepository.findByNationalId("550e8400-e29b-41d4-a716-446655440000");
Ps ps2 = psRepository.findByNationalId("81");
Expand Down Expand Up @@ -103,7 +103,7 @@ public void PSIandRPPStogglePsRef() throws Exception {
@Test
@DisplayName(value = "should toggle PsRef, PSI only case")
@MongoDataSet(value = "/dataset/toggle_PSI_only.json", cleanBefore = true, cleanAfter = true)
public void psiTogglePsRef() throws Exception {
void psiTogglePsRef() throws Exception {

Ps ps1 = psRepository.findByNationalId("855e8700-e29b-41d4-a716-44665544111");
Ps ps2 = psRepository.findByNationalId("3 110000056/000000001");
Expand Down Expand Up @@ -139,7 +139,7 @@ public void psiTogglePsRef() throws Exception {
@Test
@DisplayName(value = "should toggle PsRef, RPPS only case")
@MongoDataSet(value = "/dataset/toggle_RPPS_only.json", cleanBefore = true, cleanAfter = true)
public void rppsTogglePsRef() throws Exception {
void rppsTogglePsRef() throws Exception {

Ps ps1 = psRepository.findByNationalId("4380527788/8165");
Ps ps2 = psRepository.findByNationalId("811234567896");
Expand Down Expand Up @@ -170,7 +170,7 @@ public void rppsTogglePsRef() throws Exception {
@Test
@DisplayName(value = "should toggle PsRef, Adeli case")
@MongoDataSet(value = "/dataset/toggle_Adeli.json", cleanBefore = true, cleanAfter = true)
public void adeliTogglePsRef() throws Exception {
void adeliTogglePsRef() throws Exception {

Ps ps1 = psRepository.findByNationalId("000327008728");
Ps ps2 = psRepository.findByNationalId("538052778800034/8165");
Expand Down