diff --git a/src/test/java/it/cnr/isti/epasmed/web/rest/epas/EPASPersonsResourceIT.java b/src/test/java/it/cnr/isti/epasmed/web/rest/epas/EPASPersonsResourceIT.java index 8cdbfe8..af4957c 100755 --- a/src/test/java/it/cnr/isti/epasmed/web/rest/epas/EPASPersonsResourceIT.java +++ b/src/test/java/it/cnr/isti/epasmed/web/rest/epas/EPASPersonsResourceIT.java @@ -52,7 +52,6 @@ public class EPASPersonsResourceIT { private final Logger log = LoggerFactory.getLogger(getClass()); - private static final String PERSON_DEFAULT_ID = "11694"; private static final String PERSON_DEFAULT_NAME = "nometest1"; private static final String PERSON_DEFAULT_SURNAME = "cognometest1"; @@ -113,14 +112,15 @@ public class EPASPersonsResourceIT { @Test public void getPersonById() throws Exception { - restEPASPersonsMockMvc.perform(get("/api/epas/persons/"+PERSON_DEFAULT_ID)).andExpect(status().isOk()); + restEPASPersonsMockMvc.perform(get("/api/epas/persons/" + PERSON_DEFAULT_ID)).andExpect(status().isOk()); } - + @Test public void getPersonByFiscalCode() throws Exception { - restEPASPersonsMockMvc.perform(get("/api/epas/persons/show?fiscalCode="+PERSON_DEFAULT_FISCAL_CODE)).andExpect(status().isOk()); + restEPASPersonsMockMvc.perform(get("/api/epas/persons/show?fiscalCode=" + PERSON_DEFAULT_FISCAL_CODE)) + .andExpect(status().isOk()); } - + @Test public void getPersonList() throws Exception { restEPASPersonsMockMvc.perform(get("/api/epas/persons?officeId=" + OfficeConstants.ISTI_OFFICE_ID)) @@ -136,6 +136,43 @@ public class EPASPersonsResourceIT { } + @Test + public void checkFiscalCode() { + List epasPersons = null; + try { + MvcResult result = restEPASPersonsMockMvc + .perform(get("/api/epas/persons?officeId=" + OfficeConstants.ISTI_OFFICE_ID)) + .andExpect(status().isOk()).andReturn(); + + ObjectMapper mapper = new ObjectMapper(); + epasPersons = mapper.readValue(result.getResponse().getContentAsString(), + new TypeReference>() { + }); + + } catch (Exception e) { + log.error(e.getLocalizedMessage(), e); + return; + } + + if (epasPersons != null && !epasPersons.isEmpty()) { + log.info("EPAS Persons loaded: {}", epasPersons.size()); + } else { + log.error("EPAS Persons not loaded"); + } + + boolean e=false; + for(EPASPersons p: epasPersons) { + if(p.getFiscalCode()==null||p.getFiscalCode().isEmpty()) { + log.error("Invalid Fiscal Code: ePASPerson[{}, {}, {}]", p.getSurname(),p.getName(),p.getFiscalCode()); + e=true; + } + } + if(!e){ + log.info("All persons have a Fiscal Code"); + } + log.info("Check Fiscal Code End."); + } + @Test public void istiUpdatedPerson() { String userDirectory = System.getProperty("user.dir"); @@ -152,7 +189,8 @@ public class EPASPersonsResourceIT { List epasPersons = null; try { - MvcResult result = restEPASPersonsMockMvc.perform(get("/api/epas/persons?officeId=" + OfficeConstants.ISTI_OFFICE_ID)) + MvcResult result = restEPASPersonsMockMvc + .perform(get("/api/epas/persons?officeId=" + OfficeConstants.ISTI_OFFICE_ID)) .andExpect(status().isOk()).andReturn(); ObjectMapper mapper = new ObjectMapper();