Updated EPAS Certifications support

This commit is contained in:
Giancarlo Panichi 2021-12-02 18:44:30 +01:00
parent 9f3f0afe32
commit bbfba14014
17 changed files with 545 additions and 68 deletions

View File

@ -0,0 +1,77 @@
package it.cnr.isti.epasmed.epas.client;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import it.cnr.isti.epasmed.config.ApplicationProperties;
import it.cnr.isti.epasmed.epas.model.EPASCertifications;
@Component
public class EPASCertificationsClient {
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
@Qualifier("RestTemplateForSecondUser")
RestTemplate rt;
@Autowired
ApplicationProperties appProps;
public EPASCertifications getCertificationsByPersonId(String id, String year, String month) {
log.info("Retrieving EPASCertifications for person id: {}", id);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("id", id);
uriVariables.put("year", year);
uriVariables.put("month", month);
EPASCertifications epasCertifications = rt.getForObject(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/certifications/getMonthValidationStatusByPerson?id={id}&year={year}&month={month}",
EPASCertifications.class,uriVariables);
log.info("Retrieved EPASCertifications: {}", epasCertifications);
return epasCertifications;
}
public EPASCertifications getCertificationsByPersonFiscalCode(String fc, String year, String month) {
log.info("Retrieving EPASCertifications for person fiscalCode: {}", fc);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("fc", fc);
uriVariables.put("year", year);
uriVariables.put("month", month);
EPASCertifications epasCertifications = rt.getForObject(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/certifications/getMonthValidationStatusByPerson?fiscalCode={fc}&year={year}&month={month}",
EPASCertifications.class,uriVariables);
log.info("Retrieved EPASCertifications: {}", epasCertifications);
return epasCertifications;
}
public List<EPASCertifications> getCertificationsByOfficeCodeId(String id, String year, String month) {
log.info("Retrieving EPASCertifications for office codeId: {}", id);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("sedeId", id);
uriVariables.put("year", year);
uriVariables.put("month", month);
ResponseEntity<List<EPASCertifications>> responseEntity = rt.exchange(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/certifications/getMonthSituationByOffice?sedeId={sedeId}&year={year}&month={month}", HttpMethod.GET, null,
new ParameterizedTypeReference<List<EPASCertifications>>() {
}, uriVariables);
List<EPASCertifications> listEPASTimeCards = responseEntity.getBody();
log.info("Retrieved EPASCertifications: {}", listEPASTimeCards);
return listEPASTimeCards;
}
}

View File

@ -0,0 +1,57 @@
package it.cnr.isti.epasmed.epas.client;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import it.cnr.isti.epasmed.config.ApplicationProperties;
import it.cnr.isti.epasmed.epas.model.EPASValidates;
@Component
public class EPASValidatesClient {
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
@Qualifier("RestTemplateForSecondUser")
RestTemplate rt;
@Autowired
ApplicationProperties appProps;
public String isValidatesByPersonEmail(String email, String year, String month) {
log.info("Retrieving EPASValidates status for person email: {}", email);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("email", email);
uriVariables.put("year", year);
uriVariables.put("month", month);
String epasValidates = rt.getForObject(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/certifications/getMonthValidationStatusByPerson?email={email}&year={year}&month={month}",
String.class,uriVariables);
log.info("Retrieved EPASValidated status: {}", epasValidates);
return epasValidates;
}
public EPASValidates getValidatesByOfficeCodeId(String id, String year, String month) {
log.info("Retrieving EPASValidates for office codeId: {}", id);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("sedeId", id);
uriVariables.put("year", year);
uriVariables.put("month", month);
EPASValidates epasValidates = rt.getForObject(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/certifications/getMonthValidationStatusByOffice?sedeId={sedeId}&year={year}&month={month}",
EPASValidates.class,uriVariables);
log.info("Retrieved EPASValidates: {}", epasValidates);
return epasValidates;
}
}

View File

@ -16,7 +16,7 @@ import it.cnr.isti.epasmed.config.ApplicationProperties;
import it.cnr.isti.epasmed.epas.model.EPASWorkingTimeTypes;
@Component
public class EPASWorkinTipeTypesCient {
public class EPASWorkingTimeTypesClient {
private final Logger log = LoggerFactory.getLogger(getClass());
@ -29,19 +29,19 @@ public class EPASWorkinTipeTypesCient {
public EPASWorkingTimeTypes getById(String id) {
EPASWorkingTimeTypes epasWorkingTimeTypes = rt.getForObject(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/workingtimetypes/show?id={id}",
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/workingtimetypes/show/{id}",
EPASWorkingTimeTypes.class, id);
log.info("Retrieved Working Time Types : {}", epasWorkingTimeTypes);
log.info("Retrieved Working Time Type : {}", epasWorkingTimeTypes);
return epasWorkingTimeTypes;
}
public List<EPASWorkingTimeTypes> getList(String officeId) {
public List<EPASWorkingTimeTypes> getListByOfficeCodeId(String officeCodeId) {
ResponseEntity<List<EPASWorkingTimeTypes>> responseEntity = rt.exchange(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/workingtimetypes/list?id={officeId}", HttpMethod.GET,
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/workingtimetypes/list?codeId={officeCodeId}", HttpMethod.GET,
null, new ParameterizedTypeReference<List<EPASWorkingTimeTypes>>() {
}, officeId);
}, officeCodeId);
List<EPASWorkingTimeTypes> listEPASWorkingTimeTypes = responseEntity.getBody();
log.info("Retrieved Retrieved Working Time Types: {}", listEPASWorkingTimeTypes);
log.info("Retrieved Working Time Types: {}", listEPASWorkingTimeTypes);
return listEPASWorkingTimeTypes;
}

View File

@ -0,0 +1,26 @@
package it.cnr.isti.epasmed.epas.model;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EPASCertifications implements Serializable {
private static final long serialVersionUID = 1L;
private EPASAbsences[] absences;
private EPASCompetences[] competences;
private String fullName;
private EPASTickets[] mealTickets;
private String month;
private String number;
private String[] trainingHours;
private String year;
}

View File

@ -0,0 +1,19 @@
package it.cnr.isti.epasmed.epas.model;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EPASCompetences implements Serializable {
private static final long serialVersionUID = 1L;
private String code;
private String quantity;
}

View File

@ -0,0 +1,19 @@
package it.cnr.isti.epasmed.epas.model;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EPASTickets implements Serializable {
private static final long serialVersionUID = 1L;
private String code;
private String quantity;
}

View File

@ -0,0 +1,21 @@
package it.cnr.isti.epasmed.epas.model;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EPASValidates implements Serializable {
private static final long serialVersionUID = 1L;
Boolean allCertificationsValidated;
EPASPersons[] notValidatedPersons;
EPASPersons[] validatedPersons;
}

View File

@ -0,0 +1,30 @@
package it.cnr.isti.epasmed.epas.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import it.cnr.isti.epasmed.epas.client.EPASCertificationsClient;
import it.cnr.isti.epasmed.epas.model.EPASCertifications;
@Service
public class EPASCertificationsService {
@Autowired
EPASCertificationsClient epasCertificationsClient;
public EPASCertifications getCertificationsByPersonId(String id, String year, String month) {
return epasCertificationsClient.getCertificationsByPersonId(id, year, month);
}
public EPASCertifications getCertificationsByPersonFiscalCode(String fc, String year, String month) {
return epasCertificationsClient.getCertificationsByPersonFiscalCode(fc, year, month);
}
public List<EPASCertifications> getCertificationsByOfficeCodeId(String id, String year, String month) {
return epasCertificationsClient.getCertificationsByOfficeCodeId(id, year, month);
}
}

View File

@ -0,0 +1,24 @@
package it.cnr.isti.epasmed.epas.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import it.cnr.isti.epasmed.epas.client.EPASValidatesClient;
import it.cnr.isti.epasmed.epas.model.EPASValidates;
@Service
public class EPASValidatesService {
@Autowired
EPASValidatesClient epasValidatesClient;
public String isValidatesByPersonEmail(String email, String year, String month) {
return epasValidatesClient.isValidatesByPersonEmail(email, year, month);
}
public EPASValidates getValidatesByOfficeCodeId(String id, String year, String month) {
return epasValidatesClient.getValidatesByOfficeCodeId(id, year, month);
}
}

View File

@ -5,7 +5,7 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import it.cnr.isti.epasmed.epas.client.EPASWorkinTipeTypesCient;
import it.cnr.isti.epasmed.epas.client.EPASWorkingTimeTypesClient;
import it.cnr.isti.epasmed.epas.model.EPASWorkingTimeTypes;
@ -13,14 +13,14 @@ import it.cnr.isti.epasmed.epas.model.EPASWorkingTimeTypes;
public class EPASWorkingTimeTypesService {
@Autowired
EPASWorkinTipeTypesCient epasWorkingTimeTypesClient;
EPASWorkingTimeTypesClient epasWorkingTimeTypesClient;
public EPASWorkingTimeTypes getById(String id) {
return epasWorkingTimeTypesClient.getById(id);
}
public List<EPASWorkingTimeTypes> getList(String officeId) {
return epasWorkingTimeTypesClient.getList(officeId);
public List<EPASWorkingTimeTypes> getListByOfficeCodeId(String officeCodeId) {
return epasWorkingTimeTypesClient.getListByOfficeCodeId(officeCodeId);
}
}

View File

@ -13,6 +13,7 @@ import it.cnr.isti.epasmed.epas.dto.EPASPersonsDTO;
import it.cnr.isti.epasmed.epas.mapper.EPASPersonsMapper;
import it.cnr.isti.epasmed.epas.model.EPASPersons;
import it.cnr.isti.epasmed.epas.service.EPASPersonsService;
import it.cnr.isti.epasmed.epas.service.EPASTimeCardsService;
import it.cnr.isti.epasmed.service.TabsSIService;
import it.cnr.isti.epasmed.sistemainformativo.model.SIAnagrafico;
import it.cnr.isti.epasmed.sistemainformativo.model.SIEmail;
@ -46,9 +47,12 @@ public class SyncService {
@Autowired
EPASPersonsService epasPersonsService;
@Autowired
EPASPersonsMapper epasPersonsMapper;
@Autowired
EPASTimeCardsService epasTimeCardsService;
private boolean banagrafico;
private boolean bemail;
@ -76,7 +80,7 @@ public class SyncService {
List<TabsSI> tabsSI = tabsSIService.getAllTabsSI();
siMasterLogService.startFluxReads();
readData(tabsSI);
siMasterLogService.closeFluxReads(tabellelette());
siMasterLogService.closeFluxReads(readTabs());
}
@ -91,13 +95,13 @@ public class SyncService {
List<TabsSI> tabsSI = tabsSIService.getAllTabsSI();
Long idFlux=siMasterLogService.startFluxWrites();
writeData(idFlux,tabsSI);
siMasterLogService.closeFluxWrites(idFlux,tabellelette());
siMasterLogService.closeFluxWrites(idFlux,writeTabs());
}
private void readData(List<TabsSI> tabsSI) {
TabsSI posizioniTab = null;
TabsSI prorogheTab = null;
//TabsSI posizioniTab = null;
//TabsSI prorogheTab = null;
for (TabsSI tab : tabsSI) {
log.info("TabSI: {}", tab);
if (tab.getOperazioni() != null && !tab.getOperazioni().isEmpty()
@ -121,21 +125,21 @@ public class SyncService {
case "gruppo_pers":
syncGruppoPers(tab);
break;
case "posizioni":
posizioniTab = tab;
break;
case "proroghe":
prorogheTab = tab;
break;
//case "posizioni":
// posizioniTab = tab;
// break;
//case "proroghe":
// prorogheTab = tab;
// break;
default:
break;
}
}
}
if (posizioniTab != null || prorogheTab != null) {
syncPosizioniAndProroghe(posizioniTab, prorogheTab);
}
//if (posizioniTab != null || prorogheTab != null) {
// syncPosizioniAndProroghe(posizioniTab, prorogheTab);
//}
}
private void syncAnagrafico(TabsSI tab) {
@ -297,47 +301,51 @@ public class SyncService {
}
private void syncPosizioniAndProroghe(TabsSI posizioniTab, TabsSI prorogheTab) {
//private void syncPosizioniAndProroghe(TabsSI posizioniTab, TabsSI prorogheTab) {
//
//}
}
private String tabellelette() {
String tabelle_lette = "";
private String readTabs() {
String readTabs = "";
if (banagrafico) {
tabelle_lette = "anagrafico";
if (readTabs == null || readTabs.isEmpty()) {
readTabs = "anagrafico";
} else {
readTabs = readTabs + ",anagrafico";
}
}
if (bemail) {
if (tabelle_lette == null || tabelle_lette.isEmpty()) {
tabelle_lette = "mail";
if (readTabs == null || readTabs.isEmpty()) {
readTabs = "mail";
} else {
tabelle_lette = tabelle_lette + ",mail";
readTabs = readTabs + ",mail";
}
}
if (btelefoni) {
if (tabelle_lette == null || tabelle_lette.isEmpty()) {
tabelle_lette = "telefoni";
if (readTabs == null || readTabs.isEmpty()) {
readTabs = "telefoni";
} else {
tabelle_lette = tabelle_lette + ",telefoni";
readTabs = readTabs + ",telefoni";
}
}
if (bgruppi) {
if (tabelle_lette == null || tabelle_lette.isEmpty()) {
tabelle_lette = "gruppi";
if (readTabs == null || readTabs.isEmpty()) {
readTabs = "gruppi";
} else {
tabelle_lette = tabelle_lette + ",gruppi";
readTabs = readTabs + ",gruppi";
}
}
if (bgruppo_pers) {
if (tabelle_lette == null || tabelle_lette.isEmpty()) {
tabelle_lette = "gruppo_pers";
if (readTabs == null || readTabs.isEmpty()) {
readTabs = "gruppo_pers";
} else {
tabelle_lette = tabelle_lette + ",gruppo_pers";
readTabs = readTabs + ",gruppo_pers";
}
}
if (bposizioni) {
/*if (bposizioni) {
if (tabelle_lette == null || tabelle_lette.isEmpty()) {
tabelle_lette = "posizioni";
} else {
@ -351,10 +359,59 @@ public class SyncService {
} else {
tabelle_lette = tabelle_lette + ",proroghe";
}
}
}*/
return tabelle_lette;
return readTabs;
}
private String writeTabs() {
String writeTabs = "";
if (borario) {
if (writeTabs == null || writeTabs.isEmpty()) {
writeTabs = "epas_orario";
} else {
writeTabs = writeTabs + ",epas_orario";
}
}
if (bcartellini) {
if (writeTabs == null || writeTabs.isEmpty()) {
writeTabs = "epas_cartellini";
} else {
writeTabs = writeTabs + ",epas_cartellini";
}
}
if (bcartellini_rendicontazioni) {
if (writeTabs == null || writeTabs.isEmpty()) {
writeTabs = "epas_cartellini_rendicontazioni";
} else {
writeTabs = writeTabs + "epas_cartellini_rendicontazioni";
}
}
if (bpers_orario) {
if (writeTabs == null || writeTabs.isEmpty()) {
writeTabs = "epas_pers_orario";
} else {
writeTabs = writeTabs + "epas_pers_orario";
}
}
if (blavoro_fuori_sede) {
if (writeTabs == null || writeTabs.isEmpty()) {
writeTabs = "epas_lavoro_fuori_sede";
} else {
writeTabs = writeTabs + "epas_lavoro_fuori_sede";
}
}
if (baspettative) {
if (writeTabs == null || writeTabs.isEmpty()) {
writeTabs = "epas_aspettative";
} else {
writeTabs = writeTabs + "epas_aspettative";
}
}
return writeTabs;
}
private void writeData(Long idFlux, List<TabsSI> tabsSI) {
@ -362,7 +419,7 @@ public class SyncService {
TabsSI cartelliniTab = null;
/*
for (TabsSI tab : tabsSI) {
log.info("TabSI: {}", tab);
if (tab.getOperazioni() != null && !tab.getOperazioni().isEmpty()
@ -371,18 +428,14 @@ public class SyncService {
continue;
}
/*
switch (tab.getNome()) {
case "orario":
syncOrario(idFlux,tab);
break;
case "pers_orario":
syncOrario(idFlux,tab);
syncPersOrario(idFlux,tab);
break;
case "cartellini":
syncCartellini(idFlux,tab);
break;
case "cartellini_rendicontazioni":
syncCartelliniRendicontazioni(idFlux,tab);
@ -397,9 +450,10 @@ public class SyncService {
default:
break;
}
*/
}
}
}*/
}
}

View File

@ -8,13 +8,11 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.github.jhipster.web.util.ResponseUtil;
import it.cnr.isti.epasmed.epas.model.EPASPersons;
import it.cnr.isti.epasmed.epas.model.EPASTimeCards;
import it.cnr.isti.epasmed.epas.service.EPASTimeCardsService;

View File

@ -0,0 +1,72 @@
package it.cnr.isti.epasmed.web.rest.epas;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.github.jhipster.web.util.ResponseUtil;
import it.cnr.isti.epasmed.epas.model.EPASValidates;
import it.cnr.isti.epasmed.epas.service.EPASValidatesService;
@RestController
@RequestMapping("/api/epas")
public class EPASValidatesResource {
private final Logger log = LoggerFactory.getLogger(getClass());
@Value("${jhipster.clientApp.name}")
private String applicationName;
private final EPASValidatesService epasValidatesService;
public EPASValidatesResource(EPASValidatesService epasValidatesService) {
this.epasValidatesService = epasValidatesService;
}
/**
* {@code GET /validates/is} : return true if is validates the certification.
*
* @param email the email of the person.
* @param year the year.
* @param month the month.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
* the Boolean value, or with status {@code 404 (Not Found)}.
*/
@GetMapping("/validates/is")
public ResponseEntity<String> isValidatesByPersonEmail(@RequestParam("email") String email,
@RequestParam("year") String year, @RequestParam("month") String month) {
log.info("REST request to ePAS if is Validates by Person Email: email={}, year={}, month={}", email,year,month);
String validates = epasValidatesService.isValidatesByPersonEmail(email, year, month);
log.info("Retrieved Validates: {}", validates);
return ResponseUtil.wrapOrNotFound(Optional.of(validates));
}
/**
* {@code GET /validates} : get the list of certification validates.
*
* @param officeCodeId the id of the office.
* @param year the year.
* @param month the month.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
* the EPAS Validates, or with status {@code 404 (Not Found)}.
*/
@GetMapping("/validates")
public ResponseEntity<EPASValidates> getEPASValidatesByOfficeCodeId(@RequestParam("officeCodeId") String officeCodeId,
@RequestParam("year") String year, @RequestParam("month") String month) {
log.info("REST request to get ePAS TimeCard list: officeCodeId={}, year={}, month={}", officeCodeId,year,month);
EPASValidates epasValidates = epasValidatesService.getValidatesByOfficeCodeId(officeCodeId, year, month);
return ResponseUtil.wrapOrNotFound(Optional.of(epasValidates));
}
}

View File

@ -52,14 +52,14 @@ public class EPASWorkingTimeTypesResource {
/**
* {@code GET /workingtimetypes} : get the workingtimetypes list.
*
* @param officeId the office id.
* @param officeCodeId the office codeId.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
* the list of EPASWorkingTimeTypes, or with status {@code 404 (Not Found)}.
*/
@GetMapping("/workingtimetypes")
public ResponseEntity<List<EPASWorkingTimeTypes>> getEPASWorkingTimeTypes(@RequestParam("officeId") String id) {
log.info("REST request to get ePAS WorkingTimeTypes list for Office: {}", id);
List<EPASWorkingTimeTypes> epasWorkingTimeTypesList = epasWorkingTimeTypesService.getList(id);
public ResponseEntity<List<EPASWorkingTimeTypes>> getEPASWorkingTimeTypes(@RequestParam("officeCodeId") String officeCodeId) {
log.info("REST request to get ePAS WorkingTimeTypes list for Office: {}", officeCodeId);
List<EPASWorkingTimeTypes> epasWorkingTimeTypesList = epasWorkingTimeTypesService.getListByOfficeCodeId(officeCodeId);
return ResponseUtil.wrapOrNotFound(Optional.of(epasWorkingTimeTypesList));
}

View File

@ -19,7 +19,7 @@ import it.cnr.isti.epasmed.EpasmedApp;
import it.cnr.isti.epasmed.security.AuthoritiesConstants;
/**
* Integration tests for the {@link EPASPersonsResource} REST controller.
* Integration tests for the {@link EPASTimeCardsResource} REST controller.
*/
@AutoConfigureMockMvc
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
@ -29,9 +29,9 @@ public class EPASTimeCardsResourceIT {
private final Logger log = LoggerFactory.getLogger(getClass());
private static final String OFFICE_DEFAULT_ID = "1";
private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa";
private static final String OFFICE_DEFAULT_CODE = "074000";
//private static final String OFFICE_DEFAULT_ID = "1";
//private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa";
//private static final String OFFICE_DEFAULT_CODE = "074000";
private static final String OFFICE_DEFAULT_CODEID = "225200";

View File

@ -0,0 +1,80 @@
package it.cnr.isti.epasmed.web.rest.epas;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.context.junit.jupiter.EnabledIf;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import it.cnr.isti.epasmed.EpasmedApp;
import it.cnr.isti.epasmed.epas.model.EPASValidates;
import it.cnr.isti.epasmed.security.AuthoritiesConstants;
/**
* Integration tests for the {@link EPASValidatesResource} REST
* controller.
*/
@AutoConfigureMockMvc
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
@SpringBootTest(classes = EpasmedApp.class)
@EnabledIf("true")
public class EPASValidatesResourceIT {
private final Logger log = LoggerFactory.getLogger(getClass());
//private static final String OFFICE_DEFAULT_ID = "1";
// private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa";
// private static final String OFFICE_DEFAULT_CODE = "074000";
private static final String OFFICE_DEFAULT_CODEID = "225200";
@Autowired
private MockMvc restEPASValidatesMockMvc;
@Autowired
private Environment environment;
@BeforeEach
public void initTest() {
for (String profileName : environment.getActiveProfiles()) {
log.info("Currently active profile - " + profileName);
}
}
@Test
public void isValidatesByPersonEmail() throws Exception {
MvcResult result = restEPASValidatesMockMvc.perform(get("/api/epas/validates/is?email=giancarlo.panichi@cnr.it&"
+ "year=2021&month=11")).andExpect(status().isOk()).andReturn();
ObjectMapper mapper = new ObjectMapper();
String validated = mapper.readValue(result.getResponse().getContentAsString(),
new TypeReference<String>() {
});
log.info("EPASValidates is: {}", validated);
}
@Test
public void getEPASValidatesByOfficeCodeId() throws Exception {
MvcResult result = restEPASValidatesMockMvc.perform(get("/api/epas/validates?officeCodeId="+OFFICE_DEFAULT_CODEID+"&"
+ "year=2021&month=10")).andExpect(status().isOk()).andReturn();
ObjectMapper mapper = new ObjectMapper();
EPASValidates validates = mapper.readValue(result.getResponse().getContentAsString(),
new TypeReference<EPASValidates>() {
});
log.info("EPASValidates: {}", validates);
}
}

View File

@ -33,15 +33,15 @@ import it.cnr.isti.epasmed.security.AuthoritiesConstants;
@AutoConfigureMockMvc
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
@SpringBootTest(classes = EpasmedApp.class)
@EnabledIf("false")
@EnabledIf("true")
public class EPASWorkingTimeTypesResourceIT {
private final Logger log = LoggerFactory.getLogger(getClass());
private static final String OFFICE_DEFAULT_ID = "1";
//private static final String OFFICE_DEFAULT_ID = "1";
// private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa";
// private static final String OFFICE_DEFAULT_CODE = "074000";
// private static final String OFFICE_DEFAULT_CODEID = "225200";
private static final String OFFICE_DEFAULT_CODEID = "225200";
@Autowired
private MockMvc restEPASWorkingTimeTypesMockMvc;
@ -73,7 +73,7 @@ public class EPASWorkingTimeTypesResourceIT {
@Test
public void getWorkingTimeTypesList() throws Exception {
MvcResult result = restEPASWorkingTimeTypesMockMvc
.perform(get("/api/epas/workingtimetypes?officeId=" + OFFICE_DEFAULT_ID)).andExpect(status().isOk())
.perform(get("/api/epas/workingtimetypes?officeCodeId=" + OFFICE_DEFAULT_CODEID)).andExpect(status().isOk())
.andReturn();
ObjectMapper mapper = new ObjectMapper();