From 9ad99bd05fa31745192c6b40afaba55cdcdf13c1 Mon Sep 17 00:00:00 2001 From: Simone Bierti Date: Wed, 10 Dec 2025 17:19:16 +0100 Subject: [PATCH] generazione applicazione e entita --- .jhipster/AuditLog.json | 49 + .jhipster/Conferma.json | 39 + .jhipster/Disponibilita.json | 57 ++ .jhipster/Liberatoria.json | 32 + .jhipster/Messaggio.json | 33 + .jhipster/ModelloLiberatoria.json | 41 + .jhipster/Notifica.json | 52 + .jhipster/Prenotazione.json | 62 ++ .jhipster/Struttura.json | 62 ++ .jhipster/UtenteApp.json | 86 ++ .yo-rc.json | 14 +- jhipster-jdl.jdl | 75 +- .../artegna/config/CacheConfiguration.java | 13 + .../sw/pa/comune/artegna/domain/AuditLog.java | 193 ++++ .../sw/pa/comune/artegna/domain/Conferma.java | 145 +++ .../comune/artegna/domain/Disponibilita.java | 228 +++++ .../pa/comune/artegna/domain/Liberatoria.java | 121 +++ .../pa/comune/artegna/domain/Messaggio.java | 138 +++ .../artegna/domain/ModelloLiberatoria.java | 190 ++++ .../sw/pa/comune/artegna/domain/Notifica.java | 210 ++++ .../comune/artegna/domain/Prenotazione.java | 226 ++++ .../pa/comune/artegna/domain/Struttura.java | 280 +++++ .../pa/comune/artegna/domain/UtenteApp.java | 369 +++++++ .../domain/enumeration/AzioneAudit.java | 12 + .../domain/enumeration/GiornoSettimana.java | 14 + .../artegna/domain/enumeration/Ruolo.java | 10 + .../domain/enumeration/StatoPrenotazione.java | 11 + .../enumeration/TipoCanaleNotifica.java | 10 + .../domain/enumeration/TipoConferma.java | 9 + .../domain/enumeration/TipoDisponibilita.java | 9 + .../domain/enumeration/TipoEntita.java | 9 + .../enumeration/TipoEventoNotifica.java | 12 + .../domain/enumeration/package-info.java | 4 + .../repository/AuditLogRepository.java | 40 + .../repository/ConfermaRepository.java | 40 + .../repository/DisponibilitaRepository.java | 40 + .../repository/LiberatoriaRepository.java | 40 + .../repository/MessaggioRepository.java | 40 + .../ModelloLiberatoriaRepository.java | 12 + .../repository/NotificaRepository.java | 12 + .../repository/PrenotazioneRepository.java | 42 + .../repository/StrutturaRepository.java | 12 + .../repository/UtenteAppRepository.java | 12 + .../artegna/service/AuditLogQueryService.java | 88 ++ .../artegna/service/AuditLogService.java | 58 ++ .../artegna/service/ConfermaQueryService.java | 89 ++ .../artegna/service/ConfermaService.java | 66 ++ .../artegna/service/DisponibilitaService.java | 66 ++ .../artegna/service/LiberatoriaService.java | 66 ++ .../artegna/service/MessaggioService.java | 66 ++ .../service/ModelloLiberatoriaService.java | 56 + .../artegna/service/NotificaQueryService.java | 89 ++ .../artegna/service/NotificaService.java | 48 + .../service/PrenotazioneQueryService.java | 90 ++ .../artegna/service/PrenotazioneService.java | 58 ++ .../service/StrutturaQueryService.java | 95 ++ .../artegna/service/StrutturaService.java | 48 + .../artegna/service/UtenteAppService.java | 56 + .../service/criteria/AuditLogCriteria.java | 313 ++++++ .../service/criteria/ConfermaCriteria.java | 223 ++++ .../service/criteria/NotificaCriteria.java | 337 ++++++ .../criteria/PrenotazioneCriteria.java | 355 +++++++ .../service/criteria/StrutturaCriteria.java | 362 +++++++ .../service/criteria/package-info.java | 4 + .../artegna/service/dto/AuditLogDTO.java | 130 +++ .../artegna/service/dto/ConfermaDTO.java | 84 ++ .../artegna/service/dto/DisponibilitaDTO.java | 153 +++ .../artegna/service/dto/LiberatoriaDTO.java | 84 ++ .../artegna/service/dto/MessaggioDTO.java | 95 ++ .../service/dto/ModelloLiberatoriaDTO.java | 129 +++ .../artegna/service/dto/NotificaDTO.java | 141 +++ .../artegna/service/dto/PrenotazioneDTO.java | 151 +++ .../artegna/service/dto/StrutturaDTO.java | 139 +++ .../artegna/service/dto/UtenteAppDTO.java | 221 ++++ .../service/impl/AuditLogServiceImpl.java | 81 ++ .../service/impl/ConfermaServiceImpl.java | 98 ++ .../impl/DisponibilitaServiceImpl.java | 88 ++ .../service/impl/LiberatoriaServiceImpl.java | 91 ++ .../service/impl/MessaggioServiceImpl.java | 91 ++ .../impl/ModelloLiberatoriaServiceImpl.java | 92 ++ .../service/impl/NotificaServiceImpl.java | 75 ++ .../service/impl/PrenotazioneServiceImpl.java | 81 ++ .../service/impl/StrutturaServiceImpl.java | 75 ++ .../service/impl/UtenteAppServiceImpl.java | 85 ++ .../artegna/service/impl/package-info.java | 4 + .../service/mapper/AuditLogMapper.java | 22 + .../service/mapper/ConfermaMapper.java | 22 + .../service/mapper/DisponibilitaMapper.java | 22 + .../artegna/service/mapper/EntityMapper.java | 28 + .../service/mapper/LiberatoriaMapper.java | 30 + .../service/mapper/MessaggioMapper.java | 22 + .../mapper/ModelloLiberatoriaMapper.java | 21 + .../service/mapper/NotificaMapper.java | 21 + .../service/mapper/PrenotazioneMapper.java | 39 + .../service/mapper/StrutturaMapper.java | 11 + .../service/mapper/UtenteAppMapper.java | 11 + .../artegna/web/rest/AuditLogResource.java | 203 ++++ .../artegna/web/rest/ConfermaResource.java | 203 ++++ .../web/rest/DisponibilitaResource.java | 186 ++++ .../artegna/web/rest/LiberatoriaResource.java | 172 ++++ .../artegna/web/rest/MessaggioResource.java | 172 ++++ .../web/rest/ModelloLiberatoriaResource.java | 173 ++++ .../artegna/web/rest/NotificaResource.java | 203 ++++ .../web/rest/PrenotazioneResource.java | 203 ++++ .../artegna/web/rest/StrutturaResource.java | 203 ++++ .../artegna/web/rest/UtenteAppResource.java | 171 ++++ .../20251210161121_added_entity_AuditLog.xml | 69 ++ ...1121_added_entity_constraints_AuditLog.xml | 20 + ...51210161122_added_entity_Disponibilita.xml | 78 ++ ...added_entity_constraints_Disponibilita.xml | 20 + .../20251210161123_added_entity_Notifica.xml | 74 ++ ...1123_added_entity_constraints_Notifica.xml | 20 + ...251210161124_added_entity_Prenotazione.xml | 76 ++ ..._added_entity_constraints_Prenotazione.xml | 34 + .../20251210161125_added_entity_Conferma.xml | 52 + ...1125_added_entity_constraints_Conferma.xml | 20 + .../20251210161126_added_entity_Struttura.xml | 75 ++ .../20251210161127_added_entity_UtenteApp.xml | 101 ++ ...0251210161128_added_entity_Liberatoria.xml | 52 + ...8_added_entity_constraints_Liberatoria.xml | 27 + ...161129_added_entity_ModelloLiberatoria.xml | 70 ++ ..._entity_constraints_ModelloLiberatoria.xml | 20 + .../20251210161130_added_entity_Messaggio.xml | 58 ++ ...130_added_entity_constraints_Messaggio.xml | 20 + .../config/liquibase/fake-data/audit_log.csv | 11 + .../liquibase/fake-data/blob/hipster.png | Bin 0 -> 7564 bytes .../config/liquibase/fake-data/conferma.csv | 11 + .../liquibase/fake-data/disponibilita.csv | 11 + .../liquibase/fake-data/liberatoria.csv | 11 + .../config/liquibase/fake-data/messaggio.csv | 11 + .../fake-data/modello_liberatoria.csv | 11 + .../config/liquibase/fake-data/notifica.csv | 11 + .../liquibase/fake-data/prenotazione.csv | 11 + .../config/liquibase/fake-data/struttura.csv | 11 + .../config/liquibase/fake-data/utente_app.csv | 11 + .../resources/config/liquibase/master.xml | 18 + .../audit-log-details.component.spec.ts | 91 ++ .../audit-log/audit-log-details.component.ts | 46 + .../entities/audit-log/audit-log-details.vue | 69 ++ .../audit-log-update.component.spec.ts | 161 +++ .../audit-log/audit-log-update.component.ts | 122 +++ .../entities/audit-log/audit-log-update.vue | 136 +++ .../audit-log/audit-log.component.spec.ts | 166 +++ .../entities/audit-log/audit-log.component.ts | 137 +++ .../audit-log/audit-log.service.spec.ts | 186 ++++ .../entities/audit-log/audit-log.service.ts | 86 ++ .../app/entities/audit-log/audit-log.vue | 151 +++ .../conferma-details.component.spec.ts | 91 ++ .../conferma/conferma-details.component.ts | 43 + .../entities/conferma/conferma-details.vue | 45 + .../conferma-update.component.spec.ts | 138 +++ .../conferma/conferma-update.component.ts | 114 +++ .../app/entities/conferma/conferma-update.vue | 83 ++ .../conferma/conferma.component.spec.ts | 166 +++ .../entities/conferma/conferma.component.ts | 134 +++ .../conferma/conferma.service.spec.ts | 160 +++ .../app/entities/conferma/conferma.service.ts | 86 ++ .../webapp/app/entities/conferma/conferma.vue | 131 +++ .../disponibilita-details.component.spec.ts | 91 ++ .../disponibilita-details.component.ts | 46 + .../disponibilita/disponibilita-details.vue | 86 ++ .../disponibilita-update.component.spec.ts | 161 +++ .../disponibilita-update.component.ts | 125 +++ .../disponibilita/disponibilita-update.vue | 187 ++++ .../disponibilita.component.spec.ts | 158 +++ .../disponibilita/disponibilita.component.ts | 164 +++ .../disponibilita.service.spec.ts | 202 ++++ .../disponibilita/disponibilita.service.ts | 86 ++ .../entities/disponibilita/disponibilita.vue | 158 +++ .../webapp/app/entities/entities-menu.vue | 40 + .../webapp/app/entities/entities.component.ts | 21 + .../liberatoria-details.component.spec.ts | 91 ++ .../liberatoria-details.component.ts | 46 + .../liberatoria/liberatoria-details.vue | 54 + .../liberatoria-update.component.spec.ts | 166 +++ .../liberatoria-update.component.ts | 124 +++ .../liberatoria/liberatoria-update.vue | 83 ++ .../liberatoria/liberatoria.component.spec.ts | 102 ++ .../liberatoria/liberatoria.component.ts | 81 ++ .../liberatoria/liberatoria.service.spec.ts | 164 +++ .../liberatoria/liberatoria.service.ts | 85 ++ .../app/entities/liberatoria/liberatoria.vue | 128 +++ .../messaggio-details.component.spec.ts | 91 ++ .../messaggio/messaggio-details.component.ts | 46 + .../entities/messaggio/messaggio-details.vue | 56 + .../messaggio-update.component.spec.ts | 161 +++ .../messaggio/messaggio-update.component.ts | 114 +++ .../entities/messaggio/messaggio-update.vue | 87 ++ .../messaggio/messaggio.component.spec.ts | 102 ++ .../entities/messaggio/messaggio.component.ts | 81 ++ .../messaggio/messaggio.service.spec.ts | 183 ++++ .../entities/messaggio/messaggio.service.ts | 85 ++ .../app/entities/messaggio/messaggio.vue | 123 +++ ...ello-liberatoria-details.component.spec.ts | 91 ++ .../modello-liberatoria-details.component.ts | 51 + .../modello-liberatoria-details.vue | 68 ++ ...dello-liberatoria-update.component.spec.ts | 161 +++ .../modello-liberatoria-update.component.ts | 120 +++ .../modello-liberatoria-update.vue | 152 +++ .../modello-liberatoria.component.spec.ts | 102 ++ .../modello-liberatoria.component.ts | 84 ++ .../modello-liberatoria.service.spec.ts | 193 ++++ .../modello-liberatoria.service.ts | 85 ++ .../modello-liberatoria.vue | 135 +++ .../notifica-details.component.spec.ts | 91 ++ .../notifica/notifica-details.component.ts | 46 + .../entities/notifica/notifica-details.vue | 75 ++ .../notifica-update.component.spec.ts | 161 +++ .../notifica/notifica-update.component.ts | 124 +++ .../app/entities/notifica/notifica-update.vue | 151 +++ .../notifica/notifica.component.spec.ts | 166 +++ .../entities/notifica/notifica.component.ts | 137 +++ .../notifica/notifica.service.spec.ts | 197 ++++ .../app/entities/notifica/notifica.service.ts | 86 ++ .../webapp/app/entities/notifica/notifica.vue | 156 +++ .../prenotazione-details.component.spec.ts | 91 ++ .../prenotazione-details.component.ts | 46 + .../prenotazione/prenotazione-details.vue | 94 ++ .../prenotazione-update.component.spec.ts | 171 ++++ .../prenotazione-update.component.ts | 146 +++ .../prenotazione/prenotazione-update.vue | 159 +++ .../prenotazione.component.spec.ts | 166 +++ .../prenotazione/prenotazione.component.ts | 137 +++ .../prenotazione/prenotazione.service.spec.ts | 195 ++++ .../prenotazione/prenotazione.service.ts | 86 ++ .../entities/prenotazione/prenotazione.vue | 177 ++++ .../struttura-details.component.spec.ts | 91 ++ .../struttura/struttura-details.component.ts | 46 + .../entities/struttura/struttura-details.vue | 76 ++ .../struttura-update.component.spec.ts | 156 +++ .../struttura/struttura-update.component.ts | 107 ++ .../entities/struttura/struttura-update.vue | 134 +++ .../struttura/struttura.component.spec.ts | 166 +++ .../entities/struttura/struttura.component.ts | 137 +++ .../struttura/struttura.service.spec.ts | 193 ++++ .../entities/struttura/struttura.service.ts | 86 ++ .../app/entities/struttura/struttura.vue | 150 +++ .../utente-app-details.component.spec.ts | 91 ++ .../utente-app-details.component.ts | 43 + .../utente-app/utente-app-details.vue | 118 +++ .../utente-app-update.component.spec.ts | 133 +++ .../utente-app/utente-app-update.component.ts | 121 +++ .../entities/utente-app/utente-app-update.vue | 231 +++++ .../utente-app/utente-app.component.spec.ts | 102 ++ .../utente-app/utente-app.component.ts | 78 ++ .../utente-app/utente-app.service.spec.ts | 223 ++++ .../entities/utente-app/utente-app.service.ts | 85 ++ .../app/entities/utente-app/utente-app.vue | 161 +++ src/main/webapp/app/router/entities.ts | 281 +++++ .../app/shared/model/audit-log.model.ts | 27 + .../webapp/app/shared/model/conferma.model.ts | 18 + .../app/shared/model/disponibilita.model.ts | 30 + .../model/enumerations/azione-audit.model.ts | 11 + .../enumerations/giorno-settimana.model.ts | 15 + .../shared/model/enumerations/ruolo.model.ts | 7 + .../enumerations/stato-prenotazione.model.ts | 9 + .../tipo-canale-notifica.model.ts | 7 + .../model/enumerations/tipo-conferma.model.ts | 5 + .../enumerations/tipo-disponibilita.model.ts | 5 + .../model/enumerations/tipo-entita.model.ts | 5 + .../tipo-evento-notifica.model.ts | 11 + .../app/shared/model/liberatoria.model.ts | 18 + .../app/shared/model/messaggio.model.ts | 19 + .../shared/model/modello-liberatoria.model.ts | 25 + .../webapp/app/shared/model/notifica.model.ts | 30 + .../app/shared/model/prenotazione.model.ts | 32 + .../app/shared/model/struttura.model.ts | 27 + .../app/shared/model/utente-app.model.ts | 42 + src/main/webapp/i18n/it/auditLog.json | 30 + src/main/webapp/i18n/it/azioneAudit.json | 12 + src/main/webapp/i18n/it/conferma.json | 27 + src/main/webapp/i18n/it/disponibilita.json | 32 + src/main/webapp/i18n/it/giornoSettimana.json | 14 + src/main/webapp/i18n/it/global.json | 12 +- src/main/webapp/i18n/it/liberatoria.json | 26 + src/main/webapp/i18n/it/messaggio.json | 27 + .../webapp/i18n/it/modelloLiberatoria.json | 29 + src/main/webapp/i18n/it/notifica.json | 31 + src/main/webapp/i18n/it/prenotazione.json | 32 + src/main/webapp/i18n/it/ruolo.json | 10 + .../webapp/i18n/it/statoPrenotazione.json | 11 + src/main/webapp/i18n/it/struttura.json | 33 + .../webapp/i18n/it/tipoCanaleNotifica.json | 10 + src/main/webapp/i18n/it/tipoConferma.json | 9 + .../webapp/i18n/it/tipoDisponibilita.json | 9 + src/main/webapp/i18n/it/tipoEntita.json | 9 + .../webapp/i18n/it/tipoEventoNotifica.json | 12 + src/main/webapp/i18n/it/utenteApp.json | 39 + .../artegna/domain/AuditLogAsserts.java | 69 ++ .../comune/artegna/domain/AuditLogTest.java | 37 + .../artegna/domain/AuditLogTestSamples.java | 27 + .../artegna/domain/ConfermaAsserts.java | 65 ++ .../comune/artegna/domain/ConfermaTest.java | 52 + .../artegna/domain/ConfermaTestSamples.java | 23 + .../artegna/domain/DisponibilitaAsserts.java | 71 ++ .../artegna/domain/DisponibilitaTest.java | 37 + .../domain/DisponibilitaTestSamples.java | 27 + .../artegna/domain/LiberatoriaAsserts.java | 67 ++ .../artegna/domain/LiberatoriaTest.java | 50 + .../domain/LiberatoriaTestSamples.java | 22 + .../artegna/domain/MessaggioAsserts.java | 66 ++ .../comune/artegna/domain/MessaggioTest.java | 37 + .../artegna/domain/MessaggioTestSamples.java | 23 + .../domain/ModelloLiberatoriaAsserts.java | 71 ++ .../domain/ModelloLiberatoriaTest.java | 37 + .../domain/ModelloLiberatoriaTestSamples.java | 26 + .../artegna/domain/NotificaAsserts.java | 70 ++ .../comune/artegna/domain/NotificaTest.java | 37 + .../artegna/domain/NotificaTestSamples.java | 23 + .../artegna/domain/PrenotazioneAsserts.java | 73 ++ .../artegna/domain/PrenotazioneTest.java | 63 ++ .../domain/PrenotazioneTestSamples.java | 29 + .../artegna/domain/StrutturaAsserts.java | 69 ++ .../comune/artegna/domain/StrutturaTest.java | 72 ++ .../artegna/domain/StrutturaTestSamples.java | 31 + .../artegna/domain/UtenteAppAsserts.java | 76 ++ .../comune/artegna/domain/UtenteAppTest.java | 49 + .../artegna/domain/UtenteAppTestSamples.java | 65 ++ .../criteria/AuditLogCriteriaTest.java | 120 +++ .../criteria/ConfermaCriteriaTest.java | 111 ++ .../criteria/NotificaCriteriaTest.java | 123 +++ .../criteria/PrenotazioneCriteriaTest.java | 129 +++ .../criteria/StrutturaCriteriaTest.java | 129 +++ .../artegna/service/dto/AuditLogDTOTest.java | 24 + .../artegna/service/dto/ConfermaDTOTest.java | 24 + .../service/dto/DisponibilitaDTOTest.java | 24 + .../service/dto/LiberatoriaDTOTest.java | 24 + .../artegna/service/dto/MessaggioDTOTest.java | 24 + .../dto/ModelloLiberatoriaDTOTest.java | 24 + .../artegna/service/dto/NotificaDTOTest.java | 24 + .../service/dto/PrenotazioneDTOTest.java | 24 + .../artegna/service/dto/StrutturaDTOTest.java | 24 + .../artegna/service/dto/UtenteAppDTOTest.java | 24 + .../service/mapper/AuditLogMapperTest.java | 24 + .../service/mapper/ConfermaMapperTest.java | 24 + .../mapper/DisponibilitaMapperTest.java | 24 + .../service/mapper/LiberatoriaMapperTest.java | 24 + .../service/mapper/MessaggioMapperTest.java | 24 + .../mapper/ModelloLiberatoriaMapperTest.java | 24 + .../service/mapper/NotificaMapperTest.java | 24 + .../mapper/PrenotazioneMapperTest.java | 24 + .../service/mapper/StrutturaMapperTest.java | 24 + .../service/mapper/UtenteAppMapperTest.java | 24 + .../artegna/web/rest/AuditLogResourceIT.java | 876 ++++++++++++++++ .../artegna/web/rest/ConfermaResourceIT.java | 653 ++++++++++++ .../web/rest/DisponibilitaResourceIT.java | 564 ++++++++++ .../web/rest/LiberatoriaResourceIT.java | 480 +++++++++ .../artegna/web/rest/MessaggioResourceIT.java | 488 +++++++++ .../rest/ModelloLiberatoriaResourceIT.java | 520 ++++++++++ .../artegna/web/rest/NotificaResourceIT.java | 846 +++++++++++++++ .../web/rest/PrenotazioneResourceIT.java | 962 ++++++++++++++++++ .../artegna/web/rest/StrutturaResourceIT.java | 951 +++++++++++++++++ .../artegna/web/rest/UtenteAppResourceIT.java | 652 ++++++++++++ .../cypress/e2e/entity/audit-log.cy.ts | 192 ++++ .../cypress/e2e/entity/conferma.cy.ts | 180 ++++ .../cypress/e2e/entity/disponibilita.cy.ts | 200 ++++ .../cypress/e2e/entity/liberatoria.cy.ts | 176 ++++ .../cypress/e2e/entity/messaggio.cy.ts | 183 ++++ .../e2e/entity/modello-liberatoria.cy.ts | 190 ++++ .../cypress/e2e/entity/notifica.cy.ts | 197 ++++ .../cypress/e2e/entity/prenotazione.cy.ts | 194 ++++ .../cypress/e2e/entity/struttura.cy.ts | 202 ++++ .../cypress/e2e/entity/utente-app.cy.ts | 217 ++++ 363 files changed, 36699 insertions(+), 44 deletions(-) create mode 100644 .jhipster/AuditLog.json create mode 100644 .jhipster/Conferma.json create mode 100644 .jhipster/Disponibilita.json create mode 100644 .jhipster/Liberatoria.json create mode 100644 .jhipster/Messaggio.json create mode 100644 .jhipster/ModelloLiberatoria.json create mode 100644 .jhipster/Notifica.json create mode 100644 .jhipster/Prenotazione.json create mode 100644 .jhipster/Struttura.json create mode 100644 .jhipster/UtenteApp.json create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/AuditLog.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/Conferma.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/Disponibilita.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/Liberatoria.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/Messaggio.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoria.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/Notifica.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/Prenotazione.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/Struttura.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/UtenteApp.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/enumeration/AzioneAudit.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/enumeration/GiornoSettimana.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/enumeration/Ruolo.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/enumeration/StatoPrenotazione.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoCanaleNotifica.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoConferma.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoDisponibilita.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoEntita.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoEventoNotifica.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/domain/enumeration/package-info.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/repository/AuditLogRepository.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/repository/ConfermaRepository.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/repository/DisponibilitaRepository.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/repository/LiberatoriaRepository.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/repository/MessaggioRepository.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/repository/ModelloLiberatoriaRepository.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/repository/NotificaRepository.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/repository/PrenotazioneRepository.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/repository/StrutturaRepository.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/repository/UtenteAppRepository.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/AuditLogQueryService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/AuditLogService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/ConfermaQueryService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/ConfermaService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/DisponibilitaService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/LiberatoriaService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/MessaggioService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/ModelloLiberatoriaService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/NotificaQueryService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/NotificaService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/PrenotazioneQueryService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/PrenotazioneService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/StrutturaQueryService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/StrutturaService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/UtenteAppService.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/criteria/AuditLogCriteria.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/criteria/ConfermaCriteria.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/criteria/NotificaCriteria.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/criteria/PrenotazioneCriteria.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/criteria/StrutturaCriteria.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/criteria/package-info.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/dto/AuditLogDTO.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/dto/ConfermaDTO.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/dto/DisponibilitaDTO.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/dto/LiberatoriaDTO.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/dto/MessaggioDTO.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/dto/ModelloLiberatoriaDTO.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/dto/NotificaDTO.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/dto/PrenotazioneDTO.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/dto/StrutturaDTO.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/dto/UtenteAppDTO.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/impl/AuditLogServiceImpl.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/impl/ConfermaServiceImpl.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/impl/DisponibilitaServiceImpl.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/impl/LiberatoriaServiceImpl.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/impl/MessaggioServiceImpl.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/impl/ModelloLiberatoriaServiceImpl.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/impl/NotificaServiceImpl.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/impl/PrenotazioneServiceImpl.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/impl/StrutturaServiceImpl.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/impl/UtenteAppServiceImpl.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/impl/package-info.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/mapper/AuditLogMapper.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/mapper/ConfermaMapper.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/mapper/DisponibilitaMapper.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/mapper/EntityMapper.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/mapper/LiberatoriaMapper.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/mapper/MessaggioMapper.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/mapper/ModelloLiberatoriaMapper.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/mapper/NotificaMapper.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/mapper/PrenotazioneMapper.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/mapper/StrutturaMapper.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/service/mapper/UtenteAppMapper.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/web/rest/AuditLogResource.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/web/rest/ConfermaResource.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/web/rest/DisponibilitaResource.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/web/rest/LiberatoriaResource.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/web/rest/MessaggioResource.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/web/rest/ModelloLiberatoriaResource.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/web/rest/NotificaResource.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/web/rest/PrenotazioneResource.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/web/rest/StrutturaResource.java create mode 100644 src/main/java/it/sw/pa/comune/artegna/web/rest/UtenteAppResource.java create mode 100644 src/main/resources/config/liquibase/changelog/20251210161121_added_entity_AuditLog.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161121_added_entity_constraints_AuditLog.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161122_added_entity_Disponibilita.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161122_added_entity_constraints_Disponibilita.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161123_added_entity_Notifica.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161123_added_entity_constraints_Notifica.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161124_added_entity_Prenotazione.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161124_added_entity_constraints_Prenotazione.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161125_added_entity_Conferma.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161125_added_entity_constraints_Conferma.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161126_added_entity_Struttura.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161127_added_entity_UtenteApp.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161128_added_entity_Liberatoria.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161128_added_entity_constraints_Liberatoria.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161129_added_entity_ModelloLiberatoria.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161129_added_entity_constraints_ModelloLiberatoria.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161130_added_entity_Messaggio.xml create mode 100644 src/main/resources/config/liquibase/changelog/20251210161130_added_entity_constraints_Messaggio.xml create mode 100644 src/main/resources/config/liquibase/fake-data/audit_log.csv create mode 100644 src/main/resources/config/liquibase/fake-data/blob/hipster.png create mode 100644 src/main/resources/config/liquibase/fake-data/conferma.csv create mode 100644 src/main/resources/config/liquibase/fake-data/disponibilita.csv create mode 100644 src/main/resources/config/liquibase/fake-data/liberatoria.csv create mode 100644 src/main/resources/config/liquibase/fake-data/messaggio.csv create mode 100644 src/main/resources/config/liquibase/fake-data/modello_liberatoria.csv create mode 100644 src/main/resources/config/liquibase/fake-data/notifica.csv create mode 100644 src/main/resources/config/liquibase/fake-data/prenotazione.csv create mode 100644 src/main/resources/config/liquibase/fake-data/struttura.csv create mode 100644 src/main/resources/config/liquibase/fake-data/utente_app.csv create mode 100644 src/main/webapp/app/entities/audit-log/audit-log-details.component.spec.ts create mode 100644 src/main/webapp/app/entities/audit-log/audit-log-details.component.ts create mode 100644 src/main/webapp/app/entities/audit-log/audit-log-details.vue create mode 100644 src/main/webapp/app/entities/audit-log/audit-log-update.component.spec.ts create mode 100644 src/main/webapp/app/entities/audit-log/audit-log-update.component.ts create mode 100644 src/main/webapp/app/entities/audit-log/audit-log-update.vue create mode 100644 src/main/webapp/app/entities/audit-log/audit-log.component.spec.ts create mode 100644 src/main/webapp/app/entities/audit-log/audit-log.component.ts create mode 100644 src/main/webapp/app/entities/audit-log/audit-log.service.spec.ts create mode 100644 src/main/webapp/app/entities/audit-log/audit-log.service.ts create mode 100644 src/main/webapp/app/entities/audit-log/audit-log.vue create mode 100644 src/main/webapp/app/entities/conferma/conferma-details.component.spec.ts create mode 100644 src/main/webapp/app/entities/conferma/conferma-details.component.ts create mode 100644 src/main/webapp/app/entities/conferma/conferma-details.vue create mode 100644 src/main/webapp/app/entities/conferma/conferma-update.component.spec.ts create mode 100644 src/main/webapp/app/entities/conferma/conferma-update.component.ts create mode 100644 src/main/webapp/app/entities/conferma/conferma-update.vue create mode 100644 src/main/webapp/app/entities/conferma/conferma.component.spec.ts create mode 100644 src/main/webapp/app/entities/conferma/conferma.component.ts create mode 100644 src/main/webapp/app/entities/conferma/conferma.service.spec.ts create mode 100644 src/main/webapp/app/entities/conferma/conferma.service.ts create mode 100644 src/main/webapp/app/entities/conferma/conferma.vue create mode 100644 src/main/webapp/app/entities/disponibilita/disponibilita-details.component.spec.ts create mode 100644 src/main/webapp/app/entities/disponibilita/disponibilita-details.component.ts create mode 100644 src/main/webapp/app/entities/disponibilita/disponibilita-details.vue create mode 100644 src/main/webapp/app/entities/disponibilita/disponibilita-update.component.spec.ts create mode 100644 src/main/webapp/app/entities/disponibilita/disponibilita-update.component.ts create mode 100644 src/main/webapp/app/entities/disponibilita/disponibilita-update.vue create mode 100644 src/main/webapp/app/entities/disponibilita/disponibilita.component.spec.ts create mode 100644 src/main/webapp/app/entities/disponibilita/disponibilita.component.ts create mode 100644 src/main/webapp/app/entities/disponibilita/disponibilita.service.spec.ts create mode 100644 src/main/webapp/app/entities/disponibilita/disponibilita.service.ts create mode 100644 src/main/webapp/app/entities/disponibilita/disponibilita.vue create mode 100644 src/main/webapp/app/entities/liberatoria/liberatoria-details.component.spec.ts create mode 100644 src/main/webapp/app/entities/liberatoria/liberatoria-details.component.ts create mode 100644 src/main/webapp/app/entities/liberatoria/liberatoria-details.vue create mode 100644 src/main/webapp/app/entities/liberatoria/liberatoria-update.component.spec.ts create mode 100644 src/main/webapp/app/entities/liberatoria/liberatoria-update.component.ts create mode 100644 src/main/webapp/app/entities/liberatoria/liberatoria-update.vue create mode 100644 src/main/webapp/app/entities/liberatoria/liberatoria.component.spec.ts create mode 100644 src/main/webapp/app/entities/liberatoria/liberatoria.component.ts create mode 100644 src/main/webapp/app/entities/liberatoria/liberatoria.service.spec.ts create mode 100644 src/main/webapp/app/entities/liberatoria/liberatoria.service.ts create mode 100644 src/main/webapp/app/entities/liberatoria/liberatoria.vue create mode 100644 src/main/webapp/app/entities/messaggio/messaggio-details.component.spec.ts create mode 100644 src/main/webapp/app/entities/messaggio/messaggio-details.component.ts create mode 100644 src/main/webapp/app/entities/messaggio/messaggio-details.vue create mode 100644 src/main/webapp/app/entities/messaggio/messaggio-update.component.spec.ts create mode 100644 src/main/webapp/app/entities/messaggio/messaggio-update.component.ts create mode 100644 src/main/webapp/app/entities/messaggio/messaggio-update.vue create mode 100644 src/main/webapp/app/entities/messaggio/messaggio.component.spec.ts create mode 100644 src/main/webapp/app/entities/messaggio/messaggio.component.ts create mode 100644 src/main/webapp/app/entities/messaggio/messaggio.service.spec.ts create mode 100644 src/main/webapp/app/entities/messaggio/messaggio.service.ts create mode 100644 src/main/webapp/app/entities/messaggio/messaggio.vue create mode 100644 src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-details.component.spec.ts create mode 100644 src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-details.component.ts create mode 100644 src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-details.vue create mode 100644 src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-update.component.spec.ts create mode 100644 src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-update.component.ts create mode 100644 src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-update.vue create mode 100644 src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.component.spec.ts create mode 100644 src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.component.ts create mode 100644 src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.service.spec.ts create mode 100644 src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.service.ts create mode 100644 src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.vue create mode 100644 src/main/webapp/app/entities/notifica/notifica-details.component.spec.ts create mode 100644 src/main/webapp/app/entities/notifica/notifica-details.component.ts create mode 100644 src/main/webapp/app/entities/notifica/notifica-details.vue create mode 100644 src/main/webapp/app/entities/notifica/notifica-update.component.spec.ts create mode 100644 src/main/webapp/app/entities/notifica/notifica-update.component.ts create mode 100644 src/main/webapp/app/entities/notifica/notifica-update.vue create mode 100644 src/main/webapp/app/entities/notifica/notifica.component.spec.ts create mode 100644 src/main/webapp/app/entities/notifica/notifica.component.ts create mode 100644 src/main/webapp/app/entities/notifica/notifica.service.spec.ts create mode 100644 src/main/webapp/app/entities/notifica/notifica.service.ts create mode 100644 src/main/webapp/app/entities/notifica/notifica.vue create mode 100644 src/main/webapp/app/entities/prenotazione/prenotazione-details.component.spec.ts create mode 100644 src/main/webapp/app/entities/prenotazione/prenotazione-details.component.ts create mode 100644 src/main/webapp/app/entities/prenotazione/prenotazione-details.vue create mode 100644 src/main/webapp/app/entities/prenotazione/prenotazione-update.component.spec.ts create mode 100644 src/main/webapp/app/entities/prenotazione/prenotazione-update.component.ts create mode 100644 src/main/webapp/app/entities/prenotazione/prenotazione-update.vue create mode 100644 src/main/webapp/app/entities/prenotazione/prenotazione.component.spec.ts create mode 100644 src/main/webapp/app/entities/prenotazione/prenotazione.component.ts create mode 100644 src/main/webapp/app/entities/prenotazione/prenotazione.service.spec.ts create mode 100644 src/main/webapp/app/entities/prenotazione/prenotazione.service.ts create mode 100644 src/main/webapp/app/entities/prenotazione/prenotazione.vue create mode 100644 src/main/webapp/app/entities/struttura/struttura-details.component.spec.ts create mode 100644 src/main/webapp/app/entities/struttura/struttura-details.component.ts create mode 100644 src/main/webapp/app/entities/struttura/struttura-details.vue create mode 100644 src/main/webapp/app/entities/struttura/struttura-update.component.spec.ts create mode 100644 src/main/webapp/app/entities/struttura/struttura-update.component.ts create mode 100644 src/main/webapp/app/entities/struttura/struttura-update.vue create mode 100644 src/main/webapp/app/entities/struttura/struttura.component.spec.ts create mode 100644 src/main/webapp/app/entities/struttura/struttura.component.ts create mode 100644 src/main/webapp/app/entities/struttura/struttura.service.spec.ts create mode 100644 src/main/webapp/app/entities/struttura/struttura.service.ts create mode 100644 src/main/webapp/app/entities/struttura/struttura.vue create mode 100644 src/main/webapp/app/entities/utente-app/utente-app-details.component.spec.ts create mode 100644 src/main/webapp/app/entities/utente-app/utente-app-details.component.ts create mode 100644 src/main/webapp/app/entities/utente-app/utente-app-details.vue create mode 100644 src/main/webapp/app/entities/utente-app/utente-app-update.component.spec.ts create mode 100644 src/main/webapp/app/entities/utente-app/utente-app-update.component.ts create mode 100644 src/main/webapp/app/entities/utente-app/utente-app-update.vue create mode 100644 src/main/webapp/app/entities/utente-app/utente-app.component.spec.ts create mode 100644 src/main/webapp/app/entities/utente-app/utente-app.component.ts create mode 100644 src/main/webapp/app/entities/utente-app/utente-app.service.spec.ts create mode 100644 src/main/webapp/app/entities/utente-app/utente-app.service.ts create mode 100644 src/main/webapp/app/entities/utente-app/utente-app.vue create mode 100644 src/main/webapp/app/shared/model/audit-log.model.ts create mode 100644 src/main/webapp/app/shared/model/conferma.model.ts create mode 100644 src/main/webapp/app/shared/model/disponibilita.model.ts create mode 100644 src/main/webapp/app/shared/model/enumerations/azione-audit.model.ts create mode 100644 src/main/webapp/app/shared/model/enumerations/giorno-settimana.model.ts create mode 100644 src/main/webapp/app/shared/model/enumerations/ruolo.model.ts create mode 100644 src/main/webapp/app/shared/model/enumerations/stato-prenotazione.model.ts create mode 100644 src/main/webapp/app/shared/model/enumerations/tipo-canale-notifica.model.ts create mode 100644 src/main/webapp/app/shared/model/enumerations/tipo-conferma.model.ts create mode 100644 src/main/webapp/app/shared/model/enumerations/tipo-disponibilita.model.ts create mode 100644 src/main/webapp/app/shared/model/enumerations/tipo-entita.model.ts create mode 100644 src/main/webapp/app/shared/model/enumerations/tipo-evento-notifica.model.ts create mode 100644 src/main/webapp/app/shared/model/liberatoria.model.ts create mode 100644 src/main/webapp/app/shared/model/messaggio.model.ts create mode 100644 src/main/webapp/app/shared/model/modello-liberatoria.model.ts create mode 100644 src/main/webapp/app/shared/model/notifica.model.ts create mode 100644 src/main/webapp/app/shared/model/prenotazione.model.ts create mode 100644 src/main/webapp/app/shared/model/struttura.model.ts create mode 100644 src/main/webapp/app/shared/model/utente-app.model.ts create mode 100644 src/main/webapp/i18n/it/auditLog.json create mode 100644 src/main/webapp/i18n/it/azioneAudit.json create mode 100644 src/main/webapp/i18n/it/conferma.json create mode 100644 src/main/webapp/i18n/it/disponibilita.json create mode 100644 src/main/webapp/i18n/it/giornoSettimana.json create mode 100644 src/main/webapp/i18n/it/liberatoria.json create mode 100644 src/main/webapp/i18n/it/messaggio.json create mode 100644 src/main/webapp/i18n/it/modelloLiberatoria.json create mode 100644 src/main/webapp/i18n/it/notifica.json create mode 100644 src/main/webapp/i18n/it/prenotazione.json create mode 100644 src/main/webapp/i18n/it/ruolo.json create mode 100644 src/main/webapp/i18n/it/statoPrenotazione.json create mode 100644 src/main/webapp/i18n/it/struttura.json create mode 100644 src/main/webapp/i18n/it/tipoCanaleNotifica.json create mode 100644 src/main/webapp/i18n/it/tipoConferma.json create mode 100644 src/main/webapp/i18n/it/tipoDisponibilita.json create mode 100644 src/main/webapp/i18n/it/tipoEntita.json create mode 100644 src/main/webapp/i18n/it/tipoEventoNotifica.json create mode 100644 src/main/webapp/i18n/it/utenteApp.json create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/AuditLogAsserts.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/AuditLogTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/AuditLogTestSamples.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/ConfermaAsserts.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/ConfermaTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/ConfermaTestSamples.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/DisponibilitaAsserts.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/DisponibilitaTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/DisponibilitaTestSamples.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/LiberatoriaAsserts.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/LiberatoriaTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/LiberatoriaTestSamples.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/MessaggioAsserts.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/MessaggioTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/MessaggioTestSamples.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoriaAsserts.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoriaTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoriaTestSamples.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/NotificaAsserts.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/NotificaTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/NotificaTestSamples.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/PrenotazioneAsserts.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/PrenotazioneTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/PrenotazioneTestSamples.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/StrutturaAsserts.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/StrutturaTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/StrutturaTestSamples.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/UtenteAppAsserts.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/UtenteAppTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/domain/UtenteAppTestSamples.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/criteria/AuditLogCriteriaTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/criteria/ConfermaCriteriaTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/criteria/NotificaCriteriaTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/criteria/PrenotazioneCriteriaTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/criteria/StrutturaCriteriaTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/dto/AuditLogDTOTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/dto/ConfermaDTOTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/dto/DisponibilitaDTOTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/dto/LiberatoriaDTOTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/dto/MessaggioDTOTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/dto/ModelloLiberatoriaDTOTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/dto/NotificaDTOTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/dto/PrenotazioneDTOTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/dto/StrutturaDTOTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/dto/UtenteAppDTOTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/mapper/AuditLogMapperTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/mapper/ConfermaMapperTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/mapper/DisponibilitaMapperTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/mapper/LiberatoriaMapperTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/mapper/MessaggioMapperTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/mapper/ModelloLiberatoriaMapperTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/mapper/NotificaMapperTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/mapper/PrenotazioneMapperTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/mapper/StrutturaMapperTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/service/mapper/UtenteAppMapperTest.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/web/rest/AuditLogResourceIT.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/web/rest/ConfermaResourceIT.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/web/rest/DisponibilitaResourceIT.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/web/rest/LiberatoriaResourceIT.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/web/rest/MessaggioResourceIT.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/web/rest/ModelloLiberatoriaResourceIT.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/web/rest/NotificaResourceIT.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/web/rest/PrenotazioneResourceIT.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/web/rest/StrutturaResourceIT.java create mode 100644 src/test/java/it/sw/pa/comune/artegna/web/rest/UtenteAppResourceIT.java create mode 100644 src/test/javascript/cypress/e2e/entity/audit-log.cy.ts create mode 100644 src/test/javascript/cypress/e2e/entity/conferma.cy.ts create mode 100644 src/test/javascript/cypress/e2e/entity/disponibilita.cy.ts create mode 100644 src/test/javascript/cypress/e2e/entity/liberatoria.cy.ts create mode 100644 src/test/javascript/cypress/e2e/entity/messaggio.cy.ts create mode 100644 src/test/javascript/cypress/e2e/entity/modello-liberatoria.cy.ts create mode 100644 src/test/javascript/cypress/e2e/entity/notifica.cy.ts create mode 100644 src/test/javascript/cypress/e2e/entity/prenotazione.cy.ts create mode 100644 src/test/javascript/cypress/e2e/entity/struttura.cy.ts create mode 100644 src/test/javascript/cypress/e2e/entity/utente-app.cy.ts diff --git a/.jhipster/AuditLog.json b/.jhipster/AuditLog.json new file mode 100644 index 0000000..34dc6de --- /dev/null +++ b/.jhipster/AuditLog.json @@ -0,0 +1,49 @@ +{ + "annotations": { + "changelogDate": "20251210161121" + }, + "applications": ["*"], + "dto": "mapstruct", + "fields": [ + { + "fieldName": "entitaTipo", + "fieldType": "TipoEntita", + "fieldValues": "PRENOTAZIONE,CONFERMA" + }, + { + "fieldName": "entitaId", + "fieldType": "Long" + }, + { + "fieldName": "azione", + "fieldType": "AzioneAudit", + "fieldValues": "CREATE,UPDATE,DELETE,CONFIRM,REJECT" + }, + { + "fieldName": "dettagli", + "fieldType": "String" + }, + { + "fieldName": "ipAddress", + "fieldType": "String" + }, + { + "fieldName": "createdAt", + "fieldType": "Instant" + } + ], + "jpaMetamodelFiltering": true, + "name": "AuditLog", + "pagination": "pagination", + "relationships": [ + { + "otherEntityField": "username", + "otherEntityName": "utenteApp", + "relationshipName": "utente", + "relationshipSide": "left", + "relationshipType": "many-to-one" + } + ], + "searchEngine": "no", + "service": "serviceImpl" +} diff --git a/.jhipster/Conferma.json b/.jhipster/Conferma.json new file mode 100644 index 0000000..368b5d9 --- /dev/null +++ b/.jhipster/Conferma.json @@ -0,0 +1,39 @@ +{ + "annotations": { + "changelogDate": "20251210161125" + }, + "applications": ["*"], + "dto": "mapstruct", + "fields": [ + { + "fieldName": "motivoConferma", + "fieldType": "String" + }, + { + "fieldName": "tipoConferma", + "fieldType": "TipoConferma", + "fieldValues": "CONFERMATA,RIFIUTATA" + } + ], + "jpaMetamodelFiltering": true, + "name": "Conferma", + "pagination": "pagination", + "relationships": [ + { + "otherEntityField": "username", + "otherEntityName": "utenteApp", + "relationshipName": "confermataDa", + "relationshipSide": "left", + "relationshipType": "many-to-one" + }, + { + "otherEntityName": "prenotazione", + "otherEntityRelationshipName": "conferma", + "relationshipName": "prenotazione", + "relationshipSide": "right", + "relationshipType": "one-to-one" + } + ], + "searchEngine": "no", + "service": "serviceImpl" +} diff --git a/.jhipster/Disponibilita.json b/.jhipster/Disponibilita.json new file mode 100644 index 0000000..a66c679 --- /dev/null +++ b/.jhipster/Disponibilita.json @@ -0,0 +1,57 @@ +{ + "annotations": { + "changelogDate": "20251210161122" + }, + "applications": ["*"], + "dto": "mapstruct", + "fields": [ + { + "fieldName": "giornoSettimana", + "fieldType": "GiornoSettimana", + "fieldValues": "LUNEDI,MARTEDI,MERCOLEDI,GIOVEDI,VENERDI,SABATO,DOMENICA" + }, + { + "fieldName": "dataSpecifica", + "fieldType": "LocalDate" + }, + { + "fieldName": "oraInizio", + "fieldType": "Instant" + }, + { + "fieldName": "oraFine", + "fieldType": "Instant" + }, + { + "fieldName": "orarioInizio", + "fieldType": "String" + }, + { + "fieldName": "orarioFine", + "fieldType": "String" + }, + { + "fieldName": "tipo", + "fieldType": "TipoDisponibilita", + "fieldValues": "DISPONIBILE,CHIUSURA" + }, + { + "fieldName": "note", + "fieldType": "String" + } + ], + "name": "Disponibilita", + "pagination": "infinite-scroll", + "relationships": [ + { + "otherEntityField": "nome", + "otherEntityName": "struttura", + "otherEntityRelationshipName": "disponibilita", + "relationshipName": "struttura", + "relationshipSide": "left", + "relationshipType": "many-to-one" + } + ], + "searchEngine": "no", + "service": "serviceImpl" +} diff --git a/.jhipster/Liberatoria.json b/.jhipster/Liberatoria.json new file mode 100644 index 0000000..4752b49 --- /dev/null +++ b/.jhipster/Liberatoria.json @@ -0,0 +1,32 @@ +{ + "annotations": { + "changelogDate": "20251210161128" + }, + "applications": ["*"], + "dto": "mapstruct", + "fields": [ + { + "fieldName": "accettata", + "fieldType": "Instant" + } + ], + "name": "Liberatoria", + "relationships": [ + { + "otherEntityField": "username", + "otherEntityName": "utenteApp", + "otherEntityRelationshipName": "liberatorie", + "relationshipName": "utente", + "relationshipSide": "left", + "relationshipType": "many-to-one" + }, + { + "otherEntityName": "modelloLiberatoria", + "relationshipName": "modelloLiberatoria", + "relationshipSide": "left", + "relationshipType": "many-to-one" + } + ], + "searchEngine": "no", + "service": "serviceImpl" +} diff --git a/.jhipster/Messaggio.json b/.jhipster/Messaggio.json new file mode 100644 index 0000000..8d8469c --- /dev/null +++ b/.jhipster/Messaggio.json @@ -0,0 +1,33 @@ +{ + "annotations": { + "changelogDate": "20251210161130" + }, + "applications": ["*"], + "dto": "mapstruct", + "fields": [ + { + "fieldName": "spedito", + "fieldType": "Instant" + }, + { + "fieldName": "testo", + "fieldType": "String" + }, + { + "fieldName": "letto", + "fieldType": "Instant" + } + ], + "name": "Messaggio", + "relationships": [ + { + "otherEntityField": "username", + "otherEntityName": "utenteApp", + "relationshipName": "utente", + "relationshipSide": "left", + "relationshipType": "many-to-one" + } + ], + "searchEngine": "no", + "service": "serviceImpl" +} diff --git a/.jhipster/ModelloLiberatoria.json b/.jhipster/ModelloLiberatoria.json new file mode 100644 index 0000000..cadd268 --- /dev/null +++ b/.jhipster/ModelloLiberatoria.json @@ -0,0 +1,41 @@ +{ + "annotations": { + "changelogDate": "20251210161129" + }, + "applications": ["*"], + "dto": "mapstruct", + "fields": [ + { + "fieldName": "nome", + "fieldType": "String" + }, + { + "fieldName": "testo", + "fieldType": "String" + }, + { + "fieldName": "documento", + "fieldType": "Blob" + }, + { + "fieldName": "validoDal", + "fieldType": "Instant" + }, + { + "fieldName": "validoAl", + "fieldType": "Instant" + } + ], + "name": "ModelloLiberatoria", + "relationships": [ + { + "otherEntityName": "struttura", + "otherEntityRelationshipName": "moduliLiberatorie", + "relationshipName": "struttura", + "relationshipSide": "left", + "relationshipType": "many-to-one" + } + ], + "searchEngine": "no", + "service": "serviceImpl" +} diff --git a/.jhipster/Notifica.json b/.jhipster/Notifica.json new file mode 100644 index 0000000..ce44860 --- /dev/null +++ b/.jhipster/Notifica.json @@ -0,0 +1,52 @@ +{ + "annotations": { + "changelogDate": "20251210161123" + }, + "applications": ["*"], + "dto": "mapstruct", + "fields": [ + { + "fieldName": "tipoCanale", + "fieldType": "TipoCanaleNotifica", + "fieldValues": "EMAIL,WHATSAPP,SISTEMA" + }, + { + "fieldName": "tipoEvento", + "fieldType": "TipoEventoNotifica", + "fieldValues": "RICHIESTA_CREATA,PRENOTAZIONE_CONFERMATA,PRENOTAZIONE_RIFIUTATA,REMINDER,ANNULLAMENTO" + }, + { + "fieldName": "messaggio", + "fieldType": "String" + }, + { + "fieldName": "inviata", + "fieldType": "Boolean" + }, + { + "fieldName": "inviataAt", + "fieldType": "Instant" + }, + { + "fieldName": "errore", + "fieldType": "String" + }, + { + "fieldName": "createdAt", + "fieldType": "Instant" + } + ], + "jpaMetamodelFiltering": true, + "name": "Notifica", + "pagination": "pagination", + "relationships": [ + { + "otherEntityName": "conferma", + "relationshipName": "conferma", + "relationshipSide": "left", + "relationshipType": "many-to-one" + } + ], + "searchEngine": "no", + "service": "serviceImpl" +} diff --git a/.jhipster/Prenotazione.json b/.jhipster/Prenotazione.json new file mode 100644 index 0000000..0dad1cc --- /dev/null +++ b/.jhipster/Prenotazione.json @@ -0,0 +1,62 @@ +{ + "annotations": { + "changelogDate": "20251210161124" + }, + "applications": ["*"], + "dto": "mapstruct", + "fields": [ + { + "fieldName": "oraInizio", + "fieldType": "Instant" + }, + { + "fieldName": "oraFine", + "fieldType": "Instant" + }, + { + "fieldName": "stato", + "fieldType": "StatoPrenotazione", + "fieldValues": "RICHIESTA,CONFERMATA,RIFIUTATA,ANNULLATA" + }, + { + "fieldName": "motivoEvento", + "fieldType": "String" + }, + { + "fieldName": "numeroPartecipanti", + "fieldType": "Integer" + }, + { + "fieldName": "noteUtente", + "fieldType": "String" + } + ], + "jpaMetamodelFiltering": true, + "name": "Prenotazione", + "pagination": "pagination", + "relationships": [ + { + "otherEntityName": "conferma", + "otherEntityRelationshipName": "prenotazione", + "relationshipName": "conferma", + "relationshipSide": "left", + "relationshipType": "one-to-one" + }, + { + "otherEntityField": "username", + "otherEntityName": "utenteApp", + "relationshipName": "utente", + "relationshipSide": "left", + "relationshipType": "many-to-one" + }, + { + "otherEntityField": "nome", + "otherEntityName": "struttura", + "relationshipName": "struttura", + "relationshipSide": "left", + "relationshipType": "many-to-one" + } + ], + "searchEngine": "no", + "service": "serviceImpl" +} diff --git a/.jhipster/Struttura.json b/.jhipster/Struttura.json new file mode 100644 index 0000000..1870061 --- /dev/null +++ b/.jhipster/Struttura.json @@ -0,0 +1,62 @@ +{ + "annotations": { + "changelogDate": "20251210161126" + }, + "applications": ["*"], + "dto": "mapstruct", + "fields": [ + { + "fieldName": "nome", + "fieldType": "String" + }, + { + "fieldName": "descrizione", + "fieldType": "String" + }, + { + "fieldName": "indirizzo", + "fieldType": "String" + }, + { + "fieldName": "capienzaMax", + "fieldType": "Integer" + }, + { + "fieldName": "attiva", + "fieldType": "Boolean" + }, + { + "fieldName": "fotoUrl", + "fieldType": "String" + }, + { + "fieldName": "createdAt", + "fieldType": "Instant" + }, + { + "fieldName": "updatedAt", + "fieldType": "Instant" + } + ], + "jpaMetamodelFiltering": true, + "name": "Struttura", + "pagination": "pagination", + "relationships": [ + { + "otherEntityName": "disponibilita", + "otherEntityRelationshipName": "struttura", + "relationshipName": "disponibilita", + "relationshipSide": "right", + "relationshipType": "one-to-many" + }, + { + "otherEntityName": "modelloLiberatoria", + "otherEntityRelationshipName": "struttura", + "relationshipName": "moduliLiberatorie", + "relationshipSide": "right", + "relationshipType": "one-to-many" + } + ], + "searchEngine": "no", + "service": "serviceImpl" +} diff --git a/.jhipster/UtenteApp.json b/.jhipster/UtenteApp.json new file mode 100644 index 0000000..5674211 --- /dev/null +++ b/.jhipster/UtenteApp.json @@ -0,0 +1,86 @@ +{ + "annotations": { + "changelogDate": "20251210161127" + }, + "applications": ["*"], + "dto": "mapstruct", + "fields": [ + { + "fieldName": "username", + "fieldType": "String", + "fieldValidateRules": ["required", "unique"] + }, + { + "fieldName": "email", + "fieldType": "String", + "fieldValidateRules": ["required"] + }, + { + "fieldName": "telefono", + "fieldType": "String" + }, + { + "fieldName": "ruolo", + "fieldType": "Ruolo", + "fieldValidateRules": ["required"], + "fieldValues": "USER,INCARICATO,ADMIN" + }, + { + "fieldName": "attivo", + "fieldType": "Boolean", + "fieldValidateRules": ["required"] + }, + { + "fieldName": "nome", + "fieldType": "String" + }, + { + "fieldName": "cognome", + "fieldType": "String" + }, + { + "fieldName": "luogoNascita", + "fieldType": "String" + }, + { + "fieldName": "dataNascita", + "fieldType": "String" + }, + { + "fieldName": "residente", + "fieldType": "String" + }, + { + "fieldName": "societa", + "fieldType": "String" + }, + { + "fieldName": "sede", + "fieldType": "String" + }, + { + "fieldName": "codfiscale", + "fieldType": "String" + }, + { + "fieldName": "telefonoSoc", + "fieldType": "String" + }, + { + "fieldName": "emailSoc", + "fieldType": "String" + } + ], + "name": "UtenteApp", + "relationships": [ + { + "otherEntityName": "liberatoria", + "otherEntityRelationshipName": "utente", + "relationshipName": "liberatorie", + "relationshipSide": "right", + "relationshipType": "one-to-many" + } + ], + "searchEngine": "no", + "service": "serviceImpl" +} diff --git a/.yo-rc.json b/.yo-rc.json index ff38f98..be862a9 100644 --- a/.yo-rc.json +++ b/.yo-rc.json @@ -16,11 +16,23 @@ "enableGradleDevelocity": false, "enableHibernateCache": true, "enableTranslation": true, - "entities": [], + "entities": [ + "AuditLog", + "Disponibilita", + "Notifica", + "Prenotazione", + "Conferma", + "Struttura", + "UtenteApp", + "Liberatoria", + "ModelloLiberatoria", + "Messaggio" + ], "feignClient": null, "gradleDevelocityHost": null, "jhipsterVersion": "9.0.0-beta.0", "languages": ["it"], + "lastLiquibaseTimestamp": 1765383090000, "microfrontend": null, "microfrontends": [], "nativeLanguage": "it", diff --git a/jhipster-jdl.jdl b/jhipster-jdl.jdl index 53f9f84..7c18188 100644 --- a/jhipster-jdl.jdl +++ b/jhipster-jdl.jdl @@ -1,35 +1,3 @@ -application { - config { - applicationType monolith - authenticationType session - baseName smartbooking - buildTool gradle - cacheProvider ehcache - clientFramework vue - clientTheme yeti - clientThemeVariant primary - creationTimestamp 1765013775744 - databaseType sql - devDatabaseType postgresql - enableGradleEnterprise false - enableHibernateCache true - enableTranslation true - jhipsterVersion "8.11.0" - languages [it] - microfrontends [] - nativeLanguage it - packageName it.softwarepa.comune.artegna - prodDatabaseType postgresql - reactive false - rememberMeKey "810f1205976fd73602beb36796a53c78e3c4974c4fe22f343acbab764cdc74e50f3aeb807a64e1aa922f6f557ada00a8c89f" - testFrameworks [cucumber, cypress] - withAdminUi true - } - - entities AuditLog, Conferma, Disponibilita, Notifica, Prenotazione, Struttura, UtenteApp, Messaggio -} - - entity AuditLog { entitaTipo TipoEntita entitaId Long @@ -53,7 +21,7 @@ entity Disponibilita { entity Notifica { tipoCanale TipoCanaleNotifica tipoEvento TipoEventoNotifica - messaggio String + messaggio String inviata Boolean inviataAt Instant errore String @@ -70,8 +38,8 @@ entity Prenotazione { } entity Conferma { - motivoConferma String - tipoConferma TipoConferma + motivoConferma String + tipoConferma TipoConferma } entity Struttura { @@ -91,8 +59,28 @@ entity UtenteApp { telefono String ruolo Ruolo required attivo Boolean required - createdAt Instant - updatedAt Instant + nome String + cognome String + luogoNascita String + dataNascita String + residente String + societa String + sede String + codfiscale String + telefonoSoc String + emailSoc String +} + +entity Liberatoria { + accettata Instant +} + +entity ModelloLiberatoria { + nome String + testo String + documento Blob + validoDal Instant + validoAl Instant } entity Messaggio { @@ -102,8 +90,8 @@ entity Messaggio { } enum TipoEntita { - PRENOTAZIONE, - CONFERMA + PRENOTAZIONE, + CONFERMA } enum TipoConferma { @@ -155,7 +143,7 @@ enum Ruolo { } relationship OneToOne { - Prenotazione to Conferma + Prenotazione to Conferma } @@ -167,11 +155,14 @@ relationship ManyToOne { Prenotazione{struttura(nome)} to Struttura Conferma{confermataDa(username)} to UtenteApp Messaggio{utente(username)} to UtenteApp + ModelloLiberatoria{struttura} to Struttura{moduliLiberatorie} + Liberatoria{utente(username)} to UtenteApp{liberatorie} + Liberatoria{modelloLiberatoria} to ModelloLiberatoria } -dto AuditLog, Disponibilita, Notifica, Prenotazione, Conferma, Struttura, UtenteApp, Messaggio with mapstruct +dto AuditLog, Disponibilita, Notifica, Prenotazione, Conferma, Struttura, UtenteApp, Messaggio, Liberatoria, ModelloLiberatoria with mapstruct paginate AuditLog, Notifica, Prenotazione, Struttura, Conferma with pagination paginate Disponibilita with infinite-scroll -service AuditLog, Conferma, Disponibilita, Notifica, Prenotazione, Struttura, UtenteApp with serviceImpl +service AuditLog, Conferma, Disponibilita, Notifica, Prenotazione, Struttura, UtenteApp, Messaggio, Liberatoria, ModelloLiberatoria with serviceImpl search AuditLog, Conferma, Disponibilita, Notifica, Prenotazione, Struttura, UtenteApp with no filter AuditLog, Notifica, Prenotazione, Struttura, Conferma diff --git a/src/main/java/it/sw/pa/comune/artegna/config/CacheConfiguration.java b/src/main/java/it/sw/pa/comune/artegna/config/CacheConfiguration.java index 993a584..6361e69 100644 --- a/src/main/java/it/sw/pa/comune/artegna/config/CacheConfiguration.java +++ b/src/main/java/it/sw/pa/comune/artegna/config/CacheConfiguration.java @@ -52,6 +52,19 @@ public class CacheConfiguration { createCache(cm, it.sw.pa.comune.artegna.domain.User.class.getName() + ".authorities"); createCache(cm, it.sw.pa.comune.artegna.domain.PersistentToken.class.getName()); createCache(cm, it.sw.pa.comune.artegna.domain.User.class.getName() + ".persistentTokens"); + createCache(cm, it.sw.pa.comune.artegna.domain.AuditLog.class.getName()); + createCache(cm, it.sw.pa.comune.artegna.domain.Disponibilita.class.getName()); + createCache(cm, it.sw.pa.comune.artegna.domain.Notifica.class.getName()); + createCache(cm, it.sw.pa.comune.artegna.domain.Prenotazione.class.getName()); + createCache(cm, it.sw.pa.comune.artegna.domain.Conferma.class.getName()); + createCache(cm, it.sw.pa.comune.artegna.domain.Struttura.class.getName()); + createCache(cm, it.sw.pa.comune.artegna.domain.Struttura.class.getName() + ".disponibilitas"); + createCache(cm, it.sw.pa.comune.artegna.domain.Struttura.class.getName() + ".moduliLiberatories"); + createCache(cm, it.sw.pa.comune.artegna.domain.UtenteApp.class.getName()); + createCache(cm, it.sw.pa.comune.artegna.domain.UtenteApp.class.getName() + ".liberatories"); + createCache(cm, it.sw.pa.comune.artegna.domain.Liberatoria.class.getName()); + createCache(cm, it.sw.pa.comune.artegna.domain.ModelloLiberatoria.class.getName()); + createCache(cm, it.sw.pa.comune.artegna.domain.Messaggio.class.getName()); // jhipster-needle-ehcache-add-entry }; } diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/AuditLog.java b/src/main/java/it/sw/pa/comune/artegna/domain/AuditLog.java new file mode 100644 index 0000000..8a7b9e7 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/AuditLog.java @@ -0,0 +1,193 @@ +package it.sw.pa.comune.artegna.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import it.sw.pa.comune.artegna.domain.enumeration.AzioneAudit; +import it.sw.pa.comune.artegna.domain.enumeration.TipoEntita; +import jakarta.persistence.*; +import java.io.Serial; +import java.io.Serializable; +import java.time.Instant; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +/** + * A AuditLog. + */ +@Entity +@Table(name = "audit_log") +@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) +@SuppressWarnings("common-java:DuplicatedBlocks") +public class AuditLog implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + @Column(name = "id") + private Long id; + + @Enumerated(EnumType.STRING) + @Column(name = "entita_tipo") + private TipoEntita entitaTipo; + + @Column(name = "entita_id") + private Long entitaId; + + @Enumerated(EnumType.STRING) + @Column(name = "azione") + private AzioneAudit azione; + + @Column(name = "dettagli") + private String dettagli; + + @Column(name = "ip_address") + private String ipAddress; + + @Column(name = "created_at") + private Instant createdAt; + + @ManyToOne(fetch = FetchType.LAZY) + @JsonIgnoreProperties(value = { "liberatories" }, allowSetters = true) + private UtenteApp utente; + + // jhipster-needle-entity-add-field - JHipster will add fields here + + public Long getId() { + return this.id; + } + + public AuditLog id(Long id) { + this.setId(id); + return this; + } + + public void setId(Long id) { + this.id = id; + } + + public TipoEntita getEntitaTipo() { + return this.entitaTipo; + } + + public AuditLog entitaTipo(TipoEntita entitaTipo) { + this.setEntitaTipo(entitaTipo); + return this; + } + + public void setEntitaTipo(TipoEntita entitaTipo) { + this.entitaTipo = entitaTipo; + } + + public Long getEntitaId() { + return this.entitaId; + } + + public AuditLog entitaId(Long entitaId) { + this.setEntitaId(entitaId); + return this; + } + + public void setEntitaId(Long entitaId) { + this.entitaId = entitaId; + } + + public AzioneAudit getAzione() { + return this.azione; + } + + public AuditLog azione(AzioneAudit azione) { + this.setAzione(azione); + return this; + } + + public void setAzione(AzioneAudit azione) { + this.azione = azione; + } + + public String getDettagli() { + return this.dettagli; + } + + public AuditLog dettagli(String dettagli) { + this.setDettagli(dettagli); + return this; + } + + public void setDettagli(String dettagli) { + this.dettagli = dettagli; + } + + public String getIpAddress() { + return this.ipAddress; + } + + public AuditLog ipAddress(String ipAddress) { + this.setIpAddress(ipAddress); + return this; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public Instant getCreatedAt() { + return this.createdAt; + } + + public AuditLog createdAt(Instant createdAt) { + this.setCreatedAt(createdAt); + return this; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public UtenteApp getUtente() { + return this.utente; + } + + public void setUtente(UtenteApp utenteApp) { + this.utente = utenteApp; + } + + public AuditLog utente(UtenteApp utenteApp) { + this.setUtente(utenteApp); + return this; + } + + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof AuditLog)) { + return false; + } + return getId() != null && getId().equals(((AuditLog) o).getId()); + } + + @Override + public int hashCode() { + // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/ + return getClass().hashCode(); + } + + // prettier-ignore + @Override + public String toString() { + return "AuditLog{" + + "id=" + getId() + + ", entitaTipo='" + getEntitaTipo() + "'" + + ", entitaId=" + getEntitaId() + + ", azione='" + getAzione() + "'" + + ", dettagli='" + getDettagli() + "'" + + ", ipAddress='" + getIpAddress() + "'" + + ", createdAt='" + getCreatedAt() + "'" + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/Conferma.java b/src/main/java/it/sw/pa/comune/artegna/domain/Conferma.java new file mode 100644 index 0000000..34a307c --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/Conferma.java @@ -0,0 +1,145 @@ +package it.sw.pa.comune.artegna.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import it.sw.pa.comune.artegna.domain.enumeration.TipoConferma; +import jakarta.persistence.*; +import java.io.Serial; +import java.io.Serializable; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +/** + * A Conferma. + */ +@Entity +@Table(name = "conferma") +@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) +@SuppressWarnings("common-java:DuplicatedBlocks") +public class Conferma implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + @Column(name = "id") + private Long id; + + @Column(name = "motivo_conferma") + private String motivoConferma; + + @Enumerated(EnumType.STRING) + @Column(name = "tipo_conferma") + private TipoConferma tipoConferma; + + @ManyToOne(fetch = FetchType.LAZY) + @JsonIgnoreProperties(value = { "liberatories" }, allowSetters = true) + private UtenteApp confermataDa; + + @JsonIgnoreProperties(value = { "conferma", "utente", "struttura" }, allowSetters = true) + @OneToOne(fetch = FetchType.LAZY, mappedBy = "conferma") + private Prenotazione prenotazione; + + // jhipster-needle-entity-add-field - JHipster will add fields here + + public Long getId() { + return this.id; + } + + public Conferma id(Long id) { + this.setId(id); + return this; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMotivoConferma() { + return this.motivoConferma; + } + + public Conferma motivoConferma(String motivoConferma) { + this.setMotivoConferma(motivoConferma); + return this; + } + + public void setMotivoConferma(String motivoConferma) { + this.motivoConferma = motivoConferma; + } + + public TipoConferma getTipoConferma() { + return this.tipoConferma; + } + + public Conferma tipoConferma(TipoConferma tipoConferma) { + this.setTipoConferma(tipoConferma); + return this; + } + + public void setTipoConferma(TipoConferma tipoConferma) { + this.tipoConferma = tipoConferma; + } + + public UtenteApp getConfermataDa() { + return this.confermataDa; + } + + public void setConfermataDa(UtenteApp utenteApp) { + this.confermataDa = utenteApp; + } + + public Conferma confermataDa(UtenteApp utenteApp) { + this.setConfermataDa(utenteApp); + return this; + } + + public Prenotazione getPrenotazione() { + return this.prenotazione; + } + + public void setPrenotazione(Prenotazione prenotazione) { + if (this.prenotazione != null) { + this.prenotazione.setConferma(null); + } + if (prenotazione != null) { + prenotazione.setConferma(this); + } + this.prenotazione = prenotazione; + } + + public Conferma prenotazione(Prenotazione prenotazione) { + this.setPrenotazione(prenotazione); + return this; + } + + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Conferma)) { + return false; + } + return getId() != null && getId().equals(((Conferma) o).getId()); + } + + @Override + public int hashCode() { + // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/ + return getClass().hashCode(); + } + + // prettier-ignore + @Override + public String toString() { + return "Conferma{" + + "id=" + getId() + + ", motivoConferma='" + getMotivoConferma() + "'" + + ", tipoConferma='" + getTipoConferma() + "'" + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/Disponibilita.java b/src/main/java/it/sw/pa/comune/artegna/domain/Disponibilita.java new file mode 100644 index 0000000..020b3f6 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/Disponibilita.java @@ -0,0 +1,228 @@ +package it.sw.pa.comune.artegna.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import it.sw.pa.comune.artegna.domain.enumeration.GiornoSettimana; +import it.sw.pa.comune.artegna.domain.enumeration.TipoDisponibilita; +import jakarta.persistence.*; +import java.io.Serial; +import java.io.Serializable; +import java.time.Instant; +import java.time.LocalDate; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +/** + * A Disponibilita. + */ +@Entity +@Table(name = "disponibilita") +@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) +@SuppressWarnings("common-java:DuplicatedBlocks") +public class Disponibilita implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + @Column(name = "id") + private Long id; + + @Enumerated(EnumType.STRING) + @Column(name = "giorno_settimana") + private GiornoSettimana giornoSettimana; + + @Column(name = "data_specifica") + private LocalDate dataSpecifica; + + @Column(name = "ora_inizio") + private Instant oraInizio; + + @Column(name = "ora_fine") + private Instant oraFine; + + @Column(name = "orario_inizio") + private String orarioInizio; + + @Column(name = "orario_fine") + private String orarioFine; + + @Enumerated(EnumType.STRING) + @Column(name = "tipo") + private TipoDisponibilita tipo; + + @Column(name = "note") + private String note; + + @ManyToOne(fetch = FetchType.LAZY) + @JsonIgnoreProperties(value = { "disponibilitas", "moduliLiberatories" }, allowSetters = true) + private Struttura struttura; + + // jhipster-needle-entity-add-field - JHipster will add fields here + + public Long getId() { + return this.id; + } + + public Disponibilita id(Long id) { + this.setId(id); + return this; + } + + public void setId(Long id) { + this.id = id; + } + + public GiornoSettimana getGiornoSettimana() { + return this.giornoSettimana; + } + + public Disponibilita giornoSettimana(GiornoSettimana giornoSettimana) { + this.setGiornoSettimana(giornoSettimana); + return this; + } + + public void setGiornoSettimana(GiornoSettimana giornoSettimana) { + this.giornoSettimana = giornoSettimana; + } + + public LocalDate getDataSpecifica() { + return this.dataSpecifica; + } + + public Disponibilita dataSpecifica(LocalDate dataSpecifica) { + this.setDataSpecifica(dataSpecifica); + return this; + } + + public void setDataSpecifica(LocalDate dataSpecifica) { + this.dataSpecifica = dataSpecifica; + } + + public Instant getOraInizio() { + return this.oraInizio; + } + + public Disponibilita oraInizio(Instant oraInizio) { + this.setOraInizio(oraInizio); + return this; + } + + public void setOraInizio(Instant oraInizio) { + this.oraInizio = oraInizio; + } + + public Instant getOraFine() { + return this.oraFine; + } + + public Disponibilita oraFine(Instant oraFine) { + this.setOraFine(oraFine); + return this; + } + + public void setOraFine(Instant oraFine) { + this.oraFine = oraFine; + } + + public String getOrarioInizio() { + return this.orarioInizio; + } + + public Disponibilita orarioInizio(String orarioInizio) { + this.setOrarioInizio(orarioInizio); + return this; + } + + public void setOrarioInizio(String orarioInizio) { + this.orarioInizio = orarioInizio; + } + + public String getOrarioFine() { + return this.orarioFine; + } + + public Disponibilita orarioFine(String orarioFine) { + this.setOrarioFine(orarioFine); + return this; + } + + public void setOrarioFine(String orarioFine) { + this.orarioFine = orarioFine; + } + + public TipoDisponibilita getTipo() { + return this.tipo; + } + + public Disponibilita tipo(TipoDisponibilita tipo) { + this.setTipo(tipo); + return this; + } + + public void setTipo(TipoDisponibilita tipo) { + this.tipo = tipo; + } + + public String getNote() { + return this.note; + } + + public Disponibilita note(String note) { + this.setNote(note); + return this; + } + + public void setNote(String note) { + this.note = note; + } + + public Struttura getStruttura() { + return this.struttura; + } + + public void setStruttura(Struttura struttura) { + this.struttura = struttura; + } + + public Disponibilita struttura(Struttura struttura) { + this.setStruttura(struttura); + return this; + } + + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Disponibilita)) { + return false; + } + return getId() != null && getId().equals(((Disponibilita) o).getId()); + } + + @Override + public int hashCode() { + // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/ + return getClass().hashCode(); + } + + // prettier-ignore + @Override + public String toString() { + return "Disponibilita{" + + "id=" + getId() + + ", giornoSettimana='" + getGiornoSettimana() + "'" + + ", dataSpecifica='" + getDataSpecifica() + "'" + + ", oraInizio='" + getOraInizio() + "'" + + ", oraFine='" + getOraFine() + "'" + + ", orarioInizio='" + getOrarioInizio() + "'" + + ", orarioFine='" + getOrarioFine() + "'" + + ", tipo='" + getTipo() + "'" + + ", note='" + getNote() + "'" + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/Liberatoria.java b/src/main/java/it/sw/pa/comune/artegna/domain/Liberatoria.java new file mode 100644 index 0000000..dd680b3 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/Liberatoria.java @@ -0,0 +1,121 @@ +package it.sw.pa.comune.artegna.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import jakarta.persistence.*; +import java.io.Serial; +import java.io.Serializable; +import java.time.Instant; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +/** + * A Liberatoria. + */ +@Entity +@Table(name = "liberatoria") +@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) +@SuppressWarnings("common-java:DuplicatedBlocks") +public class Liberatoria implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + @Column(name = "id") + private Long id; + + @Column(name = "accettata") + private Instant accettata; + + @ManyToOne(fetch = FetchType.LAZY) + @JsonIgnoreProperties(value = { "liberatories" }, allowSetters = true) + private UtenteApp utente; + + @ManyToOne(fetch = FetchType.LAZY) + @JsonIgnoreProperties(value = { "struttura" }, allowSetters = true) + private ModelloLiberatoria modelloLiberatoria; + + // jhipster-needle-entity-add-field - JHipster will add fields here + + public Long getId() { + return this.id; + } + + public Liberatoria id(Long id) { + this.setId(id); + return this; + } + + public void setId(Long id) { + this.id = id; + } + + public Instant getAccettata() { + return this.accettata; + } + + public Liberatoria accettata(Instant accettata) { + this.setAccettata(accettata); + return this; + } + + public void setAccettata(Instant accettata) { + this.accettata = accettata; + } + + public UtenteApp getUtente() { + return this.utente; + } + + public void setUtente(UtenteApp utenteApp) { + this.utente = utenteApp; + } + + public Liberatoria utente(UtenteApp utenteApp) { + this.setUtente(utenteApp); + return this; + } + + public ModelloLiberatoria getModelloLiberatoria() { + return this.modelloLiberatoria; + } + + public void setModelloLiberatoria(ModelloLiberatoria modelloLiberatoria) { + this.modelloLiberatoria = modelloLiberatoria; + } + + public Liberatoria modelloLiberatoria(ModelloLiberatoria modelloLiberatoria) { + this.setModelloLiberatoria(modelloLiberatoria); + return this; + } + + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Liberatoria)) { + return false; + } + return getId() != null && getId().equals(((Liberatoria) o).getId()); + } + + @Override + public int hashCode() { + // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/ + return getClass().hashCode(); + } + + // prettier-ignore + @Override + public String toString() { + return "Liberatoria{" + + "id=" + getId() + + ", accettata='" + getAccettata() + "'" + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/Messaggio.java b/src/main/java/it/sw/pa/comune/artegna/domain/Messaggio.java new file mode 100644 index 0000000..4cfb64f --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/Messaggio.java @@ -0,0 +1,138 @@ +package it.sw.pa.comune.artegna.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import jakarta.persistence.*; +import java.io.Serial; +import java.io.Serializable; +import java.time.Instant; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +/** + * A Messaggio. + */ +@Entity +@Table(name = "messaggio") +@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) +@SuppressWarnings("common-java:DuplicatedBlocks") +public class Messaggio implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + @Column(name = "id") + private Long id; + + @Column(name = "spedito") + private Instant spedito; + + @Column(name = "testo") + private String testo; + + @Column(name = "letto") + private Instant letto; + + @ManyToOne(fetch = FetchType.LAZY) + @JsonIgnoreProperties(value = { "liberatories" }, allowSetters = true) + private UtenteApp utente; + + // jhipster-needle-entity-add-field - JHipster will add fields here + + public Long getId() { + return this.id; + } + + public Messaggio id(Long id) { + this.setId(id); + return this; + } + + public void setId(Long id) { + this.id = id; + } + + public Instant getSpedito() { + return this.spedito; + } + + public Messaggio spedito(Instant spedito) { + this.setSpedito(spedito); + return this; + } + + public void setSpedito(Instant spedito) { + this.spedito = spedito; + } + + public String getTesto() { + return this.testo; + } + + public Messaggio testo(String testo) { + this.setTesto(testo); + return this; + } + + public void setTesto(String testo) { + this.testo = testo; + } + + public Instant getLetto() { + return this.letto; + } + + public Messaggio letto(Instant letto) { + this.setLetto(letto); + return this; + } + + public void setLetto(Instant letto) { + this.letto = letto; + } + + public UtenteApp getUtente() { + return this.utente; + } + + public void setUtente(UtenteApp utenteApp) { + this.utente = utenteApp; + } + + public Messaggio utente(UtenteApp utenteApp) { + this.setUtente(utenteApp); + return this; + } + + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Messaggio)) { + return false; + } + return getId() != null && getId().equals(((Messaggio) o).getId()); + } + + @Override + public int hashCode() { + // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/ + return getClass().hashCode(); + } + + // prettier-ignore + @Override + public String toString() { + return "Messaggio{" + + "id=" + getId() + + ", spedito='" + getSpedito() + "'" + + ", testo='" + getTesto() + "'" + + ", letto='" + getLetto() + "'" + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoria.java b/src/main/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoria.java new file mode 100644 index 0000000..eeabe2c --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoria.java @@ -0,0 +1,190 @@ +package it.sw.pa.comune.artegna.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import jakarta.persistence.*; +import java.io.Serial; +import java.io.Serializable; +import java.time.Instant; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +/** + * A ModelloLiberatoria. + */ +@Entity +@Table(name = "modello_liberatoria") +@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) +@SuppressWarnings("common-java:DuplicatedBlocks") +public class ModelloLiberatoria implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + @Column(name = "id") + private Long id; + + @Column(name = "nome") + private String nome; + + @Column(name = "testo") + private String testo; + + @Lob + @Column(name = "documento") + private byte[] documento; + + @Column(name = "documento_content_type") + private String documentoContentType; + + @Column(name = "valido_dal") + private Instant validoDal; + + @Column(name = "valido_al") + private Instant validoAl; + + @ManyToOne(fetch = FetchType.LAZY) + @JsonIgnoreProperties(value = { "disponibilitas", "moduliLiberatories" }, allowSetters = true) + private Struttura struttura; + + // jhipster-needle-entity-add-field - JHipster will add fields here + + public Long getId() { + return this.id; + } + + public ModelloLiberatoria id(Long id) { + this.setId(id); + return this; + } + + public void setId(Long id) { + this.id = id; + } + + public String getNome() { + return this.nome; + } + + public ModelloLiberatoria nome(String nome) { + this.setNome(nome); + return this; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public String getTesto() { + return this.testo; + } + + public ModelloLiberatoria testo(String testo) { + this.setTesto(testo); + return this; + } + + public void setTesto(String testo) { + this.testo = testo; + } + + public byte[] getDocumento() { + return this.documento; + } + + public ModelloLiberatoria documento(byte[] documento) { + this.setDocumento(documento); + return this; + } + + public void setDocumento(byte[] documento) { + this.documento = documento; + } + + public String getDocumentoContentType() { + return this.documentoContentType; + } + + public ModelloLiberatoria documentoContentType(String documentoContentType) { + this.documentoContentType = documentoContentType; + return this; + } + + public void setDocumentoContentType(String documentoContentType) { + this.documentoContentType = documentoContentType; + } + + public Instant getValidoDal() { + return this.validoDal; + } + + public ModelloLiberatoria validoDal(Instant validoDal) { + this.setValidoDal(validoDal); + return this; + } + + public void setValidoDal(Instant validoDal) { + this.validoDal = validoDal; + } + + public Instant getValidoAl() { + return this.validoAl; + } + + public ModelloLiberatoria validoAl(Instant validoAl) { + this.setValidoAl(validoAl); + return this; + } + + public void setValidoAl(Instant validoAl) { + this.validoAl = validoAl; + } + + public Struttura getStruttura() { + return this.struttura; + } + + public void setStruttura(Struttura struttura) { + this.struttura = struttura; + } + + public ModelloLiberatoria struttura(Struttura struttura) { + this.setStruttura(struttura); + return this; + } + + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof ModelloLiberatoria)) { + return false; + } + return getId() != null && getId().equals(((ModelloLiberatoria) o).getId()); + } + + @Override + public int hashCode() { + // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/ + return getClass().hashCode(); + } + + // prettier-ignore + @Override + public String toString() { + return "ModelloLiberatoria{" + + "id=" + getId() + + ", nome='" + getNome() + "'" + + ", testo='" + getTesto() + "'" + + ", documento='" + getDocumento() + "'" + + ", documentoContentType='" + getDocumentoContentType() + "'" + + ", validoDal='" + getValidoDal() + "'" + + ", validoAl='" + getValidoAl() + "'" + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/Notifica.java b/src/main/java/it/sw/pa/comune/artegna/domain/Notifica.java new file mode 100644 index 0000000..a391a5b --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/Notifica.java @@ -0,0 +1,210 @@ +package it.sw.pa.comune.artegna.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import it.sw.pa.comune.artegna.domain.enumeration.TipoCanaleNotifica; +import it.sw.pa.comune.artegna.domain.enumeration.TipoEventoNotifica; +import jakarta.persistence.*; +import java.io.Serial; +import java.io.Serializable; +import java.time.Instant; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +/** + * A Notifica. + */ +@Entity +@Table(name = "notifica") +@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) +@SuppressWarnings("common-java:DuplicatedBlocks") +public class Notifica implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + @Column(name = "id") + private Long id; + + @Enumerated(EnumType.STRING) + @Column(name = "tipo_canale") + private TipoCanaleNotifica tipoCanale; + + @Enumerated(EnumType.STRING) + @Column(name = "tipo_evento") + private TipoEventoNotifica tipoEvento; + + @Column(name = "messaggio") + private String messaggio; + + @Column(name = "inviata") + private Boolean inviata; + + @Column(name = "inviata_at") + private Instant inviataAt; + + @Column(name = "errore") + private String errore; + + @Column(name = "created_at") + private Instant createdAt; + + @ManyToOne(fetch = FetchType.LAZY) + @JsonIgnoreProperties(value = { "confermataDa", "prenotazione" }, allowSetters = true) + private Conferma conferma; + + // jhipster-needle-entity-add-field - JHipster will add fields here + + public Long getId() { + return this.id; + } + + public Notifica id(Long id) { + this.setId(id); + return this; + } + + public void setId(Long id) { + this.id = id; + } + + public TipoCanaleNotifica getTipoCanale() { + return this.tipoCanale; + } + + public Notifica tipoCanale(TipoCanaleNotifica tipoCanale) { + this.setTipoCanale(tipoCanale); + return this; + } + + public void setTipoCanale(TipoCanaleNotifica tipoCanale) { + this.tipoCanale = tipoCanale; + } + + public TipoEventoNotifica getTipoEvento() { + return this.tipoEvento; + } + + public Notifica tipoEvento(TipoEventoNotifica tipoEvento) { + this.setTipoEvento(tipoEvento); + return this; + } + + public void setTipoEvento(TipoEventoNotifica tipoEvento) { + this.tipoEvento = tipoEvento; + } + + public String getMessaggio() { + return this.messaggio; + } + + public Notifica messaggio(String messaggio) { + this.setMessaggio(messaggio); + return this; + } + + public void setMessaggio(String messaggio) { + this.messaggio = messaggio; + } + + public Boolean getInviata() { + return this.inviata; + } + + public Notifica inviata(Boolean inviata) { + this.setInviata(inviata); + return this; + } + + public void setInviata(Boolean inviata) { + this.inviata = inviata; + } + + public Instant getInviataAt() { + return this.inviataAt; + } + + public Notifica inviataAt(Instant inviataAt) { + this.setInviataAt(inviataAt); + return this; + } + + public void setInviataAt(Instant inviataAt) { + this.inviataAt = inviataAt; + } + + public String getErrore() { + return this.errore; + } + + public Notifica errore(String errore) { + this.setErrore(errore); + return this; + } + + public void setErrore(String errore) { + this.errore = errore; + } + + public Instant getCreatedAt() { + return this.createdAt; + } + + public Notifica createdAt(Instant createdAt) { + this.setCreatedAt(createdAt); + return this; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Conferma getConferma() { + return this.conferma; + } + + public void setConferma(Conferma conferma) { + this.conferma = conferma; + } + + public Notifica conferma(Conferma conferma) { + this.setConferma(conferma); + return this; + } + + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Notifica)) { + return false; + } + return getId() != null && getId().equals(((Notifica) o).getId()); + } + + @Override + public int hashCode() { + // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/ + return getClass().hashCode(); + } + + // prettier-ignore + @Override + public String toString() { + return "Notifica{" + + "id=" + getId() + + ", tipoCanale='" + getTipoCanale() + "'" + + ", tipoEvento='" + getTipoEvento() + "'" + + ", messaggio='" + getMessaggio() + "'" + + ", inviata='" + getInviata() + "'" + + ", inviataAt='" + getInviataAt() + "'" + + ", errore='" + getErrore() + "'" + + ", createdAt='" + getCreatedAt() + "'" + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/Prenotazione.java b/src/main/java/it/sw/pa/comune/artegna/domain/Prenotazione.java new file mode 100644 index 0000000..a5bafd2 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/Prenotazione.java @@ -0,0 +1,226 @@ +package it.sw.pa.comune.artegna.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import it.sw.pa.comune.artegna.domain.enumeration.StatoPrenotazione; +import jakarta.persistence.*; +import java.io.Serial; +import java.io.Serializable; +import java.time.Instant; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +/** + * A Prenotazione. + */ +@Entity +@Table(name = "prenotazione") +@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) +@SuppressWarnings("common-java:DuplicatedBlocks") +public class Prenotazione implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + @Column(name = "id") + private Long id; + + @Column(name = "ora_inizio") + private Instant oraInizio; + + @Column(name = "ora_fine") + private Instant oraFine; + + @Enumerated(EnumType.STRING) + @Column(name = "stato") + private StatoPrenotazione stato; + + @Column(name = "motivo_evento") + private String motivoEvento; + + @Column(name = "numero_partecipanti") + private Integer numeroPartecipanti; + + @Column(name = "note_utente") + private String noteUtente; + + @JsonIgnoreProperties(value = { "confermataDa", "prenotazione" }, allowSetters = true) + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(unique = true) + private Conferma conferma; + + @ManyToOne(fetch = FetchType.LAZY) + @JsonIgnoreProperties(value = { "liberatories" }, allowSetters = true) + private UtenteApp utente; + + @ManyToOne(fetch = FetchType.LAZY) + @JsonIgnoreProperties(value = { "disponibilitas", "moduliLiberatories" }, allowSetters = true) + private Struttura struttura; + + // jhipster-needle-entity-add-field - JHipster will add fields here + + public Long getId() { + return this.id; + } + + public Prenotazione id(Long id) { + this.setId(id); + return this; + } + + public void setId(Long id) { + this.id = id; + } + + public Instant getOraInizio() { + return this.oraInizio; + } + + public Prenotazione oraInizio(Instant oraInizio) { + this.setOraInizio(oraInizio); + return this; + } + + public void setOraInizio(Instant oraInizio) { + this.oraInizio = oraInizio; + } + + public Instant getOraFine() { + return this.oraFine; + } + + public Prenotazione oraFine(Instant oraFine) { + this.setOraFine(oraFine); + return this; + } + + public void setOraFine(Instant oraFine) { + this.oraFine = oraFine; + } + + public StatoPrenotazione getStato() { + return this.stato; + } + + public Prenotazione stato(StatoPrenotazione stato) { + this.setStato(stato); + return this; + } + + public void setStato(StatoPrenotazione stato) { + this.stato = stato; + } + + public String getMotivoEvento() { + return this.motivoEvento; + } + + public Prenotazione motivoEvento(String motivoEvento) { + this.setMotivoEvento(motivoEvento); + return this; + } + + public void setMotivoEvento(String motivoEvento) { + this.motivoEvento = motivoEvento; + } + + public Integer getNumeroPartecipanti() { + return this.numeroPartecipanti; + } + + public Prenotazione numeroPartecipanti(Integer numeroPartecipanti) { + this.setNumeroPartecipanti(numeroPartecipanti); + return this; + } + + public void setNumeroPartecipanti(Integer numeroPartecipanti) { + this.numeroPartecipanti = numeroPartecipanti; + } + + public String getNoteUtente() { + return this.noteUtente; + } + + public Prenotazione noteUtente(String noteUtente) { + this.setNoteUtente(noteUtente); + return this; + } + + public void setNoteUtente(String noteUtente) { + this.noteUtente = noteUtente; + } + + public Conferma getConferma() { + return this.conferma; + } + + public void setConferma(Conferma conferma) { + this.conferma = conferma; + } + + public Prenotazione conferma(Conferma conferma) { + this.setConferma(conferma); + return this; + } + + public UtenteApp getUtente() { + return this.utente; + } + + public void setUtente(UtenteApp utenteApp) { + this.utente = utenteApp; + } + + public Prenotazione utente(UtenteApp utenteApp) { + this.setUtente(utenteApp); + return this; + } + + public Struttura getStruttura() { + return this.struttura; + } + + public void setStruttura(Struttura struttura) { + this.struttura = struttura; + } + + public Prenotazione struttura(Struttura struttura) { + this.setStruttura(struttura); + return this; + } + + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Prenotazione)) { + return false; + } + return getId() != null && getId().equals(((Prenotazione) o).getId()); + } + + @Override + public int hashCode() { + // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/ + return getClass().hashCode(); + } + + // prettier-ignore + @Override + public String toString() { + return "Prenotazione{" + + "id=" + getId() + + ", oraInizio='" + getOraInizio() + "'" + + ", oraFine='" + getOraFine() + "'" + + ", stato='" + getStato() + "'" + + ", motivoEvento='" + getMotivoEvento() + "'" + + ", numeroPartecipanti=" + getNumeroPartecipanti() + + ", noteUtente='" + getNoteUtente() + "'" + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/Struttura.java b/src/main/java/it/sw/pa/comune/artegna/domain/Struttura.java new file mode 100644 index 0000000..f0cd163 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/Struttura.java @@ -0,0 +1,280 @@ +package it.sw.pa.comune.artegna.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import jakarta.persistence.*; +import java.io.Serial; +import java.io.Serializable; +import java.time.Instant; +import java.util.HashSet; +import java.util.Set; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +/** + * A Struttura. + */ +@Entity +@Table(name = "struttura") +@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) +@SuppressWarnings("common-java:DuplicatedBlocks") +public class Struttura implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + @Column(name = "id") + private Long id; + + @Column(name = "nome") + private String nome; + + @Column(name = "descrizione") + private String descrizione; + + @Column(name = "indirizzo") + private String indirizzo; + + @Column(name = "capienza_max") + private Integer capienzaMax; + + @Column(name = "attiva") + private Boolean attiva; + + @Column(name = "foto_url") + private String fotoUrl; + + @Column(name = "created_at") + private Instant createdAt; + + @Column(name = "updated_at") + private Instant updatedAt; + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "struttura") + @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) + @JsonIgnoreProperties(value = { "struttura" }, allowSetters = true) + private Set disponibilitas = new HashSet<>(); + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "struttura") + @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) + @JsonIgnoreProperties(value = { "struttura" }, allowSetters = true) + private Set moduliLiberatories = new HashSet<>(); + + // jhipster-needle-entity-add-field - JHipster will add fields here + + public Long getId() { + return this.id; + } + + public Struttura id(Long id) { + this.setId(id); + return this; + } + + public void setId(Long id) { + this.id = id; + } + + public String getNome() { + return this.nome; + } + + public Struttura nome(String nome) { + this.setNome(nome); + return this; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public String getDescrizione() { + return this.descrizione; + } + + public Struttura descrizione(String descrizione) { + this.setDescrizione(descrizione); + return this; + } + + public void setDescrizione(String descrizione) { + this.descrizione = descrizione; + } + + public String getIndirizzo() { + return this.indirizzo; + } + + public Struttura indirizzo(String indirizzo) { + this.setIndirizzo(indirizzo); + return this; + } + + public void setIndirizzo(String indirizzo) { + this.indirizzo = indirizzo; + } + + public Integer getCapienzaMax() { + return this.capienzaMax; + } + + public Struttura capienzaMax(Integer capienzaMax) { + this.setCapienzaMax(capienzaMax); + return this; + } + + public void setCapienzaMax(Integer capienzaMax) { + this.capienzaMax = capienzaMax; + } + + public Boolean getAttiva() { + return this.attiva; + } + + public Struttura attiva(Boolean attiva) { + this.setAttiva(attiva); + return this; + } + + public void setAttiva(Boolean attiva) { + this.attiva = attiva; + } + + public String getFotoUrl() { + return this.fotoUrl; + } + + public Struttura fotoUrl(String fotoUrl) { + this.setFotoUrl(fotoUrl); + return this; + } + + public void setFotoUrl(String fotoUrl) { + this.fotoUrl = fotoUrl; + } + + public Instant getCreatedAt() { + return this.createdAt; + } + + public Struttura createdAt(Instant createdAt) { + this.setCreatedAt(createdAt); + return this; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return this.updatedAt; + } + + public Struttura updatedAt(Instant updatedAt) { + this.setUpdatedAt(updatedAt); + return this; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public Set getDisponibilitas() { + return this.disponibilitas; + } + + public void setDisponibilitas(Set disponibilitas) { + if (this.disponibilitas != null) { + this.disponibilitas.forEach(i -> i.setStruttura(null)); + } + if (disponibilitas != null) { + disponibilitas.forEach(i -> i.setStruttura(this)); + } + this.disponibilitas = disponibilitas; + } + + public Struttura disponibilitas(Set disponibilitas) { + this.setDisponibilitas(disponibilitas); + return this; + } + + public Struttura addDisponibilita(Disponibilita disponibilita) { + this.disponibilitas.add(disponibilita); + disponibilita.setStruttura(this); + return this; + } + + public Struttura removeDisponibilita(Disponibilita disponibilita) { + this.disponibilitas.remove(disponibilita); + disponibilita.setStruttura(null); + return this; + } + + public Set getModuliLiberatories() { + return this.moduliLiberatories; + } + + public void setModuliLiberatories(Set modelloLiberatorias) { + if (this.moduliLiberatories != null) { + this.moduliLiberatories.forEach(i -> i.setStruttura(null)); + } + if (modelloLiberatorias != null) { + modelloLiberatorias.forEach(i -> i.setStruttura(this)); + } + this.moduliLiberatories = modelloLiberatorias; + } + + public Struttura moduliLiberatories(Set modelloLiberatorias) { + this.setModuliLiberatories(modelloLiberatorias); + return this; + } + + public Struttura addModuliLiberatorie(ModelloLiberatoria modelloLiberatoria) { + this.moduliLiberatories.add(modelloLiberatoria); + modelloLiberatoria.setStruttura(this); + return this; + } + + public Struttura removeModuliLiberatorie(ModelloLiberatoria modelloLiberatoria) { + this.moduliLiberatories.remove(modelloLiberatoria); + modelloLiberatoria.setStruttura(null); + return this; + } + + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Struttura)) { + return false; + } + return getId() != null && getId().equals(((Struttura) o).getId()); + } + + @Override + public int hashCode() { + // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/ + return getClass().hashCode(); + } + + // prettier-ignore + @Override + public String toString() { + return "Struttura{" + + "id=" + getId() + + ", nome='" + getNome() + "'" + + ", descrizione='" + getDescrizione() + "'" + + ", indirizzo='" + getIndirizzo() + "'" + + ", capienzaMax=" + getCapienzaMax() + + ", attiva='" + getAttiva() + "'" + + ", fotoUrl='" + getFotoUrl() + "'" + + ", createdAt='" + getCreatedAt() + "'" + + ", updatedAt='" + getUpdatedAt() + "'" + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/UtenteApp.java b/src/main/java/it/sw/pa/comune/artegna/domain/UtenteApp.java new file mode 100644 index 0000000..be586ff --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/UtenteApp.java @@ -0,0 +1,369 @@ +package it.sw.pa.comune.artegna.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import it.sw.pa.comune.artegna.domain.enumeration.Ruolo; +import jakarta.persistence.*; +import jakarta.validation.constraints.*; +import java.io.Serial; +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +/** + * A UtenteApp. + */ +@Entity +@Table(name = "utente_app") +@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) +@SuppressWarnings("common-java:DuplicatedBlocks") +public class UtenteApp implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + @Column(name = "id") + private Long id; + + @NotNull + @Column(name = "username", nullable = false, unique = true) + private String username; + + @NotNull + @Column(name = "email", nullable = false) + private String email; + + @Column(name = "telefono") + private String telefono; + + @NotNull + @Enumerated(EnumType.STRING) + @Column(name = "ruolo", nullable = false) + private Ruolo ruolo; + + @NotNull + @Column(name = "attivo", nullable = false) + private Boolean attivo; + + @Column(name = "nome") + private String nome; + + @Column(name = "cognome") + private String cognome; + + @Column(name = "luogo_nascita") + private String luogoNascita; + + @Column(name = "data_nascita") + private String dataNascita; + + @Column(name = "residente") + private String residente; + + @Column(name = "societa") + private String societa; + + @Column(name = "sede") + private String sede; + + @Column(name = "codfiscale") + private String codfiscale; + + @Column(name = "telefono_soc") + private String telefonoSoc; + + @Column(name = "email_soc") + private String emailSoc; + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "utente") + @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) + @JsonIgnoreProperties(value = { "utente", "modelloLiberatoria" }, allowSetters = true) + private Set liberatories = new HashSet<>(); + + // jhipster-needle-entity-add-field - JHipster will add fields here + + public Long getId() { + return this.id; + } + + public UtenteApp id(Long id) { + this.setId(id); + return this; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUsername() { + return this.username; + } + + public UtenteApp username(String username) { + this.setUsername(username); + return this; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getEmail() { + return this.email; + } + + public UtenteApp email(String email) { + this.setEmail(email); + return this; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getTelefono() { + return this.telefono; + } + + public UtenteApp telefono(String telefono) { + this.setTelefono(telefono); + return this; + } + + public void setTelefono(String telefono) { + this.telefono = telefono; + } + + public Ruolo getRuolo() { + return this.ruolo; + } + + public UtenteApp ruolo(Ruolo ruolo) { + this.setRuolo(ruolo); + return this; + } + + public void setRuolo(Ruolo ruolo) { + this.ruolo = ruolo; + } + + public Boolean getAttivo() { + return this.attivo; + } + + public UtenteApp attivo(Boolean attivo) { + this.setAttivo(attivo); + return this; + } + + public void setAttivo(Boolean attivo) { + this.attivo = attivo; + } + + public String getNome() { + return this.nome; + } + + public UtenteApp nome(String nome) { + this.setNome(nome); + return this; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public String getCognome() { + return this.cognome; + } + + public UtenteApp cognome(String cognome) { + this.setCognome(cognome); + return this; + } + + public void setCognome(String cognome) { + this.cognome = cognome; + } + + public String getLuogoNascita() { + return this.luogoNascita; + } + + public UtenteApp luogoNascita(String luogoNascita) { + this.setLuogoNascita(luogoNascita); + return this; + } + + public void setLuogoNascita(String luogoNascita) { + this.luogoNascita = luogoNascita; + } + + public String getDataNascita() { + return this.dataNascita; + } + + public UtenteApp dataNascita(String dataNascita) { + this.setDataNascita(dataNascita); + return this; + } + + public void setDataNascita(String dataNascita) { + this.dataNascita = dataNascita; + } + + public String getResidente() { + return this.residente; + } + + public UtenteApp residente(String residente) { + this.setResidente(residente); + return this; + } + + public void setResidente(String residente) { + this.residente = residente; + } + + public String getSocieta() { + return this.societa; + } + + public UtenteApp societa(String societa) { + this.setSocieta(societa); + return this; + } + + public void setSocieta(String societa) { + this.societa = societa; + } + + public String getSede() { + return this.sede; + } + + public UtenteApp sede(String sede) { + this.setSede(sede); + return this; + } + + public void setSede(String sede) { + this.sede = sede; + } + + public String getCodfiscale() { + return this.codfiscale; + } + + public UtenteApp codfiscale(String codfiscale) { + this.setCodfiscale(codfiscale); + return this; + } + + public void setCodfiscale(String codfiscale) { + this.codfiscale = codfiscale; + } + + public String getTelefonoSoc() { + return this.telefonoSoc; + } + + public UtenteApp telefonoSoc(String telefonoSoc) { + this.setTelefonoSoc(telefonoSoc); + return this; + } + + public void setTelefonoSoc(String telefonoSoc) { + this.telefonoSoc = telefonoSoc; + } + + public String getEmailSoc() { + return this.emailSoc; + } + + public UtenteApp emailSoc(String emailSoc) { + this.setEmailSoc(emailSoc); + return this; + } + + public void setEmailSoc(String emailSoc) { + this.emailSoc = emailSoc; + } + + public Set getLiberatories() { + return this.liberatories; + } + + public void setLiberatories(Set liberatorias) { + if (this.liberatories != null) { + this.liberatories.forEach(i -> i.setUtente(null)); + } + if (liberatorias != null) { + liberatorias.forEach(i -> i.setUtente(this)); + } + this.liberatories = liberatorias; + } + + public UtenteApp liberatories(Set liberatorias) { + this.setLiberatories(liberatorias); + return this; + } + + public UtenteApp addLiberatorie(Liberatoria liberatoria) { + this.liberatories.add(liberatoria); + liberatoria.setUtente(this); + return this; + } + + public UtenteApp removeLiberatorie(Liberatoria liberatoria) { + this.liberatories.remove(liberatoria); + liberatoria.setUtente(null); + return this; + } + + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof UtenteApp)) { + return false; + } + return getId() != null && getId().equals(((UtenteApp) o).getId()); + } + + @Override + public int hashCode() { + // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/ + return getClass().hashCode(); + } + + // prettier-ignore + @Override + public String toString() { + return "UtenteApp{" + + "id=" + getId() + + ", username='" + getUsername() + "'" + + ", email='" + getEmail() + "'" + + ", telefono='" + getTelefono() + "'" + + ", ruolo='" + getRuolo() + "'" + + ", attivo='" + getAttivo() + "'" + + ", nome='" + getNome() + "'" + + ", cognome='" + getCognome() + "'" + + ", luogoNascita='" + getLuogoNascita() + "'" + + ", dataNascita='" + getDataNascita() + "'" + + ", residente='" + getResidente() + "'" + + ", societa='" + getSocieta() + "'" + + ", sede='" + getSede() + "'" + + ", codfiscale='" + getCodfiscale() + "'" + + ", telefonoSoc='" + getTelefonoSoc() + "'" + + ", emailSoc='" + getEmailSoc() + "'" + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/AzioneAudit.java b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/AzioneAudit.java new file mode 100644 index 0000000..c9bf401 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/AzioneAudit.java @@ -0,0 +1,12 @@ +package it.sw.pa.comune.artegna.domain.enumeration; + +/** + * The AzioneAudit enumeration. + */ +public enum AzioneAudit { + CREATE, + UPDATE, + DELETE, + CONFIRM, + REJECT, +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/GiornoSettimana.java b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/GiornoSettimana.java new file mode 100644 index 0000000..995f503 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/GiornoSettimana.java @@ -0,0 +1,14 @@ +package it.sw.pa.comune.artegna.domain.enumeration; + +/** + * The GiornoSettimana enumeration. + */ +public enum GiornoSettimana { + LUNEDI, + MARTEDI, + MERCOLEDI, + GIOVEDI, + VENERDI, + SABATO, + DOMENICA, +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/Ruolo.java b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/Ruolo.java new file mode 100644 index 0000000..a38ce7b --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/Ruolo.java @@ -0,0 +1,10 @@ +package it.sw.pa.comune.artegna.domain.enumeration; + +/** + * The Ruolo enumeration. + */ +public enum Ruolo { + USER, + INCARICATO, + ADMIN, +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/StatoPrenotazione.java b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/StatoPrenotazione.java new file mode 100644 index 0000000..0c6c013 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/StatoPrenotazione.java @@ -0,0 +1,11 @@ +package it.sw.pa.comune.artegna.domain.enumeration; + +/** + * The StatoPrenotazione enumeration. + */ +public enum StatoPrenotazione { + RICHIESTA, + CONFERMATA, + RIFIUTATA, + ANNULLATA, +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoCanaleNotifica.java b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoCanaleNotifica.java new file mode 100644 index 0000000..15aaa92 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoCanaleNotifica.java @@ -0,0 +1,10 @@ +package it.sw.pa.comune.artegna.domain.enumeration; + +/** + * The TipoCanaleNotifica enumeration. + */ +public enum TipoCanaleNotifica { + EMAIL, + WHATSAPP, + SISTEMA, +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoConferma.java b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoConferma.java new file mode 100644 index 0000000..89787b2 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoConferma.java @@ -0,0 +1,9 @@ +package it.sw.pa.comune.artegna.domain.enumeration; + +/** + * The TipoConferma enumeration. + */ +public enum TipoConferma { + CONFERMATA, + RIFIUTATA, +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoDisponibilita.java b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoDisponibilita.java new file mode 100644 index 0000000..ba1c8fa --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoDisponibilita.java @@ -0,0 +1,9 @@ +package it.sw.pa.comune.artegna.domain.enumeration; + +/** + * The TipoDisponibilita enumeration. + */ +public enum TipoDisponibilita { + DISPONIBILE, + CHIUSURA, +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoEntita.java b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoEntita.java new file mode 100644 index 0000000..4adab4b --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoEntita.java @@ -0,0 +1,9 @@ +package it.sw.pa.comune.artegna.domain.enumeration; + +/** + * The TipoEntita enumeration. + */ +public enum TipoEntita { + PRENOTAZIONE, + CONFERMA, +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoEventoNotifica.java b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoEventoNotifica.java new file mode 100644 index 0000000..729b68d --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/TipoEventoNotifica.java @@ -0,0 +1,12 @@ +package it.sw.pa.comune.artegna.domain.enumeration; + +/** + * The TipoEventoNotifica enumeration. + */ +public enum TipoEventoNotifica { + RICHIESTA_CREATA, + PRENOTAZIONE_CONFERMATA, + PRENOTAZIONE_RIFIUTATA, + REMINDER, + ANNULLAMENTO, +} diff --git a/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/package-info.java b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/package-info.java new file mode 100644 index 0000000..abe897b --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/domain/enumeration/package-info.java @@ -0,0 +1,4 @@ +/** + * This package file was generated by JHipster + */ +package it.sw.pa.comune.artegna.domain.enumeration; diff --git a/src/main/java/it/sw/pa/comune/artegna/repository/AuditLogRepository.java b/src/main/java/it/sw/pa/comune/artegna/repository/AuditLogRepository.java new file mode 100644 index 0000000..b4d3576 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/repository/AuditLogRepository.java @@ -0,0 +1,40 @@ +package it.sw.pa.comune.artegna.repository; + +import it.sw.pa.comune.artegna.domain.AuditLog; +import java.util.List; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.*; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +/** + * Spring Data JPA repository for the AuditLog entity. + */ +@Repository +public interface AuditLogRepository extends JpaRepository, JpaSpecificationExecutor { + default Optional findOneWithEagerRelationships(Long id) { + return this.findOneWithToOneRelationships(id); + } + + default List findAllWithEagerRelationships() { + return this.findAllWithToOneRelationships(); + } + + default Page findAllWithEagerRelationships(Pageable pageable) { + return this.findAllWithToOneRelationships(pageable); + } + + @Query( + value = "select auditLog from AuditLog auditLog left join fetch auditLog.utente", + countQuery = "select count(auditLog) from AuditLog auditLog" + ) + Page findAllWithToOneRelationships(Pageable pageable); + + @Query("select auditLog from AuditLog auditLog left join fetch auditLog.utente") + List findAllWithToOneRelationships(); + + @Query("select auditLog from AuditLog auditLog left join fetch auditLog.utente where auditLog.id =:id") + Optional findOneWithToOneRelationships(@Param("id") Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/repository/ConfermaRepository.java b/src/main/java/it/sw/pa/comune/artegna/repository/ConfermaRepository.java new file mode 100644 index 0000000..e9dc566 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/repository/ConfermaRepository.java @@ -0,0 +1,40 @@ +package it.sw.pa.comune.artegna.repository; + +import it.sw.pa.comune.artegna.domain.Conferma; +import java.util.List; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.*; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +/** + * Spring Data JPA repository for the Conferma entity. + */ +@Repository +public interface ConfermaRepository extends JpaRepository, JpaSpecificationExecutor { + default Optional findOneWithEagerRelationships(Long id) { + return this.findOneWithToOneRelationships(id); + } + + default List findAllWithEagerRelationships() { + return this.findAllWithToOneRelationships(); + } + + default Page findAllWithEagerRelationships(Pageable pageable) { + return this.findAllWithToOneRelationships(pageable); + } + + @Query( + value = "select conferma from Conferma conferma left join fetch conferma.confermataDa", + countQuery = "select count(conferma) from Conferma conferma" + ) + Page findAllWithToOneRelationships(Pageable pageable); + + @Query("select conferma from Conferma conferma left join fetch conferma.confermataDa") + List findAllWithToOneRelationships(); + + @Query("select conferma from Conferma conferma left join fetch conferma.confermataDa where conferma.id =:id") + Optional findOneWithToOneRelationships(@Param("id") Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/repository/DisponibilitaRepository.java b/src/main/java/it/sw/pa/comune/artegna/repository/DisponibilitaRepository.java new file mode 100644 index 0000000..27ddb58 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/repository/DisponibilitaRepository.java @@ -0,0 +1,40 @@ +package it.sw.pa.comune.artegna.repository; + +import it.sw.pa.comune.artegna.domain.Disponibilita; +import java.util.List; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.*; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +/** + * Spring Data JPA repository for the Disponibilita entity. + */ +@Repository +public interface DisponibilitaRepository extends JpaRepository { + default Optional findOneWithEagerRelationships(Long id) { + return this.findOneWithToOneRelationships(id); + } + + default List findAllWithEagerRelationships() { + return this.findAllWithToOneRelationships(); + } + + default Page findAllWithEagerRelationships(Pageable pageable) { + return this.findAllWithToOneRelationships(pageable); + } + + @Query( + value = "select disponibilita from Disponibilita disponibilita left join fetch disponibilita.struttura", + countQuery = "select count(disponibilita) from Disponibilita disponibilita" + ) + Page findAllWithToOneRelationships(Pageable pageable); + + @Query("select disponibilita from Disponibilita disponibilita left join fetch disponibilita.struttura") + List findAllWithToOneRelationships(); + + @Query("select disponibilita from Disponibilita disponibilita left join fetch disponibilita.struttura where disponibilita.id =:id") + Optional findOneWithToOneRelationships(@Param("id") Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/repository/LiberatoriaRepository.java b/src/main/java/it/sw/pa/comune/artegna/repository/LiberatoriaRepository.java new file mode 100644 index 0000000..5abc6c9 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/repository/LiberatoriaRepository.java @@ -0,0 +1,40 @@ +package it.sw.pa.comune.artegna.repository; + +import it.sw.pa.comune.artegna.domain.Liberatoria; +import java.util.List; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.*; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +/** + * Spring Data JPA repository for the Liberatoria entity. + */ +@Repository +public interface LiberatoriaRepository extends JpaRepository { + default Optional findOneWithEagerRelationships(Long id) { + return this.findOneWithToOneRelationships(id); + } + + default List findAllWithEagerRelationships() { + return this.findAllWithToOneRelationships(); + } + + default Page findAllWithEagerRelationships(Pageable pageable) { + return this.findAllWithToOneRelationships(pageable); + } + + @Query( + value = "select liberatoria from Liberatoria liberatoria left join fetch liberatoria.utente", + countQuery = "select count(liberatoria) from Liberatoria liberatoria" + ) + Page findAllWithToOneRelationships(Pageable pageable); + + @Query("select liberatoria from Liberatoria liberatoria left join fetch liberatoria.utente") + List findAllWithToOneRelationships(); + + @Query("select liberatoria from Liberatoria liberatoria left join fetch liberatoria.utente where liberatoria.id =:id") + Optional findOneWithToOneRelationships(@Param("id") Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/repository/MessaggioRepository.java b/src/main/java/it/sw/pa/comune/artegna/repository/MessaggioRepository.java new file mode 100644 index 0000000..6191866 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/repository/MessaggioRepository.java @@ -0,0 +1,40 @@ +package it.sw.pa.comune.artegna.repository; + +import it.sw.pa.comune.artegna.domain.Messaggio; +import java.util.List; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.*; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +/** + * Spring Data JPA repository for the Messaggio entity. + */ +@Repository +public interface MessaggioRepository extends JpaRepository { + default Optional findOneWithEagerRelationships(Long id) { + return this.findOneWithToOneRelationships(id); + } + + default List findAllWithEagerRelationships() { + return this.findAllWithToOneRelationships(); + } + + default Page findAllWithEagerRelationships(Pageable pageable) { + return this.findAllWithToOneRelationships(pageable); + } + + @Query( + value = "select messaggio from Messaggio messaggio left join fetch messaggio.utente", + countQuery = "select count(messaggio) from Messaggio messaggio" + ) + Page findAllWithToOneRelationships(Pageable pageable); + + @Query("select messaggio from Messaggio messaggio left join fetch messaggio.utente") + List findAllWithToOneRelationships(); + + @Query("select messaggio from Messaggio messaggio left join fetch messaggio.utente where messaggio.id =:id") + Optional findOneWithToOneRelationships(@Param("id") Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/repository/ModelloLiberatoriaRepository.java b/src/main/java/it/sw/pa/comune/artegna/repository/ModelloLiberatoriaRepository.java new file mode 100644 index 0000000..b588bf6 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/repository/ModelloLiberatoriaRepository.java @@ -0,0 +1,12 @@ +package it.sw.pa.comune.artegna.repository; + +import it.sw.pa.comune.artegna.domain.ModelloLiberatoria; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + +/** + * Spring Data JPA repository for the ModelloLiberatoria entity. + */ +@SuppressWarnings("unused") +@Repository +public interface ModelloLiberatoriaRepository extends JpaRepository {} diff --git a/src/main/java/it/sw/pa/comune/artegna/repository/NotificaRepository.java b/src/main/java/it/sw/pa/comune/artegna/repository/NotificaRepository.java new file mode 100644 index 0000000..9a09c4b --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/repository/NotificaRepository.java @@ -0,0 +1,12 @@ +package it.sw.pa.comune.artegna.repository; + +import it.sw.pa.comune.artegna.domain.Notifica; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + +/** + * Spring Data JPA repository for the Notifica entity. + */ +@SuppressWarnings("unused") +@Repository +public interface NotificaRepository extends JpaRepository, JpaSpecificationExecutor {} diff --git a/src/main/java/it/sw/pa/comune/artegna/repository/PrenotazioneRepository.java b/src/main/java/it/sw/pa/comune/artegna/repository/PrenotazioneRepository.java new file mode 100644 index 0000000..0bcade2 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/repository/PrenotazioneRepository.java @@ -0,0 +1,42 @@ +package it.sw.pa.comune.artegna.repository; + +import it.sw.pa.comune.artegna.domain.Prenotazione; +import java.util.List; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.*; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +/** + * Spring Data JPA repository for the Prenotazione entity. + */ +@Repository +public interface PrenotazioneRepository extends JpaRepository, JpaSpecificationExecutor { + default Optional findOneWithEagerRelationships(Long id) { + return this.findOneWithToOneRelationships(id); + } + + default List findAllWithEagerRelationships() { + return this.findAllWithToOneRelationships(); + } + + default Page findAllWithEagerRelationships(Pageable pageable) { + return this.findAllWithToOneRelationships(pageable); + } + + @Query( + value = "select prenotazione from Prenotazione prenotazione left join fetch prenotazione.utente left join fetch prenotazione.struttura", + countQuery = "select count(prenotazione) from Prenotazione prenotazione" + ) + Page findAllWithToOneRelationships(Pageable pageable); + + @Query("select prenotazione from Prenotazione prenotazione left join fetch prenotazione.utente left join fetch prenotazione.struttura") + List findAllWithToOneRelationships(); + + @Query( + "select prenotazione from Prenotazione prenotazione left join fetch prenotazione.utente left join fetch prenotazione.struttura where prenotazione.id =:id" + ) + Optional findOneWithToOneRelationships(@Param("id") Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/repository/StrutturaRepository.java b/src/main/java/it/sw/pa/comune/artegna/repository/StrutturaRepository.java new file mode 100644 index 0000000..d5b7230 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/repository/StrutturaRepository.java @@ -0,0 +1,12 @@ +package it.sw.pa.comune.artegna.repository; + +import it.sw.pa.comune.artegna.domain.Struttura; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + +/** + * Spring Data JPA repository for the Struttura entity. + */ +@SuppressWarnings("unused") +@Repository +public interface StrutturaRepository extends JpaRepository, JpaSpecificationExecutor {} diff --git a/src/main/java/it/sw/pa/comune/artegna/repository/UtenteAppRepository.java b/src/main/java/it/sw/pa/comune/artegna/repository/UtenteAppRepository.java new file mode 100644 index 0000000..5d09ee4 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/repository/UtenteAppRepository.java @@ -0,0 +1,12 @@ +package it.sw.pa.comune.artegna.repository; + +import it.sw.pa.comune.artegna.domain.UtenteApp; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + +/** + * Spring Data JPA repository for the UtenteApp entity. + */ +@SuppressWarnings("unused") +@Repository +public interface UtenteAppRepository extends JpaRepository {} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/AuditLogQueryService.java b/src/main/java/it/sw/pa/comune/artegna/service/AuditLogQueryService.java new file mode 100644 index 0000000..3e6a3e9 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/AuditLogQueryService.java @@ -0,0 +1,88 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.domain.*; // for static metamodels +import it.sw.pa.comune.artegna.domain.AuditLog; +import it.sw.pa.comune.artegna.repository.AuditLogRepository; +import it.sw.pa.comune.artegna.service.criteria.AuditLogCriteria; +import it.sw.pa.comune.artegna.service.dto.AuditLogDTO; +import it.sw.pa.comune.artegna.service.mapper.AuditLogMapper; +import jakarta.persistence.criteria.JoinType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import tech.jhipster.service.QueryService; + +/** + * Service for executing complex queries for {@link AuditLog} entities in the database. + * The main input is a {@link AuditLogCriteria} which gets converted to {@link Specification}, + * in a way that all the filters must apply. + * It returns a {@link Page} of {@link AuditLogDTO} which fulfills the criteria. + */ +@Service +@Transactional(readOnly = true) +public class AuditLogQueryService extends QueryService { + + private static final Logger LOG = LoggerFactory.getLogger(AuditLogQueryService.class); + + private final AuditLogRepository auditLogRepository; + + private final AuditLogMapper auditLogMapper; + + public AuditLogQueryService(AuditLogRepository auditLogRepository, AuditLogMapper auditLogMapper) { + this.auditLogRepository = auditLogRepository; + this.auditLogMapper = auditLogMapper; + } + + /** + * Return a {@link Page} of {@link AuditLogDTO} which matches the criteria from the database. + * @param criteria The object which holds all the filters, which the entities should match. + * @param page The page, which should be returned. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public Page findByCriteria(AuditLogCriteria criteria, Pageable page) { + LOG.debug("find by criteria : {}, page: {}", criteria, page); + final Specification specification = createSpecification(criteria); + return auditLogRepository.findAll(specification, page).map(auditLogMapper::toDto); + } + + /** + * Return the number of matching entities in the database. + * @param criteria The object which holds all the filters, which the entities should match. + * @return the number of matching entities. + */ + @Transactional(readOnly = true) + public long countByCriteria(AuditLogCriteria criteria) { + LOG.debug("count by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return auditLogRepository.count(specification); + } + + /** + * Function to convert {@link AuditLogCriteria} to a {@link Specification} + * @param criteria The object which holds all the filters, which the entities should match. + * @return the matching {@link Specification} of the entity. + */ + protected Specification createSpecification(AuditLogCriteria criteria) { + Specification specification = Specification.unrestricted(); + if (criteria != null) { + // This has to be called first, because the distinct method returns null + specification = Specification.allOf( + Boolean.TRUE.equals(criteria.getDistinct()) ? distinct(criteria.getDistinct()) : null, + buildRangeSpecification(criteria.getId(), AuditLog_.id), + buildSpecification(criteria.getEntitaTipo(), AuditLog_.entitaTipo), + buildRangeSpecification(criteria.getEntitaId(), AuditLog_.entitaId), + buildSpecification(criteria.getAzione(), AuditLog_.azione), + buildStringSpecification(criteria.getDettagli(), AuditLog_.dettagli), + buildStringSpecification(criteria.getIpAddress(), AuditLog_.ipAddress), + buildRangeSpecification(criteria.getCreatedAt(), AuditLog_.createdAt), + buildSpecification(criteria.getUtenteId(), root -> root.join(AuditLog_.utente, JoinType.LEFT).get(UtenteApp_.id)) + ); + } + return specification; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/AuditLogService.java b/src/main/java/it/sw/pa/comune/artegna/service/AuditLogService.java new file mode 100644 index 0000000..ad0a4ba --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/AuditLogService.java @@ -0,0 +1,58 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.service.dto.AuditLogDTO; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +/** + * Service Interface for managing {@link it.sw.pa.comune.artegna.domain.AuditLog}. + */ +public interface AuditLogService { + /** + * Save a auditLog. + * + * @param auditLogDTO the entity to save. + * @return the persisted entity. + */ + AuditLogDTO save(AuditLogDTO auditLogDTO); + + /** + * Updates a auditLog. + * + * @param auditLogDTO the entity to update. + * @return the persisted entity. + */ + AuditLogDTO update(AuditLogDTO auditLogDTO); + + /** + * Partially updates a auditLog. + * + * @param auditLogDTO the entity to update partially. + * @return the persisted entity. + */ + Optional partialUpdate(AuditLogDTO auditLogDTO); + + /** + * Get all the auditLogs with eager load of many-to-many relationships. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + Page findAllWithEagerRelationships(Pageable pageable); + + /** + * Get the "id" auditLog. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" auditLog. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/ConfermaQueryService.java b/src/main/java/it/sw/pa/comune/artegna/service/ConfermaQueryService.java new file mode 100644 index 0000000..717bce5 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/ConfermaQueryService.java @@ -0,0 +1,89 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.domain.*; // for static metamodels +import it.sw.pa.comune.artegna.domain.Conferma; +import it.sw.pa.comune.artegna.repository.ConfermaRepository; +import it.sw.pa.comune.artegna.service.criteria.ConfermaCriteria; +import it.sw.pa.comune.artegna.service.dto.ConfermaDTO; +import it.sw.pa.comune.artegna.service.mapper.ConfermaMapper; +import jakarta.persistence.criteria.JoinType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import tech.jhipster.service.QueryService; + +/** + * Service for executing complex queries for {@link Conferma} entities in the database. + * The main input is a {@link ConfermaCriteria} which gets converted to {@link Specification}, + * in a way that all the filters must apply. + * It returns a {@link Page} of {@link ConfermaDTO} which fulfills the criteria. + */ +@Service +@Transactional(readOnly = true) +public class ConfermaQueryService extends QueryService { + + private static final Logger LOG = LoggerFactory.getLogger(ConfermaQueryService.class); + + private final ConfermaRepository confermaRepository; + + private final ConfermaMapper confermaMapper; + + public ConfermaQueryService(ConfermaRepository confermaRepository, ConfermaMapper confermaMapper) { + this.confermaRepository = confermaRepository; + this.confermaMapper = confermaMapper; + } + + /** + * Return a {@link Page} of {@link ConfermaDTO} which matches the criteria from the database. + * @param criteria The object which holds all the filters, which the entities should match. + * @param page The page, which should be returned. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public Page findByCriteria(ConfermaCriteria criteria, Pageable page) { + LOG.debug("find by criteria : {}, page: {}", criteria, page); + final Specification specification = createSpecification(criteria); + return confermaRepository.findAll(specification, page).map(confermaMapper::toDto); + } + + /** + * Return the number of matching entities in the database. + * @param criteria The object which holds all the filters, which the entities should match. + * @return the number of matching entities. + */ + @Transactional(readOnly = true) + public long countByCriteria(ConfermaCriteria criteria) { + LOG.debug("count by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return confermaRepository.count(specification); + } + + /** + * Function to convert {@link ConfermaCriteria} to a {@link Specification} + * @param criteria The object which holds all the filters, which the entities should match. + * @return the matching {@link Specification} of the entity. + */ + protected Specification createSpecification(ConfermaCriteria criteria) { + Specification specification = Specification.unrestricted(); + if (criteria != null) { + // This has to be called first, because the distinct method returns null + specification = Specification.allOf( + Boolean.TRUE.equals(criteria.getDistinct()) ? distinct(criteria.getDistinct()) : null, + buildRangeSpecification(criteria.getId(), Conferma_.id), + buildStringSpecification(criteria.getMotivoConferma(), Conferma_.motivoConferma), + buildSpecification(criteria.getTipoConferma(), Conferma_.tipoConferma), + buildSpecification(criteria.getConfermataDaId(), root -> + root.join(Conferma_.confermataDa, JoinType.LEFT).get(UtenteApp_.id) + ), + buildSpecification(criteria.getPrenotazioneId(), root -> + root.join(Conferma_.prenotazione, JoinType.LEFT).get(Prenotazione_.id) + ) + ); + } + return specification; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/ConfermaService.java b/src/main/java/it/sw/pa/comune/artegna/service/ConfermaService.java new file mode 100644 index 0000000..1ccebfe --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/ConfermaService.java @@ -0,0 +1,66 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.service.dto.ConfermaDTO; +import java.util.List; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +/** + * Service Interface for managing {@link it.sw.pa.comune.artegna.domain.Conferma}. + */ +public interface ConfermaService { + /** + * Save a conferma. + * + * @param confermaDTO the entity to save. + * @return the persisted entity. + */ + ConfermaDTO save(ConfermaDTO confermaDTO); + + /** + * Updates a conferma. + * + * @param confermaDTO the entity to update. + * @return the persisted entity. + */ + ConfermaDTO update(ConfermaDTO confermaDTO); + + /** + * Partially updates a conferma. + * + * @param confermaDTO the entity to update partially. + * @return the persisted entity. + */ + Optional partialUpdate(ConfermaDTO confermaDTO); + + /** + * Get all the ConfermaDTO where Prenotazione is {@code null}. + * + * @return the {@link List} of entities. + */ + List findAllWherePrenotazioneIsNull(); + + /** + * Get all the confermas with eager load of many-to-many relationships. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + Page findAllWithEagerRelationships(Pageable pageable); + + /** + * Get the "id" conferma. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" conferma. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/DisponibilitaService.java b/src/main/java/it/sw/pa/comune/artegna/service/DisponibilitaService.java new file mode 100644 index 0000000..81c6431 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/DisponibilitaService.java @@ -0,0 +1,66 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.service.dto.DisponibilitaDTO; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +/** + * Service Interface for managing {@link it.sw.pa.comune.artegna.domain.Disponibilita}. + */ +public interface DisponibilitaService { + /** + * Save a disponibilita. + * + * @param disponibilitaDTO the entity to save. + * @return the persisted entity. + */ + DisponibilitaDTO save(DisponibilitaDTO disponibilitaDTO); + + /** + * Updates a disponibilita. + * + * @param disponibilitaDTO the entity to update. + * @return the persisted entity. + */ + DisponibilitaDTO update(DisponibilitaDTO disponibilitaDTO); + + /** + * Partially updates a disponibilita. + * + * @param disponibilitaDTO the entity to update partially. + * @return the persisted entity. + */ + Optional partialUpdate(DisponibilitaDTO disponibilitaDTO); + + /** + * Get all the disponibilitas. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + Page findAll(Pageable pageable); + + /** + * Get all the disponibilitas with eager load of many-to-many relationships. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + Page findAllWithEagerRelationships(Pageable pageable); + + /** + * Get the "id" disponibilita. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" disponibilita. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/LiberatoriaService.java b/src/main/java/it/sw/pa/comune/artegna/service/LiberatoriaService.java new file mode 100644 index 0000000..782fb3b --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/LiberatoriaService.java @@ -0,0 +1,66 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.service.dto.LiberatoriaDTO; +import java.util.List; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +/** + * Service Interface for managing {@link it.sw.pa.comune.artegna.domain.Liberatoria}. + */ +public interface LiberatoriaService { + /** + * Save a liberatoria. + * + * @param liberatoriaDTO the entity to save. + * @return the persisted entity. + */ + LiberatoriaDTO save(LiberatoriaDTO liberatoriaDTO); + + /** + * Updates a liberatoria. + * + * @param liberatoriaDTO the entity to update. + * @return the persisted entity. + */ + LiberatoriaDTO update(LiberatoriaDTO liberatoriaDTO); + + /** + * Partially updates a liberatoria. + * + * @param liberatoriaDTO the entity to update partially. + * @return the persisted entity. + */ + Optional partialUpdate(LiberatoriaDTO liberatoriaDTO); + + /** + * Get all the liberatorias. + * + * @return the list of entities. + */ + List findAll(); + + /** + * Get all the liberatorias with eager load of many-to-many relationships. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + Page findAllWithEagerRelationships(Pageable pageable); + + /** + * Get the "id" liberatoria. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" liberatoria. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/MessaggioService.java b/src/main/java/it/sw/pa/comune/artegna/service/MessaggioService.java new file mode 100644 index 0000000..ebc8741 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/MessaggioService.java @@ -0,0 +1,66 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.service.dto.MessaggioDTO; +import java.util.List; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +/** + * Service Interface for managing {@link it.sw.pa.comune.artegna.domain.Messaggio}. + */ +public interface MessaggioService { + /** + * Save a messaggio. + * + * @param messaggioDTO the entity to save. + * @return the persisted entity. + */ + MessaggioDTO save(MessaggioDTO messaggioDTO); + + /** + * Updates a messaggio. + * + * @param messaggioDTO the entity to update. + * @return the persisted entity. + */ + MessaggioDTO update(MessaggioDTO messaggioDTO); + + /** + * Partially updates a messaggio. + * + * @param messaggioDTO the entity to update partially. + * @return the persisted entity. + */ + Optional partialUpdate(MessaggioDTO messaggioDTO); + + /** + * Get all the messaggios. + * + * @return the list of entities. + */ + List findAll(); + + /** + * Get all the messaggios with eager load of many-to-many relationships. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + Page findAllWithEagerRelationships(Pageable pageable); + + /** + * Get the "id" messaggio. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" messaggio. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/ModelloLiberatoriaService.java b/src/main/java/it/sw/pa/comune/artegna/service/ModelloLiberatoriaService.java new file mode 100644 index 0000000..0cb4d14 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/ModelloLiberatoriaService.java @@ -0,0 +1,56 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.service.dto.ModelloLiberatoriaDTO; +import java.util.List; +import java.util.Optional; + +/** + * Service Interface for managing {@link it.sw.pa.comune.artegna.domain.ModelloLiberatoria}. + */ +public interface ModelloLiberatoriaService { + /** + * Save a modelloLiberatoria. + * + * @param modelloLiberatoriaDTO the entity to save. + * @return the persisted entity. + */ + ModelloLiberatoriaDTO save(ModelloLiberatoriaDTO modelloLiberatoriaDTO); + + /** + * Updates a modelloLiberatoria. + * + * @param modelloLiberatoriaDTO the entity to update. + * @return the persisted entity. + */ + ModelloLiberatoriaDTO update(ModelloLiberatoriaDTO modelloLiberatoriaDTO); + + /** + * Partially updates a modelloLiberatoria. + * + * @param modelloLiberatoriaDTO the entity to update partially. + * @return the persisted entity. + */ + Optional partialUpdate(ModelloLiberatoriaDTO modelloLiberatoriaDTO); + + /** + * Get all the modelloLiberatorias. + * + * @return the list of entities. + */ + List findAll(); + + /** + * Get the "id" modelloLiberatoria. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" modelloLiberatoria. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/NotificaQueryService.java b/src/main/java/it/sw/pa/comune/artegna/service/NotificaQueryService.java new file mode 100644 index 0000000..2475c6d --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/NotificaQueryService.java @@ -0,0 +1,89 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.domain.*; // for static metamodels +import it.sw.pa.comune.artegna.domain.Notifica; +import it.sw.pa.comune.artegna.repository.NotificaRepository; +import it.sw.pa.comune.artegna.service.criteria.NotificaCriteria; +import it.sw.pa.comune.artegna.service.dto.NotificaDTO; +import it.sw.pa.comune.artegna.service.mapper.NotificaMapper; +import jakarta.persistence.criteria.JoinType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import tech.jhipster.service.QueryService; + +/** + * Service for executing complex queries for {@link Notifica} entities in the database. + * The main input is a {@link NotificaCriteria} which gets converted to {@link Specification}, + * in a way that all the filters must apply. + * It returns a {@link Page} of {@link NotificaDTO} which fulfills the criteria. + */ +@Service +@Transactional(readOnly = true) +public class NotificaQueryService extends QueryService { + + private static final Logger LOG = LoggerFactory.getLogger(NotificaQueryService.class); + + private final NotificaRepository notificaRepository; + + private final NotificaMapper notificaMapper; + + public NotificaQueryService(NotificaRepository notificaRepository, NotificaMapper notificaMapper) { + this.notificaRepository = notificaRepository; + this.notificaMapper = notificaMapper; + } + + /** + * Return a {@link Page} of {@link NotificaDTO} which matches the criteria from the database. + * @param criteria The object which holds all the filters, which the entities should match. + * @param page The page, which should be returned. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public Page findByCriteria(NotificaCriteria criteria, Pageable page) { + LOG.debug("find by criteria : {}, page: {}", criteria, page); + final Specification specification = createSpecification(criteria); + return notificaRepository.findAll(specification, page).map(notificaMapper::toDto); + } + + /** + * Return the number of matching entities in the database. + * @param criteria The object which holds all the filters, which the entities should match. + * @return the number of matching entities. + */ + @Transactional(readOnly = true) + public long countByCriteria(NotificaCriteria criteria) { + LOG.debug("count by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return notificaRepository.count(specification); + } + + /** + * Function to convert {@link NotificaCriteria} to a {@link Specification} + * @param criteria The object which holds all the filters, which the entities should match. + * @return the matching {@link Specification} of the entity. + */ + protected Specification createSpecification(NotificaCriteria criteria) { + Specification specification = Specification.unrestricted(); + if (criteria != null) { + // This has to be called first, because the distinct method returns null + specification = Specification.allOf( + Boolean.TRUE.equals(criteria.getDistinct()) ? distinct(criteria.getDistinct()) : null, + buildRangeSpecification(criteria.getId(), Notifica_.id), + buildSpecification(criteria.getTipoCanale(), Notifica_.tipoCanale), + buildSpecification(criteria.getTipoEvento(), Notifica_.tipoEvento), + buildStringSpecification(criteria.getMessaggio(), Notifica_.messaggio), + buildSpecification(criteria.getInviata(), Notifica_.inviata), + buildRangeSpecification(criteria.getInviataAt(), Notifica_.inviataAt), + buildStringSpecification(criteria.getErrore(), Notifica_.errore), + buildRangeSpecification(criteria.getCreatedAt(), Notifica_.createdAt), + buildSpecification(criteria.getConfermaId(), root -> root.join(Notifica_.conferma, JoinType.LEFT).get(Conferma_.id)) + ); + } + return specification; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/NotificaService.java b/src/main/java/it/sw/pa/comune/artegna/service/NotificaService.java new file mode 100644 index 0000000..2a1441b --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/NotificaService.java @@ -0,0 +1,48 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.service.dto.NotificaDTO; +import java.util.Optional; + +/** + * Service Interface for managing {@link it.sw.pa.comune.artegna.domain.Notifica}. + */ +public interface NotificaService { + /** + * Save a notifica. + * + * @param notificaDTO the entity to save. + * @return the persisted entity. + */ + NotificaDTO save(NotificaDTO notificaDTO); + + /** + * Updates a notifica. + * + * @param notificaDTO the entity to update. + * @return the persisted entity. + */ + NotificaDTO update(NotificaDTO notificaDTO); + + /** + * Partially updates a notifica. + * + * @param notificaDTO the entity to update partially. + * @return the persisted entity. + */ + Optional partialUpdate(NotificaDTO notificaDTO); + + /** + * Get the "id" notifica. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" notifica. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/PrenotazioneQueryService.java b/src/main/java/it/sw/pa/comune/artegna/service/PrenotazioneQueryService.java new file mode 100644 index 0000000..ed6996f --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/PrenotazioneQueryService.java @@ -0,0 +1,90 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.domain.*; // for static metamodels +import it.sw.pa.comune.artegna.domain.Prenotazione; +import it.sw.pa.comune.artegna.repository.PrenotazioneRepository; +import it.sw.pa.comune.artegna.service.criteria.PrenotazioneCriteria; +import it.sw.pa.comune.artegna.service.dto.PrenotazioneDTO; +import it.sw.pa.comune.artegna.service.mapper.PrenotazioneMapper; +import jakarta.persistence.criteria.JoinType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import tech.jhipster.service.QueryService; + +/** + * Service for executing complex queries for {@link Prenotazione} entities in the database. + * The main input is a {@link PrenotazioneCriteria} which gets converted to {@link Specification}, + * in a way that all the filters must apply. + * It returns a {@link Page} of {@link PrenotazioneDTO} which fulfills the criteria. + */ +@Service +@Transactional(readOnly = true) +public class PrenotazioneQueryService extends QueryService { + + private static final Logger LOG = LoggerFactory.getLogger(PrenotazioneQueryService.class); + + private final PrenotazioneRepository prenotazioneRepository; + + private final PrenotazioneMapper prenotazioneMapper; + + public PrenotazioneQueryService(PrenotazioneRepository prenotazioneRepository, PrenotazioneMapper prenotazioneMapper) { + this.prenotazioneRepository = prenotazioneRepository; + this.prenotazioneMapper = prenotazioneMapper; + } + + /** + * Return a {@link Page} of {@link PrenotazioneDTO} which matches the criteria from the database. + * @param criteria The object which holds all the filters, which the entities should match. + * @param page The page, which should be returned. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public Page findByCriteria(PrenotazioneCriteria criteria, Pageable page) { + LOG.debug("find by criteria : {}, page: {}", criteria, page); + final Specification specification = createSpecification(criteria); + return prenotazioneRepository.findAll(specification, page).map(prenotazioneMapper::toDto); + } + + /** + * Return the number of matching entities in the database. + * @param criteria The object which holds all the filters, which the entities should match. + * @return the number of matching entities. + */ + @Transactional(readOnly = true) + public long countByCriteria(PrenotazioneCriteria criteria) { + LOG.debug("count by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return prenotazioneRepository.count(specification); + } + + /** + * Function to convert {@link PrenotazioneCriteria} to a {@link Specification} + * @param criteria The object which holds all the filters, which the entities should match. + * @return the matching {@link Specification} of the entity. + */ + protected Specification createSpecification(PrenotazioneCriteria criteria) { + Specification specification = Specification.unrestricted(); + if (criteria != null) { + // This has to be called first, because the distinct method returns null + specification = Specification.allOf( + Boolean.TRUE.equals(criteria.getDistinct()) ? distinct(criteria.getDistinct()) : null, + buildRangeSpecification(criteria.getId(), Prenotazione_.id), + buildRangeSpecification(criteria.getOraInizio(), Prenotazione_.oraInizio), + buildRangeSpecification(criteria.getOraFine(), Prenotazione_.oraFine), + buildSpecification(criteria.getStato(), Prenotazione_.stato), + buildStringSpecification(criteria.getMotivoEvento(), Prenotazione_.motivoEvento), + buildRangeSpecification(criteria.getNumeroPartecipanti(), Prenotazione_.numeroPartecipanti), + buildStringSpecification(criteria.getNoteUtente(), Prenotazione_.noteUtente), + buildSpecification(criteria.getConfermaId(), root -> root.join(Prenotazione_.conferma, JoinType.LEFT).get(Conferma_.id)), + buildSpecification(criteria.getUtenteId(), root -> root.join(Prenotazione_.utente, JoinType.LEFT).get(UtenteApp_.id)), + buildSpecification(criteria.getStrutturaId(), root -> root.join(Prenotazione_.struttura, JoinType.LEFT).get(Struttura_.id)) + ); + } + return specification; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/PrenotazioneService.java b/src/main/java/it/sw/pa/comune/artegna/service/PrenotazioneService.java new file mode 100644 index 0000000..bc14e6b --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/PrenotazioneService.java @@ -0,0 +1,58 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.service.dto.PrenotazioneDTO; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +/** + * Service Interface for managing {@link it.sw.pa.comune.artegna.domain.Prenotazione}. + */ +public interface PrenotazioneService { + /** + * Save a prenotazione. + * + * @param prenotazioneDTO the entity to save. + * @return the persisted entity. + */ + PrenotazioneDTO save(PrenotazioneDTO prenotazioneDTO); + + /** + * Updates a prenotazione. + * + * @param prenotazioneDTO the entity to update. + * @return the persisted entity. + */ + PrenotazioneDTO update(PrenotazioneDTO prenotazioneDTO); + + /** + * Partially updates a prenotazione. + * + * @param prenotazioneDTO the entity to update partially. + * @return the persisted entity. + */ + Optional partialUpdate(PrenotazioneDTO prenotazioneDTO); + + /** + * Get all the prenotaziones with eager load of many-to-many relationships. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + Page findAllWithEagerRelationships(Pageable pageable); + + /** + * Get the "id" prenotazione. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" prenotazione. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/StrutturaQueryService.java b/src/main/java/it/sw/pa/comune/artegna/service/StrutturaQueryService.java new file mode 100644 index 0000000..e49aa77 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/StrutturaQueryService.java @@ -0,0 +1,95 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.domain.*; // for static metamodels +import it.sw.pa.comune.artegna.domain.Struttura; +import it.sw.pa.comune.artegna.repository.StrutturaRepository; +import it.sw.pa.comune.artegna.service.criteria.StrutturaCriteria; +import it.sw.pa.comune.artegna.service.dto.StrutturaDTO; +import it.sw.pa.comune.artegna.service.mapper.StrutturaMapper; +import jakarta.persistence.criteria.JoinType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import tech.jhipster.service.QueryService; + +/** + * Service for executing complex queries for {@link Struttura} entities in the database. + * The main input is a {@link StrutturaCriteria} which gets converted to {@link Specification}, + * in a way that all the filters must apply. + * It returns a {@link Page} of {@link StrutturaDTO} which fulfills the criteria. + */ +@Service +@Transactional(readOnly = true) +public class StrutturaQueryService extends QueryService { + + private static final Logger LOG = LoggerFactory.getLogger(StrutturaQueryService.class); + + private final StrutturaRepository strutturaRepository; + + private final StrutturaMapper strutturaMapper; + + public StrutturaQueryService(StrutturaRepository strutturaRepository, StrutturaMapper strutturaMapper) { + this.strutturaRepository = strutturaRepository; + this.strutturaMapper = strutturaMapper; + } + + /** + * Return a {@link Page} of {@link StrutturaDTO} which matches the criteria from the database. + * @param criteria The object which holds all the filters, which the entities should match. + * @param page The page, which should be returned. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public Page findByCriteria(StrutturaCriteria criteria, Pageable page) { + LOG.debug("find by criteria : {}, page: {}", criteria, page); + final Specification specification = createSpecification(criteria); + return strutturaRepository.findAll(specification, page).map(strutturaMapper::toDto); + } + + /** + * Return the number of matching entities in the database. + * @param criteria The object which holds all the filters, which the entities should match. + * @return the number of matching entities. + */ + @Transactional(readOnly = true) + public long countByCriteria(StrutturaCriteria criteria) { + LOG.debug("count by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return strutturaRepository.count(specification); + } + + /** + * Function to convert {@link StrutturaCriteria} to a {@link Specification} + * @param criteria The object which holds all the filters, which the entities should match. + * @return the matching {@link Specification} of the entity. + */ + protected Specification createSpecification(StrutturaCriteria criteria) { + Specification specification = Specification.unrestricted(); + if (criteria != null) { + // This has to be called first, because the distinct method returns null + specification = Specification.allOf( + Boolean.TRUE.equals(criteria.getDistinct()) ? distinct(criteria.getDistinct()) : null, + buildRangeSpecification(criteria.getId(), Struttura_.id), + buildStringSpecification(criteria.getNome(), Struttura_.nome), + buildStringSpecification(criteria.getDescrizione(), Struttura_.descrizione), + buildStringSpecification(criteria.getIndirizzo(), Struttura_.indirizzo), + buildRangeSpecification(criteria.getCapienzaMax(), Struttura_.capienzaMax), + buildSpecification(criteria.getAttiva(), Struttura_.attiva), + buildStringSpecification(criteria.getFotoUrl(), Struttura_.fotoUrl), + buildRangeSpecification(criteria.getCreatedAt(), Struttura_.createdAt), + buildRangeSpecification(criteria.getUpdatedAt(), Struttura_.updatedAt), + buildSpecification(criteria.getDisponibilitaId(), root -> + root.join(Struttura_.disponibilitas, JoinType.LEFT).get(Disponibilita_.id) + ), + buildSpecification(criteria.getModuliLiberatorieId(), root -> + root.join(Struttura_.moduliLiberatories, JoinType.LEFT).get(ModelloLiberatoria_.id) + ) + ); + } + return specification; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/StrutturaService.java b/src/main/java/it/sw/pa/comune/artegna/service/StrutturaService.java new file mode 100644 index 0000000..fc9173a --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/StrutturaService.java @@ -0,0 +1,48 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.service.dto.StrutturaDTO; +import java.util.Optional; + +/** + * Service Interface for managing {@link it.sw.pa.comune.artegna.domain.Struttura}. + */ +public interface StrutturaService { + /** + * Save a struttura. + * + * @param strutturaDTO the entity to save. + * @return the persisted entity. + */ + StrutturaDTO save(StrutturaDTO strutturaDTO); + + /** + * Updates a struttura. + * + * @param strutturaDTO the entity to update. + * @return the persisted entity. + */ + StrutturaDTO update(StrutturaDTO strutturaDTO); + + /** + * Partially updates a struttura. + * + * @param strutturaDTO the entity to update partially. + * @return the persisted entity. + */ + Optional partialUpdate(StrutturaDTO strutturaDTO); + + /** + * Get the "id" struttura. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" struttura. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/UtenteAppService.java b/src/main/java/it/sw/pa/comune/artegna/service/UtenteAppService.java new file mode 100644 index 0000000..f5f3adc --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/UtenteAppService.java @@ -0,0 +1,56 @@ +package it.sw.pa.comune.artegna.service; + +import it.sw.pa.comune.artegna.service.dto.UtenteAppDTO; +import java.util.List; +import java.util.Optional; + +/** + * Service Interface for managing {@link it.sw.pa.comune.artegna.domain.UtenteApp}. + */ +public interface UtenteAppService { + /** + * Save a utenteApp. + * + * @param utenteAppDTO the entity to save. + * @return the persisted entity. + */ + UtenteAppDTO save(UtenteAppDTO utenteAppDTO); + + /** + * Updates a utenteApp. + * + * @param utenteAppDTO the entity to update. + * @return the persisted entity. + */ + UtenteAppDTO update(UtenteAppDTO utenteAppDTO); + + /** + * Partially updates a utenteApp. + * + * @param utenteAppDTO the entity to update partially. + * @return the persisted entity. + */ + Optional partialUpdate(UtenteAppDTO utenteAppDTO); + + /** + * Get all the utenteApps. + * + * @return the list of entities. + */ + List findAll(); + + /** + * Get the "id" utenteApp. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" utenteApp. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/criteria/AuditLogCriteria.java b/src/main/java/it/sw/pa/comune/artegna/service/criteria/AuditLogCriteria.java new file mode 100644 index 0000000..ea345ed --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/criteria/AuditLogCriteria.java @@ -0,0 +1,313 @@ +package it.sw.pa.comune.artegna.service.criteria; + +import it.sw.pa.comune.artegna.domain.enumeration.AzioneAudit; +import it.sw.pa.comune.artegna.domain.enumeration.TipoEntita; +import java.io.Serial; +import java.io.Serializable; +import java.util.Objects; +import java.util.Optional; +import org.springdoc.core.annotations.ParameterObject; +import tech.jhipster.service.Criteria; +import tech.jhipster.service.filter.*; + +/** + * Criteria class for the {@link it.sw.pa.comune.artegna.domain.AuditLog} entity. This class is used + * in {@link it.sw.pa.comune.artegna.web.rest.AuditLogResource} to receive all the possible filtering options from + * the Http GET request parameters. + * For example the following could be a valid request: + * {@code /audit-logs?id.greaterThan=5&attr1.contains=something&attr2.specified=false} + * As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use + * fix type specific filters. + */ +@ParameterObject +@SuppressWarnings("common-java:DuplicatedBlocks") +public class AuditLogCriteria implements Serializable, Criteria { + + /** + * Class for filtering TipoEntita + */ + public static class TipoEntitaFilter extends Filter { + + public TipoEntitaFilter() {} + + public TipoEntitaFilter(TipoEntitaFilter filter) { + super(filter); + } + + @Override + public TipoEntitaFilter copy() { + return new TipoEntitaFilter(this); + } + } + + /** + * Class for filtering AzioneAudit + */ + public static class AzioneAuditFilter extends Filter { + + public AzioneAuditFilter() {} + + public AzioneAuditFilter(AzioneAuditFilter filter) { + super(filter); + } + + @Override + public AzioneAuditFilter copy() { + return new AzioneAuditFilter(this); + } + } + + @Serial + private static final long serialVersionUID = 1L; + + private LongFilter id; + + private TipoEntitaFilter entitaTipo; + + private LongFilter entitaId; + + private AzioneAuditFilter azione; + + private StringFilter dettagli; + + private StringFilter ipAddress; + + private InstantFilter createdAt; + + private LongFilter utenteId; + + private Boolean distinct; + + public AuditLogCriteria() {} + + public AuditLogCriteria(AuditLogCriteria other) { + this.id = other.optionalId().map(LongFilter::copy).orElse(null); + this.entitaTipo = other.optionalEntitaTipo().map(TipoEntitaFilter::copy).orElse(null); + this.entitaId = other.optionalEntitaId().map(LongFilter::copy).orElse(null); + this.azione = other.optionalAzione().map(AzioneAuditFilter::copy).orElse(null); + this.dettagli = other.optionalDettagli().map(StringFilter::copy).orElse(null); + this.ipAddress = other.optionalIpAddress().map(StringFilter::copy).orElse(null); + this.createdAt = other.optionalCreatedAt().map(InstantFilter::copy).orElse(null); + this.utenteId = other.optionalUtenteId().map(LongFilter::copy).orElse(null); + this.distinct = other.distinct; + } + + @Override + public AuditLogCriteria copy() { + return new AuditLogCriteria(this); + } + + public LongFilter getId() { + return id; + } + + public Optional optionalId() { + return Optional.ofNullable(id); + } + + public LongFilter id() { + if (id == null) { + setId(new LongFilter()); + } + return id; + } + + public void setId(LongFilter id) { + this.id = id; + } + + public TipoEntitaFilter getEntitaTipo() { + return entitaTipo; + } + + public Optional optionalEntitaTipo() { + return Optional.ofNullable(entitaTipo); + } + + public TipoEntitaFilter entitaTipo() { + if (entitaTipo == null) { + setEntitaTipo(new TipoEntitaFilter()); + } + return entitaTipo; + } + + public void setEntitaTipo(TipoEntitaFilter entitaTipo) { + this.entitaTipo = entitaTipo; + } + + public LongFilter getEntitaId() { + return entitaId; + } + + public Optional optionalEntitaId() { + return Optional.ofNullable(entitaId); + } + + public LongFilter entitaId() { + if (entitaId == null) { + setEntitaId(new LongFilter()); + } + return entitaId; + } + + public void setEntitaId(LongFilter entitaId) { + this.entitaId = entitaId; + } + + public AzioneAuditFilter getAzione() { + return azione; + } + + public Optional optionalAzione() { + return Optional.ofNullable(azione); + } + + public AzioneAuditFilter azione() { + if (azione == null) { + setAzione(new AzioneAuditFilter()); + } + return azione; + } + + public void setAzione(AzioneAuditFilter azione) { + this.azione = azione; + } + + public StringFilter getDettagli() { + return dettagli; + } + + public Optional optionalDettagli() { + return Optional.ofNullable(dettagli); + } + + public StringFilter dettagli() { + if (dettagli == null) { + setDettagli(new StringFilter()); + } + return dettagli; + } + + public void setDettagli(StringFilter dettagli) { + this.dettagli = dettagli; + } + + public StringFilter getIpAddress() { + return ipAddress; + } + + public Optional optionalIpAddress() { + return Optional.ofNullable(ipAddress); + } + + public StringFilter ipAddress() { + if (ipAddress == null) { + setIpAddress(new StringFilter()); + } + return ipAddress; + } + + public void setIpAddress(StringFilter ipAddress) { + this.ipAddress = ipAddress; + } + + public InstantFilter getCreatedAt() { + return createdAt; + } + + public Optional optionalCreatedAt() { + return Optional.ofNullable(createdAt); + } + + public InstantFilter createdAt() { + if (createdAt == null) { + setCreatedAt(new InstantFilter()); + } + return createdAt; + } + + public void setCreatedAt(InstantFilter createdAt) { + this.createdAt = createdAt; + } + + public LongFilter getUtenteId() { + return utenteId; + } + + public Optional optionalUtenteId() { + return Optional.ofNullable(utenteId); + } + + public LongFilter utenteId() { + if (utenteId == null) { + setUtenteId(new LongFilter()); + } + return utenteId; + } + + public void setUtenteId(LongFilter utenteId) { + this.utenteId = utenteId; + } + + public Boolean getDistinct() { + return distinct; + } + + public Optional optionalDistinct() { + return Optional.ofNullable(distinct); + } + + public Boolean distinct() { + if (distinct == null) { + setDistinct(true); + } + return distinct; + } + + public void setDistinct(Boolean distinct) { + this.distinct = distinct; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final AuditLogCriteria that = (AuditLogCriteria) o; + return ( + Objects.equals(id, that.id) && + Objects.equals(entitaTipo, that.entitaTipo) && + Objects.equals(entitaId, that.entitaId) && + Objects.equals(azione, that.azione) && + Objects.equals(dettagli, that.dettagli) && + Objects.equals(ipAddress, that.ipAddress) && + Objects.equals(createdAt, that.createdAt) && + Objects.equals(utenteId, that.utenteId) && + Objects.equals(distinct, that.distinct) + ); + } + + @Override + public int hashCode() { + return Objects.hash(id, entitaTipo, entitaId, azione, dettagli, ipAddress, createdAt, utenteId, distinct); + } + + // prettier-ignore + @Override + public String toString() { + return "AuditLogCriteria{" + + optionalId().map(f -> "id=" + f + ", ").orElse("") + + optionalEntitaTipo().map(f -> "entitaTipo=" + f + ", ").orElse("") + + optionalEntitaId().map(f -> "entitaId=" + f + ", ").orElse("") + + optionalAzione().map(f -> "azione=" + f + ", ").orElse("") + + optionalDettagli().map(f -> "dettagli=" + f + ", ").orElse("") + + optionalIpAddress().map(f -> "ipAddress=" + f + ", ").orElse("") + + optionalCreatedAt().map(f -> "createdAt=" + f + ", ").orElse("") + + optionalUtenteId().map(f -> "utenteId=" + f + ", ").orElse("") + + optionalDistinct().map(f -> "distinct=" + f + ", ").orElse("") + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/criteria/ConfermaCriteria.java b/src/main/java/it/sw/pa/comune/artegna/service/criteria/ConfermaCriteria.java new file mode 100644 index 0000000..1d5e017 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/criteria/ConfermaCriteria.java @@ -0,0 +1,223 @@ +package it.sw.pa.comune.artegna.service.criteria; + +import it.sw.pa.comune.artegna.domain.enumeration.TipoConferma; +import java.io.Serial; +import java.io.Serializable; +import java.util.Objects; +import java.util.Optional; +import org.springdoc.core.annotations.ParameterObject; +import tech.jhipster.service.Criteria; +import tech.jhipster.service.filter.*; + +/** + * Criteria class for the {@link it.sw.pa.comune.artegna.domain.Conferma} entity. This class is used + * in {@link it.sw.pa.comune.artegna.web.rest.ConfermaResource} to receive all the possible filtering options from + * the Http GET request parameters. + * For example the following could be a valid request: + * {@code /confermas?id.greaterThan=5&attr1.contains=something&attr2.specified=false} + * As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use + * fix type specific filters. + */ +@ParameterObject +@SuppressWarnings("common-java:DuplicatedBlocks") +public class ConfermaCriteria implements Serializable, Criteria { + + /** + * Class for filtering TipoConferma + */ + public static class TipoConfermaFilter extends Filter { + + public TipoConfermaFilter() {} + + public TipoConfermaFilter(TipoConfermaFilter filter) { + super(filter); + } + + @Override + public TipoConfermaFilter copy() { + return new TipoConfermaFilter(this); + } + } + + @Serial + private static final long serialVersionUID = 1L; + + private LongFilter id; + + private StringFilter motivoConferma; + + private TipoConfermaFilter tipoConferma; + + private LongFilter confermataDaId; + + private LongFilter prenotazioneId; + + private Boolean distinct; + + public ConfermaCriteria() {} + + public ConfermaCriteria(ConfermaCriteria other) { + this.id = other.optionalId().map(LongFilter::copy).orElse(null); + this.motivoConferma = other.optionalMotivoConferma().map(StringFilter::copy).orElse(null); + this.tipoConferma = other.optionalTipoConferma().map(TipoConfermaFilter::copy).orElse(null); + this.confermataDaId = other.optionalConfermataDaId().map(LongFilter::copy).orElse(null); + this.prenotazioneId = other.optionalPrenotazioneId().map(LongFilter::copy).orElse(null); + this.distinct = other.distinct; + } + + @Override + public ConfermaCriteria copy() { + return new ConfermaCriteria(this); + } + + public LongFilter getId() { + return id; + } + + public Optional optionalId() { + return Optional.ofNullable(id); + } + + public LongFilter id() { + if (id == null) { + setId(new LongFilter()); + } + return id; + } + + public void setId(LongFilter id) { + this.id = id; + } + + public StringFilter getMotivoConferma() { + return motivoConferma; + } + + public Optional optionalMotivoConferma() { + return Optional.ofNullable(motivoConferma); + } + + public StringFilter motivoConferma() { + if (motivoConferma == null) { + setMotivoConferma(new StringFilter()); + } + return motivoConferma; + } + + public void setMotivoConferma(StringFilter motivoConferma) { + this.motivoConferma = motivoConferma; + } + + public TipoConfermaFilter getTipoConferma() { + return tipoConferma; + } + + public Optional optionalTipoConferma() { + return Optional.ofNullable(tipoConferma); + } + + public TipoConfermaFilter tipoConferma() { + if (tipoConferma == null) { + setTipoConferma(new TipoConfermaFilter()); + } + return tipoConferma; + } + + public void setTipoConferma(TipoConfermaFilter tipoConferma) { + this.tipoConferma = tipoConferma; + } + + public LongFilter getConfermataDaId() { + return confermataDaId; + } + + public Optional optionalConfermataDaId() { + return Optional.ofNullable(confermataDaId); + } + + public LongFilter confermataDaId() { + if (confermataDaId == null) { + setConfermataDaId(new LongFilter()); + } + return confermataDaId; + } + + public void setConfermataDaId(LongFilter confermataDaId) { + this.confermataDaId = confermataDaId; + } + + public LongFilter getPrenotazioneId() { + return prenotazioneId; + } + + public Optional optionalPrenotazioneId() { + return Optional.ofNullable(prenotazioneId); + } + + public LongFilter prenotazioneId() { + if (prenotazioneId == null) { + setPrenotazioneId(new LongFilter()); + } + return prenotazioneId; + } + + public void setPrenotazioneId(LongFilter prenotazioneId) { + this.prenotazioneId = prenotazioneId; + } + + public Boolean getDistinct() { + return distinct; + } + + public Optional optionalDistinct() { + return Optional.ofNullable(distinct); + } + + public Boolean distinct() { + if (distinct == null) { + setDistinct(true); + } + return distinct; + } + + public void setDistinct(Boolean distinct) { + this.distinct = distinct; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ConfermaCriteria that = (ConfermaCriteria) o; + return ( + Objects.equals(id, that.id) && + Objects.equals(motivoConferma, that.motivoConferma) && + Objects.equals(tipoConferma, that.tipoConferma) && + Objects.equals(confermataDaId, that.confermataDaId) && + Objects.equals(prenotazioneId, that.prenotazioneId) && + Objects.equals(distinct, that.distinct) + ); + } + + @Override + public int hashCode() { + return Objects.hash(id, motivoConferma, tipoConferma, confermataDaId, prenotazioneId, distinct); + } + + // prettier-ignore + @Override + public String toString() { + return "ConfermaCriteria{" + + optionalId().map(f -> "id=" + f + ", ").orElse("") + + optionalMotivoConferma().map(f -> "motivoConferma=" + f + ", ").orElse("") + + optionalTipoConferma().map(f -> "tipoConferma=" + f + ", ").orElse("") + + optionalConfermataDaId().map(f -> "confermataDaId=" + f + ", ").orElse("") + + optionalPrenotazioneId().map(f -> "prenotazioneId=" + f + ", ").orElse("") + + optionalDistinct().map(f -> "distinct=" + f + ", ").orElse("") + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/criteria/NotificaCriteria.java b/src/main/java/it/sw/pa/comune/artegna/service/criteria/NotificaCriteria.java new file mode 100644 index 0000000..6926c6c --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/criteria/NotificaCriteria.java @@ -0,0 +1,337 @@ +package it.sw.pa.comune.artegna.service.criteria; + +import it.sw.pa.comune.artegna.domain.enumeration.TipoCanaleNotifica; +import it.sw.pa.comune.artegna.domain.enumeration.TipoEventoNotifica; +import java.io.Serial; +import java.io.Serializable; +import java.util.Objects; +import java.util.Optional; +import org.springdoc.core.annotations.ParameterObject; +import tech.jhipster.service.Criteria; +import tech.jhipster.service.filter.*; + +/** + * Criteria class for the {@link it.sw.pa.comune.artegna.domain.Notifica} entity. This class is used + * in {@link it.sw.pa.comune.artegna.web.rest.NotificaResource} to receive all the possible filtering options from + * the Http GET request parameters. + * For example the following could be a valid request: + * {@code /notificas?id.greaterThan=5&attr1.contains=something&attr2.specified=false} + * As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use + * fix type specific filters. + */ +@ParameterObject +@SuppressWarnings("common-java:DuplicatedBlocks") +public class NotificaCriteria implements Serializable, Criteria { + + /** + * Class for filtering TipoCanaleNotifica + */ + public static class TipoCanaleNotificaFilter extends Filter { + + public TipoCanaleNotificaFilter() {} + + public TipoCanaleNotificaFilter(TipoCanaleNotificaFilter filter) { + super(filter); + } + + @Override + public TipoCanaleNotificaFilter copy() { + return new TipoCanaleNotificaFilter(this); + } + } + + /** + * Class for filtering TipoEventoNotifica + */ + public static class TipoEventoNotificaFilter extends Filter { + + public TipoEventoNotificaFilter() {} + + public TipoEventoNotificaFilter(TipoEventoNotificaFilter filter) { + super(filter); + } + + @Override + public TipoEventoNotificaFilter copy() { + return new TipoEventoNotificaFilter(this); + } + } + + @Serial + private static final long serialVersionUID = 1L; + + private LongFilter id; + + private TipoCanaleNotificaFilter tipoCanale; + + private TipoEventoNotificaFilter tipoEvento; + + private StringFilter messaggio; + + private BooleanFilter inviata; + + private InstantFilter inviataAt; + + private StringFilter errore; + + private InstantFilter createdAt; + + private LongFilter confermaId; + + private Boolean distinct; + + public NotificaCriteria() {} + + public NotificaCriteria(NotificaCriteria other) { + this.id = other.optionalId().map(LongFilter::copy).orElse(null); + this.tipoCanale = other.optionalTipoCanale().map(TipoCanaleNotificaFilter::copy).orElse(null); + this.tipoEvento = other.optionalTipoEvento().map(TipoEventoNotificaFilter::copy).orElse(null); + this.messaggio = other.optionalMessaggio().map(StringFilter::copy).orElse(null); + this.inviata = other.optionalInviata().map(BooleanFilter::copy).orElse(null); + this.inviataAt = other.optionalInviataAt().map(InstantFilter::copy).orElse(null); + this.errore = other.optionalErrore().map(StringFilter::copy).orElse(null); + this.createdAt = other.optionalCreatedAt().map(InstantFilter::copy).orElse(null); + this.confermaId = other.optionalConfermaId().map(LongFilter::copy).orElse(null); + this.distinct = other.distinct; + } + + @Override + public NotificaCriteria copy() { + return new NotificaCriteria(this); + } + + public LongFilter getId() { + return id; + } + + public Optional optionalId() { + return Optional.ofNullable(id); + } + + public LongFilter id() { + if (id == null) { + setId(new LongFilter()); + } + return id; + } + + public void setId(LongFilter id) { + this.id = id; + } + + public TipoCanaleNotificaFilter getTipoCanale() { + return tipoCanale; + } + + public Optional optionalTipoCanale() { + return Optional.ofNullable(tipoCanale); + } + + public TipoCanaleNotificaFilter tipoCanale() { + if (tipoCanale == null) { + setTipoCanale(new TipoCanaleNotificaFilter()); + } + return tipoCanale; + } + + public void setTipoCanale(TipoCanaleNotificaFilter tipoCanale) { + this.tipoCanale = tipoCanale; + } + + public TipoEventoNotificaFilter getTipoEvento() { + return tipoEvento; + } + + public Optional optionalTipoEvento() { + return Optional.ofNullable(tipoEvento); + } + + public TipoEventoNotificaFilter tipoEvento() { + if (tipoEvento == null) { + setTipoEvento(new TipoEventoNotificaFilter()); + } + return tipoEvento; + } + + public void setTipoEvento(TipoEventoNotificaFilter tipoEvento) { + this.tipoEvento = tipoEvento; + } + + public StringFilter getMessaggio() { + return messaggio; + } + + public Optional optionalMessaggio() { + return Optional.ofNullable(messaggio); + } + + public StringFilter messaggio() { + if (messaggio == null) { + setMessaggio(new StringFilter()); + } + return messaggio; + } + + public void setMessaggio(StringFilter messaggio) { + this.messaggio = messaggio; + } + + public BooleanFilter getInviata() { + return inviata; + } + + public Optional optionalInviata() { + return Optional.ofNullable(inviata); + } + + public BooleanFilter inviata() { + if (inviata == null) { + setInviata(new BooleanFilter()); + } + return inviata; + } + + public void setInviata(BooleanFilter inviata) { + this.inviata = inviata; + } + + public InstantFilter getInviataAt() { + return inviataAt; + } + + public Optional optionalInviataAt() { + return Optional.ofNullable(inviataAt); + } + + public InstantFilter inviataAt() { + if (inviataAt == null) { + setInviataAt(new InstantFilter()); + } + return inviataAt; + } + + public void setInviataAt(InstantFilter inviataAt) { + this.inviataAt = inviataAt; + } + + public StringFilter getErrore() { + return errore; + } + + public Optional optionalErrore() { + return Optional.ofNullable(errore); + } + + public StringFilter errore() { + if (errore == null) { + setErrore(new StringFilter()); + } + return errore; + } + + public void setErrore(StringFilter errore) { + this.errore = errore; + } + + public InstantFilter getCreatedAt() { + return createdAt; + } + + public Optional optionalCreatedAt() { + return Optional.ofNullable(createdAt); + } + + public InstantFilter createdAt() { + if (createdAt == null) { + setCreatedAt(new InstantFilter()); + } + return createdAt; + } + + public void setCreatedAt(InstantFilter createdAt) { + this.createdAt = createdAt; + } + + public LongFilter getConfermaId() { + return confermaId; + } + + public Optional optionalConfermaId() { + return Optional.ofNullable(confermaId); + } + + public LongFilter confermaId() { + if (confermaId == null) { + setConfermaId(new LongFilter()); + } + return confermaId; + } + + public void setConfermaId(LongFilter confermaId) { + this.confermaId = confermaId; + } + + public Boolean getDistinct() { + return distinct; + } + + public Optional optionalDistinct() { + return Optional.ofNullable(distinct); + } + + public Boolean distinct() { + if (distinct == null) { + setDistinct(true); + } + return distinct; + } + + public void setDistinct(Boolean distinct) { + this.distinct = distinct; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final NotificaCriteria that = (NotificaCriteria) o; + return ( + Objects.equals(id, that.id) && + Objects.equals(tipoCanale, that.tipoCanale) && + Objects.equals(tipoEvento, that.tipoEvento) && + Objects.equals(messaggio, that.messaggio) && + Objects.equals(inviata, that.inviata) && + Objects.equals(inviataAt, that.inviataAt) && + Objects.equals(errore, that.errore) && + Objects.equals(createdAt, that.createdAt) && + Objects.equals(confermaId, that.confermaId) && + Objects.equals(distinct, that.distinct) + ); + } + + @Override + public int hashCode() { + return Objects.hash(id, tipoCanale, tipoEvento, messaggio, inviata, inviataAt, errore, createdAt, confermaId, distinct); + } + + // prettier-ignore + @Override + public String toString() { + return "NotificaCriteria{" + + optionalId().map(f -> "id=" + f + ", ").orElse("") + + optionalTipoCanale().map(f -> "tipoCanale=" + f + ", ").orElse("") + + optionalTipoEvento().map(f -> "tipoEvento=" + f + ", ").orElse("") + + optionalMessaggio().map(f -> "messaggio=" + f + ", ").orElse("") + + optionalInviata().map(f -> "inviata=" + f + ", ").orElse("") + + optionalInviataAt().map(f -> "inviataAt=" + f + ", ").orElse("") + + optionalErrore().map(f -> "errore=" + f + ", ").orElse("") + + optionalCreatedAt().map(f -> "createdAt=" + f + ", ").orElse("") + + optionalConfermaId().map(f -> "confermaId=" + f + ", ").orElse("") + + optionalDistinct().map(f -> "distinct=" + f + ", ").orElse("") + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/criteria/PrenotazioneCriteria.java b/src/main/java/it/sw/pa/comune/artegna/service/criteria/PrenotazioneCriteria.java new file mode 100644 index 0000000..16ceb81 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/criteria/PrenotazioneCriteria.java @@ -0,0 +1,355 @@ +package it.sw.pa.comune.artegna.service.criteria; + +import it.sw.pa.comune.artegna.domain.enumeration.StatoPrenotazione; +import java.io.Serial; +import java.io.Serializable; +import java.util.Objects; +import java.util.Optional; +import org.springdoc.core.annotations.ParameterObject; +import tech.jhipster.service.Criteria; +import tech.jhipster.service.filter.*; + +/** + * Criteria class for the {@link it.sw.pa.comune.artegna.domain.Prenotazione} entity. This class is used + * in {@link it.sw.pa.comune.artegna.web.rest.PrenotazioneResource} to receive all the possible filtering options from + * the Http GET request parameters. + * For example the following could be a valid request: + * {@code /prenotaziones?id.greaterThan=5&attr1.contains=something&attr2.specified=false} + * As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use + * fix type specific filters. + */ +@ParameterObject +@SuppressWarnings("common-java:DuplicatedBlocks") +public class PrenotazioneCriteria implements Serializable, Criteria { + + /** + * Class for filtering StatoPrenotazione + */ + public static class StatoPrenotazioneFilter extends Filter { + + public StatoPrenotazioneFilter() {} + + public StatoPrenotazioneFilter(StatoPrenotazioneFilter filter) { + super(filter); + } + + @Override + public StatoPrenotazioneFilter copy() { + return new StatoPrenotazioneFilter(this); + } + } + + @Serial + private static final long serialVersionUID = 1L; + + private LongFilter id; + + private InstantFilter oraInizio; + + private InstantFilter oraFine; + + private StatoPrenotazioneFilter stato; + + private StringFilter motivoEvento; + + private IntegerFilter numeroPartecipanti; + + private StringFilter noteUtente; + + private LongFilter confermaId; + + private LongFilter utenteId; + + private LongFilter strutturaId; + + private Boolean distinct; + + public PrenotazioneCriteria() {} + + public PrenotazioneCriteria(PrenotazioneCriteria other) { + this.id = other.optionalId().map(LongFilter::copy).orElse(null); + this.oraInizio = other.optionalOraInizio().map(InstantFilter::copy).orElse(null); + this.oraFine = other.optionalOraFine().map(InstantFilter::copy).orElse(null); + this.stato = other.optionalStato().map(StatoPrenotazioneFilter::copy).orElse(null); + this.motivoEvento = other.optionalMotivoEvento().map(StringFilter::copy).orElse(null); + this.numeroPartecipanti = other.optionalNumeroPartecipanti().map(IntegerFilter::copy).orElse(null); + this.noteUtente = other.optionalNoteUtente().map(StringFilter::copy).orElse(null); + this.confermaId = other.optionalConfermaId().map(LongFilter::copy).orElse(null); + this.utenteId = other.optionalUtenteId().map(LongFilter::copy).orElse(null); + this.strutturaId = other.optionalStrutturaId().map(LongFilter::copy).orElse(null); + this.distinct = other.distinct; + } + + @Override + public PrenotazioneCriteria copy() { + return new PrenotazioneCriteria(this); + } + + public LongFilter getId() { + return id; + } + + public Optional optionalId() { + return Optional.ofNullable(id); + } + + public LongFilter id() { + if (id == null) { + setId(new LongFilter()); + } + return id; + } + + public void setId(LongFilter id) { + this.id = id; + } + + public InstantFilter getOraInizio() { + return oraInizio; + } + + public Optional optionalOraInizio() { + return Optional.ofNullable(oraInizio); + } + + public InstantFilter oraInizio() { + if (oraInizio == null) { + setOraInizio(new InstantFilter()); + } + return oraInizio; + } + + public void setOraInizio(InstantFilter oraInizio) { + this.oraInizio = oraInizio; + } + + public InstantFilter getOraFine() { + return oraFine; + } + + public Optional optionalOraFine() { + return Optional.ofNullable(oraFine); + } + + public InstantFilter oraFine() { + if (oraFine == null) { + setOraFine(new InstantFilter()); + } + return oraFine; + } + + public void setOraFine(InstantFilter oraFine) { + this.oraFine = oraFine; + } + + public StatoPrenotazioneFilter getStato() { + return stato; + } + + public Optional optionalStato() { + return Optional.ofNullable(stato); + } + + public StatoPrenotazioneFilter stato() { + if (stato == null) { + setStato(new StatoPrenotazioneFilter()); + } + return stato; + } + + public void setStato(StatoPrenotazioneFilter stato) { + this.stato = stato; + } + + public StringFilter getMotivoEvento() { + return motivoEvento; + } + + public Optional optionalMotivoEvento() { + return Optional.ofNullable(motivoEvento); + } + + public StringFilter motivoEvento() { + if (motivoEvento == null) { + setMotivoEvento(new StringFilter()); + } + return motivoEvento; + } + + public void setMotivoEvento(StringFilter motivoEvento) { + this.motivoEvento = motivoEvento; + } + + public IntegerFilter getNumeroPartecipanti() { + return numeroPartecipanti; + } + + public Optional optionalNumeroPartecipanti() { + return Optional.ofNullable(numeroPartecipanti); + } + + public IntegerFilter numeroPartecipanti() { + if (numeroPartecipanti == null) { + setNumeroPartecipanti(new IntegerFilter()); + } + return numeroPartecipanti; + } + + public void setNumeroPartecipanti(IntegerFilter numeroPartecipanti) { + this.numeroPartecipanti = numeroPartecipanti; + } + + public StringFilter getNoteUtente() { + return noteUtente; + } + + public Optional optionalNoteUtente() { + return Optional.ofNullable(noteUtente); + } + + public StringFilter noteUtente() { + if (noteUtente == null) { + setNoteUtente(new StringFilter()); + } + return noteUtente; + } + + public void setNoteUtente(StringFilter noteUtente) { + this.noteUtente = noteUtente; + } + + public LongFilter getConfermaId() { + return confermaId; + } + + public Optional optionalConfermaId() { + return Optional.ofNullable(confermaId); + } + + public LongFilter confermaId() { + if (confermaId == null) { + setConfermaId(new LongFilter()); + } + return confermaId; + } + + public void setConfermaId(LongFilter confermaId) { + this.confermaId = confermaId; + } + + public LongFilter getUtenteId() { + return utenteId; + } + + public Optional optionalUtenteId() { + return Optional.ofNullable(utenteId); + } + + public LongFilter utenteId() { + if (utenteId == null) { + setUtenteId(new LongFilter()); + } + return utenteId; + } + + public void setUtenteId(LongFilter utenteId) { + this.utenteId = utenteId; + } + + public LongFilter getStrutturaId() { + return strutturaId; + } + + public Optional optionalStrutturaId() { + return Optional.ofNullable(strutturaId); + } + + public LongFilter strutturaId() { + if (strutturaId == null) { + setStrutturaId(new LongFilter()); + } + return strutturaId; + } + + public void setStrutturaId(LongFilter strutturaId) { + this.strutturaId = strutturaId; + } + + public Boolean getDistinct() { + return distinct; + } + + public Optional optionalDistinct() { + return Optional.ofNullable(distinct); + } + + public Boolean distinct() { + if (distinct == null) { + setDistinct(true); + } + return distinct; + } + + public void setDistinct(Boolean distinct) { + this.distinct = distinct; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final PrenotazioneCriteria that = (PrenotazioneCriteria) o; + return ( + Objects.equals(id, that.id) && + Objects.equals(oraInizio, that.oraInizio) && + Objects.equals(oraFine, that.oraFine) && + Objects.equals(stato, that.stato) && + Objects.equals(motivoEvento, that.motivoEvento) && + Objects.equals(numeroPartecipanti, that.numeroPartecipanti) && + Objects.equals(noteUtente, that.noteUtente) && + Objects.equals(confermaId, that.confermaId) && + Objects.equals(utenteId, that.utenteId) && + Objects.equals(strutturaId, that.strutturaId) && + Objects.equals(distinct, that.distinct) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + oraInizio, + oraFine, + stato, + motivoEvento, + numeroPartecipanti, + noteUtente, + confermaId, + utenteId, + strutturaId, + distinct + ); + } + + // prettier-ignore + @Override + public String toString() { + return "PrenotazioneCriteria{" + + optionalId().map(f -> "id=" + f + ", ").orElse("") + + optionalOraInizio().map(f -> "oraInizio=" + f + ", ").orElse("") + + optionalOraFine().map(f -> "oraFine=" + f + ", ").orElse("") + + optionalStato().map(f -> "stato=" + f + ", ").orElse("") + + optionalMotivoEvento().map(f -> "motivoEvento=" + f + ", ").orElse("") + + optionalNumeroPartecipanti().map(f -> "numeroPartecipanti=" + f + ", ").orElse("") + + optionalNoteUtente().map(f -> "noteUtente=" + f + ", ").orElse("") + + optionalConfermaId().map(f -> "confermaId=" + f + ", ").orElse("") + + optionalUtenteId().map(f -> "utenteId=" + f + ", ").orElse("") + + optionalStrutturaId().map(f -> "strutturaId=" + f + ", ").orElse("") + + optionalDistinct().map(f -> "distinct=" + f + ", ").orElse("") + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/criteria/StrutturaCriteria.java b/src/main/java/it/sw/pa/comune/artegna/service/criteria/StrutturaCriteria.java new file mode 100644 index 0000000..c7d3b2c --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/criteria/StrutturaCriteria.java @@ -0,0 +1,362 @@ +package it.sw.pa.comune.artegna.service.criteria; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Objects; +import java.util.Optional; +import org.springdoc.core.annotations.ParameterObject; +import tech.jhipster.service.Criteria; +import tech.jhipster.service.filter.*; + +/** + * Criteria class for the {@link it.sw.pa.comune.artegna.domain.Struttura} entity. This class is used + * in {@link it.sw.pa.comune.artegna.web.rest.StrutturaResource} to receive all the possible filtering options from + * the Http GET request parameters. + * For example the following could be a valid request: + * {@code /strutturas?id.greaterThan=5&attr1.contains=something&attr2.specified=false} + * As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use + * fix type specific filters. + */ +@ParameterObject +@SuppressWarnings("common-java:DuplicatedBlocks") +public class StrutturaCriteria implements Serializable, Criteria { + + @Serial + private static final long serialVersionUID = 1L; + + private LongFilter id; + + private StringFilter nome; + + private StringFilter descrizione; + + private StringFilter indirizzo; + + private IntegerFilter capienzaMax; + + private BooleanFilter attiva; + + private StringFilter fotoUrl; + + private InstantFilter createdAt; + + private InstantFilter updatedAt; + + private LongFilter disponibilitaId; + + private LongFilter moduliLiberatorieId; + + private Boolean distinct; + + public StrutturaCriteria() {} + + public StrutturaCriteria(StrutturaCriteria other) { + this.id = other.optionalId().map(LongFilter::copy).orElse(null); + this.nome = other.optionalNome().map(StringFilter::copy).orElse(null); + this.descrizione = other.optionalDescrizione().map(StringFilter::copy).orElse(null); + this.indirizzo = other.optionalIndirizzo().map(StringFilter::copy).orElse(null); + this.capienzaMax = other.optionalCapienzaMax().map(IntegerFilter::copy).orElse(null); + this.attiva = other.optionalAttiva().map(BooleanFilter::copy).orElse(null); + this.fotoUrl = other.optionalFotoUrl().map(StringFilter::copy).orElse(null); + this.createdAt = other.optionalCreatedAt().map(InstantFilter::copy).orElse(null); + this.updatedAt = other.optionalUpdatedAt().map(InstantFilter::copy).orElse(null); + this.disponibilitaId = other.optionalDisponibilitaId().map(LongFilter::copy).orElse(null); + this.moduliLiberatorieId = other.optionalModuliLiberatorieId().map(LongFilter::copy).orElse(null); + this.distinct = other.distinct; + } + + @Override + public StrutturaCriteria copy() { + return new StrutturaCriteria(this); + } + + public LongFilter getId() { + return id; + } + + public Optional optionalId() { + return Optional.ofNullable(id); + } + + public LongFilter id() { + if (id == null) { + setId(new LongFilter()); + } + return id; + } + + public void setId(LongFilter id) { + this.id = id; + } + + public StringFilter getNome() { + return nome; + } + + public Optional optionalNome() { + return Optional.ofNullable(nome); + } + + public StringFilter nome() { + if (nome == null) { + setNome(new StringFilter()); + } + return nome; + } + + public void setNome(StringFilter nome) { + this.nome = nome; + } + + public StringFilter getDescrizione() { + return descrizione; + } + + public Optional optionalDescrizione() { + return Optional.ofNullable(descrizione); + } + + public StringFilter descrizione() { + if (descrizione == null) { + setDescrizione(new StringFilter()); + } + return descrizione; + } + + public void setDescrizione(StringFilter descrizione) { + this.descrizione = descrizione; + } + + public StringFilter getIndirizzo() { + return indirizzo; + } + + public Optional optionalIndirizzo() { + return Optional.ofNullable(indirizzo); + } + + public StringFilter indirizzo() { + if (indirizzo == null) { + setIndirizzo(new StringFilter()); + } + return indirizzo; + } + + public void setIndirizzo(StringFilter indirizzo) { + this.indirizzo = indirizzo; + } + + public IntegerFilter getCapienzaMax() { + return capienzaMax; + } + + public Optional optionalCapienzaMax() { + return Optional.ofNullable(capienzaMax); + } + + public IntegerFilter capienzaMax() { + if (capienzaMax == null) { + setCapienzaMax(new IntegerFilter()); + } + return capienzaMax; + } + + public void setCapienzaMax(IntegerFilter capienzaMax) { + this.capienzaMax = capienzaMax; + } + + public BooleanFilter getAttiva() { + return attiva; + } + + public Optional optionalAttiva() { + return Optional.ofNullable(attiva); + } + + public BooleanFilter attiva() { + if (attiva == null) { + setAttiva(new BooleanFilter()); + } + return attiva; + } + + public void setAttiva(BooleanFilter attiva) { + this.attiva = attiva; + } + + public StringFilter getFotoUrl() { + return fotoUrl; + } + + public Optional optionalFotoUrl() { + return Optional.ofNullable(fotoUrl); + } + + public StringFilter fotoUrl() { + if (fotoUrl == null) { + setFotoUrl(new StringFilter()); + } + return fotoUrl; + } + + public void setFotoUrl(StringFilter fotoUrl) { + this.fotoUrl = fotoUrl; + } + + public InstantFilter getCreatedAt() { + return createdAt; + } + + public Optional optionalCreatedAt() { + return Optional.ofNullable(createdAt); + } + + public InstantFilter createdAt() { + if (createdAt == null) { + setCreatedAt(new InstantFilter()); + } + return createdAt; + } + + public void setCreatedAt(InstantFilter createdAt) { + this.createdAt = createdAt; + } + + public InstantFilter getUpdatedAt() { + return updatedAt; + } + + public Optional optionalUpdatedAt() { + return Optional.ofNullable(updatedAt); + } + + public InstantFilter updatedAt() { + if (updatedAt == null) { + setUpdatedAt(new InstantFilter()); + } + return updatedAt; + } + + public void setUpdatedAt(InstantFilter updatedAt) { + this.updatedAt = updatedAt; + } + + public LongFilter getDisponibilitaId() { + return disponibilitaId; + } + + public Optional optionalDisponibilitaId() { + return Optional.ofNullable(disponibilitaId); + } + + public LongFilter disponibilitaId() { + if (disponibilitaId == null) { + setDisponibilitaId(new LongFilter()); + } + return disponibilitaId; + } + + public void setDisponibilitaId(LongFilter disponibilitaId) { + this.disponibilitaId = disponibilitaId; + } + + public LongFilter getModuliLiberatorieId() { + return moduliLiberatorieId; + } + + public Optional optionalModuliLiberatorieId() { + return Optional.ofNullable(moduliLiberatorieId); + } + + public LongFilter moduliLiberatorieId() { + if (moduliLiberatorieId == null) { + setModuliLiberatorieId(new LongFilter()); + } + return moduliLiberatorieId; + } + + public void setModuliLiberatorieId(LongFilter moduliLiberatorieId) { + this.moduliLiberatorieId = moduliLiberatorieId; + } + + public Boolean getDistinct() { + return distinct; + } + + public Optional optionalDistinct() { + return Optional.ofNullable(distinct); + } + + public Boolean distinct() { + if (distinct == null) { + setDistinct(true); + } + return distinct; + } + + public void setDistinct(Boolean distinct) { + this.distinct = distinct; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final StrutturaCriteria that = (StrutturaCriteria) o; + return ( + Objects.equals(id, that.id) && + Objects.equals(nome, that.nome) && + Objects.equals(descrizione, that.descrizione) && + Objects.equals(indirizzo, that.indirizzo) && + Objects.equals(capienzaMax, that.capienzaMax) && + Objects.equals(attiva, that.attiva) && + Objects.equals(fotoUrl, that.fotoUrl) && + Objects.equals(createdAt, that.createdAt) && + Objects.equals(updatedAt, that.updatedAt) && + Objects.equals(disponibilitaId, that.disponibilitaId) && + Objects.equals(moduliLiberatorieId, that.moduliLiberatorieId) && + Objects.equals(distinct, that.distinct) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + nome, + descrizione, + indirizzo, + capienzaMax, + attiva, + fotoUrl, + createdAt, + updatedAt, + disponibilitaId, + moduliLiberatorieId, + distinct + ); + } + + // prettier-ignore + @Override + public String toString() { + return "StrutturaCriteria{" + + optionalId().map(f -> "id=" + f + ", ").orElse("") + + optionalNome().map(f -> "nome=" + f + ", ").orElse("") + + optionalDescrizione().map(f -> "descrizione=" + f + ", ").orElse("") + + optionalIndirizzo().map(f -> "indirizzo=" + f + ", ").orElse("") + + optionalCapienzaMax().map(f -> "capienzaMax=" + f + ", ").orElse("") + + optionalAttiva().map(f -> "attiva=" + f + ", ").orElse("") + + optionalFotoUrl().map(f -> "fotoUrl=" + f + ", ").orElse("") + + optionalCreatedAt().map(f -> "createdAt=" + f + ", ").orElse("") + + optionalUpdatedAt().map(f -> "updatedAt=" + f + ", ").orElse("") + + optionalDisponibilitaId().map(f -> "disponibilitaId=" + f + ", ").orElse("") + + optionalModuliLiberatorieId().map(f -> "moduliLiberatorieId=" + f + ", ").orElse("") + + optionalDistinct().map(f -> "distinct=" + f + ", ").orElse("") + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/criteria/package-info.java b/src/main/java/it/sw/pa/comune/artegna/service/criteria/package-info.java new file mode 100644 index 0000000..5accfa0 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/criteria/package-info.java @@ -0,0 +1,4 @@ +/** + * This package file was generated by JHipster + */ +package it.sw.pa.comune.artegna.service.criteria; diff --git a/src/main/java/it/sw/pa/comune/artegna/service/dto/AuditLogDTO.java b/src/main/java/it/sw/pa/comune/artegna/service/dto/AuditLogDTO.java new file mode 100644 index 0000000..873085c --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/dto/AuditLogDTO.java @@ -0,0 +1,130 @@ +package it.sw.pa.comune.artegna.service.dto; + +import it.sw.pa.comune.artegna.domain.enumeration.AzioneAudit; +import it.sw.pa.comune.artegna.domain.enumeration.TipoEntita; +import java.io.Serializable; +import java.time.Instant; +import java.util.Objects; + +/** + * A DTO for the {@link it.sw.pa.comune.artegna.domain.AuditLog} entity. + */ +@SuppressWarnings("common-java:DuplicatedBlocks") +public class AuditLogDTO implements Serializable { + + private Long id; + + private TipoEntita entitaTipo; + + private Long entitaId; + + private AzioneAudit azione; + + private String dettagli; + + private String ipAddress; + + private Instant createdAt; + + private UtenteAppDTO utente; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public TipoEntita getEntitaTipo() { + return entitaTipo; + } + + public void setEntitaTipo(TipoEntita entitaTipo) { + this.entitaTipo = entitaTipo; + } + + public Long getEntitaId() { + return entitaId; + } + + public void setEntitaId(Long entitaId) { + this.entitaId = entitaId; + } + + public AzioneAudit getAzione() { + return azione; + } + + public void setAzione(AzioneAudit azione) { + this.azione = azione; + } + + public String getDettagli() { + return dettagli; + } + + public void setDettagli(String dettagli) { + this.dettagli = dettagli; + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public UtenteAppDTO getUtente() { + return utente; + } + + public void setUtente(UtenteAppDTO utente) { + this.utente = utente; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof AuditLogDTO)) { + return false; + } + + AuditLogDTO auditLogDTO = (AuditLogDTO) o; + if (this.id == null) { + return false; + } + return Objects.equals(this.id, auditLogDTO.id); + } + + @Override + public int hashCode() { + return Objects.hash(this.id); + } + + // prettier-ignore + @Override + public String toString() { + return "AuditLogDTO{" + + "id=" + getId() + + ", entitaTipo='" + getEntitaTipo() + "'" + + ", entitaId=" + getEntitaId() + + ", azione='" + getAzione() + "'" + + ", dettagli='" + getDettagli() + "'" + + ", ipAddress='" + getIpAddress() + "'" + + ", createdAt='" + getCreatedAt() + "'" + + ", utente=" + getUtente() + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/dto/ConfermaDTO.java b/src/main/java/it/sw/pa/comune/artegna/service/dto/ConfermaDTO.java new file mode 100644 index 0000000..a8fd19d --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/dto/ConfermaDTO.java @@ -0,0 +1,84 @@ +package it.sw.pa.comune.artegna.service.dto; + +import it.sw.pa.comune.artegna.domain.enumeration.TipoConferma; +import java.io.Serializable; +import java.util.Objects; + +/** + * A DTO for the {@link it.sw.pa.comune.artegna.domain.Conferma} entity. + */ +@SuppressWarnings("common-java:DuplicatedBlocks") +public class ConfermaDTO implements Serializable { + + private Long id; + + private String motivoConferma; + + private TipoConferma tipoConferma; + + private UtenteAppDTO confermataDa; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMotivoConferma() { + return motivoConferma; + } + + public void setMotivoConferma(String motivoConferma) { + this.motivoConferma = motivoConferma; + } + + public TipoConferma getTipoConferma() { + return tipoConferma; + } + + public void setTipoConferma(TipoConferma tipoConferma) { + this.tipoConferma = tipoConferma; + } + + public UtenteAppDTO getConfermataDa() { + return confermataDa; + } + + public void setConfermataDa(UtenteAppDTO confermataDa) { + this.confermataDa = confermataDa; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof ConfermaDTO)) { + return false; + } + + ConfermaDTO confermaDTO = (ConfermaDTO) o; + if (this.id == null) { + return false; + } + return Objects.equals(this.id, confermaDTO.id); + } + + @Override + public int hashCode() { + return Objects.hash(this.id); + } + + // prettier-ignore + @Override + public String toString() { + return "ConfermaDTO{" + + "id=" + getId() + + ", motivoConferma='" + getMotivoConferma() + "'" + + ", tipoConferma='" + getTipoConferma() + "'" + + ", confermataDa=" + getConfermataDa() + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/dto/DisponibilitaDTO.java b/src/main/java/it/sw/pa/comune/artegna/service/dto/DisponibilitaDTO.java new file mode 100644 index 0000000..11f5f4e --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/dto/DisponibilitaDTO.java @@ -0,0 +1,153 @@ +package it.sw.pa.comune.artegna.service.dto; + +import it.sw.pa.comune.artegna.domain.enumeration.GiornoSettimana; +import it.sw.pa.comune.artegna.domain.enumeration.TipoDisponibilita; +import java.io.Serializable; +import java.time.Instant; +import java.time.LocalDate; +import java.util.Objects; + +/** + * A DTO for the {@link it.sw.pa.comune.artegna.domain.Disponibilita} entity. + */ +@SuppressWarnings("common-java:DuplicatedBlocks") +public class DisponibilitaDTO implements Serializable { + + private Long id; + + private GiornoSettimana giornoSettimana; + + private LocalDate dataSpecifica; + + private Instant oraInizio; + + private Instant oraFine; + + private String orarioInizio; + + private String orarioFine; + + private TipoDisponibilita tipo; + + private String note; + + private StrutturaDTO struttura; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public GiornoSettimana getGiornoSettimana() { + return giornoSettimana; + } + + public void setGiornoSettimana(GiornoSettimana giornoSettimana) { + this.giornoSettimana = giornoSettimana; + } + + public LocalDate getDataSpecifica() { + return dataSpecifica; + } + + public void setDataSpecifica(LocalDate dataSpecifica) { + this.dataSpecifica = dataSpecifica; + } + + public Instant getOraInizio() { + return oraInizio; + } + + public void setOraInizio(Instant oraInizio) { + this.oraInizio = oraInizio; + } + + public Instant getOraFine() { + return oraFine; + } + + public void setOraFine(Instant oraFine) { + this.oraFine = oraFine; + } + + public String getOrarioInizio() { + return orarioInizio; + } + + public void setOrarioInizio(String orarioInizio) { + this.orarioInizio = orarioInizio; + } + + public String getOrarioFine() { + return orarioFine; + } + + public void setOrarioFine(String orarioFine) { + this.orarioFine = orarioFine; + } + + public TipoDisponibilita getTipo() { + return tipo; + } + + public void setTipo(TipoDisponibilita tipo) { + this.tipo = tipo; + } + + public String getNote() { + return note; + } + + public void setNote(String note) { + this.note = note; + } + + public StrutturaDTO getStruttura() { + return struttura; + } + + public void setStruttura(StrutturaDTO struttura) { + this.struttura = struttura; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof DisponibilitaDTO)) { + return false; + } + + DisponibilitaDTO disponibilitaDTO = (DisponibilitaDTO) o; + if (this.id == null) { + return false; + } + return Objects.equals(this.id, disponibilitaDTO.id); + } + + @Override + public int hashCode() { + return Objects.hash(this.id); + } + + // prettier-ignore + @Override + public String toString() { + return "DisponibilitaDTO{" + + "id=" + getId() + + ", giornoSettimana='" + getGiornoSettimana() + "'" + + ", dataSpecifica='" + getDataSpecifica() + "'" + + ", oraInizio='" + getOraInizio() + "'" + + ", oraFine='" + getOraFine() + "'" + + ", orarioInizio='" + getOrarioInizio() + "'" + + ", orarioFine='" + getOrarioFine() + "'" + + ", tipo='" + getTipo() + "'" + + ", note='" + getNote() + "'" + + ", struttura=" + getStruttura() + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/dto/LiberatoriaDTO.java b/src/main/java/it/sw/pa/comune/artegna/service/dto/LiberatoriaDTO.java new file mode 100644 index 0000000..fbe47bc --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/dto/LiberatoriaDTO.java @@ -0,0 +1,84 @@ +package it.sw.pa.comune.artegna.service.dto; + +import java.io.Serializable; +import java.time.Instant; +import java.util.Objects; + +/** + * A DTO for the {@link it.sw.pa.comune.artegna.domain.Liberatoria} entity. + */ +@SuppressWarnings("common-java:DuplicatedBlocks") +public class LiberatoriaDTO implements Serializable { + + private Long id; + + private Instant accettata; + + private UtenteAppDTO utente; + + private ModelloLiberatoriaDTO modelloLiberatoria; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Instant getAccettata() { + return accettata; + } + + public void setAccettata(Instant accettata) { + this.accettata = accettata; + } + + public UtenteAppDTO getUtente() { + return utente; + } + + public void setUtente(UtenteAppDTO utente) { + this.utente = utente; + } + + public ModelloLiberatoriaDTO getModelloLiberatoria() { + return modelloLiberatoria; + } + + public void setModelloLiberatoria(ModelloLiberatoriaDTO modelloLiberatoria) { + this.modelloLiberatoria = modelloLiberatoria; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof LiberatoriaDTO)) { + return false; + } + + LiberatoriaDTO liberatoriaDTO = (LiberatoriaDTO) o; + if (this.id == null) { + return false; + } + return Objects.equals(this.id, liberatoriaDTO.id); + } + + @Override + public int hashCode() { + return Objects.hash(this.id); + } + + // prettier-ignore + @Override + public String toString() { + return "LiberatoriaDTO{" + + "id=" + getId() + + ", accettata='" + getAccettata() + "'" + + ", utente=" + getUtente() + + ", modelloLiberatoria=" + getModelloLiberatoria() + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/dto/MessaggioDTO.java b/src/main/java/it/sw/pa/comune/artegna/service/dto/MessaggioDTO.java new file mode 100644 index 0000000..f441152 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/dto/MessaggioDTO.java @@ -0,0 +1,95 @@ +package it.sw.pa.comune.artegna.service.dto; + +import java.io.Serializable; +import java.time.Instant; +import java.util.Objects; + +/** + * A DTO for the {@link it.sw.pa.comune.artegna.domain.Messaggio} entity. + */ +@SuppressWarnings("common-java:DuplicatedBlocks") +public class MessaggioDTO implements Serializable { + + private Long id; + + private Instant spedito; + + private String testo; + + private Instant letto; + + private UtenteAppDTO utente; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Instant getSpedito() { + return spedito; + } + + public void setSpedito(Instant spedito) { + this.spedito = spedito; + } + + public String getTesto() { + return testo; + } + + public void setTesto(String testo) { + this.testo = testo; + } + + public Instant getLetto() { + return letto; + } + + public void setLetto(Instant letto) { + this.letto = letto; + } + + public UtenteAppDTO getUtente() { + return utente; + } + + public void setUtente(UtenteAppDTO utente) { + this.utente = utente; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof MessaggioDTO)) { + return false; + } + + MessaggioDTO messaggioDTO = (MessaggioDTO) o; + if (this.id == null) { + return false; + } + return Objects.equals(this.id, messaggioDTO.id); + } + + @Override + public int hashCode() { + return Objects.hash(this.id); + } + + // prettier-ignore + @Override + public String toString() { + return "MessaggioDTO{" + + "id=" + getId() + + ", spedito='" + getSpedito() + "'" + + ", testo='" + getTesto() + "'" + + ", letto='" + getLetto() + "'" + + ", utente=" + getUtente() + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/dto/ModelloLiberatoriaDTO.java b/src/main/java/it/sw/pa/comune/artegna/service/dto/ModelloLiberatoriaDTO.java new file mode 100644 index 0000000..472b9bf --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/dto/ModelloLiberatoriaDTO.java @@ -0,0 +1,129 @@ +package it.sw.pa.comune.artegna.service.dto; + +import jakarta.persistence.Lob; +import java.io.Serializable; +import java.time.Instant; +import java.util.Objects; + +/** + * A DTO for the {@link it.sw.pa.comune.artegna.domain.ModelloLiberatoria} entity. + */ +@SuppressWarnings("common-java:DuplicatedBlocks") +public class ModelloLiberatoriaDTO implements Serializable { + + private Long id; + + private String nome; + + private String testo; + + @Lob + private byte[] documento; + + private String documentoContentType; + + private Instant validoDal; + + private Instant validoAl; + + private StrutturaDTO struttura; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public String getTesto() { + return testo; + } + + public void setTesto(String testo) { + this.testo = testo; + } + + public byte[] getDocumento() { + return documento; + } + + public void setDocumento(byte[] documento) { + this.documento = documento; + } + + public String getDocumentoContentType() { + return documentoContentType; + } + + public void setDocumentoContentType(String documentoContentType) { + this.documentoContentType = documentoContentType; + } + + public Instant getValidoDal() { + return validoDal; + } + + public void setValidoDal(Instant validoDal) { + this.validoDal = validoDal; + } + + public Instant getValidoAl() { + return validoAl; + } + + public void setValidoAl(Instant validoAl) { + this.validoAl = validoAl; + } + + public StrutturaDTO getStruttura() { + return struttura; + } + + public void setStruttura(StrutturaDTO struttura) { + this.struttura = struttura; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof ModelloLiberatoriaDTO)) { + return false; + } + + ModelloLiberatoriaDTO modelloLiberatoriaDTO = (ModelloLiberatoriaDTO) o; + if (this.id == null) { + return false; + } + return Objects.equals(this.id, modelloLiberatoriaDTO.id); + } + + @Override + public int hashCode() { + return Objects.hash(this.id); + } + + // prettier-ignore + @Override + public String toString() { + return "ModelloLiberatoriaDTO{" + + "id=" + getId() + + ", nome='" + getNome() + "'" + + ", testo='" + getTesto() + "'" + + ", documento='" + getDocumento() + "'" + + ", validoDal='" + getValidoDal() + "'" + + ", validoAl='" + getValidoAl() + "'" + + ", struttura=" + getStruttura() + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/dto/NotificaDTO.java b/src/main/java/it/sw/pa/comune/artegna/service/dto/NotificaDTO.java new file mode 100644 index 0000000..58bcdf3 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/dto/NotificaDTO.java @@ -0,0 +1,141 @@ +package it.sw.pa.comune.artegna.service.dto; + +import it.sw.pa.comune.artegna.domain.enumeration.TipoCanaleNotifica; +import it.sw.pa.comune.artegna.domain.enumeration.TipoEventoNotifica; +import java.io.Serializable; +import java.time.Instant; +import java.util.Objects; + +/** + * A DTO for the {@link it.sw.pa.comune.artegna.domain.Notifica} entity. + */ +@SuppressWarnings("common-java:DuplicatedBlocks") +public class NotificaDTO implements Serializable { + + private Long id; + + private TipoCanaleNotifica tipoCanale; + + private TipoEventoNotifica tipoEvento; + + private String messaggio; + + private Boolean inviata; + + private Instant inviataAt; + + private String errore; + + private Instant createdAt; + + private ConfermaDTO conferma; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public TipoCanaleNotifica getTipoCanale() { + return tipoCanale; + } + + public void setTipoCanale(TipoCanaleNotifica tipoCanale) { + this.tipoCanale = tipoCanale; + } + + public TipoEventoNotifica getTipoEvento() { + return tipoEvento; + } + + public void setTipoEvento(TipoEventoNotifica tipoEvento) { + this.tipoEvento = tipoEvento; + } + + public String getMessaggio() { + return messaggio; + } + + public void setMessaggio(String messaggio) { + this.messaggio = messaggio; + } + + public Boolean getInviata() { + return inviata; + } + + public void setInviata(Boolean inviata) { + this.inviata = inviata; + } + + public Instant getInviataAt() { + return inviataAt; + } + + public void setInviataAt(Instant inviataAt) { + this.inviataAt = inviataAt; + } + + public String getErrore() { + return errore; + } + + public void setErrore(String errore) { + this.errore = errore; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public ConfermaDTO getConferma() { + return conferma; + } + + public void setConferma(ConfermaDTO conferma) { + this.conferma = conferma; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof NotificaDTO)) { + return false; + } + + NotificaDTO notificaDTO = (NotificaDTO) o; + if (this.id == null) { + return false; + } + return Objects.equals(this.id, notificaDTO.id); + } + + @Override + public int hashCode() { + return Objects.hash(this.id); + } + + // prettier-ignore + @Override + public String toString() { + return "NotificaDTO{" + + "id=" + getId() + + ", tipoCanale='" + getTipoCanale() + "'" + + ", tipoEvento='" + getTipoEvento() + "'" + + ", messaggio='" + getMessaggio() + "'" + + ", inviata='" + getInviata() + "'" + + ", inviataAt='" + getInviataAt() + "'" + + ", errore='" + getErrore() + "'" + + ", createdAt='" + getCreatedAt() + "'" + + ", conferma=" + getConferma() + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/dto/PrenotazioneDTO.java b/src/main/java/it/sw/pa/comune/artegna/service/dto/PrenotazioneDTO.java new file mode 100644 index 0000000..2902f84 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/dto/PrenotazioneDTO.java @@ -0,0 +1,151 @@ +package it.sw.pa.comune.artegna.service.dto; + +import it.sw.pa.comune.artegna.domain.enumeration.StatoPrenotazione; +import java.io.Serializable; +import java.time.Instant; +import java.util.Objects; + +/** + * A DTO for the {@link it.sw.pa.comune.artegna.domain.Prenotazione} entity. + */ +@SuppressWarnings("common-java:DuplicatedBlocks") +public class PrenotazioneDTO implements Serializable { + + private Long id; + + private Instant oraInizio; + + private Instant oraFine; + + private StatoPrenotazione stato; + + private String motivoEvento; + + private Integer numeroPartecipanti; + + private String noteUtente; + + private ConfermaDTO conferma; + + private UtenteAppDTO utente; + + private StrutturaDTO struttura; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Instant getOraInizio() { + return oraInizio; + } + + public void setOraInizio(Instant oraInizio) { + this.oraInizio = oraInizio; + } + + public Instant getOraFine() { + return oraFine; + } + + public void setOraFine(Instant oraFine) { + this.oraFine = oraFine; + } + + public StatoPrenotazione getStato() { + return stato; + } + + public void setStato(StatoPrenotazione stato) { + this.stato = stato; + } + + public String getMotivoEvento() { + return motivoEvento; + } + + public void setMotivoEvento(String motivoEvento) { + this.motivoEvento = motivoEvento; + } + + public Integer getNumeroPartecipanti() { + return numeroPartecipanti; + } + + public void setNumeroPartecipanti(Integer numeroPartecipanti) { + this.numeroPartecipanti = numeroPartecipanti; + } + + public String getNoteUtente() { + return noteUtente; + } + + public void setNoteUtente(String noteUtente) { + this.noteUtente = noteUtente; + } + + public ConfermaDTO getConferma() { + return conferma; + } + + public void setConferma(ConfermaDTO conferma) { + this.conferma = conferma; + } + + public UtenteAppDTO getUtente() { + return utente; + } + + public void setUtente(UtenteAppDTO utente) { + this.utente = utente; + } + + public StrutturaDTO getStruttura() { + return struttura; + } + + public void setStruttura(StrutturaDTO struttura) { + this.struttura = struttura; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof PrenotazioneDTO)) { + return false; + } + + PrenotazioneDTO prenotazioneDTO = (PrenotazioneDTO) o; + if (this.id == null) { + return false; + } + return Objects.equals(this.id, prenotazioneDTO.id); + } + + @Override + public int hashCode() { + return Objects.hash(this.id); + } + + // prettier-ignore + @Override + public String toString() { + return "PrenotazioneDTO{" + + "id=" + getId() + + ", oraInizio='" + getOraInizio() + "'" + + ", oraFine='" + getOraFine() + "'" + + ", stato='" + getStato() + "'" + + ", motivoEvento='" + getMotivoEvento() + "'" + + ", numeroPartecipanti=" + getNumeroPartecipanti() + + ", noteUtente='" + getNoteUtente() + "'" + + ", conferma=" + getConferma() + + ", utente=" + getUtente() + + ", struttura=" + getStruttura() + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/dto/StrutturaDTO.java b/src/main/java/it/sw/pa/comune/artegna/service/dto/StrutturaDTO.java new file mode 100644 index 0000000..d97083f --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/dto/StrutturaDTO.java @@ -0,0 +1,139 @@ +package it.sw.pa.comune.artegna.service.dto; + +import java.io.Serializable; +import java.time.Instant; +import java.util.Objects; + +/** + * A DTO for the {@link it.sw.pa.comune.artegna.domain.Struttura} entity. + */ +@SuppressWarnings("common-java:DuplicatedBlocks") +public class StrutturaDTO implements Serializable { + + private Long id; + + private String nome; + + private String descrizione; + + private String indirizzo; + + private Integer capienzaMax; + + private Boolean attiva; + + private String fotoUrl; + + private Instant createdAt; + + private Instant updatedAt; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public String getDescrizione() { + return descrizione; + } + + public void setDescrizione(String descrizione) { + this.descrizione = descrizione; + } + + public String getIndirizzo() { + return indirizzo; + } + + public void setIndirizzo(String indirizzo) { + this.indirizzo = indirizzo; + } + + public Integer getCapienzaMax() { + return capienzaMax; + } + + public void setCapienzaMax(Integer capienzaMax) { + this.capienzaMax = capienzaMax; + } + + public Boolean getAttiva() { + return attiva; + } + + public void setAttiva(Boolean attiva) { + this.attiva = attiva; + } + + public String getFotoUrl() { + return fotoUrl; + } + + public void setFotoUrl(String fotoUrl) { + this.fotoUrl = fotoUrl; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof StrutturaDTO)) { + return false; + } + + StrutturaDTO strutturaDTO = (StrutturaDTO) o; + if (this.id == null) { + return false; + } + return Objects.equals(this.id, strutturaDTO.id); + } + + @Override + public int hashCode() { + return Objects.hash(this.id); + } + + // prettier-ignore + @Override + public String toString() { + return "StrutturaDTO{" + + "id=" + getId() + + ", nome='" + getNome() + "'" + + ", descrizione='" + getDescrizione() + "'" + + ", indirizzo='" + getIndirizzo() + "'" + + ", capienzaMax=" + getCapienzaMax() + + ", attiva='" + getAttiva() + "'" + + ", fotoUrl='" + getFotoUrl() + "'" + + ", createdAt='" + getCreatedAt() + "'" + + ", updatedAt='" + getUpdatedAt() + "'" + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/dto/UtenteAppDTO.java b/src/main/java/it/sw/pa/comune/artegna/service/dto/UtenteAppDTO.java new file mode 100644 index 0000000..6aaeefb --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/dto/UtenteAppDTO.java @@ -0,0 +1,221 @@ +package it.sw.pa.comune.artegna.service.dto; + +import it.sw.pa.comune.artegna.domain.enumeration.Ruolo; +import jakarta.validation.constraints.*; +import java.io.Serializable; +import java.util.Objects; + +/** + * A DTO for the {@link it.sw.pa.comune.artegna.domain.UtenteApp} entity. + */ +@SuppressWarnings("common-java:DuplicatedBlocks") +public class UtenteAppDTO implements Serializable { + + private Long id; + + @NotNull + private String username; + + @NotNull + private String email; + + private String telefono; + + @NotNull + private Ruolo ruolo; + + @NotNull + private Boolean attivo; + + private String nome; + + private String cognome; + + private String luogoNascita; + + private String dataNascita; + + private String residente; + + private String societa; + + private String sede; + + private String codfiscale; + + private String telefonoSoc; + + private String emailSoc; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getTelefono() { + return telefono; + } + + public void setTelefono(String telefono) { + this.telefono = telefono; + } + + public Ruolo getRuolo() { + return ruolo; + } + + public void setRuolo(Ruolo ruolo) { + this.ruolo = ruolo; + } + + public Boolean getAttivo() { + return attivo; + } + + public void setAttivo(Boolean attivo) { + this.attivo = attivo; + } + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public String getCognome() { + return cognome; + } + + public void setCognome(String cognome) { + this.cognome = cognome; + } + + public String getLuogoNascita() { + return luogoNascita; + } + + public void setLuogoNascita(String luogoNascita) { + this.luogoNascita = luogoNascita; + } + + public String getDataNascita() { + return dataNascita; + } + + public void setDataNascita(String dataNascita) { + this.dataNascita = dataNascita; + } + + public String getResidente() { + return residente; + } + + public void setResidente(String residente) { + this.residente = residente; + } + + public String getSocieta() { + return societa; + } + + public void setSocieta(String societa) { + this.societa = societa; + } + + public String getSede() { + return sede; + } + + public void setSede(String sede) { + this.sede = sede; + } + + public String getCodfiscale() { + return codfiscale; + } + + public void setCodfiscale(String codfiscale) { + this.codfiscale = codfiscale; + } + + public String getTelefonoSoc() { + return telefonoSoc; + } + + public void setTelefonoSoc(String telefonoSoc) { + this.telefonoSoc = telefonoSoc; + } + + public String getEmailSoc() { + return emailSoc; + } + + public void setEmailSoc(String emailSoc) { + this.emailSoc = emailSoc; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof UtenteAppDTO)) { + return false; + } + + UtenteAppDTO utenteAppDTO = (UtenteAppDTO) o; + if (this.id == null) { + return false; + } + return Objects.equals(this.id, utenteAppDTO.id); + } + + @Override + public int hashCode() { + return Objects.hash(this.id); + } + + // prettier-ignore + @Override + public String toString() { + return "UtenteAppDTO{" + + "id=" + getId() + + ", username='" + getUsername() + "'" + + ", email='" + getEmail() + "'" + + ", telefono='" + getTelefono() + "'" + + ", ruolo='" + getRuolo() + "'" + + ", attivo='" + getAttivo() + "'" + + ", nome='" + getNome() + "'" + + ", cognome='" + getCognome() + "'" + + ", luogoNascita='" + getLuogoNascita() + "'" + + ", dataNascita='" + getDataNascita() + "'" + + ", residente='" + getResidente() + "'" + + ", societa='" + getSocieta() + "'" + + ", sede='" + getSede() + "'" + + ", codfiscale='" + getCodfiscale() + "'" + + ", telefonoSoc='" + getTelefonoSoc() + "'" + + ", emailSoc='" + getEmailSoc() + "'" + + "}"; + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/impl/AuditLogServiceImpl.java b/src/main/java/it/sw/pa/comune/artegna/service/impl/AuditLogServiceImpl.java new file mode 100644 index 0000000..9245e75 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/impl/AuditLogServiceImpl.java @@ -0,0 +1,81 @@ +package it.sw.pa.comune.artegna.service.impl; + +import it.sw.pa.comune.artegna.domain.AuditLog; +import it.sw.pa.comune.artegna.repository.AuditLogRepository; +import it.sw.pa.comune.artegna.service.AuditLogService; +import it.sw.pa.comune.artegna.service.dto.AuditLogDTO; +import it.sw.pa.comune.artegna.service.mapper.AuditLogMapper; +import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * Service Implementation for managing {@link it.sw.pa.comune.artegna.domain.AuditLog}. + */ +@Service +@Transactional +public class AuditLogServiceImpl implements AuditLogService { + + private static final Logger LOG = LoggerFactory.getLogger(AuditLogServiceImpl.class); + + private final AuditLogRepository auditLogRepository; + + private final AuditLogMapper auditLogMapper; + + public AuditLogServiceImpl(AuditLogRepository auditLogRepository, AuditLogMapper auditLogMapper) { + this.auditLogRepository = auditLogRepository; + this.auditLogMapper = auditLogMapper; + } + + @Override + public AuditLogDTO save(AuditLogDTO auditLogDTO) { + LOG.debug("Request to save AuditLog : {}", auditLogDTO); + AuditLog auditLog = auditLogMapper.toEntity(auditLogDTO); + auditLog = auditLogRepository.save(auditLog); + return auditLogMapper.toDto(auditLog); + } + + @Override + public AuditLogDTO update(AuditLogDTO auditLogDTO) { + LOG.debug("Request to update AuditLog : {}", auditLogDTO); + AuditLog auditLog = auditLogMapper.toEntity(auditLogDTO); + auditLog = auditLogRepository.save(auditLog); + return auditLogMapper.toDto(auditLog); + } + + @Override + public Optional partialUpdate(AuditLogDTO auditLogDTO) { + LOG.debug("Request to partially update AuditLog : {}", auditLogDTO); + + return auditLogRepository + .findById(auditLogDTO.getId()) + .map(existingAuditLog -> { + auditLogMapper.partialUpdate(existingAuditLog, auditLogDTO); + + return existingAuditLog; + }) + .map(auditLogRepository::save) + .map(auditLogMapper::toDto); + } + + public Page findAllWithEagerRelationships(Pageable pageable) { + return auditLogRepository.findAllWithEagerRelationships(pageable).map(auditLogMapper::toDto); + } + + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + LOG.debug("Request to get AuditLog : {}", id); + return auditLogRepository.findOneWithEagerRelationships(id).map(auditLogMapper::toDto); + } + + @Override + public void delete(Long id) { + LOG.debug("Request to delete AuditLog : {}", id); + auditLogRepository.deleteById(id); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/impl/ConfermaServiceImpl.java b/src/main/java/it/sw/pa/comune/artegna/service/impl/ConfermaServiceImpl.java new file mode 100644 index 0000000..ef4cd69 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/impl/ConfermaServiceImpl.java @@ -0,0 +1,98 @@ +package it.sw.pa.comune.artegna.service.impl; + +import it.sw.pa.comune.artegna.domain.Conferma; +import it.sw.pa.comune.artegna.repository.ConfermaRepository; +import it.sw.pa.comune.artegna.service.ConfermaService; +import it.sw.pa.comune.artegna.service.dto.ConfermaDTO; +import it.sw.pa.comune.artegna.service.mapper.ConfermaMapper; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * Service Implementation for managing {@link it.sw.pa.comune.artegna.domain.Conferma}. + */ +@Service +@Transactional +public class ConfermaServiceImpl implements ConfermaService { + + private static final Logger LOG = LoggerFactory.getLogger(ConfermaServiceImpl.class); + + private final ConfermaRepository confermaRepository; + + private final ConfermaMapper confermaMapper; + + public ConfermaServiceImpl(ConfermaRepository confermaRepository, ConfermaMapper confermaMapper) { + this.confermaRepository = confermaRepository; + this.confermaMapper = confermaMapper; + } + + @Override + public ConfermaDTO save(ConfermaDTO confermaDTO) { + LOG.debug("Request to save Conferma : {}", confermaDTO); + Conferma conferma = confermaMapper.toEntity(confermaDTO); + conferma = confermaRepository.save(conferma); + return confermaMapper.toDto(conferma); + } + + @Override + public ConfermaDTO update(ConfermaDTO confermaDTO) { + LOG.debug("Request to update Conferma : {}", confermaDTO); + Conferma conferma = confermaMapper.toEntity(confermaDTO); + conferma = confermaRepository.save(conferma); + return confermaMapper.toDto(conferma); + } + + @Override + public Optional partialUpdate(ConfermaDTO confermaDTO) { + LOG.debug("Request to partially update Conferma : {}", confermaDTO); + + return confermaRepository + .findById(confermaDTO.getId()) + .map(existingConferma -> { + confermaMapper.partialUpdate(existingConferma, confermaDTO); + + return existingConferma; + }) + .map(confermaRepository::save) + .map(confermaMapper::toDto); + } + + public Page findAllWithEagerRelationships(Pageable pageable) { + return confermaRepository.findAllWithEagerRelationships(pageable).map(confermaMapper::toDto); + } + + /** + * Get all the confermas where Prenotazione is {@code null}. + * @return the list of entities. + */ + @Transactional(readOnly = true) + public List findAllWherePrenotazioneIsNull() { + LOG.debug("Request to get all confermas where Prenotazione is null"); + return StreamSupport.stream(confermaRepository.findAll().spliterator(), false) + .filter(conferma -> conferma.getPrenotazione() == null) + .map(confermaMapper::toDto) + .collect(Collectors.toCollection(LinkedList::new)); + } + + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + LOG.debug("Request to get Conferma : {}", id); + return confermaRepository.findOneWithEagerRelationships(id).map(confermaMapper::toDto); + } + + @Override + public void delete(Long id) { + LOG.debug("Request to delete Conferma : {}", id); + confermaRepository.deleteById(id); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/impl/DisponibilitaServiceImpl.java b/src/main/java/it/sw/pa/comune/artegna/service/impl/DisponibilitaServiceImpl.java new file mode 100644 index 0000000..cd0fb27 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/impl/DisponibilitaServiceImpl.java @@ -0,0 +1,88 @@ +package it.sw.pa.comune.artegna.service.impl; + +import it.sw.pa.comune.artegna.domain.Disponibilita; +import it.sw.pa.comune.artegna.repository.DisponibilitaRepository; +import it.sw.pa.comune.artegna.service.DisponibilitaService; +import it.sw.pa.comune.artegna.service.dto.DisponibilitaDTO; +import it.sw.pa.comune.artegna.service.mapper.DisponibilitaMapper; +import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * Service Implementation for managing {@link it.sw.pa.comune.artegna.domain.Disponibilita}. + */ +@Service +@Transactional +public class DisponibilitaServiceImpl implements DisponibilitaService { + + private static final Logger LOG = LoggerFactory.getLogger(DisponibilitaServiceImpl.class); + + private final DisponibilitaRepository disponibilitaRepository; + + private final DisponibilitaMapper disponibilitaMapper; + + public DisponibilitaServiceImpl(DisponibilitaRepository disponibilitaRepository, DisponibilitaMapper disponibilitaMapper) { + this.disponibilitaRepository = disponibilitaRepository; + this.disponibilitaMapper = disponibilitaMapper; + } + + @Override + public DisponibilitaDTO save(DisponibilitaDTO disponibilitaDTO) { + LOG.debug("Request to save Disponibilita : {}", disponibilitaDTO); + Disponibilita disponibilita = disponibilitaMapper.toEntity(disponibilitaDTO); + disponibilita = disponibilitaRepository.save(disponibilita); + return disponibilitaMapper.toDto(disponibilita); + } + + @Override + public DisponibilitaDTO update(DisponibilitaDTO disponibilitaDTO) { + LOG.debug("Request to update Disponibilita : {}", disponibilitaDTO); + Disponibilita disponibilita = disponibilitaMapper.toEntity(disponibilitaDTO); + disponibilita = disponibilitaRepository.save(disponibilita); + return disponibilitaMapper.toDto(disponibilita); + } + + @Override + public Optional partialUpdate(DisponibilitaDTO disponibilitaDTO) { + LOG.debug("Request to partially update Disponibilita : {}", disponibilitaDTO); + + return disponibilitaRepository + .findById(disponibilitaDTO.getId()) + .map(existingDisponibilita -> { + disponibilitaMapper.partialUpdate(existingDisponibilita, disponibilitaDTO); + + return existingDisponibilita; + }) + .map(disponibilitaRepository::save) + .map(disponibilitaMapper::toDto); + } + + @Override + @Transactional(readOnly = true) + public Page findAll(Pageable pageable) { + LOG.debug("Request to get all Disponibilitas"); + return disponibilitaRepository.findAll(pageable).map(disponibilitaMapper::toDto); + } + + public Page findAllWithEagerRelationships(Pageable pageable) { + return disponibilitaRepository.findAllWithEagerRelationships(pageable).map(disponibilitaMapper::toDto); + } + + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + LOG.debug("Request to get Disponibilita : {}", id); + return disponibilitaRepository.findOneWithEagerRelationships(id).map(disponibilitaMapper::toDto); + } + + @Override + public void delete(Long id) { + LOG.debug("Request to delete Disponibilita : {}", id); + disponibilitaRepository.deleteById(id); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/impl/LiberatoriaServiceImpl.java b/src/main/java/it/sw/pa/comune/artegna/service/impl/LiberatoriaServiceImpl.java new file mode 100644 index 0000000..ce98034 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/impl/LiberatoriaServiceImpl.java @@ -0,0 +1,91 @@ +package it.sw.pa.comune.artegna.service.impl; + +import it.sw.pa.comune.artegna.domain.Liberatoria; +import it.sw.pa.comune.artegna.repository.LiberatoriaRepository; +import it.sw.pa.comune.artegna.service.LiberatoriaService; +import it.sw.pa.comune.artegna.service.dto.LiberatoriaDTO; +import it.sw.pa.comune.artegna.service.mapper.LiberatoriaMapper; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * Service Implementation for managing {@link it.sw.pa.comune.artegna.domain.Liberatoria}. + */ +@Service +@Transactional +public class LiberatoriaServiceImpl implements LiberatoriaService { + + private static final Logger LOG = LoggerFactory.getLogger(LiberatoriaServiceImpl.class); + + private final LiberatoriaRepository liberatoriaRepository; + + private final LiberatoriaMapper liberatoriaMapper; + + public LiberatoriaServiceImpl(LiberatoriaRepository liberatoriaRepository, LiberatoriaMapper liberatoriaMapper) { + this.liberatoriaRepository = liberatoriaRepository; + this.liberatoriaMapper = liberatoriaMapper; + } + + @Override + public LiberatoriaDTO save(LiberatoriaDTO liberatoriaDTO) { + LOG.debug("Request to save Liberatoria : {}", liberatoriaDTO); + Liberatoria liberatoria = liberatoriaMapper.toEntity(liberatoriaDTO); + liberatoria = liberatoriaRepository.save(liberatoria); + return liberatoriaMapper.toDto(liberatoria); + } + + @Override + public LiberatoriaDTO update(LiberatoriaDTO liberatoriaDTO) { + LOG.debug("Request to update Liberatoria : {}", liberatoriaDTO); + Liberatoria liberatoria = liberatoriaMapper.toEntity(liberatoriaDTO); + liberatoria = liberatoriaRepository.save(liberatoria); + return liberatoriaMapper.toDto(liberatoria); + } + + @Override + public Optional partialUpdate(LiberatoriaDTO liberatoriaDTO) { + LOG.debug("Request to partially update Liberatoria : {}", liberatoriaDTO); + + return liberatoriaRepository + .findById(liberatoriaDTO.getId()) + .map(existingLiberatoria -> { + liberatoriaMapper.partialUpdate(existingLiberatoria, liberatoriaDTO); + + return existingLiberatoria; + }) + .map(liberatoriaRepository::save) + .map(liberatoriaMapper::toDto); + } + + @Override + @Transactional(readOnly = true) + public List findAll() { + LOG.debug("Request to get all Liberatorias"); + return liberatoriaRepository.findAll().stream().map(liberatoriaMapper::toDto).collect(Collectors.toCollection(LinkedList::new)); + } + + public Page findAllWithEagerRelationships(Pageable pageable) { + return liberatoriaRepository.findAllWithEagerRelationships(pageable).map(liberatoriaMapper::toDto); + } + + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + LOG.debug("Request to get Liberatoria : {}", id); + return liberatoriaRepository.findOneWithEagerRelationships(id).map(liberatoriaMapper::toDto); + } + + @Override + public void delete(Long id) { + LOG.debug("Request to delete Liberatoria : {}", id); + liberatoriaRepository.deleteById(id); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/impl/MessaggioServiceImpl.java b/src/main/java/it/sw/pa/comune/artegna/service/impl/MessaggioServiceImpl.java new file mode 100644 index 0000000..022a31b --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/impl/MessaggioServiceImpl.java @@ -0,0 +1,91 @@ +package it.sw.pa.comune.artegna.service.impl; + +import it.sw.pa.comune.artegna.domain.Messaggio; +import it.sw.pa.comune.artegna.repository.MessaggioRepository; +import it.sw.pa.comune.artegna.service.MessaggioService; +import it.sw.pa.comune.artegna.service.dto.MessaggioDTO; +import it.sw.pa.comune.artegna.service.mapper.MessaggioMapper; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * Service Implementation for managing {@link it.sw.pa.comune.artegna.domain.Messaggio}. + */ +@Service +@Transactional +public class MessaggioServiceImpl implements MessaggioService { + + private static final Logger LOG = LoggerFactory.getLogger(MessaggioServiceImpl.class); + + private final MessaggioRepository messaggioRepository; + + private final MessaggioMapper messaggioMapper; + + public MessaggioServiceImpl(MessaggioRepository messaggioRepository, MessaggioMapper messaggioMapper) { + this.messaggioRepository = messaggioRepository; + this.messaggioMapper = messaggioMapper; + } + + @Override + public MessaggioDTO save(MessaggioDTO messaggioDTO) { + LOG.debug("Request to save Messaggio : {}", messaggioDTO); + Messaggio messaggio = messaggioMapper.toEntity(messaggioDTO); + messaggio = messaggioRepository.save(messaggio); + return messaggioMapper.toDto(messaggio); + } + + @Override + public MessaggioDTO update(MessaggioDTO messaggioDTO) { + LOG.debug("Request to update Messaggio : {}", messaggioDTO); + Messaggio messaggio = messaggioMapper.toEntity(messaggioDTO); + messaggio = messaggioRepository.save(messaggio); + return messaggioMapper.toDto(messaggio); + } + + @Override + public Optional partialUpdate(MessaggioDTO messaggioDTO) { + LOG.debug("Request to partially update Messaggio : {}", messaggioDTO); + + return messaggioRepository + .findById(messaggioDTO.getId()) + .map(existingMessaggio -> { + messaggioMapper.partialUpdate(existingMessaggio, messaggioDTO); + + return existingMessaggio; + }) + .map(messaggioRepository::save) + .map(messaggioMapper::toDto); + } + + @Override + @Transactional(readOnly = true) + public List findAll() { + LOG.debug("Request to get all Messaggios"); + return messaggioRepository.findAll().stream().map(messaggioMapper::toDto).collect(Collectors.toCollection(LinkedList::new)); + } + + public Page findAllWithEagerRelationships(Pageable pageable) { + return messaggioRepository.findAllWithEagerRelationships(pageable).map(messaggioMapper::toDto); + } + + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + LOG.debug("Request to get Messaggio : {}", id); + return messaggioRepository.findOneWithEagerRelationships(id).map(messaggioMapper::toDto); + } + + @Override + public void delete(Long id) { + LOG.debug("Request to delete Messaggio : {}", id); + messaggioRepository.deleteById(id); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/impl/ModelloLiberatoriaServiceImpl.java b/src/main/java/it/sw/pa/comune/artegna/service/impl/ModelloLiberatoriaServiceImpl.java new file mode 100644 index 0000000..18abedf --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/impl/ModelloLiberatoriaServiceImpl.java @@ -0,0 +1,92 @@ +package it.sw.pa.comune.artegna.service.impl; + +import it.sw.pa.comune.artegna.domain.ModelloLiberatoria; +import it.sw.pa.comune.artegna.repository.ModelloLiberatoriaRepository; +import it.sw.pa.comune.artegna.service.ModelloLiberatoriaService; +import it.sw.pa.comune.artegna.service.dto.ModelloLiberatoriaDTO; +import it.sw.pa.comune.artegna.service.mapper.ModelloLiberatoriaMapper; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * Service Implementation for managing {@link it.sw.pa.comune.artegna.domain.ModelloLiberatoria}. + */ +@Service +@Transactional +public class ModelloLiberatoriaServiceImpl implements ModelloLiberatoriaService { + + private static final Logger LOG = LoggerFactory.getLogger(ModelloLiberatoriaServiceImpl.class); + + private final ModelloLiberatoriaRepository modelloLiberatoriaRepository; + + private final ModelloLiberatoriaMapper modelloLiberatoriaMapper; + + public ModelloLiberatoriaServiceImpl( + ModelloLiberatoriaRepository modelloLiberatoriaRepository, + ModelloLiberatoriaMapper modelloLiberatoriaMapper + ) { + this.modelloLiberatoriaRepository = modelloLiberatoriaRepository; + this.modelloLiberatoriaMapper = modelloLiberatoriaMapper; + } + + @Override + public ModelloLiberatoriaDTO save(ModelloLiberatoriaDTO modelloLiberatoriaDTO) { + LOG.debug("Request to save ModelloLiberatoria : {}", modelloLiberatoriaDTO); + ModelloLiberatoria modelloLiberatoria = modelloLiberatoriaMapper.toEntity(modelloLiberatoriaDTO); + modelloLiberatoria = modelloLiberatoriaRepository.save(modelloLiberatoria); + return modelloLiberatoriaMapper.toDto(modelloLiberatoria); + } + + @Override + public ModelloLiberatoriaDTO update(ModelloLiberatoriaDTO modelloLiberatoriaDTO) { + LOG.debug("Request to update ModelloLiberatoria : {}", modelloLiberatoriaDTO); + ModelloLiberatoria modelloLiberatoria = modelloLiberatoriaMapper.toEntity(modelloLiberatoriaDTO); + modelloLiberatoria = modelloLiberatoriaRepository.save(modelloLiberatoria); + return modelloLiberatoriaMapper.toDto(modelloLiberatoria); + } + + @Override + public Optional partialUpdate(ModelloLiberatoriaDTO modelloLiberatoriaDTO) { + LOG.debug("Request to partially update ModelloLiberatoria : {}", modelloLiberatoriaDTO); + + return modelloLiberatoriaRepository + .findById(modelloLiberatoriaDTO.getId()) + .map(existingModelloLiberatoria -> { + modelloLiberatoriaMapper.partialUpdate(existingModelloLiberatoria, modelloLiberatoriaDTO); + + return existingModelloLiberatoria; + }) + .map(modelloLiberatoriaRepository::save) + .map(modelloLiberatoriaMapper::toDto); + } + + @Override + @Transactional(readOnly = true) + public List findAll() { + LOG.debug("Request to get all ModelloLiberatorias"); + return modelloLiberatoriaRepository + .findAll() + .stream() + .map(modelloLiberatoriaMapper::toDto) + .collect(Collectors.toCollection(LinkedList::new)); + } + + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + LOG.debug("Request to get ModelloLiberatoria : {}", id); + return modelloLiberatoriaRepository.findById(id).map(modelloLiberatoriaMapper::toDto); + } + + @Override + public void delete(Long id) { + LOG.debug("Request to delete ModelloLiberatoria : {}", id); + modelloLiberatoriaRepository.deleteById(id); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/impl/NotificaServiceImpl.java b/src/main/java/it/sw/pa/comune/artegna/service/impl/NotificaServiceImpl.java new file mode 100644 index 0000000..2c081ef --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/impl/NotificaServiceImpl.java @@ -0,0 +1,75 @@ +package it.sw.pa.comune.artegna.service.impl; + +import it.sw.pa.comune.artegna.domain.Notifica; +import it.sw.pa.comune.artegna.repository.NotificaRepository; +import it.sw.pa.comune.artegna.service.NotificaService; +import it.sw.pa.comune.artegna.service.dto.NotificaDTO; +import it.sw.pa.comune.artegna.service.mapper.NotificaMapper; +import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * Service Implementation for managing {@link it.sw.pa.comune.artegna.domain.Notifica}. + */ +@Service +@Transactional +public class NotificaServiceImpl implements NotificaService { + + private static final Logger LOG = LoggerFactory.getLogger(NotificaServiceImpl.class); + + private final NotificaRepository notificaRepository; + + private final NotificaMapper notificaMapper; + + public NotificaServiceImpl(NotificaRepository notificaRepository, NotificaMapper notificaMapper) { + this.notificaRepository = notificaRepository; + this.notificaMapper = notificaMapper; + } + + @Override + public NotificaDTO save(NotificaDTO notificaDTO) { + LOG.debug("Request to save Notifica : {}", notificaDTO); + Notifica notifica = notificaMapper.toEntity(notificaDTO); + notifica = notificaRepository.save(notifica); + return notificaMapper.toDto(notifica); + } + + @Override + public NotificaDTO update(NotificaDTO notificaDTO) { + LOG.debug("Request to update Notifica : {}", notificaDTO); + Notifica notifica = notificaMapper.toEntity(notificaDTO); + notifica = notificaRepository.save(notifica); + return notificaMapper.toDto(notifica); + } + + @Override + public Optional partialUpdate(NotificaDTO notificaDTO) { + LOG.debug("Request to partially update Notifica : {}", notificaDTO); + + return notificaRepository + .findById(notificaDTO.getId()) + .map(existingNotifica -> { + notificaMapper.partialUpdate(existingNotifica, notificaDTO); + + return existingNotifica; + }) + .map(notificaRepository::save) + .map(notificaMapper::toDto); + } + + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + LOG.debug("Request to get Notifica : {}", id); + return notificaRepository.findById(id).map(notificaMapper::toDto); + } + + @Override + public void delete(Long id) { + LOG.debug("Request to delete Notifica : {}", id); + notificaRepository.deleteById(id); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/impl/PrenotazioneServiceImpl.java b/src/main/java/it/sw/pa/comune/artegna/service/impl/PrenotazioneServiceImpl.java new file mode 100644 index 0000000..45ea650 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/impl/PrenotazioneServiceImpl.java @@ -0,0 +1,81 @@ +package it.sw.pa.comune.artegna.service.impl; + +import it.sw.pa.comune.artegna.domain.Prenotazione; +import it.sw.pa.comune.artegna.repository.PrenotazioneRepository; +import it.sw.pa.comune.artegna.service.PrenotazioneService; +import it.sw.pa.comune.artegna.service.dto.PrenotazioneDTO; +import it.sw.pa.comune.artegna.service.mapper.PrenotazioneMapper; +import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * Service Implementation for managing {@link it.sw.pa.comune.artegna.domain.Prenotazione}. + */ +@Service +@Transactional +public class PrenotazioneServiceImpl implements PrenotazioneService { + + private static final Logger LOG = LoggerFactory.getLogger(PrenotazioneServiceImpl.class); + + private final PrenotazioneRepository prenotazioneRepository; + + private final PrenotazioneMapper prenotazioneMapper; + + public PrenotazioneServiceImpl(PrenotazioneRepository prenotazioneRepository, PrenotazioneMapper prenotazioneMapper) { + this.prenotazioneRepository = prenotazioneRepository; + this.prenotazioneMapper = prenotazioneMapper; + } + + @Override + public PrenotazioneDTO save(PrenotazioneDTO prenotazioneDTO) { + LOG.debug("Request to save Prenotazione : {}", prenotazioneDTO); + Prenotazione prenotazione = prenotazioneMapper.toEntity(prenotazioneDTO); + prenotazione = prenotazioneRepository.save(prenotazione); + return prenotazioneMapper.toDto(prenotazione); + } + + @Override + public PrenotazioneDTO update(PrenotazioneDTO prenotazioneDTO) { + LOG.debug("Request to update Prenotazione : {}", prenotazioneDTO); + Prenotazione prenotazione = prenotazioneMapper.toEntity(prenotazioneDTO); + prenotazione = prenotazioneRepository.save(prenotazione); + return prenotazioneMapper.toDto(prenotazione); + } + + @Override + public Optional partialUpdate(PrenotazioneDTO prenotazioneDTO) { + LOG.debug("Request to partially update Prenotazione : {}", prenotazioneDTO); + + return prenotazioneRepository + .findById(prenotazioneDTO.getId()) + .map(existingPrenotazione -> { + prenotazioneMapper.partialUpdate(existingPrenotazione, prenotazioneDTO); + + return existingPrenotazione; + }) + .map(prenotazioneRepository::save) + .map(prenotazioneMapper::toDto); + } + + public Page findAllWithEagerRelationships(Pageable pageable) { + return prenotazioneRepository.findAllWithEagerRelationships(pageable).map(prenotazioneMapper::toDto); + } + + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + LOG.debug("Request to get Prenotazione : {}", id); + return prenotazioneRepository.findOneWithEagerRelationships(id).map(prenotazioneMapper::toDto); + } + + @Override + public void delete(Long id) { + LOG.debug("Request to delete Prenotazione : {}", id); + prenotazioneRepository.deleteById(id); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/impl/StrutturaServiceImpl.java b/src/main/java/it/sw/pa/comune/artegna/service/impl/StrutturaServiceImpl.java new file mode 100644 index 0000000..d6e15af --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/impl/StrutturaServiceImpl.java @@ -0,0 +1,75 @@ +package it.sw.pa.comune.artegna.service.impl; + +import it.sw.pa.comune.artegna.domain.Struttura; +import it.sw.pa.comune.artegna.repository.StrutturaRepository; +import it.sw.pa.comune.artegna.service.StrutturaService; +import it.sw.pa.comune.artegna.service.dto.StrutturaDTO; +import it.sw.pa.comune.artegna.service.mapper.StrutturaMapper; +import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * Service Implementation for managing {@link it.sw.pa.comune.artegna.domain.Struttura}. + */ +@Service +@Transactional +public class StrutturaServiceImpl implements StrutturaService { + + private static final Logger LOG = LoggerFactory.getLogger(StrutturaServiceImpl.class); + + private final StrutturaRepository strutturaRepository; + + private final StrutturaMapper strutturaMapper; + + public StrutturaServiceImpl(StrutturaRepository strutturaRepository, StrutturaMapper strutturaMapper) { + this.strutturaRepository = strutturaRepository; + this.strutturaMapper = strutturaMapper; + } + + @Override + public StrutturaDTO save(StrutturaDTO strutturaDTO) { + LOG.debug("Request to save Struttura : {}", strutturaDTO); + Struttura struttura = strutturaMapper.toEntity(strutturaDTO); + struttura = strutturaRepository.save(struttura); + return strutturaMapper.toDto(struttura); + } + + @Override + public StrutturaDTO update(StrutturaDTO strutturaDTO) { + LOG.debug("Request to update Struttura : {}", strutturaDTO); + Struttura struttura = strutturaMapper.toEntity(strutturaDTO); + struttura = strutturaRepository.save(struttura); + return strutturaMapper.toDto(struttura); + } + + @Override + public Optional partialUpdate(StrutturaDTO strutturaDTO) { + LOG.debug("Request to partially update Struttura : {}", strutturaDTO); + + return strutturaRepository + .findById(strutturaDTO.getId()) + .map(existingStruttura -> { + strutturaMapper.partialUpdate(existingStruttura, strutturaDTO); + + return existingStruttura; + }) + .map(strutturaRepository::save) + .map(strutturaMapper::toDto); + } + + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + LOG.debug("Request to get Struttura : {}", id); + return strutturaRepository.findById(id).map(strutturaMapper::toDto); + } + + @Override + public void delete(Long id) { + LOG.debug("Request to delete Struttura : {}", id); + strutturaRepository.deleteById(id); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/impl/UtenteAppServiceImpl.java b/src/main/java/it/sw/pa/comune/artegna/service/impl/UtenteAppServiceImpl.java new file mode 100644 index 0000000..bf4f33f --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/impl/UtenteAppServiceImpl.java @@ -0,0 +1,85 @@ +package it.sw.pa.comune.artegna.service.impl; + +import it.sw.pa.comune.artegna.domain.UtenteApp; +import it.sw.pa.comune.artegna.repository.UtenteAppRepository; +import it.sw.pa.comune.artegna.service.UtenteAppService; +import it.sw.pa.comune.artegna.service.dto.UtenteAppDTO; +import it.sw.pa.comune.artegna.service.mapper.UtenteAppMapper; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * Service Implementation for managing {@link it.sw.pa.comune.artegna.domain.UtenteApp}. + */ +@Service +@Transactional +public class UtenteAppServiceImpl implements UtenteAppService { + + private static final Logger LOG = LoggerFactory.getLogger(UtenteAppServiceImpl.class); + + private final UtenteAppRepository utenteAppRepository; + + private final UtenteAppMapper utenteAppMapper; + + public UtenteAppServiceImpl(UtenteAppRepository utenteAppRepository, UtenteAppMapper utenteAppMapper) { + this.utenteAppRepository = utenteAppRepository; + this.utenteAppMapper = utenteAppMapper; + } + + @Override + public UtenteAppDTO save(UtenteAppDTO utenteAppDTO) { + LOG.debug("Request to save UtenteApp : {}", utenteAppDTO); + UtenteApp utenteApp = utenteAppMapper.toEntity(utenteAppDTO); + utenteApp = utenteAppRepository.save(utenteApp); + return utenteAppMapper.toDto(utenteApp); + } + + @Override + public UtenteAppDTO update(UtenteAppDTO utenteAppDTO) { + LOG.debug("Request to update UtenteApp : {}", utenteAppDTO); + UtenteApp utenteApp = utenteAppMapper.toEntity(utenteAppDTO); + utenteApp = utenteAppRepository.save(utenteApp); + return utenteAppMapper.toDto(utenteApp); + } + + @Override + public Optional partialUpdate(UtenteAppDTO utenteAppDTO) { + LOG.debug("Request to partially update UtenteApp : {}", utenteAppDTO); + + return utenteAppRepository + .findById(utenteAppDTO.getId()) + .map(existingUtenteApp -> { + utenteAppMapper.partialUpdate(existingUtenteApp, utenteAppDTO); + + return existingUtenteApp; + }) + .map(utenteAppRepository::save) + .map(utenteAppMapper::toDto); + } + + @Override + @Transactional(readOnly = true) + public List findAll() { + LOG.debug("Request to get all UtenteApps"); + return utenteAppRepository.findAll().stream().map(utenteAppMapper::toDto).collect(Collectors.toCollection(LinkedList::new)); + } + + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + LOG.debug("Request to get UtenteApp : {}", id); + return utenteAppRepository.findById(id).map(utenteAppMapper::toDto); + } + + @Override + public void delete(Long id) { + LOG.debug("Request to delete UtenteApp : {}", id); + utenteAppRepository.deleteById(id); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/impl/package-info.java b/src/main/java/it/sw/pa/comune/artegna/service/impl/package-info.java new file mode 100644 index 0000000..4f9e6ba --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/impl/package-info.java @@ -0,0 +1,4 @@ +/** + * This package file was generated by JHipster + */ +package it.sw.pa.comune.artegna.service.impl; diff --git a/src/main/java/it/sw/pa/comune/artegna/service/mapper/AuditLogMapper.java b/src/main/java/it/sw/pa/comune/artegna/service/mapper/AuditLogMapper.java new file mode 100644 index 0000000..aec978b --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/mapper/AuditLogMapper.java @@ -0,0 +1,22 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import it.sw.pa.comune.artegna.domain.AuditLog; +import it.sw.pa.comune.artegna.domain.UtenteApp; +import it.sw.pa.comune.artegna.service.dto.AuditLogDTO; +import it.sw.pa.comune.artegna.service.dto.UtenteAppDTO; +import org.mapstruct.*; + +/** + * Mapper for the entity {@link AuditLog} and its DTO {@link AuditLogDTO}. + */ +@Mapper(componentModel = "spring") +public interface AuditLogMapper extends EntityMapper { + @Mapping(target = "utente", source = "utente", qualifiedByName = "utenteAppUsername") + AuditLogDTO toDto(AuditLog s); + + @Named("utenteAppUsername") + @BeanMapping(ignoreByDefault = true) + @Mapping(target = "id", source = "id") + @Mapping(target = "username", source = "username") + UtenteAppDTO toDtoUtenteAppUsername(UtenteApp utenteApp); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/mapper/ConfermaMapper.java b/src/main/java/it/sw/pa/comune/artegna/service/mapper/ConfermaMapper.java new file mode 100644 index 0000000..585366f --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/mapper/ConfermaMapper.java @@ -0,0 +1,22 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import it.sw.pa.comune.artegna.domain.Conferma; +import it.sw.pa.comune.artegna.domain.UtenteApp; +import it.sw.pa.comune.artegna.service.dto.ConfermaDTO; +import it.sw.pa.comune.artegna.service.dto.UtenteAppDTO; +import org.mapstruct.*; + +/** + * Mapper for the entity {@link Conferma} and its DTO {@link ConfermaDTO}. + */ +@Mapper(componentModel = "spring") +public interface ConfermaMapper extends EntityMapper { + @Mapping(target = "confermataDa", source = "confermataDa", qualifiedByName = "utenteAppUsername") + ConfermaDTO toDto(Conferma s); + + @Named("utenteAppUsername") + @BeanMapping(ignoreByDefault = true) + @Mapping(target = "id", source = "id") + @Mapping(target = "username", source = "username") + UtenteAppDTO toDtoUtenteAppUsername(UtenteApp utenteApp); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/mapper/DisponibilitaMapper.java b/src/main/java/it/sw/pa/comune/artegna/service/mapper/DisponibilitaMapper.java new file mode 100644 index 0000000..188abb7 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/mapper/DisponibilitaMapper.java @@ -0,0 +1,22 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import it.sw.pa.comune.artegna.domain.Disponibilita; +import it.sw.pa.comune.artegna.domain.Struttura; +import it.sw.pa.comune.artegna.service.dto.DisponibilitaDTO; +import it.sw.pa.comune.artegna.service.dto.StrutturaDTO; +import org.mapstruct.*; + +/** + * Mapper for the entity {@link Disponibilita} and its DTO {@link DisponibilitaDTO}. + */ +@Mapper(componentModel = "spring") +public interface DisponibilitaMapper extends EntityMapper { + @Mapping(target = "struttura", source = "struttura", qualifiedByName = "strutturaNome") + DisponibilitaDTO toDto(Disponibilita s); + + @Named("strutturaNome") + @BeanMapping(ignoreByDefault = true) + @Mapping(target = "id", source = "id") + @Mapping(target = "nome", source = "nome") + StrutturaDTO toDtoStrutturaNome(Struttura struttura); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/mapper/EntityMapper.java b/src/main/java/it/sw/pa/comune/artegna/service/mapper/EntityMapper.java new file mode 100644 index 0000000..98d01db --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/mapper/EntityMapper.java @@ -0,0 +1,28 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import java.util.List; +import org.mapstruct.BeanMapping; +import org.mapstruct.MappingTarget; +import org.mapstruct.Named; +import org.mapstruct.NullValuePropertyMappingStrategy; + +/** + * Contract for a generic dto to entity mapper. + * + * @param - DTO type parameter. + * @param - Entity type parameter. + */ + +public interface EntityMapper { + E toEntity(D dto); + + D toDto(E entity); + + List toEntity(List dtoList); + + List toDto(List entityList); + + @Named("partialUpdate") + @BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE) + void partialUpdate(@MappingTarget E entity, D dto); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/mapper/LiberatoriaMapper.java b/src/main/java/it/sw/pa/comune/artegna/service/mapper/LiberatoriaMapper.java new file mode 100644 index 0000000..335b65f --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/mapper/LiberatoriaMapper.java @@ -0,0 +1,30 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import it.sw.pa.comune.artegna.domain.Liberatoria; +import it.sw.pa.comune.artegna.domain.ModelloLiberatoria; +import it.sw.pa.comune.artegna.domain.UtenteApp; +import it.sw.pa.comune.artegna.service.dto.LiberatoriaDTO; +import it.sw.pa.comune.artegna.service.dto.ModelloLiberatoriaDTO; +import it.sw.pa.comune.artegna.service.dto.UtenteAppDTO; +import org.mapstruct.*; + +/** + * Mapper for the entity {@link Liberatoria} and its DTO {@link LiberatoriaDTO}. + */ +@Mapper(componentModel = "spring") +public interface LiberatoriaMapper extends EntityMapper { + @Mapping(target = "utente", source = "utente", qualifiedByName = "utenteAppUsername") + @Mapping(target = "modelloLiberatoria", source = "modelloLiberatoria", qualifiedByName = "modelloLiberatoriaId") + LiberatoriaDTO toDto(Liberatoria s); + + @Named("utenteAppUsername") + @BeanMapping(ignoreByDefault = true) + @Mapping(target = "id", source = "id") + @Mapping(target = "username", source = "username") + UtenteAppDTO toDtoUtenteAppUsername(UtenteApp utenteApp); + + @Named("modelloLiberatoriaId") + @BeanMapping(ignoreByDefault = true) + @Mapping(target = "id", source = "id") + ModelloLiberatoriaDTO toDtoModelloLiberatoriaId(ModelloLiberatoria modelloLiberatoria); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/mapper/MessaggioMapper.java b/src/main/java/it/sw/pa/comune/artegna/service/mapper/MessaggioMapper.java new file mode 100644 index 0000000..ea4332d --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/mapper/MessaggioMapper.java @@ -0,0 +1,22 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import it.sw.pa.comune.artegna.domain.Messaggio; +import it.sw.pa.comune.artegna.domain.UtenteApp; +import it.sw.pa.comune.artegna.service.dto.MessaggioDTO; +import it.sw.pa.comune.artegna.service.dto.UtenteAppDTO; +import org.mapstruct.*; + +/** + * Mapper for the entity {@link Messaggio} and its DTO {@link MessaggioDTO}. + */ +@Mapper(componentModel = "spring") +public interface MessaggioMapper extends EntityMapper { + @Mapping(target = "utente", source = "utente", qualifiedByName = "utenteAppUsername") + MessaggioDTO toDto(Messaggio s); + + @Named("utenteAppUsername") + @BeanMapping(ignoreByDefault = true) + @Mapping(target = "id", source = "id") + @Mapping(target = "username", source = "username") + UtenteAppDTO toDtoUtenteAppUsername(UtenteApp utenteApp); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/mapper/ModelloLiberatoriaMapper.java b/src/main/java/it/sw/pa/comune/artegna/service/mapper/ModelloLiberatoriaMapper.java new file mode 100644 index 0000000..1c29fc9 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/mapper/ModelloLiberatoriaMapper.java @@ -0,0 +1,21 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import it.sw.pa.comune.artegna.domain.ModelloLiberatoria; +import it.sw.pa.comune.artegna.domain.Struttura; +import it.sw.pa.comune.artegna.service.dto.ModelloLiberatoriaDTO; +import it.sw.pa.comune.artegna.service.dto.StrutturaDTO; +import org.mapstruct.*; + +/** + * Mapper for the entity {@link ModelloLiberatoria} and its DTO {@link ModelloLiberatoriaDTO}. + */ +@Mapper(componentModel = "spring") +public interface ModelloLiberatoriaMapper extends EntityMapper { + @Mapping(target = "struttura", source = "struttura", qualifiedByName = "strutturaId") + ModelloLiberatoriaDTO toDto(ModelloLiberatoria s); + + @Named("strutturaId") + @BeanMapping(ignoreByDefault = true) + @Mapping(target = "id", source = "id") + StrutturaDTO toDtoStrutturaId(Struttura struttura); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/mapper/NotificaMapper.java b/src/main/java/it/sw/pa/comune/artegna/service/mapper/NotificaMapper.java new file mode 100644 index 0000000..61c7dda --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/mapper/NotificaMapper.java @@ -0,0 +1,21 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import it.sw.pa.comune.artegna.domain.Conferma; +import it.sw.pa.comune.artegna.domain.Notifica; +import it.sw.pa.comune.artegna.service.dto.ConfermaDTO; +import it.sw.pa.comune.artegna.service.dto.NotificaDTO; +import org.mapstruct.*; + +/** + * Mapper for the entity {@link Notifica} and its DTO {@link NotificaDTO}. + */ +@Mapper(componentModel = "spring") +public interface NotificaMapper extends EntityMapper { + @Mapping(target = "conferma", source = "conferma", qualifiedByName = "confermaId") + NotificaDTO toDto(Notifica s); + + @Named("confermaId") + @BeanMapping(ignoreByDefault = true) + @Mapping(target = "id", source = "id") + ConfermaDTO toDtoConfermaId(Conferma conferma); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/mapper/PrenotazioneMapper.java b/src/main/java/it/sw/pa/comune/artegna/service/mapper/PrenotazioneMapper.java new file mode 100644 index 0000000..7af3bdb --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/mapper/PrenotazioneMapper.java @@ -0,0 +1,39 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import it.sw.pa.comune.artegna.domain.Conferma; +import it.sw.pa.comune.artegna.domain.Prenotazione; +import it.sw.pa.comune.artegna.domain.Struttura; +import it.sw.pa.comune.artegna.domain.UtenteApp; +import it.sw.pa.comune.artegna.service.dto.ConfermaDTO; +import it.sw.pa.comune.artegna.service.dto.PrenotazioneDTO; +import it.sw.pa.comune.artegna.service.dto.StrutturaDTO; +import it.sw.pa.comune.artegna.service.dto.UtenteAppDTO; +import org.mapstruct.*; + +/** + * Mapper for the entity {@link Prenotazione} and its DTO {@link PrenotazioneDTO}. + */ +@Mapper(componentModel = "spring") +public interface PrenotazioneMapper extends EntityMapper { + @Mapping(target = "conferma", source = "conferma", qualifiedByName = "confermaId") + @Mapping(target = "utente", source = "utente", qualifiedByName = "utenteAppUsername") + @Mapping(target = "struttura", source = "struttura", qualifiedByName = "strutturaNome") + PrenotazioneDTO toDto(Prenotazione s); + + @Named("confermaId") + @BeanMapping(ignoreByDefault = true) + @Mapping(target = "id", source = "id") + ConfermaDTO toDtoConfermaId(Conferma conferma); + + @Named("utenteAppUsername") + @BeanMapping(ignoreByDefault = true) + @Mapping(target = "id", source = "id") + @Mapping(target = "username", source = "username") + UtenteAppDTO toDtoUtenteAppUsername(UtenteApp utenteApp); + + @Named("strutturaNome") + @BeanMapping(ignoreByDefault = true) + @Mapping(target = "id", source = "id") + @Mapping(target = "nome", source = "nome") + StrutturaDTO toDtoStrutturaNome(Struttura struttura); +} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/mapper/StrutturaMapper.java b/src/main/java/it/sw/pa/comune/artegna/service/mapper/StrutturaMapper.java new file mode 100644 index 0000000..35e708b --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/mapper/StrutturaMapper.java @@ -0,0 +1,11 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import it.sw.pa.comune.artegna.domain.Struttura; +import it.sw.pa.comune.artegna.service.dto.StrutturaDTO; +import org.mapstruct.*; + +/** + * Mapper for the entity {@link Struttura} and its DTO {@link StrutturaDTO}. + */ +@Mapper(componentModel = "spring") +public interface StrutturaMapper extends EntityMapper {} diff --git a/src/main/java/it/sw/pa/comune/artegna/service/mapper/UtenteAppMapper.java b/src/main/java/it/sw/pa/comune/artegna/service/mapper/UtenteAppMapper.java new file mode 100644 index 0000000..cf29e5e --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/service/mapper/UtenteAppMapper.java @@ -0,0 +1,11 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import it.sw.pa.comune.artegna.domain.UtenteApp; +import it.sw.pa.comune.artegna.service.dto.UtenteAppDTO; +import org.mapstruct.*; + +/** + * Mapper for the entity {@link UtenteApp} and its DTO {@link UtenteAppDTO}. + */ +@Mapper(componentModel = "spring") +public interface UtenteAppMapper extends EntityMapper {} diff --git a/src/main/java/it/sw/pa/comune/artegna/web/rest/AuditLogResource.java b/src/main/java/it/sw/pa/comune/artegna/web/rest/AuditLogResource.java new file mode 100644 index 0000000..bef371b --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/web/rest/AuditLogResource.java @@ -0,0 +1,203 @@ +package it.sw.pa.comune.artegna.web.rest; + +import it.sw.pa.comune.artegna.repository.AuditLogRepository; +import it.sw.pa.comune.artegna.service.AuditLogQueryService; +import it.sw.pa.comune.artegna.service.AuditLogService; +import it.sw.pa.comune.artegna.service.criteria.AuditLogCriteria; +import it.sw.pa.comune.artegna.service.dto.AuditLogDTO; +import it.sw.pa.comune.artegna.web.rest.errors.BadRequestAlertException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.PaginationUtil; +import tech.jhipster.web.util.ResponseUtil; + +/** + * REST controller for managing {@link it.sw.pa.comune.artegna.domain.AuditLog}. + */ +@RestController +@RequestMapping("/api/audit-logs") +public class AuditLogResource { + + private static final Logger LOG = LoggerFactory.getLogger(AuditLogResource.class); + + private static final String ENTITY_NAME = "auditLog"; + + @Value("${jhipster.clientApp.name:smartbooking}") + private String applicationName; + + private final AuditLogService auditLogService; + + private final AuditLogRepository auditLogRepository; + + private final AuditLogQueryService auditLogQueryService; + + public AuditLogResource( + AuditLogService auditLogService, + AuditLogRepository auditLogRepository, + AuditLogQueryService auditLogQueryService + ) { + this.auditLogService = auditLogService; + this.auditLogRepository = auditLogRepository; + this.auditLogQueryService = auditLogQueryService; + } + + /** + * {@code POST /audit-logs} : Create a new auditLog. + * + * @param auditLogDTO the auditLogDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new auditLogDTO, or with status {@code 400 (Bad Request)} if the auditLog has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("") + public ResponseEntity createAuditLog(@RequestBody AuditLogDTO auditLogDTO) throws URISyntaxException { + LOG.debug("REST request to save AuditLog : {}", auditLogDTO); + if (auditLogDTO.getId() != null) { + throw new BadRequestAlertException("A new auditLog cannot already have an ID", ENTITY_NAME, "idexists"); + } + auditLogDTO = auditLogService.save(auditLogDTO); + return ResponseEntity.created(new URI("/api/audit-logs/" + auditLogDTO.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, auditLogDTO.getId().toString())) + .body(auditLogDTO); + } + + /** + * {@code PUT /audit-logs/:id} : Updates an existing auditLog. + * + * @param id the id of the auditLogDTO to save. + * @param auditLogDTO the auditLogDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated auditLogDTO, + * or with status {@code 400 (Bad Request)} if the auditLogDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the auditLogDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/{id}") + public ResponseEntity updateAuditLog( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody AuditLogDTO auditLogDTO + ) throws URISyntaxException { + LOG.debug("REST request to update AuditLog : {}, {}", id, auditLogDTO); + if (auditLogDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, auditLogDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!auditLogRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + auditLogDTO = auditLogService.update(auditLogDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, auditLogDTO.getId().toString())) + .body(auditLogDTO); + } + + /** + * {@code PATCH /audit-logs/:id} : Partial updates given fields of an existing auditLog, field will ignore if it is null + * + * @param id the id of the auditLogDTO to save. + * @param auditLogDTO the auditLogDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated auditLogDTO, + * or with status {@code 400 (Bad Request)} if the auditLogDTO is not valid, + * or with status {@code 404 (Not Found)} if the auditLogDTO is not found, + * or with status {@code 500 (Internal Server Error)} if the auditLogDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) + public ResponseEntity partialUpdateAuditLog( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody AuditLogDTO auditLogDTO + ) throws URISyntaxException { + LOG.debug("REST request to partial update AuditLog partially : {}, {}", id, auditLogDTO); + if (auditLogDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, auditLogDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!auditLogRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + Optional result = auditLogService.partialUpdate(auditLogDTO); + + return ResponseUtil.wrapOrNotFound( + result, + HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, auditLogDTO.getId().toString()) + ); + } + + /** + * {@code GET /audit-logs} : get all the auditLogs. + * + * @param pageable the pagination information. + * @param criteria the criteria which the requested entities should match. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of auditLogs in body. + */ + @GetMapping("") + public ResponseEntity> getAllAuditLogs( + AuditLogCriteria criteria, + @org.springdoc.core.annotations.ParameterObject Pageable pageable + ) { + LOG.debug("REST request to get AuditLogs by criteria: {}", criteria); + + Page page = auditLogQueryService.findByCriteria(criteria, pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * {@code GET /audit-logs/count} : count all the auditLogs. + * + * @param criteria the criteria which the requested entities should match. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the count in body. + */ + @GetMapping("/count") + public ResponseEntity countAuditLogs(AuditLogCriteria criteria) { + LOG.debug("REST request to count AuditLogs by criteria: {}", criteria); + return ResponseEntity.ok().body(auditLogQueryService.countByCriteria(criteria)); + } + + /** + * {@code GET /audit-logs/:id} : get the "id" auditLog. + * + * @param id the id of the auditLogDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the auditLogDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/{id}") + public ResponseEntity getAuditLog(@PathVariable("id") Long id) { + LOG.debug("REST request to get AuditLog : {}", id); + Optional auditLogDTO = auditLogService.findOne(id); + return ResponseUtil.wrapOrNotFound(auditLogDTO); + } + + /** + * {@code DELETE /audit-logs/:id} : delete the "id" auditLog. + * + * @param id the id of the auditLogDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/{id}") + public ResponseEntity deleteAuditLog(@PathVariable("id") Long id) { + LOG.debug("REST request to delete AuditLog : {}", id); + auditLogService.delete(id); + return ResponseEntity.noContent() + .headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())) + .build(); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/web/rest/ConfermaResource.java b/src/main/java/it/sw/pa/comune/artegna/web/rest/ConfermaResource.java new file mode 100644 index 0000000..ccf0777 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/web/rest/ConfermaResource.java @@ -0,0 +1,203 @@ +package it.sw.pa.comune.artegna.web.rest; + +import it.sw.pa.comune.artegna.repository.ConfermaRepository; +import it.sw.pa.comune.artegna.service.ConfermaQueryService; +import it.sw.pa.comune.artegna.service.ConfermaService; +import it.sw.pa.comune.artegna.service.criteria.ConfermaCriteria; +import it.sw.pa.comune.artegna.service.dto.ConfermaDTO; +import it.sw.pa.comune.artegna.web.rest.errors.BadRequestAlertException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.PaginationUtil; +import tech.jhipster.web.util.ResponseUtil; + +/** + * REST controller for managing {@link it.sw.pa.comune.artegna.domain.Conferma}. + */ +@RestController +@RequestMapping("/api/confermas") +public class ConfermaResource { + + private static final Logger LOG = LoggerFactory.getLogger(ConfermaResource.class); + + private static final String ENTITY_NAME = "conferma"; + + @Value("${jhipster.clientApp.name:smartbooking}") + private String applicationName; + + private final ConfermaService confermaService; + + private final ConfermaRepository confermaRepository; + + private final ConfermaQueryService confermaQueryService; + + public ConfermaResource( + ConfermaService confermaService, + ConfermaRepository confermaRepository, + ConfermaQueryService confermaQueryService + ) { + this.confermaService = confermaService; + this.confermaRepository = confermaRepository; + this.confermaQueryService = confermaQueryService; + } + + /** + * {@code POST /confermas} : Create a new conferma. + * + * @param confermaDTO the confermaDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new confermaDTO, or with status {@code 400 (Bad Request)} if the conferma has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("") + public ResponseEntity createConferma(@RequestBody ConfermaDTO confermaDTO) throws URISyntaxException { + LOG.debug("REST request to save Conferma : {}", confermaDTO); + if (confermaDTO.getId() != null) { + throw new BadRequestAlertException("A new conferma cannot already have an ID", ENTITY_NAME, "idexists"); + } + confermaDTO = confermaService.save(confermaDTO); + return ResponseEntity.created(new URI("/api/confermas/" + confermaDTO.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, confermaDTO.getId().toString())) + .body(confermaDTO); + } + + /** + * {@code PUT /confermas/:id} : Updates an existing conferma. + * + * @param id the id of the confermaDTO to save. + * @param confermaDTO the confermaDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated confermaDTO, + * or with status {@code 400 (Bad Request)} if the confermaDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the confermaDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/{id}") + public ResponseEntity updateConferma( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody ConfermaDTO confermaDTO + ) throws URISyntaxException { + LOG.debug("REST request to update Conferma : {}, {}", id, confermaDTO); + if (confermaDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, confermaDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!confermaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + confermaDTO = confermaService.update(confermaDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, confermaDTO.getId().toString())) + .body(confermaDTO); + } + + /** + * {@code PATCH /confermas/:id} : Partial updates given fields of an existing conferma, field will ignore if it is null + * + * @param id the id of the confermaDTO to save. + * @param confermaDTO the confermaDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated confermaDTO, + * or with status {@code 400 (Bad Request)} if the confermaDTO is not valid, + * or with status {@code 404 (Not Found)} if the confermaDTO is not found, + * or with status {@code 500 (Internal Server Error)} if the confermaDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) + public ResponseEntity partialUpdateConferma( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody ConfermaDTO confermaDTO + ) throws URISyntaxException { + LOG.debug("REST request to partial update Conferma partially : {}, {}", id, confermaDTO); + if (confermaDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, confermaDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!confermaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + Optional result = confermaService.partialUpdate(confermaDTO); + + return ResponseUtil.wrapOrNotFound( + result, + HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, confermaDTO.getId().toString()) + ); + } + + /** + * {@code GET /confermas} : get all the confermas. + * + * @param pageable the pagination information. + * @param criteria the criteria which the requested entities should match. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of confermas in body. + */ + @GetMapping("") + public ResponseEntity> getAllConfermas( + ConfermaCriteria criteria, + @org.springdoc.core.annotations.ParameterObject Pageable pageable + ) { + LOG.debug("REST request to get Confermas by criteria: {}", criteria); + + Page page = confermaQueryService.findByCriteria(criteria, pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * {@code GET /confermas/count} : count all the confermas. + * + * @param criteria the criteria which the requested entities should match. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the count in body. + */ + @GetMapping("/count") + public ResponseEntity countConfermas(ConfermaCriteria criteria) { + LOG.debug("REST request to count Confermas by criteria: {}", criteria); + return ResponseEntity.ok().body(confermaQueryService.countByCriteria(criteria)); + } + + /** + * {@code GET /confermas/:id} : get the "id" conferma. + * + * @param id the id of the confermaDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the confermaDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/{id}") + public ResponseEntity getConferma(@PathVariable("id") Long id) { + LOG.debug("REST request to get Conferma : {}", id); + Optional confermaDTO = confermaService.findOne(id); + return ResponseUtil.wrapOrNotFound(confermaDTO); + } + + /** + * {@code DELETE /confermas/:id} : delete the "id" conferma. + * + * @param id the id of the confermaDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/{id}") + public ResponseEntity deleteConferma(@PathVariable("id") Long id) { + LOG.debug("REST request to delete Conferma : {}", id); + confermaService.delete(id); + return ResponseEntity.noContent() + .headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())) + .build(); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/web/rest/DisponibilitaResource.java b/src/main/java/it/sw/pa/comune/artegna/web/rest/DisponibilitaResource.java new file mode 100644 index 0000000..0b46ae6 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/web/rest/DisponibilitaResource.java @@ -0,0 +1,186 @@ +package it.sw.pa.comune.artegna.web.rest; + +import it.sw.pa.comune.artegna.repository.DisponibilitaRepository; +import it.sw.pa.comune.artegna.service.DisponibilitaService; +import it.sw.pa.comune.artegna.service.dto.DisponibilitaDTO; +import it.sw.pa.comune.artegna.web.rest.errors.BadRequestAlertException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.PaginationUtil; +import tech.jhipster.web.util.ResponseUtil; + +/** + * REST controller for managing {@link it.sw.pa.comune.artegna.domain.Disponibilita}. + */ +@RestController +@RequestMapping("/api/disponibilitas") +public class DisponibilitaResource { + + private static final Logger LOG = LoggerFactory.getLogger(DisponibilitaResource.class); + + private static final String ENTITY_NAME = "disponibilita"; + + @Value("${jhipster.clientApp.name:smartbooking}") + private String applicationName; + + private final DisponibilitaService disponibilitaService; + + private final DisponibilitaRepository disponibilitaRepository; + + public DisponibilitaResource(DisponibilitaService disponibilitaService, DisponibilitaRepository disponibilitaRepository) { + this.disponibilitaService = disponibilitaService; + this.disponibilitaRepository = disponibilitaRepository; + } + + /** + * {@code POST /disponibilitas} : Create a new disponibilita. + * + * @param disponibilitaDTO the disponibilitaDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new disponibilitaDTO, or with status {@code 400 (Bad Request)} if the disponibilita has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("") + public ResponseEntity createDisponibilita(@RequestBody DisponibilitaDTO disponibilitaDTO) throws URISyntaxException { + LOG.debug("REST request to save Disponibilita : {}", disponibilitaDTO); + if (disponibilitaDTO.getId() != null) { + throw new BadRequestAlertException("A new disponibilita cannot already have an ID", ENTITY_NAME, "idexists"); + } + disponibilitaDTO = disponibilitaService.save(disponibilitaDTO); + return ResponseEntity.created(new URI("/api/disponibilitas/" + disponibilitaDTO.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, disponibilitaDTO.getId().toString())) + .body(disponibilitaDTO); + } + + /** + * {@code PUT /disponibilitas/:id} : Updates an existing disponibilita. + * + * @param id the id of the disponibilitaDTO to save. + * @param disponibilitaDTO the disponibilitaDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated disponibilitaDTO, + * or with status {@code 400 (Bad Request)} if the disponibilitaDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the disponibilitaDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/{id}") + public ResponseEntity updateDisponibilita( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody DisponibilitaDTO disponibilitaDTO + ) throws URISyntaxException { + LOG.debug("REST request to update Disponibilita : {}, {}", id, disponibilitaDTO); + if (disponibilitaDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, disponibilitaDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!disponibilitaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + disponibilitaDTO = disponibilitaService.update(disponibilitaDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, disponibilitaDTO.getId().toString())) + .body(disponibilitaDTO); + } + + /** + * {@code PATCH /disponibilitas/:id} : Partial updates given fields of an existing disponibilita, field will ignore if it is null + * + * @param id the id of the disponibilitaDTO to save. + * @param disponibilitaDTO the disponibilitaDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated disponibilitaDTO, + * or with status {@code 400 (Bad Request)} if the disponibilitaDTO is not valid, + * or with status {@code 404 (Not Found)} if the disponibilitaDTO is not found, + * or with status {@code 500 (Internal Server Error)} if the disponibilitaDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) + public ResponseEntity partialUpdateDisponibilita( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody DisponibilitaDTO disponibilitaDTO + ) throws URISyntaxException { + LOG.debug("REST request to partial update Disponibilita partially : {}, {}", id, disponibilitaDTO); + if (disponibilitaDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, disponibilitaDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!disponibilitaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + Optional result = disponibilitaService.partialUpdate(disponibilitaDTO); + + return ResponseUtil.wrapOrNotFound( + result, + HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, disponibilitaDTO.getId().toString()) + ); + } + + /** + * {@code GET /disponibilitas} : get all the disponibilitas. + * + * @param pageable the pagination information. + * @param eagerload flag to eager load entities from relationships (This is applicable for many-to-many). + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of disponibilitas in body. + */ + @GetMapping("") + public ResponseEntity> getAllDisponibilitas( + @org.springdoc.core.annotations.ParameterObject Pageable pageable, + @RequestParam(name = "eagerload", required = false, defaultValue = "true") boolean eagerload + ) { + LOG.debug("REST request to get a page of Disponibilitas"); + Page page; + if (eagerload) { + page = disponibilitaService.findAllWithEagerRelationships(pageable); + } else { + page = disponibilitaService.findAll(pageable); + } + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * {@code GET /disponibilitas/:id} : get the "id" disponibilita. + * + * @param id the id of the disponibilitaDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the disponibilitaDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/{id}") + public ResponseEntity getDisponibilita(@PathVariable("id") Long id) { + LOG.debug("REST request to get Disponibilita : {}", id); + Optional disponibilitaDTO = disponibilitaService.findOne(id); + return ResponseUtil.wrapOrNotFound(disponibilitaDTO); + } + + /** + * {@code DELETE /disponibilitas/:id} : delete the "id" disponibilita. + * + * @param id the id of the disponibilitaDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/{id}") + public ResponseEntity deleteDisponibilita(@PathVariable("id") Long id) { + LOG.debug("REST request to delete Disponibilita : {}", id); + disponibilitaService.delete(id); + return ResponseEntity.noContent() + .headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())) + .build(); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/web/rest/LiberatoriaResource.java b/src/main/java/it/sw/pa/comune/artegna/web/rest/LiberatoriaResource.java new file mode 100644 index 0000000..816b62f --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/web/rest/LiberatoriaResource.java @@ -0,0 +1,172 @@ +package it.sw.pa.comune.artegna.web.rest; + +import it.sw.pa.comune.artegna.repository.LiberatoriaRepository; +import it.sw.pa.comune.artegna.service.LiberatoriaService; +import it.sw.pa.comune.artegna.service.dto.LiberatoriaDTO; +import it.sw.pa.comune.artegna.web.rest.errors.BadRequestAlertException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Objects; +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.*; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.ResponseUtil; + +/** + * REST controller for managing {@link it.sw.pa.comune.artegna.domain.Liberatoria}. + */ +@RestController +@RequestMapping("/api/liberatorias") +public class LiberatoriaResource { + + private static final Logger LOG = LoggerFactory.getLogger(LiberatoriaResource.class); + + private static final String ENTITY_NAME = "liberatoria"; + + @Value("${jhipster.clientApp.name:smartbooking}") + private String applicationName; + + private final LiberatoriaService liberatoriaService; + + private final LiberatoriaRepository liberatoriaRepository; + + public LiberatoriaResource(LiberatoriaService liberatoriaService, LiberatoriaRepository liberatoriaRepository) { + this.liberatoriaService = liberatoriaService; + this.liberatoriaRepository = liberatoriaRepository; + } + + /** + * {@code POST /liberatorias} : Create a new liberatoria. + * + * @param liberatoriaDTO the liberatoriaDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new liberatoriaDTO, or with status {@code 400 (Bad Request)} if the liberatoria has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("") + public ResponseEntity createLiberatoria(@RequestBody LiberatoriaDTO liberatoriaDTO) throws URISyntaxException { + LOG.debug("REST request to save Liberatoria : {}", liberatoriaDTO); + if (liberatoriaDTO.getId() != null) { + throw new BadRequestAlertException("A new liberatoria cannot already have an ID", ENTITY_NAME, "idexists"); + } + liberatoriaDTO = liberatoriaService.save(liberatoriaDTO); + return ResponseEntity.created(new URI("/api/liberatorias/" + liberatoriaDTO.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, liberatoriaDTO.getId().toString())) + .body(liberatoriaDTO); + } + + /** + * {@code PUT /liberatorias/:id} : Updates an existing liberatoria. + * + * @param id the id of the liberatoriaDTO to save. + * @param liberatoriaDTO the liberatoriaDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated liberatoriaDTO, + * or with status {@code 400 (Bad Request)} if the liberatoriaDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the liberatoriaDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/{id}") + public ResponseEntity updateLiberatoria( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody LiberatoriaDTO liberatoriaDTO + ) throws URISyntaxException { + LOG.debug("REST request to update Liberatoria : {}, {}", id, liberatoriaDTO); + if (liberatoriaDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, liberatoriaDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!liberatoriaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + liberatoriaDTO = liberatoriaService.update(liberatoriaDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, liberatoriaDTO.getId().toString())) + .body(liberatoriaDTO); + } + + /** + * {@code PATCH /liberatorias/:id} : Partial updates given fields of an existing liberatoria, field will ignore if it is null + * + * @param id the id of the liberatoriaDTO to save. + * @param liberatoriaDTO the liberatoriaDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated liberatoriaDTO, + * or with status {@code 400 (Bad Request)} if the liberatoriaDTO is not valid, + * or with status {@code 404 (Not Found)} if the liberatoriaDTO is not found, + * or with status {@code 500 (Internal Server Error)} if the liberatoriaDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) + public ResponseEntity partialUpdateLiberatoria( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody LiberatoriaDTO liberatoriaDTO + ) throws URISyntaxException { + LOG.debug("REST request to partial update Liberatoria partially : {}, {}", id, liberatoriaDTO); + if (liberatoriaDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, liberatoriaDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!liberatoriaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + Optional result = liberatoriaService.partialUpdate(liberatoriaDTO); + + return ResponseUtil.wrapOrNotFound( + result, + HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, liberatoriaDTO.getId().toString()) + ); + } + + /** + * {@code GET /liberatorias} : get all the liberatorias. + * + * @param eagerload flag to eager load entities from relationships (This is applicable for many-to-many). + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of liberatorias in body. + */ + @GetMapping("") + public List getAllLiberatorias( + @RequestParam(name = "eagerload", required = false, defaultValue = "true") boolean eagerload + ) { + LOG.debug("REST request to get all Liberatorias"); + return liberatoriaService.findAll(); + } + + /** + * {@code GET /liberatorias/:id} : get the "id" liberatoria. + * + * @param id the id of the liberatoriaDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the liberatoriaDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/{id}") + public ResponseEntity getLiberatoria(@PathVariable("id") Long id) { + LOG.debug("REST request to get Liberatoria : {}", id); + Optional liberatoriaDTO = liberatoriaService.findOne(id); + return ResponseUtil.wrapOrNotFound(liberatoriaDTO); + } + + /** + * {@code DELETE /liberatorias/:id} : delete the "id" liberatoria. + * + * @param id the id of the liberatoriaDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/{id}") + public ResponseEntity deleteLiberatoria(@PathVariable("id") Long id) { + LOG.debug("REST request to delete Liberatoria : {}", id); + liberatoriaService.delete(id); + return ResponseEntity.noContent() + .headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())) + .build(); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/web/rest/MessaggioResource.java b/src/main/java/it/sw/pa/comune/artegna/web/rest/MessaggioResource.java new file mode 100644 index 0000000..470c16e --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/web/rest/MessaggioResource.java @@ -0,0 +1,172 @@ +package it.sw.pa.comune.artegna.web.rest; + +import it.sw.pa.comune.artegna.repository.MessaggioRepository; +import it.sw.pa.comune.artegna.service.MessaggioService; +import it.sw.pa.comune.artegna.service.dto.MessaggioDTO; +import it.sw.pa.comune.artegna.web.rest.errors.BadRequestAlertException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Objects; +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.*; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.ResponseUtil; + +/** + * REST controller for managing {@link it.sw.pa.comune.artegna.domain.Messaggio}. + */ +@RestController +@RequestMapping("/api/messaggios") +public class MessaggioResource { + + private static final Logger LOG = LoggerFactory.getLogger(MessaggioResource.class); + + private static final String ENTITY_NAME = "messaggio"; + + @Value("${jhipster.clientApp.name:smartbooking}") + private String applicationName; + + private final MessaggioService messaggioService; + + private final MessaggioRepository messaggioRepository; + + public MessaggioResource(MessaggioService messaggioService, MessaggioRepository messaggioRepository) { + this.messaggioService = messaggioService; + this.messaggioRepository = messaggioRepository; + } + + /** + * {@code POST /messaggios} : Create a new messaggio. + * + * @param messaggioDTO the messaggioDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new messaggioDTO, or with status {@code 400 (Bad Request)} if the messaggio has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("") + public ResponseEntity createMessaggio(@RequestBody MessaggioDTO messaggioDTO) throws URISyntaxException { + LOG.debug("REST request to save Messaggio : {}", messaggioDTO); + if (messaggioDTO.getId() != null) { + throw new BadRequestAlertException("A new messaggio cannot already have an ID", ENTITY_NAME, "idexists"); + } + messaggioDTO = messaggioService.save(messaggioDTO); + return ResponseEntity.created(new URI("/api/messaggios/" + messaggioDTO.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, messaggioDTO.getId().toString())) + .body(messaggioDTO); + } + + /** + * {@code PUT /messaggios/:id} : Updates an existing messaggio. + * + * @param id the id of the messaggioDTO to save. + * @param messaggioDTO the messaggioDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated messaggioDTO, + * or with status {@code 400 (Bad Request)} if the messaggioDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the messaggioDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/{id}") + public ResponseEntity updateMessaggio( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody MessaggioDTO messaggioDTO + ) throws URISyntaxException { + LOG.debug("REST request to update Messaggio : {}, {}", id, messaggioDTO); + if (messaggioDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, messaggioDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!messaggioRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + messaggioDTO = messaggioService.update(messaggioDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, messaggioDTO.getId().toString())) + .body(messaggioDTO); + } + + /** + * {@code PATCH /messaggios/:id} : Partial updates given fields of an existing messaggio, field will ignore if it is null + * + * @param id the id of the messaggioDTO to save. + * @param messaggioDTO the messaggioDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated messaggioDTO, + * or with status {@code 400 (Bad Request)} if the messaggioDTO is not valid, + * or with status {@code 404 (Not Found)} if the messaggioDTO is not found, + * or with status {@code 500 (Internal Server Error)} if the messaggioDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) + public ResponseEntity partialUpdateMessaggio( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody MessaggioDTO messaggioDTO + ) throws URISyntaxException { + LOG.debug("REST request to partial update Messaggio partially : {}, {}", id, messaggioDTO); + if (messaggioDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, messaggioDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!messaggioRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + Optional result = messaggioService.partialUpdate(messaggioDTO); + + return ResponseUtil.wrapOrNotFound( + result, + HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, messaggioDTO.getId().toString()) + ); + } + + /** + * {@code GET /messaggios} : get all the messaggios. + * + * @param eagerload flag to eager load entities from relationships (This is applicable for many-to-many). + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of messaggios in body. + */ + @GetMapping("") + public List getAllMessaggios( + @RequestParam(name = "eagerload", required = false, defaultValue = "true") boolean eagerload + ) { + LOG.debug("REST request to get all Messaggios"); + return messaggioService.findAll(); + } + + /** + * {@code GET /messaggios/:id} : get the "id" messaggio. + * + * @param id the id of the messaggioDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the messaggioDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/{id}") + public ResponseEntity getMessaggio(@PathVariable("id") Long id) { + LOG.debug("REST request to get Messaggio : {}", id); + Optional messaggioDTO = messaggioService.findOne(id); + return ResponseUtil.wrapOrNotFound(messaggioDTO); + } + + /** + * {@code DELETE /messaggios/:id} : delete the "id" messaggio. + * + * @param id the id of the messaggioDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/{id}") + public ResponseEntity deleteMessaggio(@PathVariable("id") Long id) { + LOG.debug("REST request to delete Messaggio : {}", id); + messaggioService.delete(id); + return ResponseEntity.noContent() + .headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())) + .build(); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/web/rest/ModelloLiberatoriaResource.java b/src/main/java/it/sw/pa/comune/artegna/web/rest/ModelloLiberatoriaResource.java new file mode 100644 index 0000000..c0586ec --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/web/rest/ModelloLiberatoriaResource.java @@ -0,0 +1,173 @@ +package it.sw.pa.comune.artegna.web.rest; + +import it.sw.pa.comune.artegna.repository.ModelloLiberatoriaRepository; +import it.sw.pa.comune.artegna.service.ModelloLiberatoriaService; +import it.sw.pa.comune.artegna.service.dto.ModelloLiberatoriaDTO; +import it.sw.pa.comune.artegna.web.rest.errors.BadRequestAlertException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Objects; +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.*; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.ResponseUtil; + +/** + * REST controller for managing {@link it.sw.pa.comune.artegna.domain.ModelloLiberatoria}. + */ +@RestController +@RequestMapping("/api/modello-liberatorias") +public class ModelloLiberatoriaResource { + + private static final Logger LOG = LoggerFactory.getLogger(ModelloLiberatoriaResource.class); + + private static final String ENTITY_NAME = "modelloLiberatoria"; + + @Value("${jhipster.clientApp.name:smartbooking}") + private String applicationName; + + private final ModelloLiberatoriaService modelloLiberatoriaService; + + private final ModelloLiberatoriaRepository modelloLiberatoriaRepository; + + public ModelloLiberatoriaResource( + ModelloLiberatoriaService modelloLiberatoriaService, + ModelloLiberatoriaRepository modelloLiberatoriaRepository + ) { + this.modelloLiberatoriaService = modelloLiberatoriaService; + this.modelloLiberatoriaRepository = modelloLiberatoriaRepository; + } + + /** + * {@code POST /modello-liberatorias} : Create a new modelloLiberatoria. + * + * @param modelloLiberatoriaDTO the modelloLiberatoriaDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new modelloLiberatoriaDTO, or with status {@code 400 (Bad Request)} if the modelloLiberatoria has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("") + public ResponseEntity createModelloLiberatoria(@RequestBody ModelloLiberatoriaDTO modelloLiberatoriaDTO) + throws URISyntaxException { + LOG.debug("REST request to save ModelloLiberatoria : {}", modelloLiberatoriaDTO); + if (modelloLiberatoriaDTO.getId() != null) { + throw new BadRequestAlertException("A new modelloLiberatoria cannot already have an ID", ENTITY_NAME, "idexists"); + } + modelloLiberatoriaDTO = modelloLiberatoriaService.save(modelloLiberatoriaDTO); + return ResponseEntity.created(new URI("/api/modello-liberatorias/" + modelloLiberatoriaDTO.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, modelloLiberatoriaDTO.getId().toString())) + .body(modelloLiberatoriaDTO); + } + + /** + * {@code PUT /modello-liberatorias/:id} : Updates an existing modelloLiberatoria. + * + * @param id the id of the modelloLiberatoriaDTO to save. + * @param modelloLiberatoriaDTO the modelloLiberatoriaDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated modelloLiberatoriaDTO, + * or with status {@code 400 (Bad Request)} if the modelloLiberatoriaDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the modelloLiberatoriaDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/{id}") + public ResponseEntity updateModelloLiberatoria( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody ModelloLiberatoriaDTO modelloLiberatoriaDTO + ) throws URISyntaxException { + LOG.debug("REST request to update ModelloLiberatoria : {}, {}", id, modelloLiberatoriaDTO); + if (modelloLiberatoriaDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, modelloLiberatoriaDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!modelloLiberatoriaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + modelloLiberatoriaDTO = modelloLiberatoriaService.update(modelloLiberatoriaDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, modelloLiberatoriaDTO.getId().toString())) + .body(modelloLiberatoriaDTO); + } + + /** + * {@code PATCH /modello-liberatorias/:id} : Partial updates given fields of an existing modelloLiberatoria, field will ignore if it is null + * + * @param id the id of the modelloLiberatoriaDTO to save. + * @param modelloLiberatoriaDTO the modelloLiberatoriaDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated modelloLiberatoriaDTO, + * or with status {@code 400 (Bad Request)} if the modelloLiberatoriaDTO is not valid, + * or with status {@code 404 (Not Found)} if the modelloLiberatoriaDTO is not found, + * or with status {@code 500 (Internal Server Error)} if the modelloLiberatoriaDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) + public ResponseEntity partialUpdateModelloLiberatoria( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody ModelloLiberatoriaDTO modelloLiberatoriaDTO + ) throws URISyntaxException { + LOG.debug("REST request to partial update ModelloLiberatoria partially : {}, {}", id, modelloLiberatoriaDTO); + if (modelloLiberatoriaDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, modelloLiberatoriaDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!modelloLiberatoriaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + Optional result = modelloLiberatoriaService.partialUpdate(modelloLiberatoriaDTO); + + return ResponseUtil.wrapOrNotFound( + result, + HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, modelloLiberatoriaDTO.getId().toString()) + ); + } + + /** + * {@code GET /modello-liberatorias} : get all the modelloLiberatorias. + * + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of modelloLiberatorias in body. + */ + @GetMapping("") + public List getAllModelloLiberatorias() { + LOG.debug("REST request to get all ModelloLiberatorias"); + return modelloLiberatoriaService.findAll(); + } + + /** + * {@code GET /modello-liberatorias/:id} : get the "id" modelloLiberatoria. + * + * @param id the id of the modelloLiberatoriaDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the modelloLiberatoriaDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/{id}") + public ResponseEntity getModelloLiberatoria(@PathVariable("id") Long id) { + LOG.debug("REST request to get ModelloLiberatoria : {}", id); + Optional modelloLiberatoriaDTO = modelloLiberatoriaService.findOne(id); + return ResponseUtil.wrapOrNotFound(modelloLiberatoriaDTO); + } + + /** + * {@code DELETE /modello-liberatorias/:id} : delete the "id" modelloLiberatoria. + * + * @param id the id of the modelloLiberatoriaDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/{id}") + public ResponseEntity deleteModelloLiberatoria(@PathVariable("id") Long id) { + LOG.debug("REST request to delete ModelloLiberatoria : {}", id); + modelloLiberatoriaService.delete(id); + return ResponseEntity.noContent() + .headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())) + .build(); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/web/rest/NotificaResource.java b/src/main/java/it/sw/pa/comune/artegna/web/rest/NotificaResource.java new file mode 100644 index 0000000..731e490 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/web/rest/NotificaResource.java @@ -0,0 +1,203 @@ +package it.sw.pa.comune.artegna.web.rest; + +import it.sw.pa.comune.artegna.repository.NotificaRepository; +import it.sw.pa.comune.artegna.service.NotificaQueryService; +import it.sw.pa.comune.artegna.service.NotificaService; +import it.sw.pa.comune.artegna.service.criteria.NotificaCriteria; +import it.sw.pa.comune.artegna.service.dto.NotificaDTO; +import it.sw.pa.comune.artegna.web.rest.errors.BadRequestAlertException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.PaginationUtil; +import tech.jhipster.web.util.ResponseUtil; + +/** + * REST controller for managing {@link it.sw.pa.comune.artegna.domain.Notifica}. + */ +@RestController +@RequestMapping("/api/notificas") +public class NotificaResource { + + private static final Logger LOG = LoggerFactory.getLogger(NotificaResource.class); + + private static final String ENTITY_NAME = "notifica"; + + @Value("${jhipster.clientApp.name:smartbooking}") + private String applicationName; + + private final NotificaService notificaService; + + private final NotificaRepository notificaRepository; + + private final NotificaQueryService notificaQueryService; + + public NotificaResource( + NotificaService notificaService, + NotificaRepository notificaRepository, + NotificaQueryService notificaQueryService + ) { + this.notificaService = notificaService; + this.notificaRepository = notificaRepository; + this.notificaQueryService = notificaQueryService; + } + + /** + * {@code POST /notificas} : Create a new notifica. + * + * @param notificaDTO the notificaDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new notificaDTO, or with status {@code 400 (Bad Request)} if the notifica has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("") + public ResponseEntity createNotifica(@RequestBody NotificaDTO notificaDTO) throws URISyntaxException { + LOG.debug("REST request to save Notifica : {}", notificaDTO); + if (notificaDTO.getId() != null) { + throw new BadRequestAlertException("A new notifica cannot already have an ID", ENTITY_NAME, "idexists"); + } + notificaDTO = notificaService.save(notificaDTO); + return ResponseEntity.created(new URI("/api/notificas/" + notificaDTO.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, notificaDTO.getId().toString())) + .body(notificaDTO); + } + + /** + * {@code PUT /notificas/:id} : Updates an existing notifica. + * + * @param id the id of the notificaDTO to save. + * @param notificaDTO the notificaDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated notificaDTO, + * or with status {@code 400 (Bad Request)} if the notificaDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the notificaDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/{id}") + public ResponseEntity updateNotifica( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody NotificaDTO notificaDTO + ) throws URISyntaxException { + LOG.debug("REST request to update Notifica : {}, {}", id, notificaDTO); + if (notificaDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, notificaDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!notificaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + notificaDTO = notificaService.update(notificaDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, notificaDTO.getId().toString())) + .body(notificaDTO); + } + + /** + * {@code PATCH /notificas/:id} : Partial updates given fields of an existing notifica, field will ignore if it is null + * + * @param id the id of the notificaDTO to save. + * @param notificaDTO the notificaDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated notificaDTO, + * or with status {@code 400 (Bad Request)} if the notificaDTO is not valid, + * or with status {@code 404 (Not Found)} if the notificaDTO is not found, + * or with status {@code 500 (Internal Server Error)} if the notificaDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) + public ResponseEntity partialUpdateNotifica( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody NotificaDTO notificaDTO + ) throws URISyntaxException { + LOG.debug("REST request to partial update Notifica partially : {}, {}", id, notificaDTO); + if (notificaDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, notificaDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!notificaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + Optional result = notificaService.partialUpdate(notificaDTO); + + return ResponseUtil.wrapOrNotFound( + result, + HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, notificaDTO.getId().toString()) + ); + } + + /** + * {@code GET /notificas} : get all the notificas. + * + * @param pageable the pagination information. + * @param criteria the criteria which the requested entities should match. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of notificas in body. + */ + @GetMapping("") + public ResponseEntity> getAllNotificas( + NotificaCriteria criteria, + @org.springdoc.core.annotations.ParameterObject Pageable pageable + ) { + LOG.debug("REST request to get Notificas by criteria: {}", criteria); + + Page page = notificaQueryService.findByCriteria(criteria, pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * {@code GET /notificas/count} : count all the notificas. + * + * @param criteria the criteria which the requested entities should match. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the count in body. + */ + @GetMapping("/count") + public ResponseEntity countNotificas(NotificaCriteria criteria) { + LOG.debug("REST request to count Notificas by criteria: {}", criteria); + return ResponseEntity.ok().body(notificaQueryService.countByCriteria(criteria)); + } + + /** + * {@code GET /notificas/:id} : get the "id" notifica. + * + * @param id the id of the notificaDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the notificaDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/{id}") + public ResponseEntity getNotifica(@PathVariable("id") Long id) { + LOG.debug("REST request to get Notifica : {}", id); + Optional notificaDTO = notificaService.findOne(id); + return ResponseUtil.wrapOrNotFound(notificaDTO); + } + + /** + * {@code DELETE /notificas/:id} : delete the "id" notifica. + * + * @param id the id of the notificaDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/{id}") + public ResponseEntity deleteNotifica(@PathVariable("id") Long id) { + LOG.debug("REST request to delete Notifica : {}", id); + notificaService.delete(id); + return ResponseEntity.noContent() + .headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())) + .build(); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/web/rest/PrenotazioneResource.java b/src/main/java/it/sw/pa/comune/artegna/web/rest/PrenotazioneResource.java new file mode 100644 index 0000000..535a4f7 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/web/rest/PrenotazioneResource.java @@ -0,0 +1,203 @@ +package it.sw.pa.comune.artegna.web.rest; + +import it.sw.pa.comune.artegna.repository.PrenotazioneRepository; +import it.sw.pa.comune.artegna.service.PrenotazioneQueryService; +import it.sw.pa.comune.artegna.service.PrenotazioneService; +import it.sw.pa.comune.artegna.service.criteria.PrenotazioneCriteria; +import it.sw.pa.comune.artegna.service.dto.PrenotazioneDTO; +import it.sw.pa.comune.artegna.web.rest.errors.BadRequestAlertException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.PaginationUtil; +import tech.jhipster.web.util.ResponseUtil; + +/** + * REST controller for managing {@link it.sw.pa.comune.artegna.domain.Prenotazione}. + */ +@RestController +@RequestMapping("/api/prenotaziones") +public class PrenotazioneResource { + + private static final Logger LOG = LoggerFactory.getLogger(PrenotazioneResource.class); + + private static final String ENTITY_NAME = "prenotazione"; + + @Value("${jhipster.clientApp.name:smartbooking}") + private String applicationName; + + private final PrenotazioneService prenotazioneService; + + private final PrenotazioneRepository prenotazioneRepository; + + private final PrenotazioneQueryService prenotazioneQueryService; + + public PrenotazioneResource( + PrenotazioneService prenotazioneService, + PrenotazioneRepository prenotazioneRepository, + PrenotazioneQueryService prenotazioneQueryService + ) { + this.prenotazioneService = prenotazioneService; + this.prenotazioneRepository = prenotazioneRepository; + this.prenotazioneQueryService = prenotazioneQueryService; + } + + /** + * {@code POST /prenotaziones} : Create a new prenotazione. + * + * @param prenotazioneDTO the prenotazioneDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new prenotazioneDTO, or with status {@code 400 (Bad Request)} if the prenotazione has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("") + public ResponseEntity createPrenotazione(@RequestBody PrenotazioneDTO prenotazioneDTO) throws URISyntaxException { + LOG.debug("REST request to save Prenotazione : {}", prenotazioneDTO); + if (prenotazioneDTO.getId() != null) { + throw new BadRequestAlertException("A new prenotazione cannot already have an ID", ENTITY_NAME, "idexists"); + } + prenotazioneDTO = prenotazioneService.save(prenotazioneDTO); + return ResponseEntity.created(new URI("/api/prenotaziones/" + prenotazioneDTO.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, prenotazioneDTO.getId().toString())) + .body(prenotazioneDTO); + } + + /** + * {@code PUT /prenotaziones/:id} : Updates an existing prenotazione. + * + * @param id the id of the prenotazioneDTO to save. + * @param prenotazioneDTO the prenotazioneDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated prenotazioneDTO, + * or with status {@code 400 (Bad Request)} if the prenotazioneDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the prenotazioneDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/{id}") + public ResponseEntity updatePrenotazione( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody PrenotazioneDTO prenotazioneDTO + ) throws URISyntaxException { + LOG.debug("REST request to update Prenotazione : {}, {}", id, prenotazioneDTO); + if (prenotazioneDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, prenotazioneDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!prenotazioneRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + prenotazioneDTO = prenotazioneService.update(prenotazioneDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, prenotazioneDTO.getId().toString())) + .body(prenotazioneDTO); + } + + /** + * {@code PATCH /prenotaziones/:id} : Partial updates given fields of an existing prenotazione, field will ignore if it is null + * + * @param id the id of the prenotazioneDTO to save. + * @param prenotazioneDTO the prenotazioneDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated prenotazioneDTO, + * or with status {@code 400 (Bad Request)} if the prenotazioneDTO is not valid, + * or with status {@code 404 (Not Found)} if the prenotazioneDTO is not found, + * or with status {@code 500 (Internal Server Error)} if the prenotazioneDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) + public ResponseEntity partialUpdatePrenotazione( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody PrenotazioneDTO prenotazioneDTO + ) throws URISyntaxException { + LOG.debug("REST request to partial update Prenotazione partially : {}, {}", id, prenotazioneDTO); + if (prenotazioneDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, prenotazioneDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!prenotazioneRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + Optional result = prenotazioneService.partialUpdate(prenotazioneDTO); + + return ResponseUtil.wrapOrNotFound( + result, + HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, prenotazioneDTO.getId().toString()) + ); + } + + /** + * {@code GET /prenotaziones} : get all the prenotaziones. + * + * @param pageable the pagination information. + * @param criteria the criteria which the requested entities should match. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of prenotaziones in body. + */ + @GetMapping("") + public ResponseEntity> getAllPrenotaziones( + PrenotazioneCriteria criteria, + @org.springdoc.core.annotations.ParameterObject Pageable pageable + ) { + LOG.debug("REST request to get Prenotaziones by criteria: {}", criteria); + + Page page = prenotazioneQueryService.findByCriteria(criteria, pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * {@code GET /prenotaziones/count} : count all the prenotaziones. + * + * @param criteria the criteria which the requested entities should match. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the count in body. + */ + @GetMapping("/count") + public ResponseEntity countPrenotaziones(PrenotazioneCriteria criteria) { + LOG.debug("REST request to count Prenotaziones by criteria: {}", criteria); + return ResponseEntity.ok().body(prenotazioneQueryService.countByCriteria(criteria)); + } + + /** + * {@code GET /prenotaziones/:id} : get the "id" prenotazione. + * + * @param id the id of the prenotazioneDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the prenotazioneDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/{id}") + public ResponseEntity getPrenotazione(@PathVariable("id") Long id) { + LOG.debug("REST request to get Prenotazione : {}", id); + Optional prenotazioneDTO = prenotazioneService.findOne(id); + return ResponseUtil.wrapOrNotFound(prenotazioneDTO); + } + + /** + * {@code DELETE /prenotaziones/:id} : delete the "id" prenotazione. + * + * @param id the id of the prenotazioneDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/{id}") + public ResponseEntity deletePrenotazione(@PathVariable("id") Long id) { + LOG.debug("REST request to delete Prenotazione : {}", id); + prenotazioneService.delete(id); + return ResponseEntity.noContent() + .headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())) + .build(); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/web/rest/StrutturaResource.java b/src/main/java/it/sw/pa/comune/artegna/web/rest/StrutturaResource.java new file mode 100644 index 0000000..f9a2981 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/web/rest/StrutturaResource.java @@ -0,0 +1,203 @@ +package it.sw.pa.comune.artegna.web.rest; + +import it.sw.pa.comune.artegna.repository.StrutturaRepository; +import it.sw.pa.comune.artegna.service.StrutturaQueryService; +import it.sw.pa.comune.artegna.service.StrutturaService; +import it.sw.pa.comune.artegna.service.criteria.StrutturaCriteria; +import it.sw.pa.comune.artegna.service.dto.StrutturaDTO; +import it.sw.pa.comune.artegna.web.rest.errors.BadRequestAlertException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.PaginationUtil; +import tech.jhipster.web.util.ResponseUtil; + +/** + * REST controller for managing {@link it.sw.pa.comune.artegna.domain.Struttura}. + */ +@RestController +@RequestMapping("/api/strutturas") +public class StrutturaResource { + + private static final Logger LOG = LoggerFactory.getLogger(StrutturaResource.class); + + private static final String ENTITY_NAME = "struttura"; + + @Value("${jhipster.clientApp.name:smartbooking}") + private String applicationName; + + private final StrutturaService strutturaService; + + private final StrutturaRepository strutturaRepository; + + private final StrutturaQueryService strutturaQueryService; + + public StrutturaResource( + StrutturaService strutturaService, + StrutturaRepository strutturaRepository, + StrutturaQueryService strutturaQueryService + ) { + this.strutturaService = strutturaService; + this.strutturaRepository = strutturaRepository; + this.strutturaQueryService = strutturaQueryService; + } + + /** + * {@code POST /strutturas} : Create a new struttura. + * + * @param strutturaDTO the strutturaDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new strutturaDTO, or with status {@code 400 (Bad Request)} if the struttura has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("") + public ResponseEntity createStruttura(@RequestBody StrutturaDTO strutturaDTO) throws URISyntaxException { + LOG.debug("REST request to save Struttura : {}", strutturaDTO); + if (strutturaDTO.getId() != null) { + throw new BadRequestAlertException("A new struttura cannot already have an ID", ENTITY_NAME, "idexists"); + } + strutturaDTO = strutturaService.save(strutturaDTO); + return ResponseEntity.created(new URI("/api/strutturas/" + strutturaDTO.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, strutturaDTO.getId().toString())) + .body(strutturaDTO); + } + + /** + * {@code PUT /strutturas/:id} : Updates an existing struttura. + * + * @param id the id of the strutturaDTO to save. + * @param strutturaDTO the strutturaDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated strutturaDTO, + * or with status {@code 400 (Bad Request)} if the strutturaDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the strutturaDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/{id}") + public ResponseEntity updateStruttura( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody StrutturaDTO strutturaDTO + ) throws URISyntaxException { + LOG.debug("REST request to update Struttura : {}, {}", id, strutturaDTO); + if (strutturaDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, strutturaDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!strutturaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + strutturaDTO = strutturaService.update(strutturaDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, strutturaDTO.getId().toString())) + .body(strutturaDTO); + } + + /** + * {@code PATCH /strutturas/:id} : Partial updates given fields of an existing struttura, field will ignore if it is null + * + * @param id the id of the strutturaDTO to save. + * @param strutturaDTO the strutturaDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated strutturaDTO, + * or with status {@code 400 (Bad Request)} if the strutturaDTO is not valid, + * or with status {@code 404 (Not Found)} if the strutturaDTO is not found, + * or with status {@code 500 (Internal Server Error)} if the strutturaDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) + public ResponseEntity partialUpdateStruttura( + @PathVariable(value = "id", required = false) final Long id, + @RequestBody StrutturaDTO strutturaDTO + ) throws URISyntaxException { + LOG.debug("REST request to partial update Struttura partially : {}, {}", id, strutturaDTO); + if (strutturaDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, strutturaDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!strutturaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + Optional result = strutturaService.partialUpdate(strutturaDTO); + + return ResponseUtil.wrapOrNotFound( + result, + HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, strutturaDTO.getId().toString()) + ); + } + + /** + * {@code GET /strutturas} : get all the strutturas. + * + * @param pageable the pagination information. + * @param criteria the criteria which the requested entities should match. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of strutturas in body. + */ + @GetMapping("") + public ResponseEntity> getAllStrutturas( + StrutturaCriteria criteria, + @org.springdoc.core.annotations.ParameterObject Pageable pageable + ) { + LOG.debug("REST request to get Strutturas by criteria: {}", criteria); + + Page page = strutturaQueryService.findByCriteria(criteria, pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * {@code GET /strutturas/count} : count all the strutturas. + * + * @param criteria the criteria which the requested entities should match. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the count in body. + */ + @GetMapping("/count") + public ResponseEntity countStrutturas(StrutturaCriteria criteria) { + LOG.debug("REST request to count Strutturas by criteria: {}", criteria); + return ResponseEntity.ok().body(strutturaQueryService.countByCriteria(criteria)); + } + + /** + * {@code GET /strutturas/:id} : get the "id" struttura. + * + * @param id the id of the strutturaDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the strutturaDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/{id}") + public ResponseEntity getStruttura(@PathVariable("id") Long id) { + LOG.debug("REST request to get Struttura : {}", id); + Optional strutturaDTO = strutturaService.findOne(id); + return ResponseUtil.wrapOrNotFound(strutturaDTO); + } + + /** + * {@code DELETE /strutturas/:id} : delete the "id" struttura. + * + * @param id the id of the strutturaDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/{id}") + public ResponseEntity deleteStruttura(@PathVariable("id") Long id) { + LOG.debug("REST request to delete Struttura : {}", id); + strutturaService.delete(id); + return ResponseEntity.noContent() + .headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())) + .build(); + } +} diff --git a/src/main/java/it/sw/pa/comune/artegna/web/rest/UtenteAppResource.java b/src/main/java/it/sw/pa/comune/artegna/web/rest/UtenteAppResource.java new file mode 100644 index 0000000..533b006 --- /dev/null +++ b/src/main/java/it/sw/pa/comune/artegna/web/rest/UtenteAppResource.java @@ -0,0 +1,171 @@ +package it.sw.pa.comune.artegna.web.rest; + +import it.sw.pa.comune.artegna.repository.UtenteAppRepository; +import it.sw.pa.comune.artegna.service.UtenteAppService; +import it.sw.pa.comune.artegna.service.dto.UtenteAppDTO; +import it.sw.pa.comune.artegna.web.rest.errors.BadRequestAlertException; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Objects; +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.*; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.ResponseUtil; + +/** + * REST controller for managing {@link it.sw.pa.comune.artegna.domain.UtenteApp}. + */ +@RestController +@RequestMapping("/api/utente-apps") +public class UtenteAppResource { + + private static final Logger LOG = LoggerFactory.getLogger(UtenteAppResource.class); + + private static final String ENTITY_NAME = "utenteApp"; + + @Value("${jhipster.clientApp.name:smartbooking}") + private String applicationName; + + private final UtenteAppService utenteAppService; + + private final UtenteAppRepository utenteAppRepository; + + public UtenteAppResource(UtenteAppService utenteAppService, UtenteAppRepository utenteAppRepository) { + this.utenteAppService = utenteAppService; + this.utenteAppRepository = utenteAppRepository; + } + + /** + * {@code POST /utente-apps} : Create a new utenteApp. + * + * @param utenteAppDTO the utenteAppDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new utenteAppDTO, or with status {@code 400 (Bad Request)} if the utenteApp has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("") + public ResponseEntity createUtenteApp(@Valid @RequestBody UtenteAppDTO utenteAppDTO) throws URISyntaxException { + LOG.debug("REST request to save UtenteApp : {}", utenteAppDTO); + if (utenteAppDTO.getId() != null) { + throw new BadRequestAlertException("A new utenteApp cannot already have an ID", ENTITY_NAME, "idexists"); + } + utenteAppDTO = utenteAppService.save(utenteAppDTO); + return ResponseEntity.created(new URI("/api/utente-apps/" + utenteAppDTO.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, utenteAppDTO.getId().toString())) + .body(utenteAppDTO); + } + + /** + * {@code PUT /utente-apps/:id} : Updates an existing utenteApp. + * + * @param id the id of the utenteAppDTO to save. + * @param utenteAppDTO the utenteAppDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated utenteAppDTO, + * or with status {@code 400 (Bad Request)} if the utenteAppDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the utenteAppDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/{id}") + public ResponseEntity updateUtenteApp( + @PathVariable(value = "id", required = false) final Long id, + @Valid @RequestBody UtenteAppDTO utenteAppDTO + ) throws URISyntaxException { + LOG.debug("REST request to update UtenteApp : {}, {}", id, utenteAppDTO); + if (utenteAppDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, utenteAppDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!utenteAppRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + utenteAppDTO = utenteAppService.update(utenteAppDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, utenteAppDTO.getId().toString())) + .body(utenteAppDTO); + } + + /** + * {@code PATCH /utente-apps/:id} : Partial updates given fields of an existing utenteApp, field will ignore if it is null + * + * @param id the id of the utenteAppDTO to save. + * @param utenteAppDTO the utenteAppDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated utenteAppDTO, + * or with status {@code 400 (Bad Request)} if the utenteAppDTO is not valid, + * or with status {@code 404 (Not Found)} if the utenteAppDTO is not found, + * or with status {@code 500 (Internal Server Error)} if the utenteAppDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) + public ResponseEntity partialUpdateUtenteApp( + @PathVariable(value = "id", required = false) final Long id, + @NotNull @RequestBody UtenteAppDTO utenteAppDTO + ) throws URISyntaxException { + LOG.debug("REST request to partial update UtenteApp partially : {}, {}", id, utenteAppDTO); + if (utenteAppDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, utenteAppDTO.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!utenteAppRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + Optional result = utenteAppService.partialUpdate(utenteAppDTO); + + return ResponseUtil.wrapOrNotFound( + result, + HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, utenteAppDTO.getId().toString()) + ); + } + + /** + * {@code GET /utente-apps} : get all the utenteApps. + * + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of utenteApps in body. + */ + @GetMapping("") + public List getAllUtenteApps() { + LOG.debug("REST request to get all UtenteApps"); + return utenteAppService.findAll(); + } + + /** + * {@code GET /utente-apps/:id} : get the "id" utenteApp. + * + * @param id the id of the utenteAppDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the utenteAppDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/{id}") + public ResponseEntity getUtenteApp(@PathVariable("id") Long id) { + LOG.debug("REST request to get UtenteApp : {}", id); + Optional utenteAppDTO = utenteAppService.findOne(id); + return ResponseUtil.wrapOrNotFound(utenteAppDTO); + } + + /** + * {@code DELETE /utente-apps/:id} : delete the "id" utenteApp. + * + * @param id the id of the utenteAppDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/{id}") + public ResponseEntity deleteUtenteApp(@PathVariable("id") Long id) { + LOG.debug("REST request to delete UtenteApp : {}", id); + utenteAppService.delete(id); + return ResponseEntity.noContent() + .headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())) + .build(); + } +} diff --git a/src/main/resources/config/liquibase/changelog/20251210161121_added_entity_AuditLog.xml b/src/main/resources/config/liquibase/changelog/20251210161121_added_entity_AuditLog.xml new file mode 100644 index 0000000..ae7ed69 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161121_added_entity_AuditLog.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161121_added_entity_constraints_AuditLog.xml b/src/main/resources/config/liquibase/changelog/20251210161121_added_entity_constraints_AuditLog.xml new file mode 100644 index 0000000..90604e6 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161121_added_entity_constraints_AuditLog.xml @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161122_added_entity_Disponibilita.xml b/src/main/resources/config/liquibase/changelog/20251210161122_added_entity_Disponibilita.xml new file mode 100644 index 0000000..2efcf33 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161122_added_entity_Disponibilita.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161122_added_entity_constraints_Disponibilita.xml b/src/main/resources/config/liquibase/changelog/20251210161122_added_entity_constraints_Disponibilita.xml new file mode 100644 index 0000000..514ae5d --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161122_added_entity_constraints_Disponibilita.xml @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161123_added_entity_Notifica.xml b/src/main/resources/config/liquibase/changelog/20251210161123_added_entity_Notifica.xml new file mode 100644 index 0000000..6ae3f21 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161123_added_entity_Notifica.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161123_added_entity_constraints_Notifica.xml b/src/main/resources/config/liquibase/changelog/20251210161123_added_entity_constraints_Notifica.xml new file mode 100644 index 0000000..f2e35c4 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161123_added_entity_constraints_Notifica.xml @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161124_added_entity_Prenotazione.xml b/src/main/resources/config/liquibase/changelog/20251210161124_added_entity_Prenotazione.xml new file mode 100644 index 0000000..4210ecb --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161124_added_entity_Prenotazione.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161124_added_entity_constraints_Prenotazione.xml b/src/main/resources/config/liquibase/changelog/20251210161124_added_entity_constraints_Prenotazione.xml new file mode 100644 index 0000000..f5b4803 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161124_added_entity_constraints_Prenotazione.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161125_added_entity_Conferma.xml b/src/main/resources/config/liquibase/changelog/20251210161125_added_entity_Conferma.xml new file mode 100644 index 0000000..b6615d8 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161125_added_entity_Conferma.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161125_added_entity_constraints_Conferma.xml b/src/main/resources/config/liquibase/changelog/20251210161125_added_entity_constraints_Conferma.xml new file mode 100644 index 0000000..dfc4046 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161125_added_entity_constraints_Conferma.xml @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161126_added_entity_Struttura.xml b/src/main/resources/config/liquibase/changelog/20251210161126_added_entity_Struttura.xml new file mode 100644 index 0000000..c030a91 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161126_added_entity_Struttura.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161127_added_entity_UtenteApp.xml b/src/main/resources/config/liquibase/changelog/20251210161127_added_entity_UtenteApp.xml new file mode 100644 index 0000000..ec35dd6 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161127_added_entity_UtenteApp.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161128_added_entity_Liberatoria.xml b/src/main/resources/config/liquibase/changelog/20251210161128_added_entity_Liberatoria.xml new file mode 100644 index 0000000..91b339d --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161128_added_entity_Liberatoria.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161128_added_entity_constraints_Liberatoria.xml b/src/main/resources/config/liquibase/changelog/20251210161128_added_entity_constraints_Liberatoria.xml new file mode 100644 index 0000000..a9cf800 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161128_added_entity_constraints_Liberatoria.xml @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161129_added_entity_ModelloLiberatoria.xml b/src/main/resources/config/liquibase/changelog/20251210161129_added_entity_ModelloLiberatoria.xml new file mode 100644 index 0000000..9072169 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161129_added_entity_ModelloLiberatoria.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161129_added_entity_constraints_ModelloLiberatoria.xml b/src/main/resources/config/liquibase/changelog/20251210161129_added_entity_constraints_ModelloLiberatoria.xml new file mode 100644 index 0000000..39c03b4 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161129_added_entity_constraints_ModelloLiberatoria.xml @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161130_added_entity_Messaggio.xml b/src/main/resources/config/liquibase/changelog/20251210161130_added_entity_Messaggio.xml new file mode 100644 index 0000000..cc27a1c --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161130_added_entity_Messaggio.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20251210161130_added_entity_constraints_Messaggio.xml b/src/main/resources/config/liquibase/changelog/20251210161130_added_entity_constraints_Messaggio.xml new file mode 100644 index 0000000..e79a250 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20251210161130_added_entity_constraints_Messaggio.xml @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/src/main/resources/config/liquibase/fake-data/audit_log.csv b/src/main/resources/config/liquibase/fake-data/audit_log.csv new file mode 100644 index 0000000..8c5fb6b --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/audit_log.csv @@ -0,0 +1,11 @@ +id;entita_tipo;entita_id;azione;dettagli;ip_address;created_at +1;PRENOTAZIONE;4430;CONFIRM;yum;so independence;2025-12-10T05:47:54 +2;PRENOTAZIONE;24782;CREATE;cow ack;as safely courageously;2025-12-10T09:01:20 +3;PRENOTAZIONE;27495;DELETE;yet short;fooey nicely;2025-12-10T00:26:36 +4;CONFERMA;4285;DELETE;mobility dusk;indeed;2025-12-10T06:36:52 +5;CONFERMA;17705;CREATE;through;consequently supposing;2025-12-10T02:20:26 +6;CONFERMA;21615;REJECT;beside transcend geez;gleefully hygienic finally;2025-12-10T07:54:38 +7;PRENOTAZIONE;22655;UPDATE;impanel;vaguely equate legend;2025-12-10T03:42:34 +8;PRENOTAZIONE;824;REJECT;depart whose;cuckoo even;2025-12-10T01:50:27 +9;PRENOTAZIONE;2992;DELETE;word bah nor;anenst;2025-12-09T19:23:50 +10;PRENOTAZIONE;17794;CREATE;jellyfish papa aha;waver confusion mechanic;2025-12-10T14:13:07 diff --git a/src/main/resources/config/liquibase/fake-data/blob/hipster.png b/src/main/resources/config/liquibase/fake-data/blob/hipster.png new file mode 100644 index 0000000000000000000000000000000000000000..5b7d50756b00d556bd39a082e16e28a041caa150 GIT binary patch literal 7564 zcmb_>^;aBCw{;JL3=$Y5xD$ee;0}R-;O@aKK|*j#LXg3NOK^wa5Foe)hXDqHI{^lF z0z9~Wyw82Vb^n3eYuE0xPwjJhRadRmKXjOen*0+SN*n+Ho+v8FXg%IL{xcxpN47%C z5C8zQI}H^b*+)58ny0L1UzQr!Toh545?mSWTN&$Hml#wT<69FKQ1uP|AH@3oO8wfD z6jT-aI18_f4`@gVu88t}^gQA*Sr*|_8z1m!dz6UpQPuyJJeGfU{Wy>pGf|e@l^Omx zTOH?L9^o}xnKoP$Ulj{)PY?YO_OUd?qa!zds491?zIeK&yeTcbuQYw*cgNq^p??;~ z&R1tH*JqFBhyQfd{mP0)^)(+(BhOHimuu7KD^sV-6DNO0k>%NYlYOU4V{6FP;hKW& z(Vp4%s-B{h>y5eMAlK97$?LVLoIX4}+~3_j9BU(@> zd~)ieXLq>kv37T~TQ{a}b8;x7Y!KPrEF9D+6*>60a1r0e@unYTRsFKx#zX?zA2W~W z%#Cl&j+T5IcD^!svN-z4OT)db^;J{-9nlF%)j!KKGBcCYGvriE6x7X>b?xNU%pWl` zGtVQgt)OnMsA2Ix_%}9JRR6D(kTcXbbx_r{QPO(%AA`Dug67-*aX#Z!QFxRZ7Q`%a zkD139poGc2ae~q>4+?uhoH9=rvkU*Vl%a%leF`U6ZWgP* zdC0NYw*8yE3bP2jeQ+6gI7z4gC$+tn$7Mi+tuUkTYt4b$1N5_!?EoWx5@gH_llHEhcXViou zBfM`faJ$2>Rg(;?r=wjjFMm}yLo6nL?#f-7P6YDI6VB(BksGY{cfF~uXF!+QV^H&4 zIN%Hme(Bpzs4tIS#jfnOeuYif`4PPAG8vAZ@SqRJ(YD?<2TC}MuAxQPY1 za$cWBj-h1IK!A(DDX7QH@nPs2O1S~~z1Tvf6g$)4GZuIfa7SmjaX3eZ2DPm<6n|zF z-6{WM=6hCr>CGE`83N@%))XuMGsMLs+8TP(yB1Fke-97+ob>jlY`0m;mz0sXTSRMY z^?1(i^@z9X^V_0oPG>y2oZp6SMw9+Wf2AfM7MhDKfB|*qMJhG1F{uZ%WE*c^?y}qo zG?w5ItbU0|eu}KhleK}CT%xUC8e9x94FbOqMV^!Q?ptb;83hWs$9|yWP>p1VfYGFG zOeSdqn?GXivFuMddmhNQZ0w(1=|92D(X{cHGk+KosnNA)WcQUbtG(UFdIH<~AjwfT zac&~}0vY2zqY#YsLSZ%U8y2JTz&<|OQV8ik!IgO`C6gq>@mKLew#(ff#--xSCluUuiZ_xN>ns+RoDz);Xvr-WrMG9TaJ zywxKsFIU9ciTq)kS3&SP{?rtIS)Rj!_&F+p$LWE4|BDvY_YlKn6iEJ;~k~1 zX%jM4dZBj@mfUL!r!IE)0=jTn2Wz)4Jq+kimN#k_OKdUkFKubmam&d&%69NREw9Zq zIVOJaC7p|*a9me#_|4y5JJZj^H+v^AddcNI{BUGVyIZ~>3JfHBk!gmrozL8XC8%wfj(0|9G5Mb8x-0Bw*jx!(L;a}RokfV@2N}ynpw2nQZokgEz zN{Lx&n8)#B^ZPVU-eJHI>h1jmDjtHS7|ScibDZVx5{cdQ!jF1cPTxRXB;w0^)6-yg zM$B%)7P(Jg#cexhzl*lB&HV?Wb$-gag}nZ`P-d{q(`0qUmmD-96J>l^tS^H#r^AR` zccHBQgLbI-<{Om5_S`>P+*Bi25%=b8`}Npc5DkhLU06dL@_NdZK3}7rWTVH28=qlK z!I58<0c1=?k_`aWONIMY+{-ZfF=T&>s;5b$ov>t(Re9V>GeJq9LpKI}dx95g;@ zYele1Kj|$zNQ4l18(H&CNAimY^E6KDl53C~%k>fY5ndLjG~6Lyr0O?Mg0F-=K}+V6 zXZ?Ix(RJZjU0W@ima8Xbd92UQgaH%IuOCyvE)voO{H5>Mj?1pWRdSqf<%XxHL2I)# z2Qhu@F#Q%M$J95$r94@i>OF=cbeV*Wuasf%BC}mlyp*zyRRWHhU9Pai__PlBP6GAs zxu}&xzw8;SNMWq%Qqa!eXO$Ix!d83_bafU*h^;uGo&W=GlS~jwV!h}yniD=&te`8f z6w#cK@wDa$fRFtW0eJdZGiu#e0Ewtw5>aAgDI(gudqvXa`vn#}D7rvbHSB4;Xf%UM z{G3lQ$El__WW}Do%uY=uW=bAb0Ck3!`VDG!6t;SivL1h%9k;-lZUu3eva zI0HE@43w`xtjcMYK- z(uQq_j{EZS)?BM?dya5chq&~SP@mcIVhCnqG1?T=y0BNAE+#p?EooCwTA-kWkxs16 zgGWGXCVcvI;fCJ%BMrd{kYl$wtC6MFWk_)1E*Q>~kC*2u^j9p%Xj6IZoRo(b!5SuC z!=J5W;Xs29y)Nzk4K^dhg7ZrbTW&ahPuCn~lU1RYLR7uVK>pzW5ZrI`ZQ?ahB*(TT zti3tg}FG{`7F*)BDHusg7t=+XBPJSq-5xNWHjpv3MCt7p@C6C z$l3U$Yt_@>A8$byhA*)?rD+a`q2cj(&kFaB&6d z{OlZvk<GFtP<_hh$XE`iApjvl5*;a?#$!2vvoKt zFIYOM;IjacHFWHGt@dnmA8Zmm5=3nWbVLJj$u zW83<0567G-X6FlnwYy9x1Hu+ed?l{Rmv7Hcw#CC8&4#F{n;|kxyQ)lPPC&fX-1?3# z{gd?JZ`L26`heg0^{31nu zZY|Bci1Qak*7-?=0b%=u(~S#-2n>xsAZ8MX-6#+RwQYUzG$x zEMT30vu@r`ZC%vT zj==jQ4F2}Y#>$?<4Z?FE_Lk#lBe8d?j)*Dcn=u7!+zTWjXM9VQZbT&Q2v@wkZ}iZQ;4cqrHi)6izrBj*A zq4ru@`k1psp&ir!9M6aC4YFciW0Xn3FsqU8sL#UcAAKFdx@(*e9jPF30LEei8Zv5F zXd-Ih$M2}c1U`y`G>(ocjR_M2p3j4xUV~;A!M?2D$LG6fpX?u2YfBee_vETHsQhO8 zUhw7Odr;RQ(JK3dlkErO40~}vGzbMv>&Ocu@PuLg3KM}_yFPxV=X*YOdM2FNuSSG~ z)PAK69e~CEUCDb1Txxq-0gQQRlAIPkUox*pI)KfV{-VKYG2ul7!DukzMj%$TV|AooupQslE(}_|y0X5vpJdKDP zk)sSSwP_i+@yxO;erH4ZygmMdOpDbNn7lzd)7Zv7umO_;a4v*5iU2_G>w7{!Grf=A4#R`ifPAR(egruYMw^H)COlkMrjTa8>~Qs+O1+aiP_smkBt@>b-Y^ zS}gT@TjkNBx1-DU%zZCx1N*qDqXx+c3mNUUiY3bTCTPcZaDPGq`il=d!A3;(G?Qq5 zLjryU8wG(nyyh#u*TZt2ysdLv*L_`p@+Jt)u-Q`}OzqIEbbzdKNwS5DH`rdd#NPh% z&y*jSSMRCrd)CnGu#69{(eoZsnsAn8qv)wMf}L>AP0^>5T7pgJu6iXFL>8LF==7c@ zH+6+0IXL2(N+MU!dH8M{toK`E&d*3hNPI$NQ6<)Qu7@pn3^p4t^StVhZie%4? zf5?C0SOyyre7uk*!El%%j`xbAl_pENnCUt`M9d?E!epzWCdId99;Dokj>_)lX^wTK~dd-f96dRD|qVsz5d{iQ-lPX;Z;ll2kN9|pb zJXS7esB5n#tKMO%%=yJCbb~rBg2wR-QC>>-RkQG} zp7%^Nc8w*=cV&Alz6j^&pO*Tb`5-)5J*EalXBRITXJ zwls$|@feL+n4qZ{0ox1F>X4xzS8d{DSAWE*+q|Gqte9K@@QytQl1Q~Pt`+Dk2UiQW z>tsKaR)VKTW7M3P4O~+yD`RYo=nd-fqVChA@StZr$Q6V{{Ca&pTkhLDnnA}Ru~F*n zNJk2raQ!dAKh!C;$jf)ogE?NZKoH=PjU{|k9V=wNLq47Qn3B41kITaqgZT1Js=PW; z)m3-x+I+8t76_}Ew9*mbe)Ze@-N9>OSJoXEHBlO)lu{H{m zMAB52ebf^KhsIV}?F!4`m25~GRrTBo!qhG`W+!-b`eEcYX%&0!cC!LH#p}iJ+`FA1 zK7_D5gXUt)+U(DnG+L_+*79wv^;a;(`VRUhBmWF(7Ht}a^$7X4mavg4giZV^Mg7Ht zr!LcT?;czZ6~w_n!>t(s-k<5`@uzR)5S-r{k$E2oC&V^-F_kqTu&F(?a4N? zZgL90HNwMy?+GXuLfh8TB3V~MkaM3M;0bZ;d*l!&_pdH;^qx1*S1`$Y)h+wo%rw3$ zVRi_Qy>cVYQWMr5`IWF$d1ay4{7ZN1U6Pa!emwhFlclC+9}#!(cl2l=pWn1BMtMx-D( za6Wg9idy;uXB6A_yE%o!R?|XKI z$;~-(szFH^HF`0lBEmVnkw6$ccb>1wGNH|G6QJQL~bvmg(K_F}!59iiNm5Gu^^^;s}Ex%Zz zkQ5wF!DAUwUzYKk0sws;8!f|114Z;k%1V+_=F%7?IrLR>K!t1gV0f0~peJx<7rb6#psp+B3!hS97SI+h|k20yWfW}fxTKlf--F$VX7fanc16Bb0wYAzZ zc%bjlgfye^OfYO38||vID36udt$(Lc{CE zU*u1qVOEtFTXxSYJzG(j|J2)q8Cyrb;(0(0%fpsa2MXh$AflpZ*TcX>&)T{pPh$&HP`3%L7;5wf|*I>mV zoEDJnLUWrg!%$Vr);+D4tU0;YwBs6nTmd3-Y;UC%u@0edie)e0u!{6F4(hAyWF(5h zBT0lE)xhZE&~ZxL7PNb9@&~ttg`Wx&&TU>7bJEfI*8M4pWO|jE?=q5i(ij(BXiH#e zB+)!-^tFjw&(peE^;+P9m5l_yfRKE4hwql2(mqL(P`%K zFh9|K&D{|O3t5p&%zFd7RVW{!kpIMU4U@}y=%|n>*q#nEOO-f0*UB0*@9^g{bdrtM z107|bRXbZ*Y+RzHNA&YCwEVLvc$>_ng7#%D%O1_;r6!_AKu1{g*0~(@l%`qswDT`n zk8zCC0KuJWfPYQN#LKnve0$u#Uu15nd@K$^Ex_B7By&qkUG%JQ}S&&n~FEsFpd%Xf?ZWk=lwXZlI^p8$hZkC5u}khP*xEQ z(kd)_N#=Wupt^bZQvML~u21W9#)&fOZ^N++pTIGnI}$@UZ!cPJw>opKnIMxEM?KAb;IoGJOaPX^Jt!m9E12G|eb~Bktb6f6bp|bA zhus&v=zwTw-iy2W8i=jcC?5%eh!D$2+~vwr!o#T6{~6t_oxWCVP+3G%I-g-o|KfZq zVIC67RGIViiZWCS*5MoY8`S5FORC}PZX=(@Vireb4*xo^Aj1rPGRlOa3S8U~KaC%_ zU)#j2h^F&`n4>cb>t*4To1W@lk=KbP_Z<=Zfj| z+y}jgnt>H68O(s@KO3EkZq!&r#X8DFU2RLu9mr(9P*(I6OyeBXF?rGh4eh$B!^ULg zM>`V>Tv5;if2AK#Ux$vi#}nZ}dGSs%UF4wEBc)}mgGDJ5a8pcnTnIO?u=eZMYKRSM z(dC7$Wrub{sB1x)S$6yr>fNvJp`&}}W*Y=wKTi@!rV9PZyApT@&99l> zo~Wj#h65|tdx5rWTp=E<{$pxz4OFw$-#{aX%<+VgxWsH4YODti<_$(f?Cu;VVoBse zI+$<)2x}rNywImElo;rN!kRn>Z=TFH-WrfZe{xfJ$RNXz^?7c}mYZ9^RSR;VWO!Je zmAGoWtqEZcnEB(s9FW`QKW1>m))n{b;d}7K=-a+5%@O0P#;Z0V>>LdJXI2Q9qf~=B z_KKUVit@C@d9AnL`T7l^3r@R^fcSCFC$6|l9XV7727wkLqHJJ)&^ML;cX$R^F literal 0 HcmV?d00001 diff --git a/src/main/resources/config/liquibase/fake-data/conferma.csv b/src/main/resources/config/liquibase/fake-data/conferma.csv new file mode 100644 index 0000000..23c8b4f --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/conferma.csv @@ -0,0 +1,11 @@ +id;motivo_conferma;tipo_conferma +1;lashes eek;RIFIUTATA +2;towards;CONFERMATA +3;ha humiliating;RIFIUTATA +4;hm heavy who;CONFERMATA +5;story;CONFERMATA +6;er;CONFERMATA +7;kindheartedly briskly nectarine;CONFERMATA +8;vice;RIFIUTATA +9;jaggedly indeed;CONFERMATA +10;part furthermore given;RIFIUTATA diff --git a/src/main/resources/config/liquibase/fake-data/disponibilita.csv b/src/main/resources/config/liquibase/fake-data/disponibilita.csv new file mode 100644 index 0000000..65897ff --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/disponibilita.csv @@ -0,0 +1,11 @@ +id;giorno_settimana;data_specifica;ora_inizio;ora_fine;orario_inizio;orario_fine;tipo;note +1;SABATO;2025-12-10;2025-12-09T23:35:32;2025-12-09T17:45:07;alarmed;whoa runway esteemed;CHIUSURA;treasure hose +2;GIOVEDI;2025-12-09;2025-12-09T22:15:09;2025-12-10T06:15:04;while;who;DISPONIBILE;hence partial +3;SABATO;2025-12-09;2025-12-09T18:42:17;2025-12-09T22:39:18;searchingly to gape;what bah certainly;CHIUSURA;react +4;MERCOLEDI;2025-12-09;2025-12-10T09:45:25;2025-12-09T17:41:52;flint;tense;CHIUSURA;bar +5;MARTEDI;2025-12-10;2025-12-10T10:28:18;2025-12-10T11:52:40;delightfully;nearly forage;DISPONIBILE;state dally drat +6;VENERDI;2025-12-09;2025-12-10T14:28:20;2025-12-09T17:20:25;lovely reporter;pro;CHIUSURA;kowtow why after +7;VENERDI;2025-12-09;2025-12-10T02:34:08;2025-12-10T10:47:44;incidentally essential sentimental;useless;CHIUSURA;astride +8;VENERDI;2025-12-10;2025-12-10T05:17:31;2025-12-10T00:26:17;cavernous thyme;wherever far-off vicinity;CHIUSURA;culture decode militate +9;GIOVEDI;2025-12-09;2025-12-10T08:59:50;2025-12-09T22:47:28;except rapidly;circa afore;CHIUSURA;circumnavigate +10;GIOVEDI;2025-12-10;2025-12-10T03:40:00;2025-12-09T17:40:42;foretell infatuated unto;below instead phooey;CHIUSURA;during however wavy diff --git a/src/main/resources/config/liquibase/fake-data/liberatoria.csv b/src/main/resources/config/liquibase/fake-data/liberatoria.csv new file mode 100644 index 0000000..71cc941 --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/liberatoria.csv @@ -0,0 +1,11 @@ +id;accettata +1;2025-12-10T13:36:22 +2;2025-12-10T05:46:55 +3;2025-12-10T02:37:41 +4;2025-12-10T07:04:25 +5;2025-12-10T12:02:35 +6;2025-12-10T04:41:18 +7;2025-12-10T12:58:50 +8;2025-12-10T05:20:20 +9;2025-12-10T04:50:20 +10;2025-12-10T15:47:20 diff --git a/src/main/resources/config/liquibase/fake-data/messaggio.csv b/src/main/resources/config/liquibase/fake-data/messaggio.csv new file mode 100644 index 0000000..3340fc2 --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/messaggio.csv @@ -0,0 +1,11 @@ +id;spedito;testo;letto +1;2025-12-09T19:39:52;nor outdo suddenly;2025-12-10T03:06:01 +2;2025-12-10T06:09:25;private concerning artistic;2025-12-10T09:41:06 +3;2025-12-10T02:11:14;colorize;2025-12-10T06:34:21 +4;2025-12-10T04:03:04;yawningly who however;2025-12-09T22:04:31 +5;2025-12-09T20:26:05;instead aftermath barring;2025-12-09T23:51:01 +6;2025-12-09T18:12:43;whose and;2025-12-10T03:36:16 +7;2025-12-10T00:29:10;reference into;2025-12-10T01:20:36 +8;2025-12-10T08:55:43;brr or;2025-12-09T22:40:10 +9;2025-12-10T10:48:39;questioningly mobility;2025-12-10T14:10:21 +10;2025-12-09T19:28:05;passport huzzah;2025-12-10T10:27:27 diff --git a/src/main/resources/config/liquibase/fake-data/modello_liberatoria.csv b/src/main/resources/config/liquibase/fake-data/modello_liberatoria.csv new file mode 100644 index 0000000..8bc6e19 --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/modello_liberatoria.csv @@ -0,0 +1,11 @@ +id;nome;testo;documento;documento_content_type;valido_dal;valido_al +1;concerning;who;../fake-data/blob/hipster.png;image/png;2025-12-10T07:08:37;2025-12-09T21:32:38 +2;onto worth gadzooks;indeed spellcheck;../fake-data/blob/hipster.png;image/png;2025-12-10T12:11:25;2025-12-10T11:16:01 +3;enraged huzzah;out dress;../fake-data/blob/hipster.png;image/png;2025-12-10T11:12:44;2025-12-09T23:51:47 +4;specific;strictly meh;../fake-data/blob/hipster.png;image/png;2025-12-10T06:50:59;2025-12-10T02:45:05 +5;bleak;eyeglasses print;../fake-data/blob/hipster.png;image/png;2025-12-10T14:47:14;2025-12-09T18:50:08 +6;athwart stranger;although;../fake-data/blob/hipster.png;image/png;2025-12-10T09:49:28;2025-12-10T04:38:09 +7;blah;if;../fake-data/blob/hipster.png;image/png;2025-12-10T11:51:11;2025-12-10T05:38:00 +8;mealy beep yahoo;where spellcheck deed;../fake-data/blob/hipster.png;image/png;2025-12-10T00:30:12;2025-12-10T00:09:58 +9;queasy nearly character;gosh turbulent;../fake-data/blob/hipster.png;image/png;2025-12-10T04:59:37;2025-12-10T13:02:58 +10;an worth;superior;../fake-data/blob/hipster.png;image/png;2025-12-09T17:09:27;2025-12-09T21:56:06 diff --git a/src/main/resources/config/liquibase/fake-data/notifica.csv b/src/main/resources/config/liquibase/fake-data/notifica.csv new file mode 100644 index 0000000..5d517b8 --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/notifica.csv @@ -0,0 +1,11 @@ +id;tipo_canale;tipo_evento;messaggio;inviata;inviata_at;errore;created_at +1;WHATSAPP;RICHIESTA_CREATA;heavy;true;2025-12-10T03:04:23;boohoo;2025-12-10T02:08:45 +2;SISTEMA;REMINDER;congregate geez battle;true;2025-12-10T00:53:33;consequently vision boohoo;2025-12-09T17:06:02 +3;SISTEMA;ANNULLAMENTO;lively woot free;false;2025-12-10T09:01:52;sternly forgery;2025-12-09T20:03:23 +4;WHATSAPP;RICHIESTA_CREATA;internationalize happily factorize;true;2025-12-09T23:07:16;amidst ouch;2025-12-10T04:16:42 +5;SISTEMA;RICHIESTA_CREATA;pity;false;2025-12-09T20:45:43;down fairly;2025-12-10T03:01:40 +6;EMAIL;ANNULLAMENTO;scale questionably;false;2025-12-09T22:01:16;geez microblog as;2025-12-10T04:17:47 +7;SISTEMA;REMINDER;since ack;false;2025-12-10T11:26:29;eek;2025-12-10T09:24:17 +8;WHATSAPP;PRENOTAZIONE_CONFERMATA;gosh shakily until;false;2025-12-09T19:27:39;throughout spanish birth;2025-12-10T05:24:03 +9;SISTEMA;REMINDER;pronoun furthermore mindless;false;2025-12-10T11:44:17;key bore mouser;2025-12-09T17:16:35 +10;EMAIL;REMINDER;aggressive flood;true;2025-12-10T06:41:47;till by;2025-12-10T05:02:59 diff --git a/src/main/resources/config/liquibase/fake-data/prenotazione.csv b/src/main/resources/config/liquibase/fake-data/prenotazione.csv new file mode 100644 index 0000000..58affd9 --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/prenotazione.csv @@ -0,0 +1,11 @@ +id;ora_inizio;ora_fine;stato;motivo_evento;numero_partecipanti;note_utente +1;2025-12-10T02:47:13;2025-12-10T04:04:24;RICHIESTA;yearly;8637;bathrobe joyously +2;2025-12-09T16:23:56;2025-12-10T02:28:03;ANNULLATA;sharply plain hmph;23437;likewise consequently +3;2025-12-10T10:20:37;2025-12-10T02:11:11;RICHIESTA;phooey;20384;blah who +4;2025-12-09T17:00:06;2025-12-10T15:34:19;RIFIUTATA;handsome sneak;23394;duster +5;2025-12-10T14:55:44;2025-12-09T17:16:35;RICHIESTA;ouch;5824;raw corny +6;2025-12-10T11:56:02;2025-12-10T08:12:54;RICHIESTA;searchingly even lampoon;22010;kiddingly +7;2025-12-10T05:12:07;2025-12-09T16:40:31;RICHIESTA;hopelessly;28110;beside demob ick +8;2025-12-09T22:51:20;2025-12-10T04:19:35;RIFIUTATA;experience gah;18511;customise +9;2025-12-09T17:23:41;2025-12-10T13:05:54;RICHIESTA;elastic;4780;with accentuate +10;2025-12-10T15:21:32;2025-12-10T04:04:03;RICHIESTA;onset instead;1486;eek minus diff --git a/src/main/resources/config/liquibase/fake-data/struttura.csv b/src/main/resources/config/liquibase/fake-data/struttura.csv new file mode 100644 index 0000000..5fdea2e --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/struttura.csv @@ -0,0 +1,11 @@ +id;nome;descrizione;indirizzo;capienza_max;attiva;foto_url;created_at;updated_at +1;entomb er oof;reapply clone likewise;meh mid;22615;false;surprisingly fork yak;2025-12-09T17:32:36;2025-12-10T13:51:00 +2;hard-to-find instead;within rosy;usefully furthermore;26413;false;anti;2025-12-10T01:55:41;2025-12-09T19:18:46 +3;scarper boohoo;amazing coaxingly whenever;signature;29765;true;athwart pigsty waltz;2025-12-10T01:21:59;2025-12-10T00:08:52 +4;of bad er;federate upliftingly sign;marimba off;6492;true;hmph so;2025-12-10T10:32:16;2025-12-10T15:46:26 +5;drat;whimsical;nor yum;18803;false;worth;2025-12-10T08:53:47;2025-12-10T13:29:52 +6;easily cellar inasmuch;atrium statement curly;apropos accountability;16467;true;trusting colorfully;2025-12-10T05:14:48;2025-12-10T11:52:32 +7;aha obnoxiously er;snow thankfully;agreement;9662;true;ethyl;2025-12-09T19:08:32;2025-12-10T12:02:43 +8;upside-down gray loftily;zowie;damaged;27283;false;unusual backbone;2025-12-09T20:09:28;2025-12-09T20:36:45 +9;wisely;loudly;tuxedo gah;26761;false;beneath;2025-12-10T15:29:25;2025-12-09T17:32:57 +10;whirlwind off;frankly;artistic mid;22635;true;saloon;2025-12-10T13:16:15;2025-12-09T23:22:01 diff --git a/src/main/resources/config/liquibase/fake-data/utente_app.csv b/src/main/resources/config/liquibase/fake-data/utente_app.csv new file mode 100644 index 0000000..5d5ecfc --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/utente_app.csv @@ -0,0 +1,11 @@ +id;username;email;telefono;ruolo;attivo;nome;cognome;luogo_nascita;data_nascita;residente;societa;sede;codfiscale;telefono_soc;email_soc +1;doodle mountain;Sicuro_Tirri@gmail.com;doubter swordfish;USER;false;nearly round acidic;step and woeful;what;whose vivaciously fondly;ack unto;fast lovely yippee;till mmm yeast;since;before;obedient or experienced +2;ugh although;Chiara18@gmail.com;crowded briefly across;ADMIN;true;trouser;whoever;lest till;ferociously sniff across;if whenever amongst;cruel;fedora mob custody;cheerfully dead;ah that suspiciously;for loyalty +3;terribly knavishly;Azelio.Schillaci89@yahoo.it;gee;INCARICATO;false;the;hunt westernise;warlike painfully;ack boohoo;eek unknown whoa;redact eek;insert ouch;if;service;bossy +4;with leading masquerade;Iginio5@hotmail.com;but so;ADMIN;true;against before why;excluding scornful authorized;nervous considerate gee;times;outlaw forgather;clinking bah;foolishly colorless beside;obscure split going;versus respray;restructure now +5;because;Tarso_Coretti42@email.it;pro often;USER;false;modulo following;toward circle;pace which;about provided;whose;inasmuch critical react;prejudge inasmuch;till pear;querulous;swing patiently whereas +6;apt;Camelia_Amoroso@hotmail.com;ick;INCARICATO;true;remarkable remark oh;swear er;deliberately;uh-huh;questioningly;psst drat;brr crocodile;whose chainstay;formation duh;after earnest +7;amazing;Dulina.LaBarbera99@hotmail.com;phooey before where;INCARICATO;false;aw zowie;though per;joyous sans remorseful;amid department;gee without after;where indeed unimportant;behind woefully;flustered pressure embody;tricky via glittering;throughout coarse +8;underneath linear;Vincenzo50@libero.it;between boo woefully;ADMIN;false;norm;statue heavenly wholly;which before belabor;rationalize vice;reassuringly enchanted;some;following;provided;meh;far +9;selfishly oof;Cremenzio.Cangiano@yahoo.it;alongside ruddy like;INCARICATO;false;outset;er openly;oof content hundred;scheme robust clone;if overconfidently raw;whether monumental;nautical hunt because;cloudy vice bulky;desk however voluntarily;blaring kookily +10;yum source;Fedro6@yahoo.com;generally phew;ADMIN;false;rubric thoughtfully powerless;clone;gifted despite begonia;without;after;afterwards perfectly;steel gosh tensely;guidance via faithfully;briskly depot;successfully diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml index 315d9ec..26018d2 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -12,7 +12,25 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/app/entities/audit-log/audit-log-details.component.spec.ts b/src/main/webapp/app/entities/audit-log/audit-log-details.component.spec.ts new file mode 100644 index 0000000..7613136 --- /dev/null +++ b/src/main/webapp/app/entities/audit-log/audit-log-details.component.spec.ts @@ -0,0 +1,91 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import AuditLogDetails from './audit-log-details.vue'; +import AuditLogService from './audit-log.service'; + +type AuditLogDetailsComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const auditLogSample = { id: 123 }; + +describe('Component Tests', () => { + let alertService: AlertService; + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('AuditLog Management Detail Component', () => { + let auditLogServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + route = {}; + auditLogServiceStub = sinon.createStubInstance(AuditLogService); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'router-link': true, + }, + provide: { + alertService, + auditLogService: () => auditLogServiceStub, + }, + }; + }); + + describe('Navigate to details', () => { + it('Should call load all on init', async () => { + // GIVEN + auditLogServiceStub.find.resolves(auditLogSample); + route = { + params: { + auditLogId: `${123}`, + }, + }; + const wrapper = shallowMount(AuditLogDetails, { global: mountOptions }); + const comp = wrapper.vm; + // WHEN + await comp.$nextTick(); + + // THEN + expect(comp.auditLog).toMatchObject(auditLogSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + auditLogServiceStub.find.resolves(auditLogSample); + const wrapper = shallowMount(AuditLogDetails, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/audit-log/audit-log-details.component.ts b/src/main/webapp/app/entities/audit-log/audit-log-details.component.ts new file mode 100644 index 0000000..5d73472 --- /dev/null +++ b/src/main/webapp/app/entities/audit-log/audit-log-details.component.ts @@ -0,0 +1,46 @@ +import { type Ref, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import { type IAuditLog } from '@/shared/model/audit-log.model'; + +import AuditLogService from './audit-log.service'; + +export default defineComponent({ + name: 'AuditLogDetails', + setup() { + const dateFormat = useDateFormat(); + const auditLogService = inject('auditLogService', () => new AuditLogService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + const auditLog: Ref = ref({}); + + const retrieveAuditLog = async auditLogId => { + try { + const res = await auditLogService().find(auditLogId); + auditLog.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.auditLogId) { + retrieveAuditLog(route.params.auditLogId); + } + + return { + ...dateFormat, + alertService, + auditLog, + + previousState, + t$: useI18n().t, + }; + }, +}); diff --git a/src/main/webapp/app/entities/audit-log/audit-log-details.vue b/src/main/webapp/app/entities/audit-log/audit-log-details.vue new file mode 100644 index 0000000..a28b701 --- /dev/null +++ b/src/main/webapp/app/entities/audit-log/audit-log-details.vue @@ -0,0 +1,69 @@ + + + diff --git a/src/main/webapp/app/entities/audit-log/audit-log-update.component.spec.ts b/src/main/webapp/app/entities/audit-log/audit-log-update.component.spec.ts new file mode 100644 index 0000000..895341b --- /dev/null +++ b/src/main/webapp/app/entities/audit-log/audit-log-update.component.spec.ts @@ -0,0 +1,161 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import dayjs from 'dayjs'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import UtenteAppService from '@/entities/utente-app/utente-app.service'; +import AlertService from '@/shared/alert/alert.service'; +import { DATE_TIME_LONG_FORMAT } from '@/shared/composables/date-format'; + +import AuditLogUpdate from './audit-log-update.vue'; +import AuditLogService from './audit-log.service'; + +type AuditLogUpdateComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const auditLogSample = { id: 123 }; + +describe('Component Tests', () => { + let mountOptions: MountingOptions['global']; + let alertService: AlertService; + + describe('AuditLog Management Update Component', () => { + let comp: AuditLogUpdateComponentType; + let auditLogServiceStub: SinonStubbedInstance; + + beforeEach(() => { + route = {}; + auditLogServiceStub = sinon.createStubInstance(AuditLogService); + auditLogServiceStub.retrieve.onFirstCall().resolves(Promise.resolve([])); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'b-input-group': true, + 'b-input-group-prepend': true, + 'b-form-datepicker': true, + 'b-form-input': true, + }, + provide: { + alertService, + auditLogService: () => auditLogServiceStub, + utenteAppService: () => + sinon.createStubInstance(UtenteAppService, { + retrieve: sinon.stub().resolves({}), + } as any), + }, + }; + }); + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('load', () => { + beforeEach(() => { + const wrapper = shallowMount(AuditLogUpdate, { global: mountOptions }); + comp = wrapper.vm; + }); + it('Should convert date from string', () => { + // GIVEN + const date = new Date('2019-10-15T11:42:02Z'); + + // WHEN + const convertedDate = comp.convertDateTimeFromServer(date); + + // THEN + expect(convertedDate).toEqual(dayjs(date).format(DATE_TIME_LONG_FORMAT)); + }); + + it('Should not convert date if date is not present', () => { + expect(comp.convertDateTimeFromServer(null)).toBeNull(); + }); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', async () => { + // GIVEN + const wrapper = shallowMount(AuditLogUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.auditLog = auditLogSample; + auditLogServiceStub.update.resolves(auditLogSample); + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(auditLogServiceStub.update.calledWith(auditLogSample)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + + it('Should call create service on save for new entity', async () => { + // GIVEN + const entity = {}; + auditLogServiceStub.create.resolves(entity); + const wrapper = shallowMount(AuditLogUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.auditLog = entity; + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(auditLogServiceStub.create.calledWith(entity)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + }); + + describe('Before route enter', () => { + it('Should retrieve data', async () => { + // GIVEN + auditLogServiceStub.find.resolves(auditLogSample); + auditLogServiceStub.retrieve.resolves([auditLogSample]); + + // WHEN + route = { + params: { + auditLogId: `${auditLogSample.id}`, + }, + }; + const wrapper = shallowMount(AuditLogUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(comp.auditLog).toMatchObject(auditLogSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + auditLogServiceStub.find.resolves(auditLogSample); + const wrapper = shallowMount(AuditLogUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/audit-log/audit-log-update.component.ts b/src/main/webapp/app/entities/audit-log/audit-log-update.component.ts new file mode 100644 index 0000000..ad9a290 --- /dev/null +++ b/src/main/webapp/app/entities/audit-log/audit-log-update.component.ts @@ -0,0 +1,122 @@ +import { type Ref, computed, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useVuelidate } from '@vuelidate/core'; + +import UtenteAppService from '@/entities/utente-app/utente-app.service'; +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat, useValidation } from '@/shared/composables'; +import { AuditLog, type IAuditLog } from '@/shared/model/audit-log.model'; +import { AzioneAudit } from '@/shared/model/enumerations/azione-audit.model'; +import { TipoEntita } from '@/shared/model/enumerations/tipo-entita.model'; +import { type IUtenteApp } from '@/shared/model/utente-app.model'; + +import AuditLogService from './audit-log.service'; + +export default defineComponent({ + name: 'AuditLogUpdate', + setup() { + const auditLogService = inject('auditLogService', () => new AuditLogService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const auditLog: Ref = ref(new AuditLog()); + + const utenteAppService = inject('utenteAppService', () => new UtenteAppService()); + + const utenteApps: Ref = ref([]); + const tipoEntitaValues: Ref = ref(Object.keys(TipoEntita)); + const azioneAuditValues: Ref = ref(Object.keys(AzioneAudit)); + const isSaving = ref(false); + const currentLanguage = inject('currentLanguage', () => computed(() => navigator.language ?? 'it'), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + + const retrieveAuditLog = async auditLogId => { + try { + const res = await auditLogService().find(auditLogId); + res.createdAt = new Date(res.createdAt); + auditLog.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.auditLogId) { + retrieveAuditLog(route.params.auditLogId); + } + + const initRelationships = () => { + utenteAppService() + .retrieve() + .then(res => { + utenteApps.value = res.data; + }); + }; + + initRelationships(); + + const { t: t$ } = useI18n(); + const validations = useValidation(); + const validationRules = { + entitaTipo: {}, + entitaId: {}, + azione: {}, + dettagli: {}, + ipAddress: {}, + createdAt: {}, + utente: {}, + }; + const v$ = useVuelidate(validationRules, auditLog as any); + v$.value.$validate(); + + return { + auditLogService, + alertService, + auditLog, + previousState, + tipoEntitaValues, + azioneAuditValues, + isSaving, + currentLanguage, + utenteApps, + v$, + ...useDateFormat({ entityRef: auditLog }), + t$, + }; + }, + created(): void {}, + methods: { + save(): void { + this.isSaving = true; + if (this.auditLog.id) { + this.auditLogService() + .update(this.auditLog) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showInfo(this.t$('smartbookingApp.auditLog.updated', { param: param.id })); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } else { + this.auditLogService() + .create(this.auditLog) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showSuccess(this.t$('smartbookingApp.auditLog.created', { param: param.id }).toString()); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } + }, + }, +}); diff --git a/src/main/webapp/app/entities/audit-log/audit-log-update.vue b/src/main/webapp/app/entities/audit-log/audit-log-update.vue new file mode 100644 index 0000000..301d18d --- /dev/null +++ b/src/main/webapp/app/entities/audit-log/audit-log-update.vue @@ -0,0 +1,136 @@ + + diff --git a/src/main/webapp/app/entities/audit-log/audit-log.component.spec.ts b/src/main/webapp/app/entities/audit-log/audit-log.component.spec.ts new file mode 100644 index 0000000..9f54407 --- /dev/null +++ b/src/main/webapp/app/entities/audit-log/audit-log.component.spec.ts @@ -0,0 +1,166 @@ +import { vitest } from 'vitest'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import AuditLogService from './audit-log.service'; +import AuditLog from './audit-log.vue'; + +type AuditLogComponentType = InstanceType; + +const bModalStub = { + render: () => {}, + methods: { + hide: () => {}, + show: () => {}, + }, +}; + +describe('Component Tests', () => { + let alertService: AlertService; + + describe('AuditLog Management Component', () => { + let auditLogServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + auditLogServiceStub = sinon.createStubInstance(AuditLogService); + auditLogServiceStub.retrieve.resolves({ headers: {} }); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + jhiItemCount: true, + bPagination: true, + bModal: bModalStub as any, + 'font-awesome-icon': true, + 'b-badge': true, + 'jhi-sort-indicator': true, + 'b-button': true, + 'router-link': true, + }, + directives: { + 'b-modal': {}, + }, + provide: { + alertService, + auditLogService: () => auditLogServiceStub, + }, + }; + }); + + describe('Mount', () => { + it('Should call load all on init', async () => { + // GIVEN + auditLogServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + const wrapper = shallowMount(AuditLog, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(auditLogServiceStub.retrieve.calledOnce).toBeTruthy(); + expect(comp.auditLogs[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for an id', async () => { + // WHEN + const wrapper = shallowMount(AuditLog, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(auditLogServiceStub.retrieve.lastCall.firstArg).toMatchObject({ + sort: ['id,asc'], + }); + }); + }); + describe('Handles', () => { + let comp: AuditLogComponentType; + + beforeEach(async () => { + const wrapper = shallowMount(AuditLog, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + auditLogServiceStub.retrieve.reset(); + auditLogServiceStub.retrieve.resolves({ headers: {}, data: [] }); + }); + + it('should load a page', async () => { + // GIVEN + auditLogServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + comp.page = 2; + await comp.$nextTick(); + + // THEN + expect(auditLogServiceStub.retrieve.called).toBeTruthy(); + expect(comp.auditLogs[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should not load a page if the page is the same as the previous page', () => { + // WHEN + comp.page = 1; + + // THEN + expect(auditLogServiceStub.retrieve.called).toBeFalsy(); + }); + + it('should re-initialize the page', async () => { + // GIVEN + comp.page = 2; + await comp.$nextTick(); + auditLogServiceStub.retrieve.reset(); + auditLogServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + comp.clear(); + await comp.$nextTick(); + + // THEN + expect(comp.page).toEqual(1); + expect(auditLogServiceStub.retrieve.callCount).toEqual(1); + expect(comp.auditLogs[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for a non-id attribute', async () => { + // WHEN + comp.propOrder = 'name'; + await comp.$nextTick(); + + // THEN + expect(auditLogServiceStub.retrieve.lastCall.firstArg).toMatchObject({ + sort: ['name,asc', 'id'], + }); + }); + + it('Should call delete service on confirmDelete', async () => { + // GIVEN + auditLogServiceStub.delete.resolves({}); + + // WHEN + comp.prepareRemove({ id: 123 }); + + comp.removeAuditLog(); + await comp.$nextTick(); // clear components + + // THEN + expect(auditLogServiceStub.delete.called).toBeTruthy(); + + // THEN + await comp.$nextTick(); // handle component clear watch + expect(auditLogServiceStub.retrieve.callCount).toEqual(1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/audit-log/audit-log.component.ts b/src/main/webapp/app/entities/audit-log/audit-log.component.ts new file mode 100644 index 0000000..847c04e --- /dev/null +++ b/src/main/webapp/app/entities/audit-log/audit-log.component.ts @@ -0,0 +1,137 @@ +import { type Ref, defineComponent, inject, onMounted, ref, watch } from 'vue'; +import { useI18n } from 'vue-i18n'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import { type IAuditLog } from '@/shared/model/audit-log.model'; + +import AuditLogService from './audit-log.service'; + +export default defineComponent({ + name: 'AuditLog', + setup() { + const { t: t$ } = useI18n(); + const dateFormat = useDateFormat(); + const auditLogService = inject('auditLogService', () => new AuditLogService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const itemsPerPage = ref(20); + const queryCount: Ref = ref(null); + const page: Ref = ref(1); + const propOrder = ref('id'); + const reverse = ref(false); + const totalItems = ref(0); + + const auditLogs: Ref = ref([]); + + const isFetching = ref(false); + + const clear = () => { + page.value = 1; + }; + + const sort = (): Array => { + const result = [`${propOrder.value},${reverse.value ? 'desc' : 'asc'}`]; + if (propOrder.value !== 'id') { + result.push('id'); + } + return result; + }; + + const retrieveAuditLogs = async () => { + isFetching.value = true; + try { + const paginationQuery = { + page: page.value - 1, + size: itemsPerPage.value, + sort: sort(), + }; + const res = await auditLogService().retrieve(paginationQuery); + totalItems.value = Number(res.headers['x-total-count']); + queryCount.value = totalItems.value; + auditLogs.value = res.data; + } catch (err) { + alertService.showHttpError(err.response); + } finally { + isFetching.value = false; + } + }; + + const handleSyncList = () => { + retrieveAuditLogs(); + }; + + onMounted(async () => { + await retrieveAuditLogs(); + }); + + const removeId: Ref = ref(null); + const removeEntity = ref(null); + const prepareRemove = (instance: IAuditLog) => { + removeId.value = instance.id; + removeEntity.value.show(); + }; + const closeDialog = () => { + removeEntity.value.hide(); + }; + const removeAuditLog = async () => { + try { + await auditLogService().delete(removeId.value); + const message = t$('smartbookingApp.auditLog.deleted', { param: removeId.value }).toString(); + alertService.showInfo(message, { variant: 'danger' }); + removeId.value = null; + retrieveAuditLogs(); + closeDialog(); + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + const changeOrder = (newOrder: string) => { + if (propOrder.value === newOrder) { + reverse.value = !reverse.value; + } else { + reverse.value = false; + } + propOrder.value = newOrder; + }; + + // Whenever order changes, reset the pagination + watch([propOrder, reverse], async () => { + if (page.value === 1) { + // first page, retrieve new data + await retrieveAuditLogs(); + } else { + // reset the pagination + clear(); + } + }); + + // Whenever page changes, switch to the new page. + watch(page, async () => { + await retrieveAuditLogs(); + }); + + return { + auditLogs, + handleSyncList, + isFetching, + retrieveAuditLogs, + clear, + ...dateFormat, + removeId, + removeEntity, + prepareRemove, + closeDialog, + removeAuditLog, + itemsPerPage, + queryCount, + page, + propOrder, + reverse, + totalItems, + changeOrder, + t$, + }; + }, +}); diff --git a/src/main/webapp/app/entities/audit-log/audit-log.service.spec.ts b/src/main/webapp/app/entities/audit-log/audit-log.service.spec.ts new file mode 100644 index 0000000..494327c --- /dev/null +++ b/src/main/webapp/app/entities/audit-log/audit-log.service.spec.ts @@ -0,0 +1,186 @@ +import axios from 'axios'; +import dayjs from 'dayjs'; +import sinon from 'sinon'; + +import { DATE_TIME_FORMAT } from '@/shared/composables/date-format'; +import { AuditLog } from '@/shared/model/audit-log.model'; + +import AuditLogService from './audit-log.service'; + +const error = { + response: { + status: null, + data: { + type: null, + }, + }, +}; + +const axiosStub = { + get: sinon.stub(axios, 'get'), + post: sinon.stub(axios, 'post'), + put: sinon.stub(axios, 'put'), + patch: sinon.stub(axios, 'patch'), + delete: sinon.stub(axios, 'delete'), +}; + +describe('Service Tests', () => { + describe('AuditLog Service', () => { + let service: AuditLogService; + let elemDefault; + let currentDate: Date; + + beforeEach(() => { + service = new AuditLogService(); + currentDate = new Date(); + elemDefault = new AuditLog(123, 'PRENOTAZIONE', 0, 'CREATE', 'AAAAAAA', 'AAAAAAA', currentDate); + }); + + describe('Service methods', () => { + it('should find an element', async () => { + const returnedFromService = { createdAt: dayjs(currentDate).format(DATE_TIME_FORMAT), ...elemDefault }; + axiosStub.get.resolves({ data: returnedFromService }); + + return service.find(123).then(res => { + expect(res).toMatchObject(elemDefault); + }); + }); + + it('should not find an element', async () => { + axiosStub.get.rejects(error); + return service + .find(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should create a AuditLog', async () => { + const returnedFromService = { id: 123, createdAt: dayjs(currentDate).format(DATE_TIME_FORMAT), ...elemDefault }; + const expected = { createdAt: currentDate, ...returnedFromService }; + + axiosStub.post.resolves({ data: returnedFromService }); + return service.create({}).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not create a AuditLog', async () => { + axiosStub.post.rejects(error); + + return service + .create({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should update a AuditLog', async () => { + const returnedFromService = { + entitaTipo: 'BBBBBB', + entitaId: 1, + azione: 'BBBBBB', + dettagli: 'BBBBBB', + ipAddress: 'BBBBBB', + createdAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + + const expected = { createdAt: currentDate, ...returnedFromService }; + axiosStub.put.resolves({ data: returnedFromService }); + + return service.update(expected).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not update a AuditLog', async () => { + axiosStub.put.rejects(error); + + return service + .update({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should partial update a AuditLog', async () => { + const patchObject = { + azione: 'BBBBBB', + dettagli: 'BBBBBB', + ipAddress: 'BBBBBB', + createdAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...new AuditLog(), + }; + const returnedFromService = Object.assign(patchObject, elemDefault); + + const expected = { createdAt: currentDate, ...returnedFromService }; + axiosStub.patch.resolves({ data: returnedFromService }); + + return service.partialUpdate(patchObject).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not partial update a AuditLog', async () => { + axiosStub.patch.rejects(error); + + return service + .partialUpdate({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should return a list of AuditLog', async () => { + const returnedFromService = { + entitaTipo: 'BBBBBB', + entitaId: 1, + azione: 'BBBBBB', + dettagli: 'BBBBBB', + ipAddress: 'BBBBBB', + createdAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + const expected = { createdAt: currentDate, ...returnedFromService }; + axiosStub.get.resolves([returnedFromService]); + return service.retrieve({ sort: {}, page: 0, size: 10 }).then(res => { + expect(res).toContainEqual(expected); + }); + }); + + it('should not return a list of AuditLog', async () => { + axiosStub.get.rejects(error); + + return service + .retrieve() + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should delete a AuditLog', async () => { + axiosStub.delete.resolves({ ok: true }); + return service.delete(123).then(res => { + expect(res.ok).toBeTruthy(); + }); + }); + + it('should not delete a AuditLog', async () => { + axiosStub.delete.rejects(error); + + return service + .delete(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/audit-log/audit-log.service.ts b/src/main/webapp/app/entities/audit-log/audit-log.service.ts new file mode 100644 index 0000000..e1448b2 --- /dev/null +++ b/src/main/webapp/app/entities/audit-log/audit-log.service.ts @@ -0,0 +1,86 @@ +import axios from 'axios'; + +import { type IAuditLog } from '@/shared/model/audit-log.model'; +import buildPaginationQueryOpts from '@/shared/sort/sorts'; + +const baseApiUrl = 'api/audit-logs'; + +export default class AuditLogService { + find(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + retrieve(paginationQuery?: any): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}?${buildPaginationQueryOpts(paginationQuery)}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + delete(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .delete(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + create(entity: IAuditLog): Promise { + return new Promise((resolve, reject) => { + axios + .post(baseApiUrl, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + update(entity: IAuditLog): Promise { + return new Promise((resolve, reject) => { + axios + .put(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + partialUpdate(entity: IAuditLog): Promise { + return new Promise((resolve, reject) => { + axios + .patch(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } +} diff --git a/src/main/webapp/app/entities/audit-log/audit-log.vue b/src/main/webapp/app/entities/audit-log/audit-log.vue new file mode 100644 index 0000000..32d98b3 --- /dev/null +++ b/src/main/webapp/app/entities/audit-log/audit-log.vue @@ -0,0 +1,151 @@ + + + diff --git a/src/main/webapp/app/entities/conferma/conferma-details.component.spec.ts b/src/main/webapp/app/entities/conferma/conferma-details.component.spec.ts new file mode 100644 index 0000000..7a2d317 --- /dev/null +++ b/src/main/webapp/app/entities/conferma/conferma-details.component.spec.ts @@ -0,0 +1,91 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import ConfermaDetails from './conferma-details.vue'; +import ConfermaService from './conferma.service'; + +type ConfermaDetailsComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const confermaSample = { id: 123 }; + +describe('Component Tests', () => { + let alertService: AlertService; + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('Conferma Management Detail Component', () => { + let confermaServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + route = {}; + confermaServiceStub = sinon.createStubInstance(ConfermaService); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'router-link': true, + }, + provide: { + alertService, + confermaService: () => confermaServiceStub, + }, + }; + }); + + describe('Navigate to details', () => { + it('Should call load all on init', async () => { + // GIVEN + confermaServiceStub.find.resolves(confermaSample); + route = { + params: { + confermaId: `${123}`, + }, + }; + const wrapper = shallowMount(ConfermaDetails, { global: mountOptions }); + const comp = wrapper.vm; + // WHEN + await comp.$nextTick(); + + // THEN + expect(comp.conferma).toMatchObject(confermaSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + confermaServiceStub.find.resolves(confermaSample); + const wrapper = shallowMount(ConfermaDetails, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/conferma/conferma-details.component.ts b/src/main/webapp/app/entities/conferma/conferma-details.component.ts new file mode 100644 index 0000000..dae03ac --- /dev/null +++ b/src/main/webapp/app/entities/conferma/conferma-details.component.ts @@ -0,0 +1,43 @@ +import { type Ref, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { type IConferma } from '@/shared/model/conferma.model'; + +import ConfermaService from './conferma.service'; + +export default defineComponent({ + name: 'ConfermaDetails', + setup() { + const confermaService = inject('confermaService', () => new ConfermaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + const conferma: Ref = ref({}); + + const retrieveConferma = async confermaId => { + try { + const res = await confermaService().find(confermaId); + conferma.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.confermaId) { + retrieveConferma(route.params.confermaId); + } + + return { + alertService, + conferma, + + previousState, + t$: useI18n().t, + }; + }, +}); diff --git a/src/main/webapp/app/entities/conferma/conferma-details.vue b/src/main/webapp/app/entities/conferma/conferma-details.vue new file mode 100644 index 0000000..7314831 --- /dev/null +++ b/src/main/webapp/app/entities/conferma/conferma-details.vue @@ -0,0 +1,45 @@ + + + diff --git a/src/main/webapp/app/entities/conferma/conferma-update.component.spec.ts b/src/main/webapp/app/entities/conferma/conferma-update.component.spec.ts new file mode 100644 index 0000000..3b32602 --- /dev/null +++ b/src/main/webapp/app/entities/conferma/conferma-update.component.spec.ts @@ -0,0 +1,138 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import UtenteAppService from '@/entities/utente-app/utente-app.service'; +import AlertService from '@/shared/alert/alert.service'; + +import ConfermaUpdate from './conferma-update.vue'; +import ConfermaService from './conferma.service'; + +type ConfermaUpdateComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const confermaSample = { id: 123 }; + +describe('Component Tests', () => { + let mountOptions: MountingOptions['global']; + let alertService: AlertService; + + describe('Conferma Management Update Component', () => { + let comp: ConfermaUpdateComponentType; + let confermaServiceStub: SinonStubbedInstance; + + beforeEach(() => { + route = {}; + confermaServiceStub = sinon.createStubInstance(ConfermaService); + confermaServiceStub.retrieve.onFirstCall().resolves(Promise.resolve([])); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'b-input-group': true, + 'b-input-group-prepend': true, + 'b-form-datepicker': true, + 'b-form-input': true, + }, + provide: { + alertService, + confermaService: () => confermaServiceStub, + utenteAppService: () => + sinon.createStubInstance(UtenteAppService, { + retrieve: sinon.stub().resolves({}), + } as any), + }, + }; + }); + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', async () => { + // GIVEN + const wrapper = shallowMount(ConfermaUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.conferma = confermaSample; + confermaServiceStub.update.resolves(confermaSample); + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(confermaServiceStub.update.calledWith(confermaSample)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + + it('Should call create service on save for new entity', async () => { + // GIVEN + const entity = {}; + confermaServiceStub.create.resolves(entity); + const wrapper = shallowMount(ConfermaUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.conferma = entity; + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(confermaServiceStub.create.calledWith(entity)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + }); + + describe('Before route enter', () => { + it('Should retrieve data', async () => { + // GIVEN + confermaServiceStub.find.resolves(confermaSample); + confermaServiceStub.retrieve.resolves([confermaSample]); + + // WHEN + route = { + params: { + confermaId: `${confermaSample.id}`, + }, + }; + const wrapper = shallowMount(ConfermaUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(comp.conferma).toMatchObject(confermaSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + confermaServiceStub.find.resolves(confermaSample); + const wrapper = shallowMount(ConfermaUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/conferma/conferma-update.component.ts b/src/main/webapp/app/entities/conferma/conferma-update.component.ts new file mode 100644 index 0000000..8d33bbc --- /dev/null +++ b/src/main/webapp/app/entities/conferma/conferma-update.component.ts @@ -0,0 +1,114 @@ +import { type Ref, computed, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useVuelidate } from '@vuelidate/core'; + +import UtenteAppService from '@/entities/utente-app/utente-app.service'; +import { useAlertService } from '@/shared/alert/alert.service'; +import { useValidation } from '@/shared/composables'; +import { Conferma, type IConferma } from '@/shared/model/conferma.model'; +import { TipoConferma } from '@/shared/model/enumerations/tipo-conferma.model'; +import { type IUtenteApp } from '@/shared/model/utente-app.model'; + +import ConfermaService from './conferma.service'; + +export default defineComponent({ + name: 'ConfermaUpdate', + setup() { + const confermaService = inject('confermaService', () => new ConfermaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const conferma: Ref = ref(new Conferma()); + + const utenteAppService = inject('utenteAppService', () => new UtenteAppService()); + + const utenteApps: Ref = ref([]); + const tipoConfermaValues: Ref = ref(Object.keys(TipoConferma)); + const isSaving = ref(false); + const currentLanguage = inject('currentLanguage', () => computed(() => navigator.language ?? 'it'), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + + const retrieveConferma = async confermaId => { + try { + const res = await confermaService().find(confermaId); + conferma.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.confermaId) { + retrieveConferma(route.params.confermaId); + } + + const initRelationships = () => { + utenteAppService() + .retrieve() + .then(res => { + utenteApps.value = res.data; + }); + }; + + initRelationships(); + + const { t: t$ } = useI18n(); + const validations = useValidation(); + const validationRules = { + motivoConferma: {}, + tipoConferma: {}, + confermataDa: {}, + prenotazione: {}, + }; + const v$ = useVuelidate(validationRules, conferma as any); + v$.value.$validate(); + + return { + confermaService, + alertService, + conferma, + previousState, + tipoConfermaValues, + isSaving, + currentLanguage, + utenteApps, + v$, + t$, + }; + }, + created(): void {}, + methods: { + save(): void { + this.isSaving = true; + if (this.conferma.id) { + this.confermaService() + .update(this.conferma) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showInfo(this.t$('smartbookingApp.conferma.updated', { param: param.id })); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } else { + this.confermaService() + .create(this.conferma) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showSuccess(this.t$('smartbookingApp.conferma.created', { param: param.id }).toString()); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } + }, + }, +}); diff --git a/src/main/webapp/app/entities/conferma/conferma-update.vue b/src/main/webapp/app/entities/conferma/conferma-update.vue new file mode 100644 index 0000000..6369a50 --- /dev/null +++ b/src/main/webapp/app/entities/conferma/conferma-update.vue @@ -0,0 +1,83 @@ + + diff --git a/src/main/webapp/app/entities/conferma/conferma.component.spec.ts b/src/main/webapp/app/entities/conferma/conferma.component.spec.ts new file mode 100644 index 0000000..d05d51e --- /dev/null +++ b/src/main/webapp/app/entities/conferma/conferma.component.spec.ts @@ -0,0 +1,166 @@ +import { vitest } from 'vitest'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import ConfermaService from './conferma.service'; +import Conferma from './conferma.vue'; + +type ConfermaComponentType = InstanceType; + +const bModalStub = { + render: () => {}, + methods: { + hide: () => {}, + show: () => {}, + }, +}; + +describe('Component Tests', () => { + let alertService: AlertService; + + describe('Conferma Management Component', () => { + let confermaServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + confermaServiceStub = sinon.createStubInstance(ConfermaService); + confermaServiceStub.retrieve.resolves({ headers: {} }); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + jhiItemCount: true, + bPagination: true, + bModal: bModalStub as any, + 'font-awesome-icon': true, + 'b-badge': true, + 'jhi-sort-indicator': true, + 'b-button': true, + 'router-link': true, + }, + directives: { + 'b-modal': {}, + }, + provide: { + alertService, + confermaService: () => confermaServiceStub, + }, + }; + }); + + describe('Mount', () => { + it('Should call load all on init', async () => { + // GIVEN + confermaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + const wrapper = shallowMount(Conferma, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(confermaServiceStub.retrieve.calledOnce).toBeTruthy(); + expect(comp.confermas[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for an id', async () => { + // WHEN + const wrapper = shallowMount(Conferma, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(confermaServiceStub.retrieve.lastCall.firstArg).toMatchObject({ + sort: ['id,asc'], + }); + }); + }); + describe('Handles', () => { + let comp: ConfermaComponentType; + + beforeEach(async () => { + const wrapper = shallowMount(Conferma, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + confermaServiceStub.retrieve.reset(); + confermaServiceStub.retrieve.resolves({ headers: {}, data: [] }); + }); + + it('should load a page', async () => { + // GIVEN + confermaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + comp.page = 2; + await comp.$nextTick(); + + // THEN + expect(confermaServiceStub.retrieve.called).toBeTruthy(); + expect(comp.confermas[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should not load a page if the page is the same as the previous page', () => { + // WHEN + comp.page = 1; + + // THEN + expect(confermaServiceStub.retrieve.called).toBeFalsy(); + }); + + it('should re-initialize the page', async () => { + // GIVEN + comp.page = 2; + await comp.$nextTick(); + confermaServiceStub.retrieve.reset(); + confermaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + comp.clear(); + await comp.$nextTick(); + + // THEN + expect(comp.page).toEqual(1); + expect(confermaServiceStub.retrieve.callCount).toEqual(1); + expect(comp.confermas[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for a non-id attribute', async () => { + // WHEN + comp.propOrder = 'name'; + await comp.$nextTick(); + + // THEN + expect(confermaServiceStub.retrieve.lastCall.firstArg).toMatchObject({ + sort: ['name,asc', 'id'], + }); + }); + + it('Should call delete service on confirmDelete', async () => { + // GIVEN + confermaServiceStub.delete.resolves({}); + + // WHEN + comp.prepareRemove({ id: 123 }); + + comp.removeConferma(); + await comp.$nextTick(); // clear components + + // THEN + expect(confermaServiceStub.delete.called).toBeTruthy(); + + // THEN + await comp.$nextTick(); // handle component clear watch + expect(confermaServiceStub.retrieve.callCount).toEqual(1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/conferma/conferma.component.ts b/src/main/webapp/app/entities/conferma/conferma.component.ts new file mode 100644 index 0000000..7ba1595 --- /dev/null +++ b/src/main/webapp/app/entities/conferma/conferma.component.ts @@ -0,0 +1,134 @@ +import { type Ref, defineComponent, inject, onMounted, ref, watch } from 'vue'; +import { useI18n } from 'vue-i18n'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { type IConferma } from '@/shared/model/conferma.model'; + +import ConfermaService from './conferma.service'; + +export default defineComponent({ + name: 'Conferma', + setup() { + const { t: t$ } = useI18n(); + const confermaService = inject('confermaService', () => new ConfermaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const itemsPerPage = ref(20); + const queryCount: Ref = ref(null); + const page: Ref = ref(1); + const propOrder = ref('id'); + const reverse = ref(false); + const totalItems = ref(0); + + const confermas: Ref = ref([]); + + const isFetching = ref(false); + + const clear = () => { + page.value = 1; + }; + + const sort = (): Array => { + const result = [`${propOrder.value},${reverse.value ? 'desc' : 'asc'}`]; + if (propOrder.value !== 'id') { + result.push('id'); + } + return result; + }; + + const retrieveConfermas = async () => { + isFetching.value = true; + try { + const paginationQuery = { + page: page.value - 1, + size: itemsPerPage.value, + sort: sort(), + }; + const res = await confermaService().retrieve(paginationQuery); + totalItems.value = Number(res.headers['x-total-count']); + queryCount.value = totalItems.value; + confermas.value = res.data; + } catch (err) { + alertService.showHttpError(err.response); + } finally { + isFetching.value = false; + } + }; + + const handleSyncList = () => { + retrieveConfermas(); + }; + + onMounted(async () => { + await retrieveConfermas(); + }); + + const removeId: Ref = ref(null); + const removeEntity = ref(null); + const prepareRemove = (instance: IConferma) => { + removeId.value = instance.id; + removeEntity.value.show(); + }; + const closeDialog = () => { + removeEntity.value.hide(); + }; + const removeConferma = async () => { + try { + await confermaService().delete(removeId.value); + const message = t$('smartbookingApp.conferma.deleted', { param: removeId.value }).toString(); + alertService.showInfo(message, { variant: 'danger' }); + removeId.value = null; + retrieveConfermas(); + closeDialog(); + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + const changeOrder = (newOrder: string) => { + if (propOrder.value === newOrder) { + reverse.value = !reverse.value; + } else { + reverse.value = false; + } + propOrder.value = newOrder; + }; + + // Whenever order changes, reset the pagination + watch([propOrder, reverse], async () => { + if (page.value === 1) { + // first page, retrieve new data + await retrieveConfermas(); + } else { + // reset the pagination + clear(); + } + }); + + // Whenever page changes, switch to the new page. + watch(page, async () => { + await retrieveConfermas(); + }); + + return { + confermas, + handleSyncList, + isFetching, + retrieveConfermas, + clear, + removeId, + removeEntity, + prepareRemove, + closeDialog, + removeConferma, + itemsPerPage, + queryCount, + page, + propOrder, + reverse, + totalItems, + changeOrder, + t$, + }; + }, +}); diff --git a/src/main/webapp/app/entities/conferma/conferma.service.spec.ts b/src/main/webapp/app/entities/conferma/conferma.service.spec.ts new file mode 100644 index 0000000..db83c97 --- /dev/null +++ b/src/main/webapp/app/entities/conferma/conferma.service.spec.ts @@ -0,0 +1,160 @@ +import axios from 'axios'; +import sinon from 'sinon'; + +import { Conferma } from '@/shared/model/conferma.model'; + +import ConfermaService from './conferma.service'; + +const error = { + response: { + status: null, + data: { + type: null, + }, + }, +}; + +const axiosStub = { + get: sinon.stub(axios, 'get'), + post: sinon.stub(axios, 'post'), + put: sinon.stub(axios, 'put'), + patch: sinon.stub(axios, 'patch'), + delete: sinon.stub(axios, 'delete'), +}; + +describe('Service Tests', () => { + describe('Conferma Service', () => { + let service: ConfermaService; + let elemDefault; + + beforeEach(() => { + service = new ConfermaService(); + elemDefault = new Conferma(123, 'AAAAAAA', 'CONFERMATA'); + }); + + describe('Service methods', () => { + it('should find an element', async () => { + const returnedFromService = { ...elemDefault }; + axiosStub.get.resolves({ data: returnedFromService }); + + return service.find(123).then(res => { + expect(res).toMatchObject(elemDefault); + }); + }); + + it('should not find an element', async () => { + axiosStub.get.rejects(error); + return service + .find(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should create a Conferma', async () => { + const returnedFromService = { id: 123, ...elemDefault }; + const expected = { ...returnedFromService }; + + axiosStub.post.resolves({ data: returnedFromService }); + return service.create({}).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not create a Conferma', async () => { + axiosStub.post.rejects(error); + + return service + .create({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should update a Conferma', async () => { + const returnedFromService = { motivoConferma: 'BBBBBB', tipoConferma: 'BBBBBB', ...elemDefault }; + + const expected = { ...returnedFromService }; + axiosStub.put.resolves({ data: returnedFromService }); + + return service.update(expected).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not update a Conferma', async () => { + axiosStub.put.rejects(error); + + return service + .update({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should partial update a Conferma', async () => { + const patchObject = { motivoConferma: 'BBBBBB', tipoConferma: 'BBBBBB', ...new Conferma() }; + const returnedFromService = Object.assign(patchObject, elemDefault); + + const expected = { ...returnedFromService }; + axiosStub.patch.resolves({ data: returnedFromService }); + + return service.partialUpdate(patchObject).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not partial update a Conferma', async () => { + axiosStub.patch.rejects(error); + + return service + .partialUpdate({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should return a list of Conferma', async () => { + const returnedFromService = { motivoConferma: 'BBBBBB', tipoConferma: 'BBBBBB', ...elemDefault }; + const expected = { ...returnedFromService }; + axiosStub.get.resolves([returnedFromService]); + return service.retrieve({ sort: {}, page: 0, size: 10 }).then(res => { + expect(res).toContainEqual(expected); + }); + }); + + it('should not return a list of Conferma', async () => { + axiosStub.get.rejects(error); + + return service + .retrieve() + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should delete a Conferma', async () => { + axiosStub.delete.resolves({ ok: true }); + return service.delete(123).then(res => { + expect(res.ok).toBeTruthy(); + }); + }); + + it('should not delete a Conferma', async () => { + axiosStub.delete.rejects(error); + + return service + .delete(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/conferma/conferma.service.ts b/src/main/webapp/app/entities/conferma/conferma.service.ts new file mode 100644 index 0000000..15b83ab --- /dev/null +++ b/src/main/webapp/app/entities/conferma/conferma.service.ts @@ -0,0 +1,86 @@ +import axios from 'axios'; + +import { type IConferma } from '@/shared/model/conferma.model'; +import buildPaginationQueryOpts from '@/shared/sort/sorts'; + +const baseApiUrl = 'api/confermas'; + +export default class ConfermaService { + find(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + retrieve(paginationQuery?: any): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}?${buildPaginationQueryOpts(paginationQuery)}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + delete(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .delete(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + create(entity: IConferma): Promise { + return new Promise((resolve, reject) => { + axios + .post(baseApiUrl, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + update(entity: IConferma): Promise { + return new Promise((resolve, reject) => { + axios + .put(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + partialUpdate(entity: IConferma): Promise { + return new Promise((resolve, reject) => { + axios + .patch(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } +} diff --git a/src/main/webapp/app/entities/conferma/conferma.vue b/src/main/webapp/app/entities/conferma/conferma.vue new file mode 100644 index 0000000..8cd96c5 --- /dev/null +++ b/src/main/webapp/app/entities/conferma/conferma.vue @@ -0,0 +1,131 @@ + + + diff --git a/src/main/webapp/app/entities/disponibilita/disponibilita-details.component.spec.ts b/src/main/webapp/app/entities/disponibilita/disponibilita-details.component.spec.ts new file mode 100644 index 0000000..f088560 --- /dev/null +++ b/src/main/webapp/app/entities/disponibilita/disponibilita-details.component.spec.ts @@ -0,0 +1,91 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import DisponibilitaDetails from './disponibilita-details.vue'; +import DisponibilitaService from './disponibilita.service'; + +type DisponibilitaDetailsComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const disponibilitaSample = { id: 123 }; + +describe('Component Tests', () => { + let alertService: AlertService; + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('Disponibilita Management Detail Component', () => { + let disponibilitaServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + route = {}; + disponibilitaServiceStub = sinon.createStubInstance(DisponibilitaService); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'router-link': true, + }, + provide: { + alertService, + disponibilitaService: () => disponibilitaServiceStub, + }, + }; + }); + + describe('Navigate to details', () => { + it('Should call load all on init', async () => { + // GIVEN + disponibilitaServiceStub.find.resolves(disponibilitaSample); + route = { + params: { + disponibilitaId: `${123}`, + }, + }; + const wrapper = shallowMount(DisponibilitaDetails, { global: mountOptions }); + const comp = wrapper.vm; + // WHEN + await comp.$nextTick(); + + // THEN + expect(comp.disponibilita).toMatchObject(disponibilitaSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + disponibilitaServiceStub.find.resolves(disponibilitaSample); + const wrapper = shallowMount(DisponibilitaDetails, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/disponibilita/disponibilita-details.component.ts b/src/main/webapp/app/entities/disponibilita/disponibilita-details.component.ts new file mode 100644 index 0000000..9b01633 --- /dev/null +++ b/src/main/webapp/app/entities/disponibilita/disponibilita-details.component.ts @@ -0,0 +1,46 @@ +import { type Ref, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import { type IDisponibilita } from '@/shared/model/disponibilita.model'; + +import DisponibilitaService from './disponibilita.service'; + +export default defineComponent({ + name: 'DisponibilitaDetails', + setup() { + const dateFormat = useDateFormat(); + const disponibilitaService = inject('disponibilitaService', () => new DisponibilitaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + const disponibilita: Ref = ref({}); + + const retrieveDisponibilita = async disponibilitaId => { + try { + const res = await disponibilitaService().find(disponibilitaId); + disponibilita.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.disponibilitaId) { + retrieveDisponibilita(route.params.disponibilitaId); + } + + return { + ...dateFormat, + alertService, + disponibilita, + + previousState, + t$: useI18n().t, + }; + }, +}); diff --git a/src/main/webapp/app/entities/disponibilita/disponibilita-details.vue b/src/main/webapp/app/entities/disponibilita/disponibilita-details.vue new file mode 100644 index 0000000..775d84d --- /dev/null +++ b/src/main/webapp/app/entities/disponibilita/disponibilita-details.vue @@ -0,0 +1,86 @@ + + + diff --git a/src/main/webapp/app/entities/disponibilita/disponibilita-update.component.spec.ts b/src/main/webapp/app/entities/disponibilita/disponibilita-update.component.spec.ts new file mode 100644 index 0000000..4315165 --- /dev/null +++ b/src/main/webapp/app/entities/disponibilita/disponibilita-update.component.spec.ts @@ -0,0 +1,161 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import dayjs from 'dayjs'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import StrutturaService from '@/entities/struttura/struttura.service'; +import AlertService from '@/shared/alert/alert.service'; +import { DATE_TIME_LONG_FORMAT } from '@/shared/composables/date-format'; + +import DisponibilitaUpdate from './disponibilita-update.vue'; +import DisponibilitaService from './disponibilita.service'; + +type DisponibilitaUpdateComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const disponibilitaSample = { id: 123 }; + +describe('Component Tests', () => { + let mountOptions: MountingOptions['global']; + let alertService: AlertService; + + describe('Disponibilita Management Update Component', () => { + let comp: DisponibilitaUpdateComponentType; + let disponibilitaServiceStub: SinonStubbedInstance; + + beforeEach(() => { + route = {}; + disponibilitaServiceStub = sinon.createStubInstance(DisponibilitaService); + disponibilitaServiceStub.retrieve.onFirstCall().resolves(Promise.resolve([])); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'b-input-group': true, + 'b-input-group-prepend': true, + 'b-form-datepicker': true, + 'b-form-input': true, + }, + provide: { + alertService, + disponibilitaService: () => disponibilitaServiceStub, + strutturaService: () => + sinon.createStubInstance(StrutturaService, { + retrieve: sinon.stub().resolves({}), + } as any), + }, + }; + }); + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('load', () => { + beforeEach(() => { + const wrapper = shallowMount(DisponibilitaUpdate, { global: mountOptions }); + comp = wrapper.vm; + }); + it('Should convert date from string', () => { + // GIVEN + const date = new Date('2019-10-15T11:42:02Z'); + + // WHEN + const convertedDate = comp.convertDateTimeFromServer(date); + + // THEN + expect(convertedDate).toEqual(dayjs(date).format(DATE_TIME_LONG_FORMAT)); + }); + + it('Should not convert date if date is not present', () => { + expect(comp.convertDateTimeFromServer(null)).toBeNull(); + }); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', async () => { + // GIVEN + const wrapper = shallowMount(DisponibilitaUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.disponibilita = disponibilitaSample; + disponibilitaServiceStub.update.resolves(disponibilitaSample); + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(disponibilitaServiceStub.update.calledWith(disponibilitaSample)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + + it('Should call create service on save for new entity', async () => { + // GIVEN + const entity = {}; + disponibilitaServiceStub.create.resolves(entity); + const wrapper = shallowMount(DisponibilitaUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.disponibilita = entity; + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(disponibilitaServiceStub.create.calledWith(entity)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + }); + + describe('Before route enter', () => { + it('Should retrieve data', async () => { + // GIVEN + disponibilitaServiceStub.find.resolves(disponibilitaSample); + disponibilitaServiceStub.retrieve.resolves([disponibilitaSample]); + + // WHEN + route = { + params: { + disponibilitaId: `${disponibilitaSample.id}`, + }, + }; + const wrapper = shallowMount(DisponibilitaUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(comp.disponibilita).toMatchObject(disponibilitaSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + disponibilitaServiceStub.find.resolves(disponibilitaSample); + const wrapper = shallowMount(DisponibilitaUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/disponibilita/disponibilita-update.component.ts b/src/main/webapp/app/entities/disponibilita/disponibilita-update.component.ts new file mode 100644 index 0000000..bef620f --- /dev/null +++ b/src/main/webapp/app/entities/disponibilita/disponibilita-update.component.ts @@ -0,0 +1,125 @@ +import { type Ref, computed, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useVuelidate } from '@vuelidate/core'; + +import StrutturaService from '@/entities/struttura/struttura.service'; +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat, useValidation } from '@/shared/composables'; +import { Disponibilita, type IDisponibilita } from '@/shared/model/disponibilita.model'; +import { GiornoSettimana } from '@/shared/model/enumerations/giorno-settimana.model'; +import { TipoDisponibilita } from '@/shared/model/enumerations/tipo-disponibilita.model'; +import { type IStruttura } from '@/shared/model/struttura.model'; + +import DisponibilitaService from './disponibilita.service'; + +export default defineComponent({ + name: 'DisponibilitaUpdate', + setup() { + const disponibilitaService = inject('disponibilitaService', () => new DisponibilitaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const disponibilita: Ref = ref(new Disponibilita()); + + const strutturaService = inject('strutturaService', () => new StrutturaService()); + + const strutturas: Ref = ref([]); + const giornoSettimanaValues: Ref = ref(Object.keys(GiornoSettimana)); + const tipoDisponibilitaValues: Ref = ref(Object.keys(TipoDisponibilita)); + const isSaving = ref(false); + const currentLanguage = inject('currentLanguage', () => computed(() => navigator.language ?? 'it'), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + + const retrieveDisponibilita = async disponibilitaId => { + try { + const res = await disponibilitaService().find(disponibilitaId); + res.oraInizio = new Date(res.oraInizio); + res.oraFine = new Date(res.oraFine); + disponibilita.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.disponibilitaId) { + retrieveDisponibilita(route.params.disponibilitaId); + } + + const initRelationships = () => { + strutturaService() + .retrieve() + .then(res => { + strutturas.value = res.data; + }); + }; + + initRelationships(); + + const { t: t$ } = useI18n(); + const validations = useValidation(); + const validationRules = { + giornoSettimana: {}, + dataSpecifica: {}, + oraInizio: {}, + oraFine: {}, + orarioInizio: {}, + orarioFine: {}, + tipo: {}, + note: {}, + struttura: {}, + }; + const v$ = useVuelidate(validationRules, disponibilita as any); + v$.value.$validate(); + + return { + disponibilitaService, + alertService, + disponibilita, + previousState, + giornoSettimanaValues, + tipoDisponibilitaValues, + isSaving, + currentLanguage, + strutturas, + v$, + ...useDateFormat({ entityRef: disponibilita }), + t$, + }; + }, + created(): void {}, + methods: { + save(): void { + this.isSaving = true; + if (this.disponibilita.id) { + this.disponibilitaService() + .update(this.disponibilita) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showInfo(this.t$('smartbookingApp.disponibilita.updated', { param: param.id })); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } else { + this.disponibilitaService() + .create(this.disponibilita) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showSuccess(this.t$('smartbookingApp.disponibilita.created', { param: param.id }).toString()); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } + }, + }, +}); diff --git a/src/main/webapp/app/entities/disponibilita/disponibilita-update.vue b/src/main/webapp/app/entities/disponibilita/disponibilita-update.vue new file mode 100644 index 0000000..3ebb420 --- /dev/null +++ b/src/main/webapp/app/entities/disponibilita/disponibilita-update.vue @@ -0,0 +1,187 @@ + + diff --git a/src/main/webapp/app/entities/disponibilita/disponibilita.component.spec.ts b/src/main/webapp/app/entities/disponibilita/disponibilita.component.spec.ts new file mode 100644 index 0000000..7dffdd7 --- /dev/null +++ b/src/main/webapp/app/entities/disponibilita/disponibilita.component.spec.ts @@ -0,0 +1,158 @@ +import { vitest } from 'vitest'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import DisponibilitaService from './disponibilita.service'; +import Disponibilita from './disponibilita.vue'; + +type DisponibilitaComponentType = InstanceType; + +const bModalStub = { + render: () => {}, + methods: { + hide: () => {}, + show: () => {}, + }, +}; + +describe('Component Tests', () => { + let alertService: AlertService; + + describe('Disponibilita Management Component', () => { + let disponibilitaServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + disponibilitaServiceStub = sinon.createStubInstance(DisponibilitaService); + disponibilitaServiceStub.retrieve.resolves({ headers: {} }); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + jhiItemCount: true, + bPagination: true, + bModal: bModalStub as any, + 'font-awesome-icon': true, + 'b-badge': true, + 'jhi-sort-indicator': true, + 'b-button': true, + 'router-link': true, + }, + directives: { + 'b-modal': {}, + }, + provide: { + alertService, + disponibilitaService: () => disponibilitaServiceStub, + }, + }; + }); + + describe('Mount', () => { + it('Should call load all on init', async () => { + // GIVEN + disponibilitaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + const wrapper = shallowMount(Disponibilita, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(disponibilitaServiceStub.retrieve.calledOnce).toBeTruthy(); + expect(comp.disponibilitas[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for an id', async () => { + // WHEN + const wrapper = shallowMount(Disponibilita, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(disponibilitaServiceStub.retrieve.lastCall.firstArg).toMatchObject({ + sort: ['id,asc'], + }); + }); + }); + describe('Handles', () => { + let comp: DisponibilitaComponentType; + + beforeEach(async () => { + const wrapper = shallowMount(Disponibilita, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + disponibilitaServiceStub.retrieve.reset(); + disponibilitaServiceStub.retrieve.resolves({ headers: {}, data: [] }); + }); + + it('should load a page', async () => { + // GIVEN + disponibilitaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + comp.page = 2; + await comp.$nextTick(); + + // THEN + expect(disponibilitaServiceStub.retrieve.called).toBeTruthy(); + expect(comp.disponibilitas[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should re-initialize the page', async () => { + // GIVEN + comp.page = 2; + await comp.$nextTick(); + disponibilitaServiceStub.retrieve.reset(); + disponibilitaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + comp.clear(); + await comp.$nextTick(); + + // THEN + expect(comp.page).toEqual(1); + expect(disponibilitaServiceStub.retrieve.callCount).toEqual(1); + expect(comp.disponibilitas[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for a non-id attribute', async () => { + // WHEN + comp.propOrder = 'name'; + await comp.$nextTick(); + + // THEN + expect(disponibilitaServiceStub.retrieve.lastCall.firstArg).toMatchObject({ + sort: ['name,asc', 'id'], + }); + }); + + it('Should call delete service on confirmDelete', async () => { + // GIVEN + disponibilitaServiceStub.delete.resolves({}); + + // WHEN + comp.prepareRemove({ id: 123 }); + + comp.removeDisponibilita(); + await comp.$nextTick(); // clear components + + // THEN + expect(disponibilitaServiceStub.delete.called).toBeTruthy(); + + // THEN + await comp.$nextTick(); // handle component clear watch + expect(disponibilitaServiceStub.retrieve.callCount).toEqual(1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/disponibilita/disponibilita.component.ts b/src/main/webapp/app/entities/disponibilita/disponibilita.component.ts new file mode 100644 index 0000000..b917ec2 --- /dev/null +++ b/src/main/webapp/app/entities/disponibilita/disponibilita.component.ts @@ -0,0 +1,164 @@ +import { type Ref, defineComponent, inject, onMounted, ref, watch, watchEffect } from 'vue'; +import { useI18n } from 'vue-i18n'; + +import { useIntersectionObserver } from '@vueuse/core'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import useDataUtils from '@/shared/data/data-utils.service'; +import { type IDisponibilita } from '@/shared/model/disponibilita.model'; + +import DisponibilitaService from './disponibilita.service'; + +export default defineComponent({ + name: 'Disponibilita', + setup() { + const { t: t$ } = useI18n(); + const dateFormat = useDateFormat(); + const dataUtils = useDataUtils(); + const disponibilitaService = inject('disponibilitaService', () => new DisponibilitaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const itemsPerPage = ref(20); + const queryCount: Ref = ref(null); + const page: Ref = ref(1); + const propOrder = ref('id'); + const reverse = ref(false); + const totalItems = ref(0); + const links: Ref = ref({}); + + const disponibilitas: Ref = ref([]); + + const isFetching = ref(false); + + const clear = () => { + page.value = 1; + links.value = {}; + disponibilitas.value = []; + }; + + const sort = (): Array => { + const result = [`${propOrder.value},${reverse.value ? 'desc' : 'asc'}`]; + if (propOrder.value !== 'id') { + result.push('id'); + } + return result; + }; + + const retrieveDisponibilitas = async () => { + isFetching.value = true; + try { + const paginationQuery = { + page: page.value - 1, + size: itemsPerPage.value, + sort: sort(), + }; + const res = await disponibilitaService().retrieve(paginationQuery); + totalItems.value = Number(res.headers['x-total-count']); + queryCount.value = totalItems.value; + links.value = dataUtils.parseLinks(res.headers?.link); + disponibilitas.value.push(...(res.data ?? [])); + } catch (err) { + alertService.showHttpError(err.response); + } finally { + isFetching.value = false; + } + }; + + const handleSyncList = () => { + clear(); + }; + + onMounted(async () => { + await retrieveDisponibilitas(); + }); + + const removeId: Ref = ref(null); + const removeEntity = ref(null); + const prepareRemove = (instance: IDisponibilita) => { + removeId.value = instance.id; + removeEntity.value.show(); + }; + const closeDialog = () => { + removeEntity.value.hide(); + }; + const removeDisponibilita = async () => { + try { + await disponibilitaService().delete(removeId.value); + const message = t$('smartbookingApp.disponibilita.deleted', { param: removeId.value }).toString(); + alertService.showInfo(message, { variant: 'danger' }); + removeId.value = null; + clear(); + closeDialog(); + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + const changeOrder = (newOrder: string) => { + if (propOrder.value === newOrder) { + reverse.value = !reverse.value; + } else { + reverse.value = false; + } + propOrder.value = newOrder; + }; + + // Whenever order changes, reset the pagination + watch([propOrder, reverse], () => { + clear(); + }); + + // Whenever the data resets or page changes, switch to the new page. + watch([disponibilitas, page], async ([data, page], [_prevData, prevPage]) => { + if (data.length === 0 || page !== prevPage) { + await retrieveDisponibilitas(); + } + }); + + const infiniteScrollEl = ref(null); + const intersectionObserver = useIntersectionObserver( + infiniteScrollEl, + intersection => { + if (intersection[0].isIntersecting && !isFetching.value) { + page.value++; + } + }, + { + threshold: 0.5, + immediate: false, + }, + ); + watchEffect(() => { + if (links.value.next) { + intersectionObserver.resume(); + } else if (intersectionObserver.isActive) { + intersectionObserver.pause(); + } + }); + + return { + disponibilitas, + handleSyncList, + isFetching, + retrieveDisponibilitas, + clear, + ...dateFormat, + removeId, + removeEntity, + prepareRemove, + closeDialog, + removeDisponibilita, + itemsPerPage, + queryCount, + page, + propOrder, + reverse, + totalItems, + changeOrder, + infiniteScrollEl, + t$, + ...dataUtils, + }; + }, +}); diff --git a/src/main/webapp/app/entities/disponibilita/disponibilita.service.spec.ts b/src/main/webapp/app/entities/disponibilita/disponibilita.service.spec.ts new file mode 100644 index 0000000..e512e3c --- /dev/null +++ b/src/main/webapp/app/entities/disponibilita/disponibilita.service.spec.ts @@ -0,0 +1,202 @@ +import axios from 'axios'; +import dayjs from 'dayjs'; +import sinon from 'sinon'; + +import { DATE_FORMAT, DATE_TIME_FORMAT } from '@/shared/composables/date-format'; +import { Disponibilita } from '@/shared/model/disponibilita.model'; + +import DisponibilitaService from './disponibilita.service'; + +const error = { + response: { + status: null, + data: { + type: null, + }, + }, +}; + +const axiosStub = { + get: sinon.stub(axios, 'get'), + post: sinon.stub(axios, 'post'), + put: sinon.stub(axios, 'put'), + patch: sinon.stub(axios, 'patch'), + delete: sinon.stub(axios, 'delete'), +}; + +describe('Service Tests', () => { + describe('Disponibilita Service', () => { + let service: DisponibilitaService; + let elemDefault; + let currentDate: Date; + + beforeEach(() => { + service = new DisponibilitaService(); + currentDate = new Date(); + elemDefault = new Disponibilita(123, 'LUNEDI', currentDate, currentDate, currentDate, 'AAAAAAA', 'AAAAAAA', 'DISPONIBILE', 'AAAAAAA'); + }); + + describe('Service methods', () => { + it('should find an element', async () => { + const returnedFromService = { + dataSpecifica: dayjs(currentDate).format(DATE_FORMAT), + oraInizio: dayjs(currentDate).format(DATE_TIME_FORMAT), + oraFine: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + axiosStub.get.resolves({ data: returnedFromService }); + + return service.find(123).then(res => { + expect(res).toMatchObject(elemDefault); + }); + }); + + it('should not find an element', async () => { + axiosStub.get.rejects(error); + return service + .find(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should create a Disponibilita', async () => { + const returnedFromService = { + id: 123, + dataSpecifica: dayjs(currentDate).format(DATE_FORMAT), + oraInizio: dayjs(currentDate).format(DATE_TIME_FORMAT), + oraFine: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + const expected = { dataSpecifica: currentDate, oraInizio: currentDate, oraFine: currentDate, ...returnedFromService }; + + axiosStub.post.resolves({ data: returnedFromService }); + return service.create({}).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not create a Disponibilita', async () => { + axiosStub.post.rejects(error); + + return service + .create({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should update a Disponibilita', async () => { + const returnedFromService = { + giornoSettimana: 'BBBBBB', + dataSpecifica: dayjs(currentDate).format(DATE_FORMAT), + oraInizio: dayjs(currentDate).format(DATE_TIME_FORMAT), + oraFine: dayjs(currentDate).format(DATE_TIME_FORMAT), + orarioInizio: 'BBBBBB', + orarioFine: 'BBBBBB', + tipo: 'BBBBBB', + note: 'BBBBBB', + ...elemDefault, + }; + + const expected = { dataSpecifica: currentDate, oraInizio: currentDate, oraFine: currentDate, ...returnedFromService }; + axiosStub.put.resolves({ data: returnedFromService }); + + return service.update(expected).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not update a Disponibilita', async () => { + axiosStub.put.rejects(error); + + return service + .update({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should partial update a Disponibilita', async () => { + const patchObject = { + giornoSettimana: 'BBBBBB', + dataSpecifica: dayjs(currentDate).format(DATE_FORMAT), + oraInizio: dayjs(currentDate).format(DATE_TIME_FORMAT), + orarioInizio: 'BBBBBB', + tipo: 'BBBBBB', + ...new Disponibilita(), + }; + const returnedFromService = Object.assign(patchObject, elemDefault); + + const expected = { dataSpecifica: currentDate, oraInizio: currentDate, oraFine: currentDate, ...returnedFromService }; + axiosStub.patch.resolves({ data: returnedFromService }); + + return service.partialUpdate(patchObject).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not partial update a Disponibilita', async () => { + axiosStub.patch.rejects(error); + + return service + .partialUpdate({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should return a list of Disponibilita', async () => { + const returnedFromService = { + giornoSettimana: 'BBBBBB', + dataSpecifica: dayjs(currentDate).format(DATE_FORMAT), + oraInizio: dayjs(currentDate).format(DATE_TIME_FORMAT), + oraFine: dayjs(currentDate).format(DATE_TIME_FORMAT), + orarioInizio: 'BBBBBB', + orarioFine: 'BBBBBB', + tipo: 'BBBBBB', + note: 'BBBBBB', + ...elemDefault, + }; + const expected = { dataSpecifica: currentDate, oraInizio: currentDate, oraFine: currentDate, ...returnedFromService }; + axiosStub.get.resolves([returnedFromService]); + return service.retrieve({ sort: {}, page: 0, size: 10 }).then(res => { + expect(res).toContainEqual(expected); + }); + }); + + it('should not return a list of Disponibilita', async () => { + axiosStub.get.rejects(error); + + return service + .retrieve() + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should delete a Disponibilita', async () => { + axiosStub.delete.resolves({ ok: true }); + return service.delete(123).then(res => { + expect(res.ok).toBeTruthy(); + }); + }); + + it('should not delete a Disponibilita', async () => { + axiosStub.delete.rejects(error); + + return service + .delete(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/disponibilita/disponibilita.service.ts b/src/main/webapp/app/entities/disponibilita/disponibilita.service.ts new file mode 100644 index 0000000..4278d08 --- /dev/null +++ b/src/main/webapp/app/entities/disponibilita/disponibilita.service.ts @@ -0,0 +1,86 @@ +import axios from 'axios'; + +import { type IDisponibilita } from '@/shared/model/disponibilita.model'; +import buildPaginationQueryOpts from '@/shared/sort/sorts'; + +const baseApiUrl = 'api/disponibilitas'; + +export default class DisponibilitaService { + find(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + retrieve(paginationQuery?: any): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}?${buildPaginationQueryOpts(paginationQuery)}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + delete(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .delete(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + create(entity: IDisponibilita): Promise { + return new Promise((resolve, reject) => { + axios + .post(baseApiUrl, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + update(entity: IDisponibilita): Promise { + return new Promise((resolve, reject) => { + axios + .put(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + partialUpdate(entity: IDisponibilita): Promise { + return new Promise((resolve, reject) => { + axios + .patch(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } +} diff --git a/src/main/webapp/app/entities/disponibilita/disponibilita.vue b/src/main/webapp/app/entities/disponibilita/disponibilita.vue new file mode 100644 index 0000000..53bcf0a --- /dev/null +++ b/src/main/webapp/app/entities/disponibilita/disponibilita.vue @@ -0,0 +1,158 @@ + + + diff --git a/src/main/webapp/app/entities/entities-menu.vue b/src/main/webapp/app/entities/entities-menu.vue index 22b4569..1f026b0 100644 --- a/src/main/webapp/app/entities/entities-menu.vue +++ b/src/main/webapp/app/entities/entities-menu.vue @@ -1,5 +1,45 @@ diff --git a/src/main/webapp/app/entities/entities.component.ts b/src/main/webapp/app/entities/entities.component.ts index 330630b..c26b343 100644 --- a/src/main/webapp/app/entities/entities.component.ts +++ b/src/main/webapp/app/entities/entities.component.ts @@ -1,12 +1,33 @@ import { defineComponent, provide } from 'vue'; import UserService from '@/entities/user/user.service'; + +import AuditLogService from './audit-log/audit-log.service'; +import ConfermaService from './conferma/conferma.service'; +import DisponibilitaService from './disponibilita/disponibilita.service'; +import LiberatoriaService from './liberatoria/liberatoria.service'; +import MessaggioService from './messaggio/messaggio.service'; +import ModelloLiberatoriaService from './modello-liberatoria/modello-liberatoria.service'; +import NotificaService from './notifica/notifica.service'; +import PrenotazioneService from './prenotazione/prenotazione.service'; +import StrutturaService from './struttura/struttura.service'; +import UtenteAppService from './utente-app/utente-app.service'; // jhipster-needle-add-entity-service-to-entities-component-import - JHipster will import entities services here export default defineComponent({ name: 'Entities', setup() { provide('userService', () => new UserService()); + provide('auditLogService', () => new AuditLogService()); + provide('disponibilitaService', () => new DisponibilitaService()); + provide('notificaService', () => new NotificaService()); + provide('prenotazioneService', () => new PrenotazioneService()); + provide('confermaService', () => new ConfermaService()); + provide('strutturaService', () => new StrutturaService()); + provide('utenteAppService', () => new UtenteAppService()); + provide('liberatoriaService', () => new LiberatoriaService()); + provide('modelloLiberatoriaService', () => new ModelloLiberatoriaService()); + provide('messaggioService', () => new MessaggioService()); // jhipster-needle-add-entity-service-to-entities-component - JHipster will import entities services here }, }); diff --git a/src/main/webapp/app/entities/liberatoria/liberatoria-details.component.spec.ts b/src/main/webapp/app/entities/liberatoria/liberatoria-details.component.spec.ts new file mode 100644 index 0000000..51dcff3 --- /dev/null +++ b/src/main/webapp/app/entities/liberatoria/liberatoria-details.component.spec.ts @@ -0,0 +1,91 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import LiberatoriaDetails from './liberatoria-details.vue'; +import LiberatoriaService from './liberatoria.service'; + +type LiberatoriaDetailsComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const liberatoriaSample = { id: 123 }; + +describe('Component Tests', () => { + let alertService: AlertService; + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('Liberatoria Management Detail Component', () => { + let liberatoriaServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + route = {}; + liberatoriaServiceStub = sinon.createStubInstance(LiberatoriaService); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'router-link': true, + }, + provide: { + alertService, + liberatoriaService: () => liberatoriaServiceStub, + }, + }; + }); + + describe('Navigate to details', () => { + it('Should call load all on init', async () => { + // GIVEN + liberatoriaServiceStub.find.resolves(liberatoriaSample); + route = { + params: { + liberatoriaId: `${123}`, + }, + }; + const wrapper = shallowMount(LiberatoriaDetails, { global: mountOptions }); + const comp = wrapper.vm; + // WHEN + await comp.$nextTick(); + + // THEN + expect(comp.liberatoria).toMatchObject(liberatoriaSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + liberatoriaServiceStub.find.resolves(liberatoriaSample); + const wrapper = shallowMount(LiberatoriaDetails, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/liberatoria/liberatoria-details.component.ts b/src/main/webapp/app/entities/liberatoria/liberatoria-details.component.ts new file mode 100644 index 0000000..665d6d0 --- /dev/null +++ b/src/main/webapp/app/entities/liberatoria/liberatoria-details.component.ts @@ -0,0 +1,46 @@ +import { type Ref, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import { type ILiberatoria } from '@/shared/model/liberatoria.model'; + +import LiberatoriaService from './liberatoria.service'; + +export default defineComponent({ + name: 'LiberatoriaDetails', + setup() { + const dateFormat = useDateFormat(); + const liberatoriaService = inject('liberatoriaService', () => new LiberatoriaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + const liberatoria: Ref = ref({}); + + const retrieveLiberatoria = async liberatoriaId => { + try { + const res = await liberatoriaService().find(liberatoriaId); + liberatoria.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.liberatoriaId) { + retrieveLiberatoria(route.params.liberatoriaId); + } + + return { + ...dateFormat, + alertService, + liberatoria, + + previousState, + t$: useI18n().t, + }; + }, +}); diff --git a/src/main/webapp/app/entities/liberatoria/liberatoria-details.vue b/src/main/webapp/app/entities/liberatoria/liberatoria-details.vue new file mode 100644 index 0000000..ec8922a --- /dev/null +++ b/src/main/webapp/app/entities/liberatoria/liberatoria-details.vue @@ -0,0 +1,54 @@ + + + diff --git a/src/main/webapp/app/entities/liberatoria/liberatoria-update.component.spec.ts b/src/main/webapp/app/entities/liberatoria/liberatoria-update.component.spec.ts new file mode 100644 index 0000000..3ec777f --- /dev/null +++ b/src/main/webapp/app/entities/liberatoria/liberatoria-update.component.spec.ts @@ -0,0 +1,166 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import dayjs from 'dayjs'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import ModelloLiberatoriaService from '@/entities/modello-liberatoria/modello-liberatoria.service'; +import UtenteAppService from '@/entities/utente-app/utente-app.service'; +import AlertService from '@/shared/alert/alert.service'; +import { DATE_TIME_LONG_FORMAT } from '@/shared/composables/date-format'; + +import LiberatoriaUpdate from './liberatoria-update.vue'; +import LiberatoriaService from './liberatoria.service'; + +type LiberatoriaUpdateComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const liberatoriaSample = { id: 123 }; + +describe('Component Tests', () => { + let mountOptions: MountingOptions['global']; + let alertService: AlertService; + + describe('Liberatoria Management Update Component', () => { + let comp: LiberatoriaUpdateComponentType; + let liberatoriaServiceStub: SinonStubbedInstance; + + beforeEach(() => { + route = {}; + liberatoriaServiceStub = sinon.createStubInstance(LiberatoriaService); + liberatoriaServiceStub.retrieve.onFirstCall().resolves(Promise.resolve([])); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'b-input-group': true, + 'b-input-group-prepend': true, + 'b-form-datepicker': true, + 'b-form-input': true, + }, + provide: { + alertService, + liberatoriaService: () => liberatoriaServiceStub, + utenteAppService: () => + sinon.createStubInstance(UtenteAppService, { + retrieve: sinon.stub().resolves({}), + } as any), + modelloLiberatoriaService: () => + sinon.createStubInstance(ModelloLiberatoriaService, { + retrieve: sinon.stub().resolves({}), + } as any), + }, + }; + }); + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('load', () => { + beforeEach(() => { + const wrapper = shallowMount(LiberatoriaUpdate, { global: mountOptions }); + comp = wrapper.vm; + }); + it('Should convert date from string', () => { + // GIVEN + const date = new Date('2019-10-15T11:42:02Z'); + + // WHEN + const convertedDate = comp.convertDateTimeFromServer(date); + + // THEN + expect(convertedDate).toEqual(dayjs(date).format(DATE_TIME_LONG_FORMAT)); + }); + + it('Should not convert date if date is not present', () => { + expect(comp.convertDateTimeFromServer(null)).toBeNull(); + }); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', async () => { + // GIVEN + const wrapper = shallowMount(LiberatoriaUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.liberatoria = liberatoriaSample; + liberatoriaServiceStub.update.resolves(liberatoriaSample); + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(liberatoriaServiceStub.update.calledWith(liberatoriaSample)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + + it('Should call create service on save for new entity', async () => { + // GIVEN + const entity = {}; + liberatoriaServiceStub.create.resolves(entity); + const wrapper = shallowMount(LiberatoriaUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.liberatoria = entity; + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(liberatoriaServiceStub.create.calledWith(entity)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + }); + + describe('Before route enter', () => { + it('Should retrieve data', async () => { + // GIVEN + liberatoriaServiceStub.find.resolves(liberatoriaSample); + liberatoriaServiceStub.retrieve.resolves([liberatoriaSample]); + + // WHEN + route = { + params: { + liberatoriaId: `${liberatoriaSample.id}`, + }, + }; + const wrapper = shallowMount(LiberatoriaUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(comp.liberatoria).toMatchObject(liberatoriaSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + liberatoriaServiceStub.find.resolves(liberatoriaSample); + const wrapper = shallowMount(LiberatoriaUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/liberatoria/liberatoria-update.component.ts b/src/main/webapp/app/entities/liberatoria/liberatoria-update.component.ts new file mode 100644 index 0000000..22b4c5b --- /dev/null +++ b/src/main/webapp/app/entities/liberatoria/liberatoria-update.component.ts @@ -0,0 +1,124 @@ +import { type Ref, computed, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useVuelidate } from '@vuelidate/core'; + +import ModelloLiberatoriaService from '@/entities/modello-liberatoria/modello-liberatoria.service'; +import UtenteAppService from '@/entities/utente-app/utente-app.service'; +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat, useValidation } from '@/shared/composables'; +import { type ILiberatoria, Liberatoria } from '@/shared/model/liberatoria.model'; +import { type IModelloLiberatoria } from '@/shared/model/modello-liberatoria.model'; +import { type IUtenteApp } from '@/shared/model/utente-app.model'; + +import LiberatoriaService from './liberatoria.service'; + +export default defineComponent({ + name: 'LiberatoriaUpdate', + setup() { + const liberatoriaService = inject('liberatoriaService', () => new LiberatoriaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const liberatoria: Ref = ref(new Liberatoria()); + + const utenteAppService = inject('utenteAppService', () => new UtenteAppService()); + + const utenteApps: Ref = ref([]); + + const modelloLiberatoriaService = inject('modelloLiberatoriaService', () => new ModelloLiberatoriaService()); + + const modelloLiberatorias: Ref = ref([]); + const isSaving = ref(false); + const currentLanguage = inject('currentLanguage', () => computed(() => navigator.language ?? 'it'), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + + const retrieveLiberatoria = async liberatoriaId => { + try { + const res = await liberatoriaService().find(liberatoriaId); + res.accettata = new Date(res.accettata); + liberatoria.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.liberatoriaId) { + retrieveLiberatoria(route.params.liberatoriaId); + } + + const initRelationships = () => { + utenteAppService() + .retrieve() + .then(res => { + utenteApps.value = res.data; + }); + modelloLiberatoriaService() + .retrieve() + .then(res => { + modelloLiberatorias.value = res.data; + }); + }; + + initRelationships(); + + const { t: t$ } = useI18n(); + const validations = useValidation(); + const validationRules = { + accettata: {}, + utente: {}, + modelloLiberatoria: {}, + }; + const v$ = useVuelidate(validationRules, liberatoria as any); + v$.value.$validate(); + + return { + liberatoriaService, + alertService, + liberatoria, + previousState, + isSaving, + currentLanguage, + utenteApps, + modelloLiberatorias, + v$, + ...useDateFormat({ entityRef: liberatoria }), + t$, + }; + }, + created(): void {}, + methods: { + save(): void { + this.isSaving = true; + if (this.liberatoria.id) { + this.liberatoriaService() + .update(this.liberatoria) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showInfo(this.t$('smartbookingApp.liberatoria.updated', { param: param.id })); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } else { + this.liberatoriaService() + .create(this.liberatoria) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showSuccess(this.t$('smartbookingApp.liberatoria.created', { param: param.id }).toString()); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } + }, + }, +}); diff --git a/src/main/webapp/app/entities/liberatoria/liberatoria-update.vue b/src/main/webapp/app/entities/liberatoria/liberatoria-update.vue new file mode 100644 index 0000000..0e2a1f5 --- /dev/null +++ b/src/main/webapp/app/entities/liberatoria/liberatoria-update.vue @@ -0,0 +1,83 @@ + + diff --git a/src/main/webapp/app/entities/liberatoria/liberatoria.component.spec.ts b/src/main/webapp/app/entities/liberatoria/liberatoria.component.spec.ts new file mode 100644 index 0000000..8ac57e1 --- /dev/null +++ b/src/main/webapp/app/entities/liberatoria/liberatoria.component.spec.ts @@ -0,0 +1,102 @@ +import { vitest } from 'vitest'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import LiberatoriaService from './liberatoria.service'; +import Liberatoria from './liberatoria.vue'; + +type LiberatoriaComponentType = InstanceType; + +const bModalStub = { + render: () => {}, + methods: { + hide: () => {}, + show: () => {}, + }, +}; + +describe('Component Tests', () => { + let alertService: AlertService; + + describe('Liberatoria Management Component', () => { + let liberatoriaServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + liberatoriaServiceStub = sinon.createStubInstance(LiberatoriaService); + liberatoriaServiceStub.retrieve.resolves({ headers: {} }); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + bModal: bModalStub as any, + 'font-awesome-icon': true, + 'b-badge': true, + 'b-button': true, + 'router-link': true, + }, + directives: { + 'b-modal': {}, + }, + provide: { + alertService, + liberatoriaService: () => liberatoriaServiceStub, + }, + }; + }); + + describe('Mount', () => { + it('Should call load all on init', async () => { + // GIVEN + liberatoriaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + const wrapper = shallowMount(Liberatoria, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(liberatoriaServiceStub.retrieve.calledOnce).toBeTruthy(); + expect(comp.liberatorias[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + }); + describe('Handles', () => { + let comp: LiberatoriaComponentType; + + beforeEach(async () => { + const wrapper = shallowMount(Liberatoria, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + liberatoriaServiceStub.retrieve.reset(); + liberatoriaServiceStub.retrieve.resolves({ headers: {}, data: [] }); + }); + + it('Should call delete service on confirmDelete', async () => { + // GIVEN + liberatoriaServiceStub.delete.resolves({}); + + // WHEN + comp.prepareRemove({ id: 123 }); + + comp.removeLiberatoria(); + await comp.$nextTick(); // clear components + + // THEN + expect(liberatoriaServiceStub.delete.called).toBeTruthy(); + + // THEN + await comp.$nextTick(); // handle component clear watch + expect(liberatoriaServiceStub.retrieve.callCount).toEqual(1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/liberatoria/liberatoria.component.ts b/src/main/webapp/app/entities/liberatoria/liberatoria.component.ts new file mode 100644 index 0000000..072a2bb --- /dev/null +++ b/src/main/webapp/app/entities/liberatoria/liberatoria.component.ts @@ -0,0 +1,81 @@ +import { type Ref, defineComponent, inject, onMounted, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import { type ILiberatoria } from '@/shared/model/liberatoria.model'; + +import LiberatoriaService from './liberatoria.service'; + +export default defineComponent({ + name: 'Liberatoria', + setup() { + const { t: t$ } = useI18n(); + const dateFormat = useDateFormat(); + const liberatoriaService = inject('liberatoriaService', () => new LiberatoriaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const liberatorias: Ref = ref([]); + + const isFetching = ref(false); + + const clear = () => {}; + + const retrieveLiberatorias = async () => { + isFetching.value = true; + try { + const res = await liberatoriaService().retrieve(); + liberatorias.value = res.data; + } catch (err) { + alertService.showHttpError(err.response); + } finally { + isFetching.value = false; + } + }; + + const handleSyncList = () => { + retrieveLiberatorias(); + }; + + onMounted(async () => { + await retrieveLiberatorias(); + }); + + const removeId: Ref = ref(null); + const removeEntity = ref(null); + const prepareRemove = (instance: ILiberatoria) => { + removeId.value = instance.id; + removeEntity.value.show(); + }; + const closeDialog = () => { + removeEntity.value.hide(); + }; + const removeLiberatoria = async () => { + try { + await liberatoriaService().delete(removeId.value); + const message = t$('smartbookingApp.liberatoria.deleted', { param: removeId.value }).toString(); + alertService.showInfo(message, { variant: 'danger' }); + removeId.value = null; + retrieveLiberatorias(); + closeDialog(); + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + return { + liberatorias, + handleSyncList, + isFetching, + retrieveLiberatorias, + clear, + ...dateFormat, + removeId, + removeEntity, + prepareRemove, + closeDialog, + removeLiberatoria, + t$, + }; + }, +}); diff --git a/src/main/webapp/app/entities/liberatoria/liberatoria.service.spec.ts b/src/main/webapp/app/entities/liberatoria/liberatoria.service.spec.ts new file mode 100644 index 0000000..35e8784 --- /dev/null +++ b/src/main/webapp/app/entities/liberatoria/liberatoria.service.spec.ts @@ -0,0 +1,164 @@ +import axios from 'axios'; +import dayjs from 'dayjs'; +import sinon from 'sinon'; + +import { DATE_TIME_FORMAT } from '@/shared/composables/date-format'; +import { Liberatoria } from '@/shared/model/liberatoria.model'; + +import LiberatoriaService from './liberatoria.service'; + +const error = { + response: { + status: null, + data: { + type: null, + }, + }, +}; + +const axiosStub = { + get: sinon.stub(axios, 'get'), + post: sinon.stub(axios, 'post'), + put: sinon.stub(axios, 'put'), + patch: sinon.stub(axios, 'patch'), + delete: sinon.stub(axios, 'delete'), +}; + +describe('Service Tests', () => { + describe('Liberatoria Service', () => { + let service: LiberatoriaService; + let elemDefault; + let currentDate: Date; + + beforeEach(() => { + service = new LiberatoriaService(); + currentDate = new Date(); + elemDefault = new Liberatoria(123, currentDate); + }); + + describe('Service methods', () => { + it('should find an element', async () => { + const returnedFromService = { accettata: dayjs(currentDate).format(DATE_TIME_FORMAT), ...elemDefault }; + axiosStub.get.resolves({ data: returnedFromService }); + + return service.find(123).then(res => { + expect(res).toMatchObject(elemDefault); + }); + }); + + it('should not find an element', async () => { + axiosStub.get.rejects(error); + return service + .find(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should create a Liberatoria', async () => { + const returnedFromService = { id: 123, accettata: dayjs(currentDate).format(DATE_TIME_FORMAT), ...elemDefault }; + const expected = { accettata: currentDate, ...returnedFromService }; + + axiosStub.post.resolves({ data: returnedFromService }); + return service.create({}).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not create a Liberatoria', async () => { + axiosStub.post.rejects(error); + + return service + .create({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should update a Liberatoria', async () => { + const returnedFromService = { accettata: dayjs(currentDate).format(DATE_TIME_FORMAT), ...elemDefault }; + + const expected = { accettata: currentDate, ...returnedFromService }; + axiosStub.put.resolves({ data: returnedFromService }); + + return service.update(expected).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not update a Liberatoria', async () => { + axiosStub.put.rejects(error); + + return service + .update({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should partial update a Liberatoria', async () => { + const patchObject = { accettata: dayjs(currentDate).format(DATE_TIME_FORMAT), ...new Liberatoria() }; + const returnedFromService = Object.assign(patchObject, elemDefault); + + const expected = { accettata: currentDate, ...returnedFromService }; + axiosStub.patch.resolves({ data: returnedFromService }); + + return service.partialUpdate(patchObject).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not partial update a Liberatoria', async () => { + axiosStub.patch.rejects(error); + + return service + .partialUpdate({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should return a list of Liberatoria', async () => { + const returnedFromService = { accettata: dayjs(currentDate).format(DATE_TIME_FORMAT), ...elemDefault }; + const expected = { accettata: currentDate, ...returnedFromService }; + axiosStub.get.resolves([returnedFromService]); + return service.retrieve().then(res => { + expect(res).toContainEqual(expected); + }); + }); + + it('should not return a list of Liberatoria', async () => { + axiosStub.get.rejects(error); + + return service + .retrieve() + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should delete a Liberatoria', async () => { + axiosStub.delete.resolves({ ok: true }); + return service.delete(123).then(res => { + expect(res.ok).toBeTruthy(); + }); + }); + + it('should not delete a Liberatoria', async () => { + axiosStub.delete.rejects(error); + + return service + .delete(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/liberatoria/liberatoria.service.ts b/src/main/webapp/app/entities/liberatoria/liberatoria.service.ts new file mode 100644 index 0000000..f8456a2 --- /dev/null +++ b/src/main/webapp/app/entities/liberatoria/liberatoria.service.ts @@ -0,0 +1,85 @@ +import axios from 'axios'; + +import { type ILiberatoria } from '@/shared/model/liberatoria.model'; + +const baseApiUrl = 'api/liberatorias'; + +export default class LiberatoriaService { + find(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + retrieve(): Promise { + return new Promise((resolve, reject) => { + axios + .get(baseApiUrl) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + delete(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .delete(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + create(entity: ILiberatoria): Promise { + return new Promise((resolve, reject) => { + axios + .post(baseApiUrl, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + update(entity: ILiberatoria): Promise { + return new Promise((resolve, reject) => { + axios + .put(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + partialUpdate(entity: ILiberatoria): Promise { + return new Promise((resolve, reject) => { + axios + .patch(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } +} diff --git a/src/main/webapp/app/entities/liberatoria/liberatoria.vue b/src/main/webapp/app/entities/liberatoria/liberatoria.vue new file mode 100644 index 0000000..9381fe8 --- /dev/null +++ b/src/main/webapp/app/entities/liberatoria/liberatoria.vue @@ -0,0 +1,128 @@ + + + diff --git a/src/main/webapp/app/entities/messaggio/messaggio-details.component.spec.ts b/src/main/webapp/app/entities/messaggio/messaggio-details.component.spec.ts new file mode 100644 index 0000000..ef37dcf --- /dev/null +++ b/src/main/webapp/app/entities/messaggio/messaggio-details.component.spec.ts @@ -0,0 +1,91 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import MessaggioDetails from './messaggio-details.vue'; +import MessaggioService from './messaggio.service'; + +type MessaggioDetailsComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const messaggioSample = { id: 123 }; + +describe('Component Tests', () => { + let alertService: AlertService; + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('Messaggio Management Detail Component', () => { + let messaggioServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + route = {}; + messaggioServiceStub = sinon.createStubInstance(MessaggioService); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'router-link': true, + }, + provide: { + alertService, + messaggioService: () => messaggioServiceStub, + }, + }; + }); + + describe('Navigate to details', () => { + it('Should call load all on init', async () => { + // GIVEN + messaggioServiceStub.find.resolves(messaggioSample); + route = { + params: { + messaggioId: `${123}`, + }, + }; + const wrapper = shallowMount(MessaggioDetails, { global: mountOptions }); + const comp = wrapper.vm; + // WHEN + await comp.$nextTick(); + + // THEN + expect(comp.messaggio).toMatchObject(messaggioSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + messaggioServiceStub.find.resolves(messaggioSample); + const wrapper = shallowMount(MessaggioDetails, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/messaggio/messaggio-details.component.ts b/src/main/webapp/app/entities/messaggio/messaggio-details.component.ts new file mode 100644 index 0000000..d3a995e --- /dev/null +++ b/src/main/webapp/app/entities/messaggio/messaggio-details.component.ts @@ -0,0 +1,46 @@ +import { type Ref, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import { type IMessaggio } from '@/shared/model/messaggio.model'; + +import MessaggioService from './messaggio.service'; + +export default defineComponent({ + name: 'MessaggioDetails', + setup() { + const dateFormat = useDateFormat(); + const messaggioService = inject('messaggioService', () => new MessaggioService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + const messaggio: Ref = ref({}); + + const retrieveMessaggio = async messaggioId => { + try { + const res = await messaggioService().find(messaggioId); + messaggio.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.messaggioId) { + retrieveMessaggio(route.params.messaggioId); + } + + return { + ...dateFormat, + alertService, + messaggio, + + previousState, + t$: useI18n().t, + }; + }, +}); diff --git a/src/main/webapp/app/entities/messaggio/messaggio-details.vue b/src/main/webapp/app/entities/messaggio/messaggio-details.vue new file mode 100644 index 0000000..efe024e --- /dev/null +++ b/src/main/webapp/app/entities/messaggio/messaggio-details.vue @@ -0,0 +1,56 @@ + + + diff --git a/src/main/webapp/app/entities/messaggio/messaggio-update.component.spec.ts b/src/main/webapp/app/entities/messaggio/messaggio-update.component.spec.ts new file mode 100644 index 0000000..fddf68d --- /dev/null +++ b/src/main/webapp/app/entities/messaggio/messaggio-update.component.spec.ts @@ -0,0 +1,161 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import dayjs from 'dayjs'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import UtenteAppService from '@/entities/utente-app/utente-app.service'; +import AlertService from '@/shared/alert/alert.service'; +import { DATE_TIME_LONG_FORMAT } from '@/shared/composables/date-format'; + +import MessaggioUpdate from './messaggio-update.vue'; +import MessaggioService from './messaggio.service'; + +type MessaggioUpdateComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const messaggioSample = { id: 123 }; + +describe('Component Tests', () => { + let mountOptions: MountingOptions['global']; + let alertService: AlertService; + + describe('Messaggio Management Update Component', () => { + let comp: MessaggioUpdateComponentType; + let messaggioServiceStub: SinonStubbedInstance; + + beforeEach(() => { + route = {}; + messaggioServiceStub = sinon.createStubInstance(MessaggioService); + messaggioServiceStub.retrieve.onFirstCall().resolves(Promise.resolve([])); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'b-input-group': true, + 'b-input-group-prepend': true, + 'b-form-datepicker': true, + 'b-form-input': true, + }, + provide: { + alertService, + messaggioService: () => messaggioServiceStub, + utenteAppService: () => + sinon.createStubInstance(UtenteAppService, { + retrieve: sinon.stub().resolves({}), + } as any), + }, + }; + }); + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('load', () => { + beforeEach(() => { + const wrapper = shallowMount(MessaggioUpdate, { global: mountOptions }); + comp = wrapper.vm; + }); + it('Should convert date from string', () => { + // GIVEN + const date = new Date('2019-10-15T11:42:02Z'); + + // WHEN + const convertedDate = comp.convertDateTimeFromServer(date); + + // THEN + expect(convertedDate).toEqual(dayjs(date).format(DATE_TIME_LONG_FORMAT)); + }); + + it('Should not convert date if date is not present', () => { + expect(comp.convertDateTimeFromServer(null)).toBeNull(); + }); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', async () => { + // GIVEN + const wrapper = shallowMount(MessaggioUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.messaggio = messaggioSample; + messaggioServiceStub.update.resolves(messaggioSample); + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(messaggioServiceStub.update.calledWith(messaggioSample)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + + it('Should call create service on save for new entity', async () => { + // GIVEN + const entity = {}; + messaggioServiceStub.create.resolves(entity); + const wrapper = shallowMount(MessaggioUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.messaggio = entity; + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(messaggioServiceStub.create.calledWith(entity)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + }); + + describe('Before route enter', () => { + it('Should retrieve data', async () => { + // GIVEN + messaggioServiceStub.find.resolves(messaggioSample); + messaggioServiceStub.retrieve.resolves([messaggioSample]); + + // WHEN + route = { + params: { + messaggioId: `${messaggioSample.id}`, + }, + }; + const wrapper = shallowMount(MessaggioUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(comp.messaggio).toMatchObject(messaggioSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + messaggioServiceStub.find.resolves(messaggioSample); + const wrapper = shallowMount(MessaggioUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/messaggio/messaggio-update.component.ts b/src/main/webapp/app/entities/messaggio/messaggio-update.component.ts new file mode 100644 index 0000000..56dbca9 --- /dev/null +++ b/src/main/webapp/app/entities/messaggio/messaggio-update.component.ts @@ -0,0 +1,114 @@ +import { type Ref, computed, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useVuelidate } from '@vuelidate/core'; + +import UtenteAppService from '@/entities/utente-app/utente-app.service'; +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat, useValidation } from '@/shared/composables'; +import { type IMessaggio, Messaggio } from '@/shared/model/messaggio.model'; +import { type IUtenteApp } from '@/shared/model/utente-app.model'; + +import MessaggioService from './messaggio.service'; + +export default defineComponent({ + name: 'MessaggioUpdate', + setup() { + const messaggioService = inject('messaggioService', () => new MessaggioService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const messaggio: Ref = ref(new Messaggio()); + + const utenteAppService = inject('utenteAppService', () => new UtenteAppService()); + + const utenteApps: Ref = ref([]); + const isSaving = ref(false); + const currentLanguage = inject('currentLanguage', () => computed(() => navigator.language ?? 'it'), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + + const retrieveMessaggio = async messaggioId => { + try { + const res = await messaggioService().find(messaggioId); + res.spedito = new Date(res.spedito); + res.letto = new Date(res.letto); + messaggio.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.messaggioId) { + retrieveMessaggio(route.params.messaggioId); + } + + const initRelationships = () => { + utenteAppService() + .retrieve() + .then(res => { + utenteApps.value = res.data; + }); + }; + + initRelationships(); + + const { t: t$ } = useI18n(); + const validations = useValidation(); + const validationRules = { + spedito: {}, + testo: {}, + letto: {}, + utente: {}, + }; + const v$ = useVuelidate(validationRules, messaggio as any); + v$.value.$validate(); + + return { + messaggioService, + alertService, + messaggio, + previousState, + isSaving, + currentLanguage, + utenteApps, + v$, + ...useDateFormat({ entityRef: messaggio }), + t$, + }; + }, + created(): void {}, + methods: { + save(): void { + this.isSaving = true; + if (this.messaggio.id) { + this.messaggioService() + .update(this.messaggio) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showInfo(this.t$('smartbookingApp.messaggio.updated', { param: param.id })); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } else { + this.messaggioService() + .create(this.messaggio) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showSuccess(this.t$('smartbookingApp.messaggio.created', { param: param.id }).toString()); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } + }, + }, +}); diff --git a/src/main/webapp/app/entities/messaggio/messaggio-update.vue b/src/main/webapp/app/entities/messaggio/messaggio-update.vue new file mode 100644 index 0000000..cf4193b --- /dev/null +++ b/src/main/webapp/app/entities/messaggio/messaggio-update.vue @@ -0,0 +1,87 @@ + + diff --git a/src/main/webapp/app/entities/messaggio/messaggio.component.spec.ts b/src/main/webapp/app/entities/messaggio/messaggio.component.spec.ts new file mode 100644 index 0000000..d22a12d --- /dev/null +++ b/src/main/webapp/app/entities/messaggio/messaggio.component.spec.ts @@ -0,0 +1,102 @@ +import { vitest } from 'vitest'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import MessaggioService from './messaggio.service'; +import Messaggio from './messaggio.vue'; + +type MessaggioComponentType = InstanceType; + +const bModalStub = { + render: () => {}, + methods: { + hide: () => {}, + show: () => {}, + }, +}; + +describe('Component Tests', () => { + let alertService: AlertService; + + describe('Messaggio Management Component', () => { + let messaggioServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + messaggioServiceStub = sinon.createStubInstance(MessaggioService); + messaggioServiceStub.retrieve.resolves({ headers: {} }); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + bModal: bModalStub as any, + 'font-awesome-icon': true, + 'b-badge': true, + 'b-button': true, + 'router-link': true, + }, + directives: { + 'b-modal': {}, + }, + provide: { + alertService, + messaggioService: () => messaggioServiceStub, + }, + }; + }); + + describe('Mount', () => { + it('Should call load all on init', async () => { + // GIVEN + messaggioServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + const wrapper = shallowMount(Messaggio, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(messaggioServiceStub.retrieve.calledOnce).toBeTruthy(); + expect(comp.messaggios[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + }); + describe('Handles', () => { + let comp: MessaggioComponentType; + + beforeEach(async () => { + const wrapper = shallowMount(Messaggio, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + messaggioServiceStub.retrieve.reset(); + messaggioServiceStub.retrieve.resolves({ headers: {}, data: [] }); + }); + + it('Should call delete service on confirmDelete', async () => { + // GIVEN + messaggioServiceStub.delete.resolves({}); + + // WHEN + comp.prepareRemove({ id: 123 }); + + comp.removeMessaggio(); + await comp.$nextTick(); // clear components + + // THEN + expect(messaggioServiceStub.delete.called).toBeTruthy(); + + // THEN + await comp.$nextTick(); // handle component clear watch + expect(messaggioServiceStub.retrieve.callCount).toEqual(1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/messaggio/messaggio.component.ts b/src/main/webapp/app/entities/messaggio/messaggio.component.ts new file mode 100644 index 0000000..20d2202 --- /dev/null +++ b/src/main/webapp/app/entities/messaggio/messaggio.component.ts @@ -0,0 +1,81 @@ +import { type Ref, defineComponent, inject, onMounted, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import { type IMessaggio } from '@/shared/model/messaggio.model'; + +import MessaggioService from './messaggio.service'; + +export default defineComponent({ + name: 'Messaggio', + setup() { + const { t: t$ } = useI18n(); + const dateFormat = useDateFormat(); + const messaggioService = inject('messaggioService', () => new MessaggioService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const messaggios: Ref = ref([]); + + const isFetching = ref(false); + + const clear = () => {}; + + const retrieveMessaggios = async () => { + isFetching.value = true; + try { + const res = await messaggioService().retrieve(); + messaggios.value = res.data; + } catch (err) { + alertService.showHttpError(err.response); + } finally { + isFetching.value = false; + } + }; + + const handleSyncList = () => { + retrieveMessaggios(); + }; + + onMounted(async () => { + await retrieveMessaggios(); + }); + + const removeId: Ref = ref(null); + const removeEntity = ref(null); + const prepareRemove = (instance: IMessaggio) => { + removeId.value = instance.id; + removeEntity.value.show(); + }; + const closeDialog = () => { + removeEntity.value.hide(); + }; + const removeMessaggio = async () => { + try { + await messaggioService().delete(removeId.value); + const message = t$('smartbookingApp.messaggio.deleted', { param: removeId.value }).toString(); + alertService.showInfo(message, { variant: 'danger' }); + removeId.value = null; + retrieveMessaggios(); + closeDialog(); + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + return { + messaggios, + handleSyncList, + isFetching, + retrieveMessaggios, + clear, + ...dateFormat, + removeId, + removeEntity, + prepareRemove, + closeDialog, + removeMessaggio, + t$, + }; + }, +}); diff --git a/src/main/webapp/app/entities/messaggio/messaggio.service.spec.ts b/src/main/webapp/app/entities/messaggio/messaggio.service.spec.ts new file mode 100644 index 0000000..a0dddab --- /dev/null +++ b/src/main/webapp/app/entities/messaggio/messaggio.service.spec.ts @@ -0,0 +1,183 @@ +import axios from 'axios'; +import dayjs from 'dayjs'; +import sinon from 'sinon'; + +import { DATE_TIME_FORMAT } from '@/shared/composables/date-format'; +import { Messaggio } from '@/shared/model/messaggio.model'; + +import MessaggioService from './messaggio.service'; + +const error = { + response: { + status: null, + data: { + type: null, + }, + }, +}; + +const axiosStub = { + get: sinon.stub(axios, 'get'), + post: sinon.stub(axios, 'post'), + put: sinon.stub(axios, 'put'), + patch: sinon.stub(axios, 'patch'), + delete: sinon.stub(axios, 'delete'), +}; + +describe('Service Tests', () => { + describe('Messaggio Service', () => { + let service: MessaggioService; + let elemDefault; + let currentDate: Date; + + beforeEach(() => { + service = new MessaggioService(); + currentDate = new Date(); + elemDefault = new Messaggio(123, currentDate, 'AAAAAAA', currentDate); + }); + + describe('Service methods', () => { + it('should find an element', async () => { + const returnedFromService = { + spedito: dayjs(currentDate).format(DATE_TIME_FORMAT), + letto: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + axiosStub.get.resolves({ data: returnedFromService }); + + return service.find(123).then(res => { + expect(res).toMatchObject(elemDefault); + }); + }); + + it('should not find an element', async () => { + axiosStub.get.rejects(error); + return service + .find(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should create a Messaggio', async () => { + const returnedFromService = { + id: 123, + spedito: dayjs(currentDate).format(DATE_TIME_FORMAT), + letto: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + const expected = { spedito: currentDate, letto: currentDate, ...returnedFromService }; + + axiosStub.post.resolves({ data: returnedFromService }); + return service.create({}).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not create a Messaggio', async () => { + axiosStub.post.rejects(error); + + return service + .create({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should update a Messaggio', async () => { + const returnedFromService = { + spedito: dayjs(currentDate).format(DATE_TIME_FORMAT), + testo: 'BBBBBB', + letto: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + + const expected = { spedito: currentDate, letto: currentDate, ...returnedFromService }; + axiosStub.put.resolves({ data: returnedFromService }); + + return service.update(expected).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not update a Messaggio', async () => { + axiosStub.put.rejects(error); + + return service + .update({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should partial update a Messaggio', async () => { + const patchObject = { spedito: dayjs(currentDate).format(DATE_TIME_FORMAT), ...new Messaggio() }; + const returnedFromService = Object.assign(patchObject, elemDefault); + + const expected = { spedito: currentDate, letto: currentDate, ...returnedFromService }; + axiosStub.patch.resolves({ data: returnedFromService }); + + return service.partialUpdate(patchObject).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not partial update a Messaggio', async () => { + axiosStub.patch.rejects(error); + + return service + .partialUpdate({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should return a list of Messaggio', async () => { + const returnedFromService = { + spedito: dayjs(currentDate).format(DATE_TIME_FORMAT), + testo: 'BBBBBB', + letto: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + const expected = { spedito: currentDate, letto: currentDate, ...returnedFromService }; + axiosStub.get.resolves([returnedFromService]); + return service.retrieve().then(res => { + expect(res).toContainEqual(expected); + }); + }); + + it('should not return a list of Messaggio', async () => { + axiosStub.get.rejects(error); + + return service + .retrieve() + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should delete a Messaggio', async () => { + axiosStub.delete.resolves({ ok: true }); + return service.delete(123).then(res => { + expect(res.ok).toBeTruthy(); + }); + }); + + it('should not delete a Messaggio', async () => { + axiosStub.delete.rejects(error); + + return service + .delete(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/messaggio/messaggio.service.ts b/src/main/webapp/app/entities/messaggio/messaggio.service.ts new file mode 100644 index 0000000..9598f7c --- /dev/null +++ b/src/main/webapp/app/entities/messaggio/messaggio.service.ts @@ -0,0 +1,85 @@ +import axios from 'axios'; + +import { type IMessaggio } from '@/shared/model/messaggio.model'; + +const baseApiUrl = 'api/messaggios'; + +export default class MessaggioService { + find(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + retrieve(): Promise { + return new Promise((resolve, reject) => { + axios + .get(baseApiUrl) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + delete(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .delete(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + create(entity: IMessaggio): Promise { + return new Promise((resolve, reject) => { + axios + .post(baseApiUrl, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + update(entity: IMessaggio): Promise { + return new Promise((resolve, reject) => { + axios + .put(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + partialUpdate(entity: IMessaggio): Promise { + return new Promise((resolve, reject) => { + axios + .patch(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } +} diff --git a/src/main/webapp/app/entities/messaggio/messaggio.vue b/src/main/webapp/app/entities/messaggio/messaggio.vue new file mode 100644 index 0000000..fefc312 --- /dev/null +++ b/src/main/webapp/app/entities/messaggio/messaggio.vue @@ -0,0 +1,123 @@ + + + diff --git a/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-details.component.spec.ts b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-details.component.spec.ts new file mode 100644 index 0000000..d9978e7 --- /dev/null +++ b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-details.component.spec.ts @@ -0,0 +1,91 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import ModelloLiberatoriaDetails from './modello-liberatoria-details.vue'; +import ModelloLiberatoriaService from './modello-liberatoria.service'; + +type ModelloLiberatoriaDetailsComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const modelloLiberatoriaSample = { id: 123 }; + +describe('Component Tests', () => { + let alertService: AlertService; + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('ModelloLiberatoria Management Detail Component', () => { + let modelloLiberatoriaServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + route = {}; + modelloLiberatoriaServiceStub = sinon.createStubInstance(ModelloLiberatoriaService); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'router-link': true, + }, + provide: { + alertService, + modelloLiberatoriaService: () => modelloLiberatoriaServiceStub, + }, + }; + }); + + describe('Navigate to details', () => { + it('Should call load all on init', async () => { + // GIVEN + modelloLiberatoriaServiceStub.find.resolves(modelloLiberatoriaSample); + route = { + params: { + modelloLiberatoriaId: `${123}`, + }, + }; + const wrapper = shallowMount(ModelloLiberatoriaDetails, { global: mountOptions }); + const comp = wrapper.vm; + // WHEN + await comp.$nextTick(); + + // THEN + expect(comp.modelloLiberatoria).toMatchObject(modelloLiberatoriaSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + modelloLiberatoriaServiceStub.find.resolves(modelloLiberatoriaSample); + const wrapper = shallowMount(ModelloLiberatoriaDetails, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-details.component.ts b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-details.component.ts new file mode 100644 index 0000000..8527092 --- /dev/null +++ b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-details.component.ts @@ -0,0 +1,51 @@ +import { type Ref, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import useDataUtils from '@/shared/data/data-utils.service'; +import { type IModelloLiberatoria } from '@/shared/model/modello-liberatoria.model'; + +import ModelloLiberatoriaService from './modello-liberatoria.service'; + +export default defineComponent({ + name: 'ModelloLiberatoriaDetails', + setup() { + const dateFormat = useDateFormat(); + const modelloLiberatoriaService = inject('modelloLiberatoriaService', () => new ModelloLiberatoriaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const dataUtils = useDataUtils(); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + const modelloLiberatoria: Ref = ref({}); + + const retrieveModelloLiberatoria = async modelloLiberatoriaId => { + try { + const res = await modelloLiberatoriaService().find(modelloLiberatoriaId); + modelloLiberatoria.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.modelloLiberatoriaId) { + retrieveModelloLiberatoria(route.params.modelloLiberatoriaId); + } + + return { + ...dateFormat, + alertService, + modelloLiberatoria, + + ...dataUtils, + + previousState, + t$: useI18n().t, + }; + }, +}); diff --git a/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-details.vue b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-details.vue new file mode 100644 index 0000000..5fc8202 --- /dev/null +++ b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-details.vue @@ -0,0 +1,68 @@ + + + diff --git a/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-update.component.spec.ts b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-update.component.spec.ts new file mode 100644 index 0000000..b5fede8 --- /dev/null +++ b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-update.component.spec.ts @@ -0,0 +1,161 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import dayjs from 'dayjs'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import StrutturaService from '@/entities/struttura/struttura.service'; +import AlertService from '@/shared/alert/alert.service'; +import { DATE_TIME_LONG_FORMAT } from '@/shared/composables/date-format'; + +import ModelloLiberatoriaUpdate from './modello-liberatoria-update.vue'; +import ModelloLiberatoriaService from './modello-liberatoria.service'; + +type ModelloLiberatoriaUpdateComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const modelloLiberatoriaSample = { id: 123 }; + +describe('Component Tests', () => { + let mountOptions: MountingOptions['global']; + let alertService: AlertService; + + describe('ModelloLiberatoria Management Update Component', () => { + let comp: ModelloLiberatoriaUpdateComponentType; + let modelloLiberatoriaServiceStub: SinonStubbedInstance; + + beforeEach(() => { + route = {}; + modelloLiberatoriaServiceStub = sinon.createStubInstance(ModelloLiberatoriaService); + modelloLiberatoriaServiceStub.retrieve.onFirstCall().resolves(Promise.resolve([])); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'b-input-group': true, + 'b-input-group-prepend': true, + 'b-form-datepicker': true, + 'b-form-input': true, + }, + provide: { + alertService, + modelloLiberatoriaService: () => modelloLiberatoriaServiceStub, + strutturaService: () => + sinon.createStubInstance(StrutturaService, { + retrieve: sinon.stub().resolves({}), + } as any), + }, + }; + }); + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('load', () => { + beforeEach(() => { + const wrapper = shallowMount(ModelloLiberatoriaUpdate, { global: mountOptions }); + comp = wrapper.vm; + }); + it('Should convert date from string', () => { + // GIVEN + const date = new Date('2019-10-15T11:42:02Z'); + + // WHEN + const convertedDate = comp.convertDateTimeFromServer(date); + + // THEN + expect(convertedDate).toEqual(dayjs(date).format(DATE_TIME_LONG_FORMAT)); + }); + + it('Should not convert date if date is not present', () => { + expect(comp.convertDateTimeFromServer(null)).toBeNull(); + }); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', async () => { + // GIVEN + const wrapper = shallowMount(ModelloLiberatoriaUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.modelloLiberatoria = modelloLiberatoriaSample; + modelloLiberatoriaServiceStub.update.resolves(modelloLiberatoriaSample); + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(modelloLiberatoriaServiceStub.update.calledWith(modelloLiberatoriaSample)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + + it('Should call create service on save for new entity', async () => { + // GIVEN + const entity = {}; + modelloLiberatoriaServiceStub.create.resolves(entity); + const wrapper = shallowMount(ModelloLiberatoriaUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.modelloLiberatoria = entity; + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(modelloLiberatoriaServiceStub.create.calledWith(entity)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + }); + + describe('Before route enter', () => { + it('Should retrieve data', async () => { + // GIVEN + modelloLiberatoriaServiceStub.find.resolves(modelloLiberatoriaSample); + modelloLiberatoriaServiceStub.retrieve.resolves([modelloLiberatoriaSample]); + + // WHEN + route = { + params: { + modelloLiberatoriaId: `${modelloLiberatoriaSample.id}`, + }, + }; + const wrapper = shallowMount(ModelloLiberatoriaUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(comp.modelloLiberatoria).toMatchObject(modelloLiberatoriaSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + modelloLiberatoriaServiceStub.find.resolves(modelloLiberatoriaSample); + const wrapper = shallowMount(ModelloLiberatoriaUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-update.component.ts b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-update.component.ts new file mode 100644 index 0000000..b62522f --- /dev/null +++ b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-update.component.ts @@ -0,0 +1,120 @@ +import { type Ref, computed, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useVuelidate } from '@vuelidate/core'; + +import StrutturaService from '@/entities/struttura/struttura.service'; +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat, useValidation } from '@/shared/composables'; +import useDataUtils from '@/shared/data/data-utils.service'; +import { type IModelloLiberatoria, ModelloLiberatoria } from '@/shared/model/modello-liberatoria.model'; +import { type IStruttura } from '@/shared/model/struttura.model'; + +import ModelloLiberatoriaService from './modello-liberatoria.service'; + +export default defineComponent({ + name: 'ModelloLiberatoriaUpdate', + setup() { + const modelloLiberatoriaService = inject('modelloLiberatoriaService', () => new ModelloLiberatoriaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const modelloLiberatoria: Ref = ref(new ModelloLiberatoria()); + + const strutturaService = inject('strutturaService', () => new StrutturaService()); + + const strutturas: Ref = ref([]); + const isSaving = ref(false); + const currentLanguage = inject('currentLanguage', () => computed(() => navigator.language ?? 'it'), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + + const retrieveModelloLiberatoria = async modelloLiberatoriaId => { + try { + const res = await modelloLiberatoriaService().find(modelloLiberatoriaId); + res.validoDal = new Date(res.validoDal); + res.validoAl = new Date(res.validoAl); + modelloLiberatoria.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.modelloLiberatoriaId) { + retrieveModelloLiberatoria(route.params.modelloLiberatoriaId); + } + + const initRelationships = () => { + strutturaService() + .retrieve() + .then(res => { + strutturas.value = res.data; + }); + }; + + initRelationships(); + + const dataUtils = useDataUtils(); + + const { t: t$ } = useI18n(); + const validations = useValidation(); + const validationRules = { + nome: {}, + testo: {}, + documento: {}, + validoDal: {}, + validoAl: {}, + struttura: {}, + }; + const v$ = useVuelidate(validationRules, modelloLiberatoria as any); + v$.value.$validate(); + + return { + modelloLiberatoriaService, + alertService, + modelloLiberatoria, + previousState, + isSaving, + currentLanguage, + strutturas, + ...dataUtils, + v$, + ...useDateFormat({ entityRef: modelloLiberatoria }), + t$, + }; + }, + created(): void {}, + methods: { + save(): void { + this.isSaving = true; + if (this.modelloLiberatoria.id) { + this.modelloLiberatoriaService() + .update(this.modelloLiberatoria) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showInfo(this.t$('smartbookingApp.modelloLiberatoria.updated', { param: param.id })); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } else { + this.modelloLiberatoriaService() + .create(this.modelloLiberatoria) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showSuccess(this.t$('smartbookingApp.modelloLiberatoria.created', { param: param.id }).toString()); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } + }, + }, +}); diff --git a/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-update.vue b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-update.vue new file mode 100644 index 0000000..40388c8 --- /dev/null +++ b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria-update.vue @@ -0,0 +1,152 @@ + + diff --git a/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.component.spec.ts b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.component.spec.ts new file mode 100644 index 0000000..57e1102 --- /dev/null +++ b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.component.spec.ts @@ -0,0 +1,102 @@ +import { vitest } from 'vitest'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import ModelloLiberatoriaService from './modello-liberatoria.service'; +import ModelloLiberatoria from './modello-liberatoria.vue'; + +type ModelloLiberatoriaComponentType = InstanceType; + +const bModalStub = { + render: () => {}, + methods: { + hide: () => {}, + show: () => {}, + }, +}; + +describe('Component Tests', () => { + let alertService: AlertService; + + describe('ModelloLiberatoria Management Component', () => { + let modelloLiberatoriaServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + modelloLiberatoriaServiceStub = sinon.createStubInstance(ModelloLiberatoriaService); + modelloLiberatoriaServiceStub.retrieve.resolves({ headers: {} }); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + bModal: bModalStub as any, + 'font-awesome-icon': true, + 'b-badge': true, + 'b-button': true, + 'router-link': true, + }, + directives: { + 'b-modal': {}, + }, + provide: { + alertService, + modelloLiberatoriaService: () => modelloLiberatoriaServiceStub, + }, + }; + }); + + describe('Mount', () => { + it('Should call load all on init', async () => { + // GIVEN + modelloLiberatoriaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + const wrapper = shallowMount(ModelloLiberatoria, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(modelloLiberatoriaServiceStub.retrieve.calledOnce).toBeTruthy(); + expect(comp.modelloLiberatorias[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + }); + describe('Handles', () => { + let comp: ModelloLiberatoriaComponentType; + + beforeEach(async () => { + const wrapper = shallowMount(ModelloLiberatoria, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + modelloLiberatoriaServiceStub.retrieve.reset(); + modelloLiberatoriaServiceStub.retrieve.resolves({ headers: {}, data: [] }); + }); + + it('Should call delete service on confirmDelete', async () => { + // GIVEN + modelloLiberatoriaServiceStub.delete.resolves({}); + + // WHEN + comp.prepareRemove({ id: 123 }); + + comp.removeModelloLiberatoria(); + await comp.$nextTick(); // clear components + + // THEN + expect(modelloLiberatoriaServiceStub.delete.called).toBeTruthy(); + + // THEN + await comp.$nextTick(); // handle component clear watch + expect(modelloLiberatoriaServiceStub.retrieve.callCount).toEqual(1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.component.ts b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.component.ts new file mode 100644 index 0000000..00f22aa --- /dev/null +++ b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.component.ts @@ -0,0 +1,84 @@ +import { type Ref, defineComponent, inject, onMounted, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import useDataUtils from '@/shared/data/data-utils.service'; +import { type IModelloLiberatoria } from '@/shared/model/modello-liberatoria.model'; + +import ModelloLiberatoriaService from './modello-liberatoria.service'; + +export default defineComponent({ + name: 'ModelloLiberatoria', + setup() { + const { t: t$ } = useI18n(); + const dateFormat = useDateFormat(); + const dataUtils = useDataUtils(); + const modelloLiberatoriaService = inject('modelloLiberatoriaService', () => new ModelloLiberatoriaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const modelloLiberatorias: Ref = ref([]); + + const isFetching = ref(false); + + const clear = () => {}; + + const retrieveModelloLiberatorias = async () => { + isFetching.value = true; + try { + const res = await modelloLiberatoriaService().retrieve(); + modelloLiberatorias.value = res.data; + } catch (err) { + alertService.showHttpError(err.response); + } finally { + isFetching.value = false; + } + }; + + const handleSyncList = () => { + retrieveModelloLiberatorias(); + }; + + onMounted(async () => { + await retrieveModelloLiberatorias(); + }); + + const removeId: Ref = ref(null); + const removeEntity = ref(null); + const prepareRemove = (instance: IModelloLiberatoria) => { + removeId.value = instance.id; + removeEntity.value.show(); + }; + const closeDialog = () => { + removeEntity.value.hide(); + }; + const removeModelloLiberatoria = async () => { + try { + await modelloLiberatoriaService().delete(removeId.value); + const message = t$('smartbookingApp.modelloLiberatoria.deleted', { param: removeId.value }).toString(); + alertService.showInfo(message, { variant: 'danger' }); + removeId.value = null; + retrieveModelloLiberatorias(); + closeDialog(); + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + return { + modelloLiberatorias, + handleSyncList, + isFetching, + retrieveModelloLiberatorias, + clear, + ...dateFormat, + removeId, + removeEntity, + prepareRemove, + closeDialog, + removeModelloLiberatoria, + t$, + ...dataUtils, + }; + }, +}); diff --git a/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.service.spec.ts b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.service.spec.ts new file mode 100644 index 0000000..055fcc9 --- /dev/null +++ b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.service.spec.ts @@ -0,0 +1,193 @@ +import axios from 'axios'; +import dayjs from 'dayjs'; +import sinon from 'sinon'; + +import { DATE_TIME_FORMAT } from '@/shared/composables/date-format'; +import { ModelloLiberatoria } from '@/shared/model/modello-liberatoria.model'; + +import ModelloLiberatoriaService from './modello-liberatoria.service'; + +const error = { + response: { + status: null, + data: { + type: null, + }, + }, +}; + +const axiosStub = { + get: sinon.stub(axios, 'get'), + post: sinon.stub(axios, 'post'), + put: sinon.stub(axios, 'put'), + patch: sinon.stub(axios, 'patch'), + delete: sinon.stub(axios, 'delete'), +}; + +describe('Service Tests', () => { + describe('ModelloLiberatoria Service', () => { + let service: ModelloLiberatoriaService; + let elemDefault; + let currentDate: Date; + + beforeEach(() => { + service = new ModelloLiberatoriaService(); + currentDate = new Date(); + elemDefault = new ModelloLiberatoria(123, 'AAAAAAA', 'AAAAAAA', 'image/png', 'AAAAAAA', currentDate, currentDate); + }); + + describe('Service methods', () => { + it('should find an element', async () => { + const returnedFromService = { + validoDal: dayjs(currentDate).format(DATE_TIME_FORMAT), + validoAl: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + axiosStub.get.resolves({ data: returnedFromService }); + + return service.find(123).then(res => { + expect(res).toMatchObject(elemDefault); + }); + }); + + it('should not find an element', async () => { + axiosStub.get.rejects(error); + return service + .find(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should create a ModelloLiberatoria', async () => { + const returnedFromService = { + id: 123, + validoDal: dayjs(currentDate).format(DATE_TIME_FORMAT), + validoAl: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + const expected = { validoDal: currentDate, validoAl: currentDate, ...returnedFromService }; + + axiosStub.post.resolves({ data: returnedFromService }); + return service.create({}).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not create a ModelloLiberatoria', async () => { + axiosStub.post.rejects(error); + + return service + .create({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should update a ModelloLiberatoria', async () => { + const returnedFromService = { + nome: 'BBBBBB', + testo: 'BBBBBB', + documento: 'BBBBBB', + validoDal: dayjs(currentDate).format(DATE_TIME_FORMAT), + validoAl: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + + const expected = { validoDal: currentDate, validoAl: currentDate, ...returnedFromService }; + axiosStub.put.resolves({ data: returnedFromService }); + + return service.update(expected).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not update a ModelloLiberatoria', async () => { + axiosStub.put.rejects(error); + + return service + .update({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should partial update a ModelloLiberatoria', async () => { + const patchObject = { + nome: 'BBBBBB', + testo: 'BBBBBB', + documento: 'BBBBBB', + validoAl: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...new ModelloLiberatoria(), + }; + const returnedFromService = Object.assign(patchObject, elemDefault); + + const expected = { validoDal: currentDate, validoAl: currentDate, ...returnedFromService }; + axiosStub.patch.resolves({ data: returnedFromService }); + + return service.partialUpdate(patchObject).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not partial update a ModelloLiberatoria', async () => { + axiosStub.patch.rejects(error); + + return service + .partialUpdate({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should return a list of ModelloLiberatoria', async () => { + const returnedFromService = { + nome: 'BBBBBB', + testo: 'BBBBBB', + documento: 'BBBBBB', + validoDal: dayjs(currentDate).format(DATE_TIME_FORMAT), + validoAl: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + const expected = { validoDal: currentDate, validoAl: currentDate, ...returnedFromService }; + axiosStub.get.resolves([returnedFromService]); + return service.retrieve().then(res => { + expect(res).toContainEqual(expected); + }); + }); + + it('should not return a list of ModelloLiberatoria', async () => { + axiosStub.get.rejects(error); + + return service + .retrieve() + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should delete a ModelloLiberatoria', async () => { + axiosStub.delete.resolves({ ok: true }); + return service.delete(123).then(res => { + expect(res.ok).toBeTruthy(); + }); + }); + + it('should not delete a ModelloLiberatoria', async () => { + axiosStub.delete.rejects(error); + + return service + .delete(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.service.ts b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.service.ts new file mode 100644 index 0000000..9feb8c5 --- /dev/null +++ b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.service.ts @@ -0,0 +1,85 @@ +import axios from 'axios'; + +import { type IModelloLiberatoria } from '@/shared/model/modello-liberatoria.model'; + +const baseApiUrl = 'api/modello-liberatorias'; + +export default class ModelloLiberatoriaService { + find(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + retrieve(): Promise { + return new Promise((resolve, reject) => { + axios + .get(baseApiUrl) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + delete(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .delete(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + create(entity: IModelloLiberatoria): Promise { + return new Promise((resolve, reject) => { + axios + .post(baseApiUrl, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + update(entity: IModelloLiberatoria): Promise { + return new Promise((resolve, reject) => { + axios + .put(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + partialUpdate(entity: IModelloLiberatoria): Promise { + return new Promise((resolve, reject) => { + axios + .patch(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } +} diff --git a/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.vue b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.vue new file mode 100644 index 0000000..d799485 --- /dev/null +++ b/src/main/webapp/app/entities/modello-liberatoria/modello-liberatoria.vue @@ -0,0 +1,135 @@ + + + diff --git a/src/main/webapp/app/entities/notifica/notifica-details.component.spec.ts b/src/main/webapp/app/entities/notifica/notifica-details.component.spec.ts new file mode 100644 index 0000000..ed457c2 --- /dev/null +++ b/src/main/webapp/app/entities/notifica/notifica-details.component.spec.ts @@ -0,0 +1,91 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import NotificaDetails from './notifica-details.vue'; +import NotificaService from './notifica.service'; + +type NotificaDetailsComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const notificaSample = { id: 123 }; + +describe('Component Tests', () => { + let alertService: AlertService; + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('Notifica Management Detail Component', () => { + let notificaServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + route = {}; + notificaServiceStub = sinon.createStubInstance(NotificaService); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'router-link': true, + }, + provide: { + alertService, + notificaService: () => notificaServiceStub, + }, + }; + }); + + describe('Navigate to details', () => { + it('Should call load all on init', async () => { + // GIVEN + notificaServiceStub.find.resolves(notificaSample); + route = { + params: { + notificaId: `${123}`, + }, + }; + const wrapper = shallowMount(NotificaDetails, { global: mountOptions }); + const comp = wrapper.vm; + // WHEN + await comp.$nextTick(); + + // THEN + expect(comp.notifica).toMatchObject(notificaSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + notificaServiceStub.find.resolves(notificaSample); + const wrapper = shallowMount(NotificaDetails, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/notifica/notifica-details.component.ts b/src/main/webapp/app/entities/notifica/notifica-details.component.ts new file mode 100644 index 0000000..97cbfb8 --- /dev/null +++ b/src/main/webapp/app/entities/notifica/notifica-details.component.ts @@ -0,0 +1,46 @@ +import { type Ref, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import { type INotifica } from '@/shared/model/notifica.model'; + +import NotificaService from './notifica.service'; + +export default defineComponent({ + name: 'NotificaDetails', + setup() { + const dateFormat = useDateFormat(); + const notificaService = inject('notificaService', () => new NotificaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + const notifica: Ref = ref({}); + + const retrieveNotifica = async notificaId => { + try { + const res = await notificaService().find(notificaId); + notifica.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.notificaId) { + retrieveNotifica(route.params.notificaId); + } + + return { + ...dateFormat, + alertService, + notifica, + + previousState, + t$: useI18n().t, + }; + }, +}); diff --git a/src/main/webapp/app/entities/notifica/notifica-details.vue b/src/main/webapp/app/entities/notifica/notifica-details.vue new file mode 100644 index 0000000..e3cac0a --- /dev/null +++ b/src/main/webapp/app/entities/notifica/notifica-details.vue @@ -0,0 +1,75 @@ + + + diff --git a/src/main/webapp/app/entities/notifica/notifica-update.component.spec.ts b/src/main/webapp/app/entities/notifica/notifica-update.component.spec.ts new file mode 100644 index 0000000..299dfcb --- /dev/null +++ b/src/main/webapp/app/entities/notifica/notifica-update.component.spec.ts @@ -0,0 +1,161 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import dayjs from 'dayjs'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import ConfermaService from '@/entities/conferma/conferma.service'; +import AlertService from '@/shared/alert/alert.service'; +import { DATE_TIME_LONG_FORMAT } from '@/shared/composables/date-format'; + +import NotificaUpdate from './notifica-update.vue'; +import NotificaService from './notifica.service'; + +type NotificaUpdateComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const notificaSample = { id: 123 }; + +describe('Component Tests', () => { + let mountOptions: MountingOptions['global']; + let alertService: AlertService; + + describe('Notifica Management Update Component', () => { + let comp: NotificaUpdateComponentType; + let notificaServiceStub: SinonStubbedInstance; + + beforeEach(() => { + route = {}; + notificaServiceStub = sinon.createStubInstance(NotificaService); + notificaServiceStub.retrieve.onFirstCall().resolves(Promise.resolve([])); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'b-input-group': true, + 'b-input-group-prepend': true, + 'b-form-datepicker': true, + 'b-form-input': true, + }, + provide: { + alertService, + notificaService: () => notificaServiceStub, + confermaService: () => + sinon.createStubInstance(ConfermaService, { + retrieve: sinon.stub().resolves({}), + } as any), + }, + }; + }); + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('load', () => { + beforeEach(() => { + const wrapper = shallowMount(NotificaUpdate, { global: mountOptions }); + comp = wrapper.vm; + }); + it('Should convert date from string', () => { + // GIVEN + const date = new Date('2019-10-15T11:42:02Z'); + + // WHEN + const convertedDate = comp.convertDateTimeFromServer(date); + + // THEN + expect(convertedDate).toEqual(dayjs(date).format(DATE_TIME_LONG_FORMAT)); + }); + + it('Should not convert date if date is not present', () => { + expect(comp.convertDateTimeFromServer(null)).toBeNull(); + }); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', async () => { + // GIVEN + const wrapper = shallowMount(NotificaUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.notifica = notificaSample; + notificaServiceStub.update.resolves(notificaSample); + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(notificaServiceStub.update.calledWith(notificaSample)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + + it('Should call create service on save for new entity', async () => { + // GIVEN + const entity = {}; + notificaServiceStub.create.resolves(entity); + const wrapper = shallowMount(NotificaUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.notifica = entity; + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(notificaServiceStub.create.calledWith(entity)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + }); + + describe('Before route enter', () => { + it('Should retrieve data', async () => { + // GIVEN + notificaServiceStub.find.resolves(notificaSample); + notificaServiceStub.retrieve.resolves([notificaSample]); + + // WHEN + route = { + params: { + notificaId: `${notificaSample.id}`, + }, + }; + const wrapper = shallowMount(NotificaUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(comp.notifica).toMatchObject(notificaSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + notificaServiceStub.find.resolves(notificaSample); + const wrapper = shallowMount(NotificaUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/notifica/notifica-update.component.ts b/src/main/webapp/app/entities/notifica/notifica-update.component.ts new file mode 100644 index 0000000..a2107ca --- /dev/null +++ b/src/main/webapp/app/entities/notifica/notifica-update.component.ts @@ -0,0 +1,124 @@ +import { type Ref, computed, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useVuelidate } from '@vuelidate/core'; + +import ConfermaService from '@/entities/conferma/conferma.service'; +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat, useValidation } from '@/shared/composables'; +import { type IConferma } from '@/shared/model/conferma.model'; +import { TipoCanaleNotifica } from '@/shared/model/enumerations/tipo-canale-notifica.model'; +import { TipoEventoNotifica } from '@/shared/model/enumerations/tipo-evento-notifica.model'; +import { type INotifica, Notifica } from '@/shared/model/notifica.model'; + +import NotificaService from './notifica.service'; + +export default defineComponent({ + name: 'NotificaUpdate', + setup() { + const notificaService = inject('notificaService', () => new NotificaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const notifica: Ref = ref(new Notifica()); + + const confermaService = inject('confermaService', () => new ConfermaService()); + + const confermas: Ref = ref([]); + const tipoCanaleNotificaValues: Ref = ref(Object.keys(TipoCanaleNotifica)); + const tipoEventoNotificaValues: Ref = ref(Object.keys(TipoEventoNotifica)); + const isSaving = ref(false); + const currentLanguage = inject('currentLanguage', () => computed(() => navigator.language ?? 'it'), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + + const retrieveNotifica = async notificaId => { + try { + const res = await notificaService().find(notificaId); + res.inviataAt = new Date(res.inviataAt); + res.createdAt = new Date(res.createdAt); + notifica.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.notificaId) { + retrieveNotifica(route.params.notificaId); + } + + const initRelationships = () => { + confermaService() + .retrieve() + .then(res => { + confermas.value = res.data; + }); + }; + + initRelationships(); + + const { t: t$ } = useI18n(); + const validations = useValidation(); + const validationRules = { + tipoCanale: {}, + tipoEvento: {}, + messaggio: {}, + inviata: {}, + inviataAt: {}, + errore: {}, + createdAt: {}, + conferma: {}, + }; + const v$ = useVuelidate(validationRules, notifica as any); + v$.value.$validate(); + + return { + notificaService, + alertService, + notifica, + previousState, + tipoCanaleNotificaValues, + tipoEventoNotificaValues, + isSaving, + currentLanguage, + confermas, + v$, + ...useDateFormat({ entityRef: notifica }), + t$, + }; + }, + created(): void {}, + methods: { + save(): void { + this.isSaving = true; + if (this.notifica.id) { + this.notificaService() + .update(this.notifica) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showInfo(this.t$('smartbookingApp.notifica.updated', { param: param.id })); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } else { + this.notificaService() + .create(this.notifica) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showSuccess(this.t$('smartbookingApp.notifica.created', { param: param.id }).toString()); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } + }, + }, +}); diff --git a/src/main/webapp/app/entities/notifica/notifica-update.vue b/src/main/webapp/app/entities/notifica/notifica-update.vue new file mode 100644 index 0000000..575cd71 --- /dev/null +++ b/src/main/webapp/app/entities/notifica/notifica-update.vue @@ -0,0 +1,151 @@ + + diff --git a/src/main/webapp/app/entities/notifica/notifica.component.spec.ts b/src/main/webapp/app/entities/notifica/notifica.component.spec.ts new file mode 100644 index 0000000..054596b --- /dev/null +++ b/src/main/webapp/app/entities/notifica/notifica.component.spec.ts @@ -0,0 +1,166 @@ +import { vitest } from 'vitest'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import NotificaService from './notifica.service'; +import Notifica from './notifica.vue'; + +type NotificaComponentType = InstanceType; + +const bModalStub = { + render: () => {}, + methods: { + hide: () => {}, + show: () => {}, + }, +}; + +describe('Component Tests', () => { + let alertService: AlertService; + + describe('Notifica Management Component', () => { + let notificaServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + notificaServiceStub = sinon.createStubInstance(NotificaService); + notificaServiceStub.retrieve.resolves({ headers: {} }); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + jhiItemCount: true, + bPagination: true, + bModal: bModalStub as any, + 'font-awesome-icon': true, + 'b-badge': true, + 'jhi-sort-indicator': true, + 'b-button': true, + 'router-link': true, + }, + directives: { + 'b-modal': {}, + }, + provide: { + alertService, + notificaService: () => notificaServiceStub, + }, + }; + }); + + describe('Mount', () => { + it('Should call load all on init', async () => { + // GIVEN + notificaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + const wrapper = shallowMount(Notifica, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(notificaServiceStub.retrieve.calledOnce).toBeTruthy(); + expect(comp.notificas[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for an id', async () => { + // WHEN + const wrapper = shallowMount(Notifica, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(notificaServiceStub.retrieve.lastCall.firstArg).toMatchObject({ + sort: ['id,asc'], + }); + }); + }); + describe('Handles', () => { + let comp: NotificaComponentType; + + beforeEach(async () => { + const wrapper = shallowMount(Notifica, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + notificaServiceStub.retrieve.reset(); + notificaServiceStub.retrieve.resolves({ headers: {}, data: [] }); + }); + + it('should load a page', async () => { + // GIVEN + notificaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + comp.page = 2; + await comp.$nextTick(); + + // THEN + expect(notificaServiceStub.retrieve.called).toBeTruthy(); + expect(comp.notificas[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should not load a page if the page is the same as the previous page', () => { + // WHEN + comp.page = 1; + + // THEN + expect(notificaServiceStub.retrieve.called).toBeFalsy(); + }); + + it('should re-initialize the page', async () => { + // GIVEN + comp.page = 2; + await comp.$nextTick(); + notificaServiceStub.retrieve.reset(); + notificaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + comp.clear(); + await comp.$nextTick(); + + // THEN + expect(comp.page).toEqual(1); + expect(notificaServiceStub.retrieve.callCount).toEqual(1); + expect(comp.notificas[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for a non-id attribute', async () => { + // WHEN + comp.propOrder = 'name'; + await comp.$nextTick(); + + // THEN + expect(notificaServiceStub.retrieve.lastCall.firstArg).toMatchObject({ + sort: ['name,asc', 'id'], + }); + }); + + it('Should call delete service on confirmDelete', async () => { + // GIVEN + notificaServiceStub.delete.resolves({}); + + // WHEN + comp.prepareRemove({ id: 123 }); + + comp.removeNotifica(); + await comp.$nextTick(); // clear components + + // THEN + expect(notificaServiceStub.delete.called).toBeTruthy(); + + // THEN + await comp.$nextTick(); // handle component clear watch + expect(notificaServiceStub.retrieve.callCount).toEqual(1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/notifica/notifica.component.ts b/src/main/webapp/app/entities/notifica/notifica.component.ts new file mode 100644 index 0000000..b287269 --- /dev/null +++ b/src/main/webapp/app/entities/notifica/notifica.component.ts @@ -0,0 +1,137 @@ +import { type Ref, defineComponent, inject, onMounted, ref, watch } from 'vue'; +import { useI18n } from 'vue-i18n'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import { type INotifica } from '@/shared/model/notifica.model'; + +import NotificaService from './notifica.service'; + +export default defineComponent({ + name: 'Notifica', + setup() { + const { t: t$ } = useI18n(); + const dateFormat = useDateFormat(); + const notificaService = inject('notificaService', () => new NotificaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const itemsPerPage = ref(20); + const queryCount: Ref = ref(null); + const page: Ref = ref(1); + const propOrder = ref('id'); + const reverse = ref(false); + const totalItems = ref(0); + + const notificas: Ref = ref([]); + + const isFetching = ref(false); + + const clear = () => { + page.value = 1; + }; + + const sort = (): Array => { + const result = [`${propOrder.value},${reverse.value ? 'desc' : 'asc'}`]; + if (propOrder.value !== 'id') { + result.push('id'); + } + return result; + }; + + const retrieveNotificas = async () => { + isFetching.value = true; + try { + const paginationQuery = { + page: page.value - 1, + size: itemsPerPage.value, + sort: sort(), + }; + const res = await notificaService().retrieve(paginationQuery); + totalItems.value = Number(res.headers['x-total-count']); + queryCount.value = totalItems.value; + notificas.value = res.data; + } catch (err) { + alertService.showHttpError(err.response); + } finally { + isFetching.value = false; + } + }; + + const handleSyncList = () => { + retrieveNotificas(); + }; + + onMounted(async () => { + await retrieveNotificas(); + }); + + const removeId: Ref = ref(null); + const removeEntity = ref(null); + const prepareRemove = (instance: INotifica) => { + removeId.value = instance.id; + removeEntity.value.show(); + }; + const closeDialog = () => { + removeEntity.value.hide(); + }; + const removeNotifica = async () => { + try { + await notificaService().delete(removeId.value); + const message = t$('smartbookingApp.notifica.deleted', { param: removeId.value }).toString(); + alertService.showInfo(message, { variant: 'danger' }); + removeId.value = null; + retrieveNotificas(); + closeDialog(); + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + const changeOrder = (newOrder: string) => { + if (propOrder.value === newOrder) { + reverse.value = !reverse.value; + } else { + reverse.value = false; + } + propOrder.value = newOrder; + }; + + // Whenever order changes, reset the pagination + watch([propOrder, reverse], async () => { + if (page.value === 1) { + // first page, retrieve new data + await retrieveNotificas(); + } else { + // reset the pagination + clear(); + } + }); + + // Whenever page changes, switch to the new page. + watch(page, async () => { + await retrieveNotificas(); + }); + + return { + notificas, + handleSyncList, + isFetching, + retrieveNotificas, + clear, + ...dateFormat, + removeId, + removeEntity, + prepareRemove, + closeDialog, + removeNotifica, + itemsPerPage, + queryCount, + page, + propOrder, + reverse, + totalItems, + changeOrder, + t$, + }; + }, +}); diff --git a/src/main/webapp/app/entities/notifica/notifica.service.spec.ts b/src/main/webapp/app/entities/notifica/notifica.service.spec.ts new file mode 100644 index 0000000..b4a1bed --- /dev/null +++ b/src/main/webapp/app/entities/notifica/notifica.service.spec.ts @@ -0,0 +1,197 @@ +import axios from 'axios'; +import dayjs from 'dayjs'; +import sinon from 'sinon'; + +import { DATE_TIME_FORMAT } from '@/shared/composables/date-format'; +import { Notifica } from '@/shared/model/notifica.model'; + +import NotificaService from './notifica.service'; + +const error = { + response: { + status: null, + data: { + type: null, + }, + }, +}; + +const axiosStub = { + get: sinon.stub(axios, 'get'), + post: sinon.stub(axios, 'post'), + put: sinon.stub(axios, 'put'), + patch: sinon.stub(axios, 'patch'), + delete: sinon.stub(axios, 'delete'), +}; + +describe('Service Tests', () => { + describe('Notifica Service', () => { + let service: NotificaService; + let elemDefault; + let currentDate: Date; + + beforeEach(() => { + service = new NotificaService(); + currentDate = new Date(); + elemDefault = new Notifica(123, 'EMAIL', 'RICHIESTA_CREATA', 'AAAAAAA', false, currentDate, 'AAAAAAA', currentDate); + }); + + describe('Service methods', () => { + it('should find an element', async () => { + const returnedFromService = { + inviataAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + createdAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + axiosStub.get.resolves({ data: returnedFromService }); + + return service.find(123).then(res => { + expect(res).toMatchObject(elemDefault); + }); + }); + + it('should not find an element', async () => { + axiosStub.get.rejects(error); + return service + .find(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should create a Notifica', async () => { + const returnedFromService = { + id: 123, + inviataAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + createdAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + const expected = { inviataAt: currentDate, createdAt: currentDate, ...returnedFromService }; + + axiosStub.post.resolves({ data: returnedFromService }); + return service.create({}).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not create a Notifica', async () => { + axiosStub.post.rejects(error); + + return service + .create({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should update a Notifica', async () => { + const returnedFromService = { + tipoCanale: 'BBBBBB', + tipoEvento: 'BBBBBB', + messaggio: 'BBBBBB', + inviata: true, + inviataAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + errore: 'BBBBBB', + createdAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + + const expected = { inviataAt: currentDate, createdAt: currentDate, ...returnedFromService }; + axiosStub.put.resolves({ data: returnedFromService }); + + return service.update(expected).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not update a Notifica', async () => { + axiosStub.put.rejects(error); + + return service + .update({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should partial update a Notifica', async () => { + const patchObject = { + tipoEvento: 'BBBBBB', + messaggio: 'BBBBBB', + inviataAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + errore: 'BBBBBB', + ...new Notifica(), + }; + const returnedFromService = Object.assign(patchObject, elemDefault); + + const expected = { inviataAt: currentDate, createdAt: currentDate, ...returnedFromService }; + axiosStub.patch.resolves({ data: returnedFromService }); + + return service.partialUpdate(patchObject).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not partial update a Notifica', async () => { + axiosStub.patch.rejects(error); + + return service + .partialUpdate({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should return a list of Notifica', async () => { + const returnedFromService = { + tipoCanale: 'BBBBBB', + tipoEvento: 'BBBBBB', + messaggio: 'BBBBBB', + inviata: true, + inviataAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + errore: 'BBBBBB', + createdAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + const expected = { inviataAt: currentDate, createdAt: currentDate, ...returnedFromService }; + axiosStub.get.resolves([returnedFromService]); + return service.retrieve({ sort: {}, page: 0, size: 10 }).then(res => { + expect(res).toContainEqual(expected); + }); + }); + + it('should not return a list of Notifica', async () => { + axiosStub.get.rejects(error); + + return service + .retrieve() + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should delete a Notifica', async () => { + axiosStub.delete.resolves({ ok: true }); + return service.delete(123).then(res => { + expect(res.ok).toBeTruthy(); + }); + }); + + it('should not delete a Notifica', async () => { + axiosStub.delete.rejects(error); + + return service + .delete(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/notifica/notifica.service.ts b/src/main/webapp/app/entities/notifica/notifica.service.ts new file mode 100644 index 0000000..969c391 --- /dev/null +++ b/src/main/webapp/app/entities/notifica/notifica.service.ts @@ -0,0 +1,86 @@ +import axios from 'axios'; + +import { type INotifica } from '@/shared/model/notifica.model'; +import buildPaginationQueryOpts from '@/shared/sort/sorts'; + +const baseApiUrl = 'api/notificas'; + +export default class NotificaService { + find(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + retrieve(paginationQuery?: any): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}?${buildPaginationQueryOpts(paginationQuery)}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + delete(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .delete(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + create(entity: INotifica): Promise { + return new Promise((resolve, reject) => { + axios + .post(baseApiUrl, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + update(entity: INotifica): Promise { + return new Promise((resolve, reject) => { + axios + .put(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + partialUpdate(entity: INotifica): Promise { + return new Promise((resolve, reject) => { + axios + .patch(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } +} diff --git a/src/main/webapp/app/entities/notifica/notifica.vue b/src/main/webapp/app/entities/notifica/notifica.vue new file mode 100644 index 0000000..0552ebc --- /dev/null +++ b/src/main/webapp/app/entities/notifica/notifica.vue @@ -0,0 +1,156 @@ + + + diff --git a/src/main/webapp/app/entities/prenotazione/prenotazione-details.component.spec.ts b/src/main/webapp/app/entities/prenotazione/prenotazione-details.component.spec.ts new file mode 100644 index 0000000..b46a6e1 --- /dev/null +++ b/src/main/webapp/app/entities/prenotazione/prenotazione-details.component.spec.ts @@ -0,0 +1,91 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import PrenotazioneDetails from './prenotazione-details.vue'; +import PrenotazioneService from './prenotazione.service'; + +type PrenotazioneDetailsComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const prenotazioneSample = { id: 123 }; + +describe('Component Tests', () => { + let alertService: AlertService; + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('Prenotazione Management Detail Component', () => { + let prenotazioneServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + route = {}; + prenotazioneServiceStub = sinon.createStubInstance(PrenotazioneService); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'router-link': true, + }, + provide: { + alertService, + prenotazioneService: () => prenotazioneServiceStub, + }, + }; + }); + + describe('Navigate to details', () => { + it('Should call load all on init', async () => { + // GIVEN + prenotazioneServiceStub.find.resolves(prenotazioneSample); + route = { + params: { + prenotazioneId: `${123}`, + }, + }; + const wrapper = shallowMount(PrenotazioneDetails, { global: mountOptions }); + const comp = wrapper.vm; + // WHEN + await comp.$nextTick(); + + // THEN + expect(comp.prenotazione).toMatchObject(prenotazioneSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + prenotazioneServiceStub.find.resolves(prenotazioneSample); + const wrapper = shallowMount(PrenotazioneDetails, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/prenotazione/prenotazione-details.component.ts b/src/main/webapp/app/entities/prenotazione/prenotazione-details.component.ts new file mode 100644 index 0000000..57bbb83 --- /dev/null +++ b/src/main/webapp/app/entities/prenotazione/prenotazione-details.component.ts @@ -0,0 +1,46 @@ +import { type Ref, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import { type IPrenotazione } from '@/shared/model/prenotazione.model'; + +import PrenotazioneService from './prenotazione.service'; + +export default defineComponent({ + name: 'PrenotazioneDetails', + setup() { + const dateFormat = useDateFormat(); + const prenotazioneService = inject('prenotazioneService', () => new PrenotazioneService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + const prenotazione: Ref = ref({}); + + const retrievePrenotazione = async prenotazioneId => { + try { + const res = await prenotazioneService().find(prenotazioneId); + prenotazione.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.prenotazioneId) { + retrievePrenotazione(route.params.prenotazioneId); + } + + return { + ...dateFormat, + alertService, + prenotazione, + + previousState, + t$: useI18n().t, + }; + }, +}); diff --git a/src/main/webapp/app/entities/prenotazione/prenotazione-details.vue b/src/main/webapp/app/entities/prenotazione/prenotazione-details.vue new file mode 100644 index 0000000..6affbee --- /dev/null +++ b/src/main/webapp/app/entities/prenotazione/prenotazione-details.vue @@ -0,0 +1,94 @@ + + + diff --git a/src/main/webapp/app/entities/prenotazione/prenotazione-update.component.spec.ts b/src/main/webapp/app/entities/prenotazione/prenotazione-update.component.spec.ts new file mode 100644 index 0000000..3436e78 --- /dev/null +++ b/src/main/webapp/app/entities/prenotazione/prenotazione-update.component.spec.ts @@ -0,0 +1,171 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import dayjs from 'dayjs'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import ConfermaService from '@/entities/conferma/conferma.service'; +import StrutturaService from '@/entities/struttura/struttura.service'; +import UtenteAppService from '@/entities/utente-app/utente-app.service'; +import AlertService from '@/shared/alert/alert.service'; +import { DATE_TIME_LONG_FORMAT } from '@/shared/composables/date-format'; + +import PrenotazioneUpdate from './prenotazione-update.vue'; +import PrenotazioneService from './prenotazione.service'; + +type PrenotazioneUpdateComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const prenotazioneSample = { id: 123 }; + +describe('Component Tests', () => { + let mountOptions: MountingOptions['global']; + let alertService: AlertService; + + describe('Prenotazione Management Update Component', () => { + let comp: PrenotazioneUpdateComponentType; + let prenotazioneServiceStub: SinonStubbedInstance; + + beforeEach(() => { + route = {}; + prenotazioneServiceStub = sinon.createStubInstance(PrenotazioneService); + prenotazioneServiceStub.retrieve.onFirstCall().resolves(Promise.resolve([])); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'b-input-group': true, + 'b-input-group-prepend': true, + 'b-form-datepicker': true, + 'b-form-input': true, + }, + provide: { + alertService, + prenotazioneService: () => prenotazioneServiceStub, + confermaService: () => + sinon.createStubInstance(ConfermaService, { + retrieve: sinon.stub().resolves({}), + } as any), + utenteAppService: () => + sinon.createStubInstance(UtenteAppService, { + retrieve: sinon.stub().resolves({}), + } as any), + strutturaService: () => + sinon.createStubInstance(StrutturaService, { + retrieve: sinon.stub().resolves({}), + } as any), + }, + }; + }); + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('load', () => { + beforeEach(() => { + const wrapper = shallowMount(PrenotazioneUpdate, { global: mountOptions }); + comp = wrapper.vm; + }); + it('Should convert date from string', () => { + // GIVEN + const date = new Date('2019-10-15T11:42:02Z'); + + // WHEN + const convertedDate = comp.convertDateTimeFromServer(date); + + // THEN + expect(convertedDate).toEqual(dayjs(date).format(DATE_TIME_LONG_FORMAT)); + }); + + it('Should not convert date if date is not present', () => { + expect(comp.convertDateTimeFromServer(null)).toBeNull(); + }); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', async () => { + // GIVEN + const wrapper = shallowMount(PrenotazioneUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.prenotazione = prenotazioneSample; + prenotazioneServiceStub.update.resolves(prenotazioneSample); + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(prenotazioneServiceStub.update.calledWith(prenotazioneSample)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + + it('Should call create service on save for new entity', async () => { + // GIVEN + const entity = {}; + prenotazioneServiceStub.create.resolves(entity); + const wrapper = shallowMount(PrenotazioneUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.prenotazione = entity; + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(prenotazioneServiceStub.create.calledWith(entity)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + }); + + describe('Before route enter', () => { + it('Should retrieve data', async () => { + // GIVEN + prenotazioneServiceStub.find.resolves(prenotazioneSample); + prenotazioneServiceStub.retrieve.resolves([prenotazioneSample]); + + // WHEN + route = { + params: { + prenotazioneId: `${prenotazioneSample.id}`, + }, + }; + const wrapper = shallowMount(PrenotazioneUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(comp.prenotazione).toMatchObject(prenotazioneSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + prenotazioneServiceStub.find.resolves(prenotazioneSample); + const wrapper = shallowMount(PrenotazioneUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/prenotazione/prenotazione-update.component.ts b/src/main/webapp/app/entities/prenotazione/prenotazione-update.component.ts new file mode 100644 index 0000000..3e5f0f4 --- /dev/null +++ b/src/main/webapp/app/entities/prenotazione/prenotazione-update.component.ts @@ -0,0 +1,146 @@ +import { type Ref, computed, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useVuelidate } from '@vuelidate/core'; + +import ConfermaService from '@/entities/conferma/conferma.service'; +import StrutturaService from '@/entities/struttura/struttura.service'; +import UtenteAppService from '@/entities/utente-app/utente-app.service'; +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat, useValidation } from '@/shared/composables'; +import { type IConferma } from '@/shared/model/conferma.model'; +import { StatoPrenotazione } from '@/shared/model/enumerations/stato-prenotazione.model'; +import { type IPrenotazione, Prenotazione } from '@/shared/model/prenotazione.model'; +import { type IStruttura } from '@/shared/model/struttura.model'; +import { type IUtenteApp } from '@/shared/model/utente-app.model'; + +import PrenotazioneService from './prenotazione.service'; + +export default defineComponent({ + name: 'PrenotazioneUpdate', + setup() { + const prenotazioneService = inject('prenotazioneService', () => new PrenotazioneService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const prenotazione: Ref = ref(new Prenotazione()); + + const confermaService = inject('confermaService', () => new ConfermaService()); + + const confermas: Ref = ref([]); + + const utenteAppService = inject('utenteAppService', () => new UtenteAppService()); + + const utenteApps: Ref = ref([]); + + const strutturaService = inject('strutturaService', () => new StrutturaService()); + + const strutturas: Ref = ref([]); + const statoPrenotazioneValues: Ref = ref(Object.keys(StatoPrenotazione)); + const isSaving = ref(false); + const currentLanguage = inject('currentLanguage', () => computed(() => navigator.language ?? 'it'), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + + const retrievePrenotazione = async prenotazioneId => { + try { + const res = await prenotazioneService().find(prenotazioneId); + res.oraInizio = new Date(res.oraInizio); + res.oraFine = new Date(res.oraFine); + prenotazione.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.prenotazioneId) { + retrievePrenotazione(route.params.prenotazioneId); + } + + const initRelationships = () => { + confermaService() + .retrieve() + .then(res => { + confermas.value = res.data; + }); + utenteAppService() + .retrieve() + .then(res => { + utenteApps.value = res.data; + }); + strutturaService() + .retrieve() + .then(res => { + strutturas.value = res.data; + }); + }; + + initRelationships(); + + const { t: t$ } = useI18n(); + const validations = useValidation(); + const validationRules = { + oraInizio: {}, + oraFine: {}, + stato: {}, + motivoEvento: {}, + numeroPartecipanti: {}, + noteUtente: {}, + conferma: {}, + utente: {}, + struttura: {}, + }; + const v$ = useVuelidate(validationRules, prenotazione as any); + v$.value.$validate(); + + return { + prenotazioneService, + alertService, + prenotazione, + previousState, + statoPrenotazioneValues, + isSaving, + currentLanguage, + confermas, + utenteApps, + strutturas, + v$, + ...useDateFormat({ entityRef: prenotazione }), + t$, + }; + }, + created(): void {}, + methods: { + save(): void { + this.isSaving = true; + if (this.prenotazione.id) { + this.prenotazioneService() + .update(this.prenotazione) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showInfo(this.t$('smartbookingApp.prenotazione.updated', { param: param.id })); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } else { + this.prenotazioneService() + .create(this.prenotazione) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showSuccess(this.t$('smartbookingApp.prenotazione.created', { param: param.id }).toString()); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } + }, + }, +}); diff --git a/src/main/webapp/app/entities/prenotazione/prenotazione-update.vue b/src/main/webapp/app/entities/prenotazione/prenotazione-update.vue new file mode 100644 index 0000000..95265c2 --- /dev/null +++ b/src/main/webapp/app/entities/prenotazione/prenotazione-update.vue @@ -0,0 +1,159 @@ + + diff --git a/src/main/webapp/app/entities/prenotazione/prenotazione.component.spec.ts b/src/main/webapp/app/entities/prenotazione/prenotazione.component.spec.ts new file mode 100644 index 0000000..b831748 --- /dev/null +++ b/src/main/webapp/app/entities/prenotazione/prenotazione.component.spec.ts @@ -0,0 +1,166 @@ +import { vitest } from 'vitest'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import PrenotazioneService from './prenotazione.service'; +import Prenotazione from './prenotazione.vue'; + +type PrenotazioneComponentType = InstanceType; + +const bModalStub = { + render: () => {}, + methods: { + hide: () => {}, + show: () => {}, + }, +}; + +describe('Component Tests', () => { + let alertService: AlertService; + + describe('Prenotazione Management Component', () => { + let prenotazioneServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + prenotazioneServiceStub = sinon.createStubInstance(PrenotazioneService); + prenotazioneServiceStub.retrieve.resolves({ headers: {} }); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + jhiItemCount: true, + bPagination: true, + bModal: bModalStub as any, + 'font-awesome-icon': true, + 'b-badge': true, + 'jhi-sort-indicator': true, + 'b-button': true, + 'router-link': true, + }, + directives: { + 'b-modal': {}, + }, + provide: { + alertService, + prenotazioneService: () => prenotazioneServiceStub, + }, + }; + }); + + describe('Mount', () => { + it('Should call load all on init', async () => { + // GIVEN + prenotazioneServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + const wrapper = shallowMount(Prenotazione, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(prenotazioneServiceStub.retrieve.calledOnce).toBeTruthy(); + expect(comp.prenotaziones[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for an id', async () => { + // WHEN + const wrapper = shallowMount(Prenotazione, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(prenotazioneServiceStub.retrieve.lastCall.firstArg).toMatchObject({ + sort: ['id,asc'], + }); + }); + }); + describe('Handles', () => { + let comp: PrenotazioneComponentType; + + beforeEach(async () => { + const wrapper = shallowMount(Prenotazione, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + prenotazioneServiceStub.retrieve.reset(); + prenotazioneServiceStub.retrieve.resolves({ headers: {}, data: [] }); + }); + + it('should load a page', async () => { + // GIVEN + prenotazioneServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + comp.page = 2; + await comp.$nextTick(); + + // THEN + expect(prenotazioneServiceStub.retrieve.called).toBeTruthy(); + expect(comp.prenotaziones[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should not load a page if the page is the same as the previous page', () => { + // WHEN + comp.page = 1; + + // THEN + expect(prenotazioneServiceStub.retrieve.called).toBeFalsy(); + }); + + it('should re-initialize the page', async () => { + // GIVEN + comp.page = 2; + await comp.$nextTick(); + prenotazioneServiceStub.retrieve.reset(); + prenotazioneServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + comp.clear(); + await comp.$nextTick(); + + // THEN + expect(comp.page).toEqual(1); + expect(prenotazioneServiceStub.retrieve.callCount).toEqual(1); + expect(comp.prenotaziones[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for a non-id attribute', async () => { + // WHEN + comp.propOrder = 'name'; + await comp.$nextTick(); + + // THEN + expect(prenotazioneServiceStub.retrieve.lastCall.firstArg).toMatchObject({ + sort: ['name,asc', 'id'], + }); + }); + + it('Should call delete service on confirmDelete', async () => { + // GIVEN + prenotazioneServiceStub.delete.resolves({}); + + // WHEN + comp.prepareRemove({ id: 123 }); + + comp.removePrenotazione(); + await comp.$nextTick(); // clear components + + // THEN + expect(prenotazioneServiceStub.delete.called).toBeTruthy(); + + // THEN + await comp.$nextTick(); // handle component clear watch + expect(prenotazioneServiceStub.retrieve.callCount).toEqual(1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/prenotazione/prenotazione.component.ts b/src/main/webapp/app/entities/prenotazione/prenotazione.component.ts new file mode 100644 index 0000000..f08c9cb --- /dev/null +++ b/src/main/webapp/app/entities/prenotazione/prenotazione.component.ts @@ -0,0 +1,137 @@ +import { type Ref, defineComponent, inject, onMounted, ref, watch } from 'vue'; +import { useI18n } from 'vue-i18n'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import { type IPrenotazione } from '@/shared/model/prenotazione.model'; + +import PrenotazioneService from './prenotazione.service'; + +export default defineComponent({ + name: 'Prenotazione', + setup() { + const { t: t$ } = useI18n(); + const dateFormat = useDateFormat(); + const prenotazioneService = inject('prenotazioneService', () => new PrenotazioneService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const itemsPerPage = ref(20); + const queryCount: Ref = ref(null); + const page: Ref = ref(1); + const propOrder = ref('id'); + const reverse = ref(false); + const totalItems = ref(0); + + const prenotaziones: Ref = ref([]); + + const isFetching = ref(false); + + const clear = () => { + page.value = 1; + }; + + const sort = (): Array => { + const result = [`${propOrder.value},${reverse.value ? 'desc' : 'asc'}`]; + if (propOrder.value !== 'id') { + result.push('id'); + } + return result; + }; + + const retrievePrenotaziones = async () => { + isFetching.value = true; + try { + const paginationQuery = { + page: page.value - 1, + size: itemsPerPage.value, + sort: sort(), + }; + const res = await prenotazioneService().retrieve(paginationQuery); + totalItems.value = Number(res.headers['x-total-count']); + queryCount.value = totalItems.value; + prenotaziones.value = res.data; + } catch (err) { + alertService.showHttpError(err.response); + } finally { + isFetching.value = false; + } + }; + + const handleSyncList = () => { + retrievePrenotaziones(); + }; + + onMounted(async () => { + await retrievePrenotaziones(); + }); + + const removeId: Ref = ref(null); + const removeEntity = ref(null); + const prepareRemove = (instance: IPrenotazione) => { + removeId.value = instance.id; + removeEntity.value.show(); + }; + const closeDialog = () => { + removeEntity.value.hide(); + }; + const removePrenotazione = async () => { + try { + await prenotazioneService().delete(removeId.value); + const message = t$('smartbookingApp.prenotazione.deleted', { param: removeId.value }).toString(); + alertService.showInfo(message, { variant: 'danger' }); + removeId.value = null; + retrievePrenotaziones(); + closeDialog(); + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + const changeOrder = (newOrder: string) => { + if (propOrder.value === newOrder) { + reverse.value = !reverse.value; + } else { + reverse.value = false; + } + propOrder.value = newOrder; + }; + + // Whenever order changes, reset the pagination + watch([propOrder, reverse], async () => { + if (page.value === 1) { + // first page, retrieve new data + await retrievePrenotaziones(); + } else { + // reset the pagination + clear(); + } + }); + + // Whenever page changes, switch to the new page. + watch(page, async () => { + await retrievePrenotaziones(); + }); + + return { + prenotaziones, + handleSyncList, + isFetching, + retrievePrenotaziones, + clear, + ...dateFormat, + removeId, + removeEntity, + prepareRemove, + closeDialog, + removePrenotazione, + itemsPerPage, + queryCount, + page, + propOrder, + reverse, + totalItems, + changeOrder, + t$, + }; + }, +}); diff --git a/src/main/webapp/app/entities/prenotazione/prenotazione.service.spec.ts b/src/main/webapp/app/entities/prenotazione/prenotazione.service.spec.ts new file mode 100644 index 0000000..8914695 --- /dev/null +++ b/src/main/webapp/app/entities/prenotazione/prenotazione.service.spec.ts @@ -0,0 +1,195 @@ +import axios from 'axios'; +import dayjs from 'dayjs'; +import sinon from 'sinon'; + +import { DATE_TIME_FORMAT } from '@/shared/composables/date-format'; +import { Prenotazione } from '@/shared/model/prenotazione.model'; + +import PrenotazioneService from './prenotazione.service'; + +const error = { + response: { + status: null, + data: { + type: null, + }, + }, +}; + +const axiosStub = { + get: sinon.stub(axios, 'get'), + post: sinon.stub(axios, 'post'), + put: sinon.stub(axios, 'put'), + patch: sinon.stub(axios, 'patch'), + delete: sinon.stub(axios, 'delete'), +}; + +describe('Service Tests', () => { + describe('Prenotazione Service', () => { + let service: PrenotazioneService; + let elemDefault; + let currentDate: Date; + + beforeEach(() => { + service = new PrenotazioneService(); + currentDate = new Date(); + elemDefault = new Prenotazione(123, currentDate, currentDate, 'RICHIESTA', 'AAAAAAA', 0, 'AAAAAAA'); + }); + + describe('Service methods', () => { + it('should find an element', async () => { + const returnedFromService = { + oraInizio: dayjs(currentDate).format(DATE_TIME_FORMAT), + oraFine: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + axiosStub.get.resolves({ data: returnedFromService }); + + return service.find(123).then(res => { + expect(res).toMatchObject(elemDefault); + }); + }); + + it('should not find an element', async () => { + axiosStub.get.rejects(error); + return service + .find(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should create a Prenotazione', async () => { + const returnedFromService = { + id: 123, + oraInizio: dayjs(currentDate).format(DATE_TIME_FORMAT), + oraFine: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + const expected = { oraInizio: currentDate, oraFine: currentDate, ...returnedFromService }; + + axiosStub.post.resolves({ data: returnedFromService }); + return service.create({}).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not create a Prenotazione', async () => { + axiosStub.post.rejects(error); + + return service + .create({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should update a Prenotazione', async () => { + const returnedFromService = { + oraInizio: dayjs(currentDate).format(DATE_TIME_FORMAT), + oraFine: dayjs(currentDate).format(DATE_TIME_FORMAT), + stato: 'BBBBBB', + motivoEvento: 'BBBBBB', + numeroPartecipanti: 1, + noteUtente: 'BBBBBB', + ...elemDefault, + }; + + const expected = { oraInizio: currentDate, oraFine: currentDate, ...returnedFromService }; + axiosStub.put.resolves({ data: returnedFromService }); + + return service.update(expected).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not update a Prenotazione', async () => { + axiosStub.put.rejects(error); + + return service + .update({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should partial update a Prenotazione', async () => { + const patchObject = { + oraInizio: dayjs(currentDate).format(DATE_TIME_FORMAT), + oraFine: dayjs(currentDate).format(DATE_TIME_FORMAT), + motivoEvento: 'BBBBBB', + noteUtente: 'BBBBBB', + ...new Prenotazione(), + }; + const returnedFromService = Object.assign(patchObject, elemDefault); + + const expected = { oraInizio: currentDate, oraFine: currentDate, ...returnedFromService }; + axiosStub.patch.resolves({ data: returnedFromService }); + + return service.partialUpdate(patchObject).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not partial update a Prenotazione', async () => { + axiosStub.patch.rejects(error); + + return service + .partialUpdate({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should return a list of Prenotazione', async () => { + const returnedFromService = { + oraInizio: dayjs(currentDate).format(DATE_TIME_FORMAT), + oraFine: dayjs(currentDate).format(DATE_TIME_FORMAT), + stato: 'BBBBBB', + motivoEvento: 'BBBBBB', + numeroPartecipanti: 1, + noteUtente: 'BBBBBB', + ...elemDefault, + }; + const expected = { oraInizio: currentDate, oraFine: currentDate, ...returnedFromService }; + axiosStub.get.resolves([returnedFromService]); + return service.retrieve({ sort: {}, page: 0, size: 10 }).then(res => { + expect(res).toContainEqual(expected); + }); + }); + + it('should not return a list of Prenotazione', async () => { + axiosStub.get.rejects(error); + + return service + .retrieve() + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should delete a Prenotazione', async () => { + axiosStub.delete.resolves({ ok: true }); + return service.delete(123).then(res => { + expect(res.ok).toBeTruthy(); + }); + }); + + it('should not delete a Prenotazione', async () => { + axiosStub.delete.rejects(error); + + return service + .delete(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/prenotazione/prenotazione.service.ts b/src/main/webapp/app/entities/prenotazione/prenotazione.service.ts new file mode 100644 index 0000000..4aaf91b --- /dev/null +++ b/src/main/webapp/app/entities/prenotazione/prenotazione.service.ts @@ -0,0 +1,86 @@ +import axios from 'axios'; + +import { type IPrenotazione } from '@/shared/model/prenotazione.model'; +import buildPaginationQueryOpts from '@/shared/sort/sorts'; + +const baseApiUrl = 'api/prenotaziones'; + +export default class PrenotazioneService { + find(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + retrieve(paginationQuery?: any): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}?${buildPaginationQueryOpts(paginationQuery)}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + delete(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .delete(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + create(entity: IPrenotazione): Promise { + return new Promise((resolve, reject) => { + axios + .post(baseApiUrl, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + update(entity: IPrenotazione): Promise { + return new Promise((resolve, reject) => { + axios + .put(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + partialUpdate(entity: IPrenotazione): Promise { + return new Promise((resolve, reject) => { + axios + .patch(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } +} diff --git a/src/main/webapp/app/entities/prenotazione/prenotazione.vue b/src/main/webapp/app/entities/prenotazione/prenotazione.vue new file mode 100644 index 0000000..966438d --- /dev/null +++ b/src/main/webapp/app/entities/prenotazione/prenotazione.vue @@ -0,0 +1,177 @@ + + + diff --git a/src/main/webapp/app/entities/struttura/struttura-details.component.spec.ts b/src/main/webapp/app/entities/struttura/struttura-details.component.spec.ts new file mode 100644 index 0000000..72e2d6c --- /dev/null +++ b/src/main/webapp/app/entities/struttura/struttura-details.component.spec.ts @@ -0,0 +1,91 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import StrutturaDetails from './struttura-details.vue'; +import StrutturaService from './struttura.service'; + +type StrutturaDetailsComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const strutturaSample = { id: 123 }; + +describe('Component Tests', () => { + let alertService: AlertService; + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('Struttura Management Detail Component', () => { + let strutturaServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + route = {}; + strutturaServiceStub = sinon.createStubInstance(StrutturaService); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'router-link': true, + }, + provide: { + alertService, + strutturaService: () => strutturaServiceStub, + }, + }; + }); + + describe('Navigate to details', () => { + it('Should call load all on init', async () => { + // GIVEN + strutturaServiceStub.find.resolves(strutturaSample); + route = { + params: { + strutturaId: `${123}`, + }, + }; + const wrapper = shallowMount(StrutturaDetails, { global: mountOptions }); + const comp = wrapper.vm; + // WHEN + await comp.$nextTick(); + + // THEN + expect(comp.struttura).toMatchObject(strutturaSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + strutturaServiceStub.find.resolves(strutturaSample); + const wrapper = shallowMount(StrutturaDetails, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/struttura/struttura-details.component.ts b/src/main/webapp/app/entities/struttura/struttura-details.component.ts new file mode 100644 index 0000000..8350f22 --- /dev/null +++ b/src/main/webapp/app/entities/struttura/struttura-details.component.ts @@ -0,0 +1,46 @@ +import { type Ref, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import { type IStruttura } from '@/shared/model/struttura.model'; + +import StrutturaService from './struttura.service'; + +export default defineComponent({ + name: 'StrutturaDetails', + setup() { + const dateFormat = useDateFormat(); + const strutturaService = inject('strutturaService', () => new StrutturaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + const struttura: Ref = ref({}); + + const retrieveStruttura = async strutturaId => { + try { + const res = await strutturaService().find(strutturaId); + struttura.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.strutturaId) { + retrieveStruttura(route.params.strutturaId); + } + + return { + ...dateFormat, + alertService, + struttura, + + previousState, + t$: useI18n().t, + }; + }, +}); diff --git a/src/main/webapp/app/entities/struttura/struttura-details.vue b/src/main/webapp/app/entities/struttura/struttura-details.vue new file mode 100644 index 0000000..1626222 --- /dev/null +++ b/src/main/webapp/app/entities/struttura/struttura-details.vue @@ -0,0 +1,76 @@ + + + diff --git a/src/main/webapp/app/entities/struttura/struttura-update.component.spec.ts b/src/main/webapp/app/entities/struttura/struttura-update.component.spec.ts new file mode 100644 index 0000000..7918146 --- /dev/null +++ b/src/main/webapp/app/entities/struttura/struttura-update.component.spec.ts @@ -0,0 +1,156 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import dayjs from 'dayjs'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; +import { DATE_TIME_LONG_FORMAT } from '@/shared/composables/date-format'; + +import StrutturaUpdate from './struttura-update.vue'; +import StrutturaService from './struttura.service'; + +type StrutturaUpdateComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const strutturaSample = { id: 123 }; + +describe('Component Tests', () => { + let mountOptions: MountingOptions['global']; + let alertService: AlertService; + + describe('Struttura Management Update Component', () => { + let comp: StrutturaUpdateComponentType; + let strutturaServiceStub: SinonStubbedInstance; + + beforeEach(() => { + route = {}; + strutturaServiceStub = sinon.createStubInstance(StrutturaService); + strutturaServiceStub.retrieve.onFirstCall().resolves(Promise.resolve([])); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'b-input-group': true, + 'b-input-group-prepend': true, + 'b-form-datepicker': true, + 'b-form-input': true, + }, + provide: { + alertService, + strutturaService: () => strutturaServiceStub, + }, + }; + }); + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('load', () => { + beforeEach(() => { + const wrapper = shallowMount(StrutturaUpdate, { global: mountOptions }); + comp = wrapper.vm; + }); + it('Should convert date from string', () => { + // GIVEN + const date = new Date('2019-10-15T11:42:02Z'); + + // WHEN + const convertedDate = comp.convertDateTimeFromServer(date); + + // THEN + expect(convertedDate).toEqual(dayjs(date).format(DATE_TIME_LONG_FORMAT)); + }); + + it('Should not convert date if date is not present', () => { + expect(comp.convertDateTimeFromServer(null)).toBeNull(); + }); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', async () => { + // GIVEN + const wrapper = shallowMount(StrutturaUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.struttura = strutturaSample; + strutturaServiceStub.update.resolves(strutturaSample); + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(strutturaServiceStub.update.calledWith(strutturaSample)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + + it('Should call create service on save for new entity', async () => { + // GIVEN + const entity = {}; + strutturaServiceStub.create.resolves(entity); + const wrapper = shallowMount(StrutturaUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.struttura = entity; + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(strutturaServiceStub.create.calledWith(entity)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + }); + + describe('Before route enter', () => { + it('Should retrieve data', async () => { + // GIVEN + strutturaServiceStub.find.resolves(strutturaSample); + strutturaServiceStub.retrieve.resolves([strutturaSample]); + + // WHEN + route = { + params: { + strutturaId: `${strutturaSample.id}`, + }, + }; + const wrapper = shallowMount(StrutturaUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(comp.struttura).toMatchObject(strutturaSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + strutturaServiceStub.find.resolves(strutturaSample); + const wrapper = shallowMount(StrutturaUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/struttura/struttura-update.component.ts b/src/main/webapp/app/entities/struttura/struttura-update.component.ts new file mode 100644 index 0000000..8ed8939 --- /dev/null +++ b/src/main/webapp/app/entities/struttura/struttura-update.component.ts @@ -0,0 +1,107 @@ +import { type Ref, computed, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useVuelidate } from '@vuelidate/core'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat, useValidation } from '@/shared/composables'; +import { type IStruttura, Struttura } from '@/shared/model/struttura.model'; + +import StrutturaService from './struttura.service'; + +export default defineComponent({ + name: 'StrutturaUpdate', + setup() { + const strutturaService = inject('strutturaService', () => new StrutturaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const struttura: Ref = ref(new Struttura()); + const isSaving = ref(false); + const currentLanguage = inject('currentLanguage', () => computed(() => navigator.language ?? 'it'), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + + const retrieveStruttura = async strutturaId => { + try { + const res = await strutturaService().find(strutturaId); + res.createdAt = new Date(res.createdAt); + res.updatedAt = new Date(res.updatedAt); + struttura.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.strutturaId) { + retrieveStruttura(route.params.strutturaId); + } + + const initRelationships = () => {}; + + initRelationships(); + + const { t: t$ } = useI18n(); + const validations = useValidation(); + const validationRules = { + nome: {}, + descrizione: {}, + indirizzo: {}, + capienzaMax: {}, + attiva: {}, + fotoUrl: {}, + createdAt: {}, + updatedAt: {}, + disponibilitas: {}, + moduliLiberatories: {}, + }; + const v$ = useVuelidate(validationRules, struttura as any); + v$.value.$validate(); + + return { + strutturaService, + alertService, + struttura, + previousState, + isSaving, + currentLanguage, + v$, + ...useDateFormat({ entityRef: struttura }), + t$, + }; + }, + created(): void {}, + methods: { + save(): void { + this.isSaving = true; + if (this.struttura.id) { + this.strutturaService() + .update(this.struttura) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showInfo(this.t$('smartbookingApp.struttura.updated', { param: param.id })); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } else { + this.strutturaService() + .create(this.struttura) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showSuccess(this.t$('smartbookingApp.struttura.created', { param: param.id }).toString()); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } + }, + }, +}); diff --git a/src/main/webapp/app/entities/struttura/struttura-update.vue b/src/main/webapp/app/entities/struttura/struttura-update.vue new file mode 100644 index 0000000..569ca2c --- /dev/null +++ b/src/main/webapp/app/entities/struttura/struttura-update.vue @@ -0,0 +1,134 @@ + + diff --git a/src/main/webapp/app/entities/struttura/struttura.component.spec.ts b/src/main/webapp/app/entities/struttura/struttura.component.spec.ts new file mode 100644 index 0000000..a3df8bf --- /dev/null +++ b/src/main/webapp/app/entities/struttura/struttura.component.spec.ts @@ -0,0 +1,166 @@ +import { vitest } from 'vitest'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import StrutturaService from './struttura.service'; +import Struttura from './struttura.vue'; + +type StrutturaComponentType = InstanceType; + +const bModalStub = { + render: () => {}, + methods: { + hide: () => {}, + show: () => {}, + }, +}; + +describe('Component Tests', () => { + let alertService: AlertService; + + describe('Struttura Management Component', () => { + let strutturaServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + strutturaServiceStub = sinon.createStubInstance(StrutturaService); + strutturaServiceStub.retrieve.resolves({ headers: {} }); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + jhiItemCount: true, + bPagination: true, + bModal: bModalStub as any, + 'font-awesome-icon': true, + 'b-badge': true, + 'jhi-sort-indicator': true, + 'b-button': true, + 'router-link': true, + }, + directives: { + 'b-modal': {}, + }, + provide: { + alertService, + strutturaService: () => strutturaServiceStub, + }, + }; + }); + + describe('Mount', () => { + it('Should call load all on init', async () => { + // GIVEN + strutturaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + const wrapper = shallowMount(Struttura, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(strutturaServiceStub.retrieve.calledOnce).toBeTruthy(); + expect(comp.strutturas[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for an id', async () => { + // WHEN + const wrapper = shallowMount(Struttura, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(strutturaServiceStub.retrieve.lastCall.firstArg).toMatchObject({ + sort: ['id,asc'], + }); + }); + }); + describe('Handles', () => { + let comp: StrutturaComponentType; + + beforeEach(async () => { + const wrapper = shallowMount(Struttura, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + strutturaServiceStub.retrieve.reset(); + strutturaServiceStub.retrieve.resolves({ headers: {}, data: [] }); + }); + + it('should load a page', async () => { + // GIVEN + strutturaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + comp.page = 2; + await comp.$nextTick(); + + // THEN + expect(strutturaServiceStub.retrieve.called).toBeTruthy(); + expect(comp.strutturas[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should not load a page if the page is the same as the previous page', () => { + // WHEN + comp.page = 1; + + // THEN + expect(strutturaServiceStub.retrieve.called).toBeFalsy(); + }); + + it('should re-initialize the page', async () => { + // GIVEN + comp.page = 2; + await comp.$nextTick(); + strutturaServiceStub.retrieve.reset(); + strutturaServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + comp.clear(); + await comp.$nextTick(); + + // THEN + expect(comp.page).toEqual(1); + expect(strutturaServiceStub.retrieve.callCount).toEqual(1); + expect(comp.strutturas[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for a non-id attribute', async () => { + // WHEN + comp.propOrder = 'name'; + await comp.$nextTick(); + + // THEN + expect(strutturaServiceStub.retrieve.lastCall.firstArg).toMatchObject({ + sort: ['name,asc', 'id'], + }); + }); + + it('Should call delete service on confirmDelete', async () => { + // GIVEN + strutturaServiceStub.delete.resolves({}); + + // WHEN + comp.prepareRemove({ id: 123 }); + + comp.removeStruttura(); + await comp.$nextTick(); // clear components + + // THEN + expect(strutturaServiceStub.delete.called).toBeTruthy(); + + // THEN + await comp.$nextTick(); // handle component clear watch + expect(strutturaServiceStub.retrieve.callCount).toEqual(1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/struttura/struttura.component.ts b/src/main/webapp/app/entities/struttura/struttura.component.ts new file mode 100644 index 0000000..e102862 --- /dev/null +++ b/src/main/webapp/app/entities/struttura/struttura.component.ts @@ -0,0 +1,137 @@ +import { type Ref, defineComponent, inject, onMounted, ref, watch } from 'vue'; +import { useI18n } from 'vue-i18n'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useDateFormat } from '@/shared/composables'; +import { type IStruttura } from '@/shared/model/struttura.model'; + +import StrutturaService from './struttura.service'; + +export default defineComponent({ + name: 'Struttura', + setup() { + const { t: t$ } = useI18n(); + const dateFormat = useDateFormat(); + const strutturaService = inject('strutturaService', () => new StrutturaService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const itemsPerPage = ref(20); + const queryCount: Ref = ref(null); + const page: Ref = ref(1); + const propOrder = ref('id'); + const reverse = ref(false); + const totalItems = ref(0); + + const strutturas: Ref = ref([]); + + const isFetching = ref(false); + + const clear = () => { + page.value = 1; + }; + + const sort = (): Array => { + const result = [`${propOrder.value},${reverse.value ? 'desc' : 'asc'}`]; + if (propOrder.value !== 'id') { + result.push('id'); + } + return result; + }; + + const retrieveStrutturas = async () => { + isFetching.value = true; + try { + const paginationQuery = { + page: page.value - 1, + size: itemsPerPage.value, + sort: sort(), + }; + const res = await strutturaService().retrieve(paginationQuery); + totalItems.value = Number(res.headers['x-total-count']); + queryCount.value = totalItems.value; + strutturas.value = res.data; + } catch (err) { + alertService.showHttpError(err.response); + } finally { + isFetching.value = false; + } + }; + + const handleSyncList = () => { + retrieveStrutturas(); + }; + + onMounted(async () => { + await retrieveStrutturas(); + }); + + const removeId: Ref = ref(null); + const removeEntity = ref(null); + const prepareRemove = (instance: IStruttura) => { + removeId.value = instance.id; + removeEntity.value.show(); + }; + const closeDialog = () => { + removeEntity.value.hide(); + }; + const removeStruttura = async () => { + try { + await strutturaService().delete(removeId.value); + const message = t$('smartbookingApp.struttura.deleted', { param: removeId.value }).toString(); + alertService.showInfo(message, { variant: 'danger' }); + removeId.value = null; + retrieveStrutturas(); + closeDialog(); + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + const changeOrder = (newOrder: string) => { + if (propOrder.value === newOrder) { + reverse.value = !reverse.value; + } else { + reverse.value = false; + } + propOrder.value = newOrder; + }; + + // Whenever order changes, reset the pagination + watch([propOrder, reverse], async () => { + if (page.value === 1) { + // first page, retrieve new data + await retrieveStrutturas(); + } else { + // reset the pagination + clear(); + } + }); + + // Whenever page changes, switch to the new page. + watch(page, async () => { + await retrieveStrutturas(); + }); + + return { + strutturas, + handleSyncList, + isFetching, + retrieveStrutturas, + clear, + ...dateFormat, + removeId, + removeEntity, + prepareRemove, + closeDialog, + removeStruttura, + itemsPerPage, + queryCount, + page, + propOrder, + reverse, + totalItems, + changeOrder, + t$, + }; + }, +}); diff --git a/src/main/webapp/app/entities/struttura/struttura.service.spec.ts b/src/main/webapp/app/entities/struttura/struttura.service.spec.ts new file mode 100644 index 0000000..7b112b4 --- /dev/null +++ b/src/main/webapp/app/entities/struttura/struttura.service.spec.ts @@ -0,0 +1,193 @@ +import axios from 'axios'; +import dayjs from 'dayjs'; +import sinon from 'sinon'; + +import { DATE_TIME_FORMAT } from '@/shared/composables/date-format'; +import { Struttura } from '@/shared/model/struttura.model'; + +import StrutturaService from './struttura.service'; + +const error = { + response: { + status: null, + data: { + type: null, + }, + }, +}; + +const axiosStub = { + get: sinon.stub(axios, 'get'), + post: sinon.stub(axios, 'post'), + put: sinon.stub(axios, 'put'), + patch: sinon.stub(axios, 'patch'), + delete: sinon.stub(axios, 'delete'), +}; + +describe('Service Tests', () => { + describe('Struttura Service', () => { + let service: StrutturaService; + let elemDefault; + let currentDate: Date; + + beforeEach(() => { + service = new StrutturaService(); + currentDate = new Date(); + elemDefault = new Struttura(123, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 0, false, 'AAAAAAA', currentDate, currentDate); + }); + + describe('Service methods', () => { + it('should find an element', async () => { + const returnedFromService = { + createdAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + updatedAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + axiosStub.get.resolves({ data: returnedFromService }); + + return service.find(123).then(res => { + expect(res).toMatchObject(elemDefault); + }); + }); + + it('should not find an element', async () => { + axiosStub.get.rejects(error); + return service + .find(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should create a Struttura', async () => { + const returnedFromService = { + id: 123, + createdAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + updatedAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + const expected = { createdAt: currentDate, updatedAt: currentDate, ...returnedFromService }; + + axiosStub.post.resolves({ data: returnedFromService }); + return service.create({}).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not create a Struttura', async () => { + axiosStub.post.rejects(error); + + return service + .create({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should update a Struttura', async () => { + const returnedFromService = { + nome: 'BBBBBB', + descrizione: 'BBBBBB', + indirizzo: 'BBBBBB', + capienzaMax: 1, + attiva: true, + fotoUrl: 'BBBBBB', + createdAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + updatedAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + + const expected = { createdAt: currentDate, updatedAt: currentDate, ...returnedFromService }; + axiosStub.put.resolves({ data: returnedFromService }); + + return service.update(expected).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not update a Struttura', async () => { + axiosStub.put.rejects(error); + + return service + .update({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should partial update a Struttura', async () => { + const patchObject = { nome: 'BBBBBB', indirizzo: 'BBBBBB', attiva: true, fotoUrl: 'BBBBBB', ...new Struttura() }; + const returnedFromService = Object.assign(patchObject, elemDefault); + + const expected = { createdAt: currentDate, updatedAt: currentDate, ...returnedFromService }; + axiosStub.patch.resolves({ data: returnedFromService }); + + return service.partialUpdate(patchObject).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not partial update a Struttura', async () => { + axiosStub.patch.rejects(error); + + return service + .partialUpdate({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should return a list of Struttura', async () => { + const returnedFromService = { + nome: 'BBBBBB', + descrizione: 'BBBBBB', + indirizzo: 'BBBBBB', + capienzaMax: 1, + attiva: true, + fotoUrl: 'BBBBBB', + createdAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + updatedAt: dayjs(currentDate).format(DATE_TIME_FORMAT), + ...elemDefault, + }; + const expected = { createdAt: currentDate, updatedAt: currentDate, ...returnedFromService }; + axiosStub.get.resolves([returnedFromService]); + return service.retrieve({ sort: {}, page: 0, size: 10 }).then(res => { + expect(res).toContainEqual(expected); + }); + }); + + it('should not return a list of Struttura', async () => { + axiosStub.get.rejects(error); + + return service + .retrieve() + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should delete a Struttura', async () => { + axiosStub.delete.resolves({ ok: true }); + return service.delete(123).then(res => { + expect(res.ok).toBeTruthy(); + }); + }); + + it('should not delete a Struttura', async () => { + axiosStub.delete.rejects(error); + + return service + .delete(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/struttura/struttura.service.ts b/src/main/webapp/app/entities/struttura/struttura.service.ts new file mode 100644 index 0000000..d107dba --- /dev/null +++ b/src/main/webapp/app/entities/struttura/struttura.service.ts @@ -0,0 +1,86 @@ +import axios from 'axios'; + +import { type IStruttura } from '@/shared/model/struttura.model'; +import buildPaginationQueryOpts from '@/shared/sort/sorts'; + +const baseApiUrl = 'api/strutturas'; + +export default class StrutturaService { + find(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + retrieve(paginationQuery?: any): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}?${buildPaginationQueryOpts(paginationQuery)}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + delete(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .delete(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + create(entity: IStruttura): Promise { + return new Promise((resolve, reject) => { + axios + .post(baseApiUrl, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + update(entity: IStruttura): Promise { + return new Promise((resolve, reject) => { + axios + .put(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + partialUpdate(entity: IStruttura): Promise { + return new Promise((resolve, reject) => { + axios + .patch(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } +} diff --git a/src/main/webapp/app/entities/struttura/struttura.vue b/src/main/webapp/app/entities/struttura/struttura.vue new file mode 100644 index 0000000..3458527 --- /dev/null +++ b/src/main/webapp/app/entities/struttura/struttura.vue @@ -0,0 +1,150 @@ + + + diff --git a/src/main/webapp/app/entities/utente-app/utente-app-details.component.spec.ts b/src/main/webapp/app/entities/utente-app/utente-app-details.component.spec.ts new file mode 100644 index 0000000..d337f79 --- /dev/null +++ b/src/main/webapp/app/entities/utente-app/utente-app-details.component.spec.ts @@ -0,0 +1,91 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import UtenteAppDetails from './utente-app-details.vue'; +import UtenteAppService from './utente-app.service'; + +type UtenteAppDetailsComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const utenteAppSample = { id: 123 }; + +describe('Component Tests', () => { + let alertService: AlertService; + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('UtenteApp Management Detail Component', () => { + let utenteAppServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + route = {}; + utenteAppServiceStub = sinon.createStubInstance(UtenteAppService); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'router-link': true, + }, + provide: { + alertService, + utenteAppService: () => utenteAppServiceStub, + }, + }; + }); + + describe('Navigate to details', () => { + it('Should call load all on init', async () => { + // GIVEN + utenteAppServiceStub.find.resolves(utenteAppSample); + route = { + params: { + utenteAppId: `${123}`, + }, + }; + const wrapper = shallowMount(UtenteAppDetails, { global: mountOptions }); + const comp = wrapper.vm; + // WHEN + await comp.$nextTick(); + + // THEN + expect(comp.utenteApp).toMatchObject(utenteAppSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + utenteAppServiceStub.find.resolves(utenteAppSample); + const wrapper = shallowMount(UtenteAppDetails, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/utente-app/utente-app-details.component.ts b/src/main/webapp/app/entities/utente-app/utente-app-details.component.ts new file mode 100644 index 0000000..d85a5e5 --- /dev/null +++ b/src/main/webapp/app/entities/utente-app/utente-app-details.component.ts @@ -0,0 +1,43 @@ +import { type Ref, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { type IUtenteApp } from '@/shared/model/utente-app.model'; + +import UtenteAppService from './utente-app.service'; + +export default defineComponent({ + name: 'UtenteAppDetails', + setup() { + const utenteAppService = inject('utenteAppService', () => new UtenteAppService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + const utenteApp: Ref = ref({}); + + const retrieveUtenteApp = async utenteAppId => { + try { + const res = await utenteAppService().find(utenteAppId); + utenteApp.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.utenteAppId) { + retrieveUtenteApp(route.params.utenteAppId); + } + + return { + alertService, + utenteApp, + + previousState, + t$: useI18n().t, + }; + }, +}); diff --git a/src/main/webapp/app/entities/utente-app/utente-app-details.vue b/src/main/webapp/app/entities/utente-app/utente-app-details.vue new file mode 100644 index 0000000..bc5e22b --- /dev/null +++ b/src/main/webapp/app/entities/utente-app/utente-app-details.vue @@ -0,0 +1,118 @@ + + + diff --git a/src/main/webapp/app/entities/utente-app/utente-app-update.component.spec.ts b/src/main/webapp/app/entities/utente-app/utente-app-update.component.spec.ts new file mode 100644 index 0000000..6931384 --- /dev/null +++ b/src/main/webapp/app/entities/utente-app/utente-app-update.component.spec.ts @@ -0,0 +1,133 @@ +import { vitest } from 'vitest'; +import { type RouteLocation } from 'vue-router'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import UtenteAppUpdate from './utente-app-update.vue'; +import UtenteAppService from './utente-app.service'; + +type UtenteAppUpdateComponentType = InstanceType; + +let route: Partial; +const routerGoMock = vitest.fn(); + +vitest.mock('vue-router', () => ({ + useRoute: () => route, + useRouter: () => ({ go: routerGoMock }), +})); + +const utenteAppSample = { id: 123 }; + +describe('Component Tests', () => { + let mountOptions: MountingOptions['global']; + let alertService: AlertService; + + describe('UtenteApp Management Update Component', () => { + let comp: UtenteAppUpdateComponentType; + let utenteAppServiceStub: SinonStubbedInstance; + + beforeEach(() => { + route = {}; + utenteAppServiceStub = sinon.createStubInstance(UtenteAppService); + utenteAppServiceStub.retrieve.onFirstCall().resolves(Promise.resolve([])); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + 'font-awesome-icon': true, + 'b-input-group': true, + 'b-input-group-prepend': true, + 'b-form-datepicker': true, + 'b-form-input': true, + }, + provide: { + alertService, + utenteAppService: () => utenteAppServiceStub, + }, + }; + }); + + afterEach(() => { + vitest.resetAllMocks(); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', async () => { + // GIVEN + const wrapper = shallowMount(UtenteAppUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.utenteApp = utenteAppSample; + utenteAppServiceStub.update.resolves(utenteAppSample); + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(utenteAppServiceStub.update.calledWith(utenteAppSample)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + + it('Should call create service on save for new entity', async () => { + // GIVEN + const entity = {}; + utenteAppServiceStub.create.resolves(entity); + const wrapper = shallowMount(UtenteAppUpdate, { global: mountOptions }); + comp = wrapper.vm; + comp.utenteApp = entity; + + // WHEN + comp.save(); + await comp.$nextTick(); + + // THEN + expect(utenteAppServiceStub.create.calledWith(entity)).toBeTruthy(); + expect(comp.isSaving).toEqual(false); + }); + }); + + describe('Before route enter', () => { + it('Should retrieve data', async () => { + // GIVEN + utenteAppServiceStub.find.resolves(utenteAppSample); + utenteAppServiceStub.retrieve.resolves([utenteAppSample]); + + // WHEN + route = { + params: { + utenteAppId: `${utenteAppSample.id}`, + }, + }; + const wrapper = shallowMount(UtenteAppUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(comp.utenteApp).toMatchObject(utenteAppSample); + }); + }); + + describe('Previous state', () => { + it('Should go previous state', async () => { + utenteAppServiceStub.find.resolves(utenteAppSample); + const wrapper = shallowMount(UtenteAppUpdate, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + + comp.previousState(); + await comp.$nextTick(); + + expect(routerGoMock).toHaveBeenCalledWith(-1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/utente-app/utente-app-update.component.ts b/src/main/webapp/app/entities/utente-app/utente-app-update.component.ts new file mode 100644 index 0000000..e57ccac --- /dev/null +++ b/src/main/webapp/app/entities/utente-app/utente-app-update.component.ts @@ -0,0 +1,121 @@ +import { type Ref, computed, defineComponent, inject, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute, useRouter } from 'vue-router'; + +import { useVuelidate } from '@vuelidate/core'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { useValidation } from '@/shared/composables'; +import { Ruolo } from '@/shared/model/enumerations/ruolo.model'; +import { type IUtenteApp, UtenteApp } from '@/shared/model/utente-app.model'; + +import UtenteAppService from './utente-app.service'; + +export default defineComponent({ + name: 'UtenteAppUpdate', + setup() { + const utenteAppService = inject('utenteAppService', () => new UtenteAppService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const utenteApp: Ref = ref(new UtenteApp()); + const ruoloValues: Ref = ref(Object.keys(Ruolo)); + const isSaving = ref(false); + const currentLanguage = inject('currentLanguage', () => computed(() => navigator.language ?? 'it'), true); + + const route = useRoute(); + const router = useRouter(); + + const previousState = () => router.go(-1); + + const retrieveUtenteApp = async utenteAppId => { + try { + const res = await utenteAppService().find(utenteAppId); + utenteApp.value = res; + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + if (route.params?.utenteAppId) { + retrieveUtenteApp(route.params.utenteAppId); + } + + const initRelationships = () => {}; + + initRelationships(); + + const { t: t$ } = useI18n(); + const validations = useValidation(); + const validationRules = { + username: { + required: validations.required(t$('entity.validation.required').toString()), + }, + email: { + required: validations.required(t$('entity.validation.required').toString()), + }, + telefono: {}, + ruolo: { + required: validations.required(t$('entity.validation.required').toString()), + }, + attivo: { + required: validations.required(t$('entity.validation.required').toString()), + }, + nome: {}, + cognome: {}, + luogoNascita: {}, + dataNascita: {}, + residente: {}, + societa: {}, + sede: {}, + codfiscale: {}, + telefonoSoc: {}, + emailSoc: {}, + liberatories: {}, + }; + const v$ = useVuelidate(validationRules, utenteApp as any); + v$.value.$validate(); + + return { + utenteAppService, + alertService, + utenteApp, + previousState, + ruoloValues, + isSaving, + currentLanguage, + v$, + t$, + }; + }, + created(): void {}, + methods: { + save(): void { + this.isSaving = true; + if (this.utenteApp.id) { + this.utenteAppService() + .update(this.utenteApp) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showInfo(this.t$('smartbookingApp.utenteApp.updated', { param: param.id })); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } else { + this.utenteAppService() + .create(this.utenteApp) + .then(param => { + this.isSaving = false; + this.previousState(); + this.alertService.showSuccess(this.t$('smartbookingApp.utenteApp.created', { param: param.id }).toString()); + }) + .catch(error => { + this.isSaving = false; + this.alertService.showHttpError(error.response); + }); + } + }, + }, +}); diff --git a/src/main/webapp/app/entities/utente-app/utente-app-update.vue b/src/main/webapp/app/entities/utente-app/utente-app-update.vue new file mode 100644 index 0000000..23ede3d --- /dev/null +++ b/src/main/webapp/app/entities/utente-app/utente-app-update.vue @@ -0,0 +1,231 @@ + + diff --git a/src/main/webapp/app/entities/utente-app/utente-app.component.spec.ts b/src/main/webapp/app/entities/utente-app/utente-app.component.spec.ts new file mode 100644 index 0000000..a0fce81 --- /dev/null +++ b/src/main/webapp/app/entities/utente-app/utente-app.component.spec.ts @@ -0,0 +1,102 @@ +import { vitest } from 'vitest'; + +import { type MountingOptions, shallowMount } from '@vue/test-utils'; +import sinon, { type SinonStubbedInstance } from 'sinon'; + +import AlertService from '@/shared/alert/alert.service'; + +import UtenteAppService from './utente-app.service'; +import UtenteApp from './utente-app.vue'; + +type UtenteAppComponentType = InstanceType; + +const bModalStub = { + render: () => {}, + methods: { + hide: () => {}, + show: () => {}, + }, +}; + +describe('Component Tests', () => { + let alertService: AlertService; + + describe('UtenteApp Management Component', () => { + let utenteAppServiceStub: SinonStubbedInstance; + let mountOptions: MountingOptions['global']; + + beforeEach(() => { + utenteAppServiceStub = sinon.createStubInstance(UtenteAppService); + utenteAppServiceStub.retrieve.resolves({ headers: {} }); + + alertService = new AlertService({ + i18n: { t: vitest.fn() } as any, + toast: { + show: vitest.fn(), + } as any, + }); + + mountOptions = { + stubs: { + bModal: bModalStub as any, + 'font-awesome-icon': true, + 'b-badge': true, + 'b-button': true, + 'router-link': true, + }, + directives: { + 'b-modal': {}, + }, + provide: { + alertService, + utenteAppService: () => utenteAppServiceStub, + }, + }; + }); + + describe('Mount', () => { + it('Should call load all on init', async () => { + // GIVEN + utenteAppServiceStub.retrieve.resolves({ headers: {}, data: [{ id: 123 }] }); + + // WHEN + const wrapper = shallowMount(UtenteApp, { global: mountOptions }); + const comp = wrapper.vm; + await comp.$nextTick(); + + // THEN + expect(utenteAppServiceStub.retrieve.calledOnce).toBeTruthy(); + expect(comp.utenteApps[0]).toEqual(expect.objectContaining({ id: 123 })); + }); + }); + describe('Handles', () => { + let comp: UtenteAppComponentType; + + beforeEach(async () => { + const wrapper = shallowMount(UtenteApp, { global: mountOptions }); + comp = wrapper.vm; + await comp.$nextTick(); + utenteAppServiceStub.retrieve.reset(); + utenteAppServiceStub.retrieve.resolves({ headers: {}, data: [] }); + }); + + it('Should call delete service on confirmDelete', async () => { + // GIVEN + utenteAppServiceStub.delete.resolves({}); + + // WHEN + comp.prepareRemove({ id: 123 }); + + comp.removeUtenteApp(); + await comp.$nextTick(); // clear components + + // THEN + expect(utenteAppServiceStub.delete.called).toBeTruthy(); + + // THEN + await comp.$nextTick(); // handle component clear watch + expect(utenteAppServiceStub.retrieve.callCount).toEqual(1); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/utente-app/utente-app.component.ts b/src/main/webapp/app/entities/utente-app/utente-app.component.ts new file mode 100644 index 0000000..f594a92 --- /dev/null +++ b/src/main/webapp/app/entities/utente-app/utente-app.component.ts @@ -0,0 +1,78 @@ +import { type Ref, defineComponent, inject, onMounted, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; + +import { useAlertService } from '@/shared/alert/alert.service'; +import { type IUtenteApp } from '@/shared/model/utente-app.model'; + +import UtenteAppService from './utente-app.service'; + +export default defineComponent({ + name: 'UtenteApp', + setup() { + const { t: t$ } = useI18n(); + const utenteAppService = inject('utenteAppService', () => new UtenteAppService()); + const alertService = inject('alertService', () => useAlertService(), true); + + const utenteApps: Ref = ref([]); + + const isFetching = ref(false); + + const clear = () => {}; + + const retrieveUtenteApps = async () => { + isFetching.value = true; + try { + const res = await utenteAppService().retrieve(); + utenteApps.value = res.data; + } catch (err) { + alertService.showHttpError(err.response); + } finally { + isFetching.value = false; + } + }; + + const handleSyncList = () => { + retrieveUtenteApps(); + }; + + onMounted(async () => { + await retrieveUtenteApps(); + }); + + const removeId: Ref = ref(null); + const removeEntity = ref(null); + const prepareRemove = (instance: IUtenteApp) => { + removeId.value = instance.id; + removeEntity.value.show(); + }; + const closeDialog = () => { + removeEntity.value.hide(); + }; + const removeUtenteApp = async () => { + try { + await utenteAppService().delete(removeId.value); + const message = t$('smartbookingApp.utenteApp.deleted', { param: removeId.value }).toString(); + alertService.showInfo(message, { variant: 'danger' }); + removeId.value = null; + retrieveUtenteApps(); + closeDialog(); + } catch (error) { + alertService.showHttpError(error.response); + } + }; + + return { + utenteApps, + handleSyncList, + isFetching, + retrieveUtenteApps, + clear, + removeId, + removeEntity, + prepareRemove, + closeDialog, + removeUtenteApp, + t$, + }; + }, +}); diff --git a/src/main/webapp/app/entities/utente-app/utente-app.service.spec.ts b/src/main/webapp/app/entities/utente-app/utente-app.service.spec.ts new file mode 100644 index 0000000..d1eadb8 --- /dev/null +++ b/src/main/webapp/app/entities/utente-app/utente-app.service.spec.ts @@ -0,0 +1,223 @@ +import axios from 'axios'; +import sinon from 'sinon'; + +import { UtenteApp } from '@/shared/model/utente-app.model'; + +import UtenteAppService from './utente-app.service'; + +const error = { + response: { + status: null, + data: { + type: null, + }, + }, +}; + +const axiosStub = { + get: sinon.stub(axios, 'get'), + post: sinon.stub(axios, 'post'), + put: sinon.stub(axios, 'put'), + patch: sinon.stub(axios, 'patch'), + delete: sinon.stub(axios, 'delete'), +}; + +describe('Service Tests', () => { + describe('UtenteApp Service', () => { + let service: UtenteAppService; + let elemDefault; + + beforeEach(() => { + service = new UtenteAppService(); + elemDefault = new UtenteApp( + 123, + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + 'USER', + false, + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + ); + }); + + describe('Service methods', () => { + it('should find an element', async () => { + const returnedFromService = { ...elemDefault }; + axiosStub.get.resolves({ data: returnedFromService }); + + return service.find(123).then(res => { + expect(res).toMatchObject(elemDefault); + }); + }); + + it('should not find an element', async () => { + axiosStub.get.rejects(error); + return service + .find(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should create a UtenteApp', async () => { + const returnedFromService = { id: 123, ...elemDefault }; + const expected = { ...returnedFromService }; + + axiosStub.post.resolves({ data: returnedFromService }); + return service.create({}).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not create a UtenteApp', async () => { + axiosStub.post.rejects(error); + + return service + .create({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should update a UtenteApp', async () => { + const returnedFromService = { + username: 'BBBBBB', + email: 'BBBBBB', + telefono: 'BBBBBB', + ruolo: 'BBBBBB', + attivo: true, + nome: 'BBBBBB', + cognome: 'BBBBBB', + luogoNascita: 'BBBBBB', + dataNascita: 'BBBBBB', + residente: 'BBBBBB', + societa: 'BBBBBB', + sede: 'BBBBBB', + codfiscale: 'BBBBBB', + telefonoSoc: 'BBBBBB', + emailSoc: 'BBBBBB', + ...elemDefault, + }; + + const expected = { ...returnedFromService }; + axiosStub.put.resolves({ data: returnedFromService }); + + return service.update(expected).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not update a UtenteApp', async () => { + axiosStub.put.rejects(error); + + return service + .update({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should partial update a UtenteApp', async () => { + const patchObject = { + username: 'BBBBBB', + telefono: 'BBBBBB', + ruolo: 'BBBBBB', + nome: 'BBBBBB', + cognome: 'BBBBBB', + luogoNascita: 'BBBBBB', + societa: 'BBBBBB', + sede: 'BBBBBB', + codfiscale: 'BBBBBB', + emailSoc: 'BBBBBB', + ...new UtenteApp(), + }; + const returnedFromService = Object.assign(patchObject, elemDefault); + + const expected = { ...returnedFromService }; + axiosStub.patch.resolves({ data: returnedFromService }); + + return service.partialUpdate(patchObject).then(res => { + expect(res).toMatchObject(expected); + }); + }); + + it('should not partial update a UtenteApp', async () => { + axiosStub.patch.rejects(error); + + return service + .partialUpdate({}) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should return a list of UtenteApp', async () => { + const returnedFromService = { + username: 'BBBBBB', + email: 'BBBBBB', + telefono: 'BBBBBB', + ruolo: 'BBBBBB', + attivo: true, + nome: 'BBBBBB', + cognome: 'BBBBBB', + luogoNascita: 'BBBBBB', + dataNascita: 'BBBBBB', + residente: 'BBBBBB', + societa: 'BBBBBB', + sede: 'BBBBBB', + codfiscale: 'BBBBBB', + telefonoSoc: 'BBBBBB', + emailSoc: 'BBBBBB', + ...elemDefault, + }; + const expected = { ...returnedFromService }; + axiosStub.get.resolves([returnedFromService]); + return service.retrieve().then(res => { + expect(res).toContainEqual(expected); + }); + }); + + it('should not return a list of UtenteApp', async () => { + axiosStub.get.rejects(error); + + return service + .retrieve() + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + + it('should delete a UtenteApp', async () => { + axiosStub.delete.resolves({ ok: true }); + return service.delete(123).then(res => { + expect(res.ok).toBeTruthy(); + }); + }); + + it('should not delete a UtenteApp', async () => { + axiosStub.delete.rejects(error); + + return service + .delete(123) + .then() + .catch(err => { + expect(err).toMatchObject(error); + }); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/utente-app/utente-app.service.ts b/src/main/webapp/app/entities/utente-app/utente-app.service.ts new file mode 100644 index 0000000..3f990e8 --- /dev/null +++ b/src/main/webapp/app/entities/utente-app/utente-app.service.ts @@ -0,0 +1,85 @@ +import axios from 'axios'; + +import { type IUtenteApp } from '@/shared/model/utente-app.model'; + +const baseApiUrl = 'api/utente-apps'; + +export default class UtenteAppService { + find(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .get(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + retrieve(): Promise { + return new Promise((resolve, reject) => { + axios + .get(baseApiUrl) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + delete(id: number): Promise { + return new Promise((resolve, reject) => { + axios + .delete(`${baseApiUrl}/${id}`) + .then(res => { + resolve(res); + }) + .catch(err => { + reject(err); + }); + }); + } + + create(entity: IUtenteApp): Promise { + return new Promise((resolve, reject) => { + axios + .post(baseApiUrl, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + update(entity: IUtenteApp): Promise { + return new Promise((resolve, reject) => { + axios + .put(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } + + partialUpdate(entity: IUtenteApp): Promise { + return new Promise((resolve, reject) => { + axios + .patch(`${baseApiUrl}/${entity.id}`, entity) + .then(res => { + resolve(res.data); + }) + .catch(err => { + reject(err); + }); + }); + } +} diff --git a/src/main/webapp/app/entities/utente-app/utente-app.vue b/src/main/webapp/app/entities/utente-app/utente-app.vue new file mode 100644 index 0000000..f593d66 --- /dev/null +++ b/src/main/webapp/app/entities/utente-app/utente-app.vue @@ -0,0 +1,161 @@ + + + diff --git a/src/main/webapp/app/router/entities.ts b/src/main/webapp/app/router/entities.ts index 451fe99..d5ae5c3 100644 --- a/src/main/webapp/app/router/entities.ts +++ b/src/main/webapp/app/router/entities.ts @@ -1,11 +1,292 @@ +import { Authority } from '@/shared/security/authority'; const Entities = () => import('@/entities/entities.vue'); +const AuditLog = () => import('@/entities/audit-log/audit-log.vue'); +const AuditLogUpdate = () => import('@/entities/audit-log/audit-log-update.vue'); +const AuditLogDetails = () => import('@/entities/audit-log/audit-log-details.vue'); + +const Disponibilita = () => import('@/entities/disponibilita/disponibilita.vue'); +const DisponibilitaUpdate = () => import('@/entities/disponibilita/disponibilita-update.vue'); +const DisponibilitaDetails = () => import('@/entities/disponibilita/disponibilita-details.vue'); + +const Notifica = () => import('@/entities/notifica/notifica.vue'); +const NotificaUpdate = () => import('@/entities/notifica/notifica-update.vue'); +const NotificaDetails = () => import('@/entities/notifica/notifica-details.vue'); + +const Prenotazione = () => import('@/entities/prenotazione/prenotazione.vue'); +const PrenotazioneUpdate = () => import('@/entities/prenotazione/prenotazione-update.vue'); +const PrenotazioneDetails = () => import('@/entities/prenotazione/prenotazione-details.vue'); + +const Conferma = () => import('@/entities/conferma/conferma.vue'); +const ConfermaUpdate = () => import('@/entities/conferma/conferma-update.vue'); +const ConfermaDetails = () => import('@/entities/conferma/conferma-details.vue'); + +const Struttura = () => import('@/entities/struttura/struttura.vue'); +const StrutturaUpdate = () => import('@/entities/struttura/struttura-update.vue'); +const StrutturaDetails = () => import('@/entities/struttura/struttura-details.vue'); + +const UtenteApp = () => import('@/entities/utente-app/utente-app.vue'); +const UtenteAppUpdate = () => import('@/entities/utente-app/utente-app-update.vue'); +const UtenteAppDetails = () => import('@/entities/utente-app/utente-app-details.vue'); + +const Liberatoria = () => import('@/entities/liberatoria/liberatoria.vue'); +const LiberatoriaUpdate = () => import('@/entities/liberatoria/liberatoria-update.vue'); +const LiberatoriaDetails = () => import('@/entities/liberatoria/liberatoria-details.vue'); + +const ModelloLiberatoria = () => import('@/entities/modello-liberatoria/modello-liberatoria.vue'); +const ModelloLiberatoriaUpdate = () => import('@/entities/modello-liberatoria/modello-liberatoria-update.vue'); +const ModelloLiberatoriaDetails = () => import('@/entities/modello-liberatoria/modello-liberatoria-details.vue'); + +const Messaggio = () => import('@/entities/messaggio/messaggio.vue'); +const MessaggioUpdate = () => import('@/entities/messaggio/messaggio-update.vue'); +const MessaggioDetails = () => import('@/entities/messaggio/messaggio-details.vue'); + // jhipster-needle-add-entity-to-router-import - JHipster will import entities to the router here export default { path: '/', component: Entities, children: [ + { + path: 'audit-log', + name: 'AuditLog', + component: AuditLog, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'audit-log/new', + name: 'AuditLogCreate', + component: AuditLogUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'audit-log/:auditLogId/edit', + name: 'AuditLogEdit', + component: AuditLogUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'audit-log/:auditLogId/view', + name: 'AuditLogView', + component: AuditLogDetails, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'disponibilita', + name: 'Disponibilita', + component: Disponibilita, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'disponibilita/new', + name: 'DisponibilitaCreate', + component: DisponibilitaUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'disponibilita/:disponibilitaId/edit', + name: 'DisponibilitaEdit', + component: DisponibilitaUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'disponibilita/:disponibilitaId/view', + name: 'DisponibilitaView', + component: DisponibilitaDetails, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'notifica', + name: 'Notifica', + component: Notifica, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'notifica/new', + name: 'NotificaCreate', + component: NotificaUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'notifica/:notificaId/edit', + name: 'NotificaEdit', + component: NotificaUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'notifica/:notificaId/view', + name: 'NotificaView', + component: NotificaDetails, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'prenotazione', + name: 'Prenotazione', + component: Prenotazione, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'prenotazione/new', + name: 'PrenotazioneCreate', + component: PrenotazioneUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'prenotazione/:prenotazioneId/edit', + name: 'PrenotazioneEdit', + component: PrenotazioneUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'prenotazione/:prenotazioneId/view', + name: 'PrenotazioneView', + component: PrenotazioneDetails, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'conferma', + name: 'Conferma', + component: Conferma, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'conferma/new', + name: 'ConfermaCreate', + component: ConfermaUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'conferma/:confermaId/edit', + name: 'ConfermaEdit', + component: ConfermaUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'conferma/:confermaId/view', + name: 'ConfermaView', + component: ConfermaDetails, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'struttura', + name: 'Struttura', + component: Struttura, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'struttura/new', + name: 'StrutturaCreate', + component: StrutturaUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'struttura/:strutturaId/edit', + name: 'StrutturaEdit', + component: StrutturaUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'struttura/:strutturaId/view', + name: 'StrutturaView', + component: StrutturaDetails, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'utente-app', + name: 'UtenteApp', + component: UtenteApp, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'utente-app/new', + name: 'UtenteAppCreate', + component: UtenteAppUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'utente-app/:utenteAppId/edit', + name: 'UtenteAppEdit', + component: UtenteAppUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'utente-app/:utenteAppId/view', + name: 'UtenteAppView', + component: UtenteAppDetails, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'liberatoria', + name: 'Liberatoria', + component: Liberatoria, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'liberatoria/new', + name: 'LiberatoriaCreate', + component: LiberatoriaUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'liberatoria/:liberatoriaId/edit', + name: 'LiberatoriaEdit', + component: LiberatoriaUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'liberatoria/:liberatoriaId/view', + name: 'LiberatoriaView', + component: LiberatoriaDetails, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'modello-liberatoria', + name: 'ModelloLiberatoria', + component: ModelloLiberatoria, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'modello-liberatoria/new', + name: 'ModelloLiberatoriaCreate', + component: ModelloLiberatoriaUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'modello-liberatoria/:modelloLiberatoriaId/edit', + name: 'ModelloLiberatoriaEdit', + component: ModelloLiberatoriaUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'modello-liberatoria/:modelloLiberatoriaId/view', + name: 'ModelloLiberatoriaView', + component: ModelloLiberatoriaDetails, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'messaggio', + name: 'Messaggio', + component: Messaggio, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'messaggio/new', + name: 'MessaggioCreate', + component: MessaggioUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'messaggio/:messaggioId/edit', + name: 'MessaggioEdit', + component: MessaggioUpdate, + meta: { authorities: [Authority.USER] }, + }, + { + path: 'messaggio/:messaggioId/view', + name: 'MessaggioView', + component: MessaggioDetails, + meta: { authorities: [Authority.USER] }, + }, // jhipster-needle-add-entity-to-router - JHipster will add entities to the router here ], }; diff --git a/src/main/webapp/app/shared/model/audit-log.model.ts b/src/main/webapp/app/shared/model/audit-log.model.ts new file mode 100644 index 0000000..eaa2997 --- /dev/null +++ b/src/main/webapp/app/shared/model/audit-log.model.ts @@ -0,0 +1,27 @@ +import { type AzioneAudit } from '@/shared/model/enumerations/azione-audit.model'; +import { type TipoEntita } from '@/shared/model/enumerations/tipo-entita.model'; +import { type IUtenteApp } from '@/shared/model/utente-app.model'; + +export interface IAuditLog { + id?: number; + entitaTipo?: keyof typeof TipoEntita | null; + entitaId?: number | null; + azione?: keyof typeof AzioneAudit | null; + dettagli?: string | null; + ipAddress?: string | null; + createdAt?: Date | null; + utente?: IUtenteApp | null; +} + +export class AuditLog implements IAuditLog { + constructor( + public id?: number, + public entitaTipo?: keyof typeof TipoEntita | null, + public entitaId?: number | null, + public azione?: keyof typeof AzioneAudit | null, + public dettagli?: string | null, + public ipAddress?: string | null, + public createdAt?: Date | null, + public utente?: IUtenteApp | null, + ) {} +} diff --git a/src/main/webapp/app/shared/model/conferma.model.ts b/src/main/webapp/app/shared/model/conferma.model.ts new file mode 100644 index 0000000..697e508 --- /dev/null +++ b/src/main/webapp/app/shared/model/conferma.model.ts @@ -0,0 +1,18 @@ +import { type TipoConferma } from '@/shared/model/enumerations/tipo-conferma.model'; +import { type IUtenteApp } from '@/shared/model/utente-app.model'; + +export interface IConferma { + id?: number; + motivoConferma?: string | null; + tipoConferma?: keyof typeof TipoConferma | null; + confermataDa?: IUtenteApp | null; +} + +export class Conferma implements IConferma { + constructor( + public id?: number, + public motivoConferma?: string | null, + public tipoConferma?: keyof typeof TipoConferma | null, + public confermataDa?: IUtenteApp | null, + ) {} +} diff --git a/src/main/webapp/app/shared/model/disponibilita.model.ts b/src/main/webapp/app/shared/model/disponibilita.model.ts new file mode 100644 index 0000000..1b869c2 --- /dev/null +++ b/src/main/webapp/app/shared/model/disponibilita.model.ts @@ -0,0 +1,30 @@ +import { type GiornoSettimana } from '@/shared/model/enumerations/giorno-settimana.model'; +import { type TipoDisponibilita } from '@/shared/model/enumerations/tipo-disponibilita.model'; +import { type IStruttura } from '@/shared/model/struttura.model'; +export interface IDisponibilita { + id?: number; + giornoSettimana?: keyof typeof GiornoSettimana | null; + dataSpecifica?: Date | null; + oraInizio?: Date | null; + oraFine?: Date | null; + orarioInizio?: string | null; + orarioFine?: string | null; + tipo?: keyof typeof TipoDisponibilita | null; + note?: string | null; + struttura?: IStruttura | null; +} + +export class Disponibilita implements IDisponibilita { + constructor( + public id?: number, + public giornoSettimana?: keyof typeof GiornoSettimana | null, + public dataSpecifica?: Date | null, + public oraInizio?: Date | null, + public oraFine?: Date | null, + public orarioInizio?: string | null, + public orarioFine?: string | null, + public tipo?: keyof typeof TipoDisponibilita | null, + public note?: string | null, + public struttura?: IStruttura | null, + ) {} +} diff --git a/src/main/webapp/app/shared/model/enumerations/azione-audit.model.ts b/src/main/webapp/app/shared/model/enumerations/azione-audit.model.ts new file mode 100644 index 0000000..b6f1546 --- /dev/null +++ b/src/main/webapp/app/shared/model/enumerations/azione-audit.model.ts @@ -0,0 +1,11 @@ +export enum AzioneAudit { + CREATE = 'CREATE', + + UPDATE = 'UPDATE', + + DELETE = 'DELETE', + + CONFIRM = 'CONFIRM', + + REJECT = 'REJECT', +} diff --git a/src/main/webapp/app/shared/model/enumerations/giorno-settimana.model.ts b/src/main/webapp/app/shared/model/enumerations/giorno-settimana.model.ts new file mode 100644 index 0000000..bd6319b --- /dev/null +++ b/src/main/webapp/app/shared/model/enumerations/giorno-settimana.model.ts @@ -0,0 +1,15 @@ +export enum GiornoSettimana { + LUNEDI = 'LUNEDI', + + MARTEDI = 'MARTEDI', + + MERCOLEDI = 'MERCOLEDI', + + GIOVEDI = 'GIOVEDI', + + VENERDI = 'VENERDI', + + SABATO = 'SABATO', + + DOMENICA = 'DOMENICA', +} diff --git a/src/main/webapp/app/shared/model/enumerations/ruolo.model.ts b/src/main/webapp/app/shared/model/enumerations/ruolo.model.ts new file mode 100644 index 0000000..3c51c10 --- /dev/null +++ b/src/main/webapp/app/shared/model/enumerations/ruolo.model.ts @@ -0,0 +1,7 @@ +export enum Ruolo { + USER = 'USER', + + INCARICATO = 'INCARICATO', + + ADMIN = 'ADMIN', +} diff --git a/src/main/webapp/app/shared/model/enumerations/stato-prenotazione.model.ts b/src/main/webapp/app/shared/model/enumerations/stato-prenotazione.model.ts new file mode 100644 index 0000000..0bb3b4b --- /dev/null +++ b/src/main/webapp/app/shared/model/enumerations/stato-prenotazione.model.ts @@ -0,0 +1,9 @@ +export enum StatoPrenotazione { + RICHIESTA = 'RICHIESTA', + + CONFERMATA = 'CONFERMATA', + + RIFIUTATA = 'RIFIUTATA', + + ANNULLATA = 'ANNULLATA', +} diff --git a/src/main/webapp/app/shared/model/enumerations/tipo-canale-notifica.model.ts b/src/main/webapp/app/shared/model/enumerations/tipo-canale-notifica.model.ts new file mode 100644 index 0000000..67d948b --- /dev/null +++ b/src/main/webapp/app/shared/model/enumerations/tipo-canale-notifica.model.ts @@ -0,0 +1,7 @@ +export enum TipoCanaleNotifica { + EMAIL = 'EMAIL', + + WHATSAPP = 'WHATSAPP', + + SISTEMA = 'SISTEMA', +} diff --git a/src/main/webapp/app/shared/model/enumerations/tipo-conferma.model.ts b/src/main/webapp/app/shared/model/enumerations/tipo-conferma.model.ts new file mode 100644 index 0000000..8edc9a2 --- /dev/null +++ b/src/main/webapp/app/shared/model/enumerations/tipo-conferma.model.ts @@ -0,0 +1,5 @@ +export enum TipoConferma { + CONFERMATA = 'CONFERMATA', + + RIFIUTATA = 'RIFIUTATA', +} diff --git a/src/main/webapp/app/shared/model/enumerations/tipo-disponibilita.model.ts b/src/main/webapp/app/shared/model/enumerations/tipo-disponibilita.model.ts new file mode 100644 index 0000000..03567e2 --- /dev/null +++ b/src/main/webapp/app/shared/model/enumerations/tipo-disponibilita.model.ts @@ -0,0 +1,5 @@ +export enum TipoDisponibilita { + DISPONIBILE = 'DISPONIBILE', + + CHIUSURA = 'CHIUSURA', +} diff --git a/src/main/webapp/app/shared/model/enumerations/tipo-entita.model.ts b/src/main/webapp/app/shared/model/enumerations/tipo-entita.model.ts new file mode 100644 index 0000000..6724e51 --- /dev/null +++ b/src/main/webapp/app/shared/model/enumerations/tipo-entita.model.ts @@ -0,0 +1,5 @@ +export enum TipoEntita { + PRENOTAZIONE = 'PRENOTAZIONE', + + CONFERMA = 'CONFERMA', +} diff --git a/src/main/webapp/app/shared/model/enumerations/tipo-evento-notifica.model.ts b/src/main/webapp/app/shared/model/enumerations/tipo-evento-notifica.model.ts new file mode 100644 index 0000000..6b00a6d --- /dev/null +++ b/src/main/webapp/app/shared/model/enumerations/tipo-evento-notifica.model.ts @@ -0,0 +1,11 @@ +export enum TipoEventoNotifica { + RICHIESTA_CREATA = 'RICHIESTA_CREATA', + + PRENOTAZIONE_CONFERMATA = 'PRENOTAZIONE_CONFERMATA', + + PRENOTAZIONE_RIFIUTATA = 'PRENOTAZIONE_RIFIUTATA', + + REMINDER = 'REMINDER', + + ANNULLAMENTO = 'ANNULLAMENTO', +} diff --git a/src/main/webapp/app/shared/model/liberatoria.model.ts b/src/main/webapp/app/shared/model/liberatoria.model.ts new file mode 100644 index 0000000..263f84c --- /dev/null +++ b/src/main/webapp/app/shared/model/liberatoria.model.ts @@ -0,0 +1,18 @@ +import { type IModelloLiberatoria } from '@/shared/model/modello-liberatoria.model'; +import { type IUtenteApp } from '@/shared/model/utente-app.model'; + +export interface ILiberatoria { + id?: number; + accettata?: Date | null; + utente?: IUtenteApp | null; + modelloLiberatoria?: IModelloLiberatoria | null; +} + +export class Liberatoria implements ILiberatoria { + constructor( + public id?: number, + public accettata?: Date | null, + public utente?: IUtenteApp | null, + public modelloLiberatoria?: IModelloLiberatoria | null, + ) {} +} diff --git a/src/main/webapp/app/shared/model/messaggio.model.ts b/src/main/webapp/app/shared/model/messaggio.model.ts new file mode 100644 index 0000000..ec91d73 --- /dev/null +++ b/src/main/webapp/app/shared/model/messaggio.model.ts @@ -0,0 +1,19 @@ +import { type IUtenteApp } from '@/shared/model/utente-app.model'; + +export interface IMessaggio { + id?: number; + spedito?: Date | null; + testo?: string | null; + letto?: Date | null; + utente?: IUtenteApp | null; +} + +export class Messaggio implements IMessaggio { + constructor( + public id?: number, + public spedito?: Date | null, + public testo?: string | null, + public letto?: Date | null, + public utente?: IUtenteApp | null, + ) {} +} diff --git a/src/main/webapp/app/shared/model/modello-liberatoria.model.ts b/src/main/webapp/app/shared/model/modello-liberatoria.model.ts new file mode 100644 index 0000000..25ffa65 --- /dev/null +++ b/src/main/webapp/app/shared/model/modello-liberatoria.model.ts @@ -0,0 +1,25 @@ +import { type IStruttura } from '@/shared/model/struttura.model'; + +export interface IModelloLiberatoria { + id?: number; + nome?: string | null; + testo?: string | null; + documentoContentType?: string | null; + documento?: string | null; + validoDal?: Date | null; + validoAl?: Date | null; + struttura?: IStruttura | null; +} + +export class ModelloLiberatoria implements IModelloLiberatoria { + constructor( + public id?: number, + public nome?: string | null, + public testo?: string | null, + public documentoContentType?: string | null, + public documento?: string | null, + public validoDal?: Date | null, + public validoAl?: Date | null, + public struttura?: IStruttura | null, + ) {} +} diff --git a/src/main/webapp/app/shared/model/notifica.model.ts b/src/main/webapp/app/shared/model/notifica.model.ts new file mode 100644 index 0000000..de66557 --- /dev/null +++ b/src/main/webapp/app/shared/model/notifica.model.ts @@ -0,0 +1,30 @@ +import { type IConferma } from '@/shared/model/conferma.model'; +import { type TipoCanaleNotifica } from '@/shared/model/enumerations/tipo-canale-notifica.model'; +import { type TipoEventoNotifica } from '@/shared/model/enumerations/tipo-evento-notifica.model'; +export interface INotifica { + id?: number; + tipoCanale?: keyof typeof TipoCanaleNotifica | null; + tipoEvento?: keyof typeof TipoEventoNotifica | null; + messaggio?: string | null; + inviata?: boolean | null; + inviataAt?: Date | null; + errore?: string | null; + createdAt?: Date | null; + conferma?: IConferma | null; +} + +export class Notifica implements INotifica { + constructor( + public id?: number, + public tipoCanale?: keyof typeof TipoCanaleNotifica | null, + public tipoEvento?: keyof typeof TipoEventoNotifica | null, + public messaggio?: string | null, + public inviata?: boolean | null, + public inviataAt?: Date | null, + public errore?: string | null, + public createdAt?: Date | null, + public conferma?: IConferma | null, + ) { + this.inviata = this.inviata ?? false; + } +} diff --git a/src/main/webapp/app/shared/model/prenotazione.model.ts b/src/main/webapp/app/shared/model/prenotazione.model.ts new file mode 100644 index 0000000..cdc718b --- /dev/null +++ b/src/main/webapp/app/shared/model/prenotazione.model.ts @@ -0,0 +1,32 @@ +import { type IConferma } from '@/shared/model/conferma.model'; +import { type StatoPrenotazione } from '@/shared/model/enumerations/stato-prenotazione.model'; +import { type IStruttura } from '@/shared/model/struttura.model'; +import { type IUtenteApp } from '@/shared/model/utente-app.model'; + +export interface IPrenotazione { + id?: number; + oraInizio?: Date | null; + oraFine?: Date | null; + stato?: keyof typeof StatoPrenotazione | null; + motivoEvento?: string | null; + numeroPartecipanti?: number | null; + noteUtente?: string | null; + conferma?: IConferma | null; + utente?: IUtenteApp | null; + struttura?: IStruttura | null; +} + +export class Prenotazione implements IPrenotazione { + constructor( + public id?: number, + public oraInizio?: Date | null, + public oraFine?: Date | null, + public stato?: keyof typeof StatoPrenotazione | null, + public motivoEvento?: string | null, + public numeroPartecipanti?: number | null, + public noteUtente?: string | null, + public conferma?: IConferma | null, + public utente?: IUtenteApp | null, + public struttura?: IStruttura | null, + ) {} +} diff --git a/src/main/webapp/app/shared/model/struttura.model.ts b/src/main/webapp/app/shared/model/struttura.model.ts new file mode 100644 index 0000000..90171ee --- /dev/null +++ b/src/main/webapp/app/shared/model/struttura.model.ts @@ -0,0 +1,27 @@ +export interface IStruttura { + id?: number; + nome?: string | null; + descrizione?: string | null; + indirizzo?: string | null; + capienzaMax?: number | null; + attiva?: boolean | null; + fotoUrl?: string | null; + createdAt?: Date | null; + updatedAt?: Date | null; +} + +export class Struttura implements IStruttura { + constructor( + public id?: number, + public nome?: string | null, + public descrizione?: string | null, + public indirizzo?: string | null, + public capienzaMax?: number | null, + public attiva?: boolean | null, + public fotoUrl?: string | null, + public createdAt?: Date | null, + public updatedAt?: Date | null, + ) { + this.attiva = this.attiva ?? false; + } +} diff --git a/src/main/webapp/app/shared/model/utente-app.model.ts b/src/main/webapp/app/shared/model/utente-app.model.ts new file mode 100644 index 0000000..665a48f --- /dev/null +++ b/src/main/webapp/app/shared/model/utente-app.model.ts @@ -0,0 +1,42 @@ +import { type Ruolo } from '@/shared/model/enumerations/ruolo.model'; +export interface IUtenteApp { + id?: number; + username?: string; + email?: string; + telefono?: string | null; + ruolo?: keyof typeof Ruolo; + attivo?: boolean; + nome?: string | null; + cognome?: string | null; + luogoNascita?: string | null; + dataNascita?: string | null; + residente?: string | null; + societa?: string | null; + sede?: string | null; + codfiscale?: string | null; + telefonoSoc?: string | null; + emailSoc?: string | null; +} + +export class UtenteApp implements IUtenteApp { + constructor( + public id?: number, + public username?: string, + public email?: string, + public telefono?: string | null, + public ruolo?: keyof typeof Ruolo, + public attivo?: boolean, + public nome?: string | null, + public cognome?: string | null, + public luogoNascita?: string | null, + public dataNascita?: string | null, + public residente?: string | null, + public societa?: string | null, + public sede?: string | null, + public codfiscale?: string | null, + public telefonoSoc?: string | null, + public emailSoc?: string | null, + ) { + this.attivo = this.attivo ?? false; + } +} diff --git a/src/main/webapp/i18n/it/auditLog.json b/src/main/webapp/i18n/it/auditLog.json new file mode 100644 index 0000000..49d7c53 --- /dev/null +++ b/src/main/webapp/i18n/it/auditLog.json @@ -0,0 +1,30 @@ +{ + "smartbookingApp": { + "auditLog": { + "home": { + "title": "AuditLogs", + "refreshListLabel": "Refresh list", + "createLabel": "Genera un nuovo Audit Log", + "createOrEditLabel": "Genera o modifica un Audit Log", + "notFound": "No Audit Logs found" + }, + "created": "È stato generato un nuovo Audit Log con identificatore { param }", + "updated": "È stato aggiornato Audit Log identificato da { param }", + "deleted": "È stato eliminato Audit Log con identificatore { param }", + "delete": { + "question": "Sei sicuro di volere eliminare Audit Log { id }?" + }, + "detail": { + "title": "Audit Log" + }, + "id": "ID", + "entitaTipo": "Entita Tipo", + "entitaId": "Entita Id", + "azione": "Azione", + "dettagli": "Dettagli", + "ipAddress": "Ip Address", + "createdAt": "Created At", + "utente": "Utente" + } + } +} diff --git a/src/main/webapp/i18n/it/azioneAudit.json b/src/main/webapp/i18n/it/azioneAudit.json new file mode 100644 index 0000000..fbd204f --- /dev/null +++ b/src/main/webapp/i18n/it/azioneAudit.json @@ -0,0 +1,12 @@ +{ + "smartbookingApp": { + "AzioneAudit": { + "null": "", + "CREATE": "CREATE", + "UPDATE": "UPDATE", + "DELETE": "DELETE", + "CONFIRM": "CONFIRM", + "REJECT": "REJECT" + } + } +} diff --git a/src/main/webapp/i18n/it/conferma.json b/src/main/webapp/i18n/it/conferma.json new file mode 100644 index 0000000..9d2c9bb --- /dev/null +++ b/src/main/webapp/i18n/it/conferma.json @@ -0,0 +1,27 @@ +{ + "smartbookingApp": { + "conferma": { + "home": { + "title": "Confermas", + "refreshListLabel": "Refresh list", + "createLabel": "Genera un nuovo Conferma", + "createOrEditLabel": "Genera o modifica un Conferma", + "notFound": "No Confermas found" + }, + "created": "È stato generato un nuovo Conferma con identificatore { param }", + "updated": "È stato aggiornato Conferma identificato da { param }", + "deleted": "È stato eliminato Conferma con identificatore { param }", + "delete": { + "question": "Sei sicuro di volere eliminare Conferma { id }?" + }, + "detail": { + "title": "Conferma" + }, + "id": "ID", + "motivoConferma": "Motivo Conferma", + "tipoConferma": "Tipo Conferma", + "confermataDa": "Confermata Da", + "prenotazione": "Prenotazione" + } + } +} diff --git a/src/main/webapp/i18n/it/disponibilita.json b/src/main/webapp/i18n/it/disponibilita.json new file mode 100644 index 0000000..1ac76fb --- /dev/null +++ b/src/main/webapp/i18n/it/disponibilita.json @@ -0,0 +1,32 @@ +{ + "smartbookingApp": { + "disponibilita": { + "home": { + "title": "Disponibilitas", + "refreshListLabel": "Refresh list", + "createLabel": "Genera un nuovo Disponibilita", + "createOrEditLabel": "Genera o modifica un Disponibilita", + "notFound": "No Disponibilitas found" + }, + "created": "È stato generato un nuovo Disponibilita con identificatore { param }", + "updated": "È stato aggiornato Disponibilita identificato da { param }", + "deleted": "È stato eliminato Disponibilita con identificatore { param }", + "delete": { + "question": "Sei sicuro di volere eliminare Disponibilita { id }?" + }, + "detail": { + "title": "Disponibilita" + }, + "id": "ID", + "giornoSettimana": "Giorno Settimana", + "dataSpecifica": "Data Specifica", + "oraInizio": "Ora Inizio", + "oraFine": "Ora Fine", + "orarioInizio": "Orario Inizio", + "orarioFine": "Orario Fine", + "tipo": "Tipo", + "note": "Note", + "struttura": "Struttura" + } + } +} diff --git a/src/main/webapp/i18n/it/giornoSettimana.json b/src/main/webapp/i18n/it/giornoSettimana.json new file mode 100644 index 0000000..291df3f --- /dev/null +++ b/src/main/webapp/i18n/it/giornoSettimana.json @@ -0,0 +1,14 @@ +{ + "smartbookingApp": { + "GiornoSettimana": { + "null": "", + "LUNEDI": "LUNEDI", + "MARTEDI": "MARTEDI", + "MERCOLEDI": "MERCOLEDI", + "GIOVEDI": "GIOVEDI", + "VENERDI": "VENERDI", + "SABATO": "SABATO", + "DOMENICA": "DOMENICA" + } + } +} diff --git a/src/main/webapp/i18n/it/global.json b/src/main/webapp/i18n/it/global.json index c158082..3295ee7 100644 --- a/src/main/webapp/i18n/it/global.json +++ b/src/main/webapp/i18n/it/global.json @@ -7,7 +7,17 @@ "jhipster-needle-menu-add-element": "JHipster will add additional menu entries here (do not translate!)", "entities": { "main": "Entità", - "jhipster-needle-menu-add-entry": "JHipster will add additional entities here (do not translate!)" + "jhipster-needle-menu-add-entry": "JHipster will add additional entities here (do not translate!)", + "auditLog": "Audit Log", + "disponibilita": "Disponibilita", + "notifica": "Notifica", + "prenotazione": "Prenotazione", + "conferma": "Conferma", + "struttura": "Struttura", + "utenteApp": "Utente App", + "liberatoria": "Liberatoria", + "modelloLiberatoria": "Modello Liberatoria", + "messaggio": "Messaggio" }, "account": { "main": "Utente", diff --git a/src/main/webapp/i18n/it/liberatoria.json b/src/main/webapp/i18n/it/liberatoria.json new file mode 100644 index 0000000..c45b78e --- /dev/null +++ b/src/main/webapp/i18n/it/liberatoria.json @@ -0,0 +1,26 @@ +{ + "smartbookingApp": { + "liberatoria": { + "home": { + "title": "Liberatorias", + "refreshListLabel": "Refresh list", + "createLabel": "Genera un nuovo Liberatoria", + "createOrEditLabel": "Genera o modifica un Liberatoria", + "notFound": "No Liberatorias found" + }, + "created": "È stato generato un nuovo Liberatoria con identificatore { param }", + "updated": "È stato aggiornato Liberatoria identificato da { param }", + "deleted": "È stato eliminato Liberatoria con identificatore { param }", + "delete": { + "question": "Sei sicuro di volere eliminare Liberatoria { id }?" + }, + "detail": { + "title": "Liberatoria" + }, + "id": "ID", + "accettata": "Accettata", + "utente": "Utente", + "modelloLiberatoria": "Modello Liberatoria" + } + } +} diff --git a/src/main/webapp/i18n/it/messaggio.json b/src/main/webapp/i18n/it/messaggio.json new file mode 100644 index 0000000..f7724d5 --- /dev/null +++ b/src/main/webapp/i18n/it/messaggio.json @@ -0,0 +1,27 @@ +{ + "smartbookingApp": { + "messaggio": { + "home": { + "title": "Messaggios", + "refreshListLabel": "Refresh list", + "createLabel": "Genera un nuovo Messaggio", + "createOrEditLabel": "Genera o modifica un Messaggio", + "notFound": "No Messaggios found" + }, + "created": "È stato generato un nuovo Messaggio con identificatore { param }", + "updated": "È stato aggiornato Messaggio identificato da { param }", + "deleted": "È stato eliminato Messaggio con identificatore { param }", + "delete": { + "question": "Sei sicuro di volere eliminare Messaggio { id }?" + }, + "detail": { + "title": "Messaggio" + }, + "id": "ID", + "spedito": "Spedito", + "testo": "Testo", + "letto": "Letto", + "utente": "Utente" + } + } +} diff --git a/src/main/webapp/i18n/it/modelloLiberatoria.json b/src/main/webapp/i18n/it/modelloLiberatoria.json new file mode 100644 index 0000000..edb5669 --- /dev/null +++ b/src/main/webapp/i18n/it/modelloLiberatoria.json @@ -0,0 +1,29 @@ +{ + "smartbookingApp": { + "modelloLiberatoria": { + "home": { + "title": "ModelloLiberatorias", + "refreshListLabel": "Refresh list", + "createLabel": "Genera un nuovo Modello Liberatoria", + "createOrEditLabel": "Genera o modifica un Modello Liberatoria", + "notFound": "No Modello Liberatorias found" + }, + "created": "È stato generato un nuovo Modello Liberatoria con identificatore { param }", + "updated": "È stato aggiornato Modello Liberatoria identificato da { param }", + "deleted": "È stato eliminato Modello Liberatoria con identificatore { param }", + "delete": { + "question": "Sei sicuro di volere eliminare Modello Liberatoria { id }?" + }, + "detail": { + "title": "Modello Liberatoria" + }, + "id": "ID", + "nome": "Nome", + "testo": "Testo", + "documento": "Documento", + "validoDal": "Valido Dal", + "validoAl": "Valido Al", + "struttura": "Struttura" + } + } +} diff --git a/src/main/webapp/i18n/it/notifica.json b/src/main/webapp/i18n/it/notifica.json new file mode 100644 index 0000000..2db6427 --- /dev/null +++ b/src/main/webapp/i18n/it/notifica.json @@ -0,0 +1,31 @@ +{ + "smartbookingApp": { + "notifica": { + "home": { + "title": "Notificas", + "refreshListLabel": "Refresh list", + "createLabel": "Genera un nuovo Notifica", + "createOrEditLabel": "Genera o modifica un Notifica", + "notFound": "No Notificas found" + }, + "created": "È stato generato un nuovo Notifica con identificatore { param }", + "updated": "È stato aggiornato Notifica identificato da { param }", + "deleted": "È stato eliminato Notifica con identificatore { param }", + "delete": { + "question": "Sei sicuro di volere eliminare Notifica { id }?" + }, + "detail": { + "title": "Notifica" + }, + "id": "ID", + "tipoCanale": "Tipo Canale", + "tipoEvento": "Tipo Evento", + "messaggio": "Messaggio", + "inviata": "Inviata", + "inviataAt": "Inviata At", + "errore": "Errore", + "createdAt": "Created At", + "conferma": "Conferma" + } + } +} diff --git a/src/main/webapp/i18n/it/prenotazione.json b/src/main/webapp/i18n/it/prenotazione.json new file mode 100644 index 0000000..cffdf07 --- /dev/null +++ b/src/main/webapp/i18n/it/prenotazione.json @@ -0,0 +1,32 @@ +{ + "smartbookingApp": { + "prenotazione": { + "home": { + "title": "Prenotaziones", + "refreshListLabel": "Refresh list", + "createLabel": "Genera un nuovo Prenotazione", + "createOrEditLabel": "Genera o modifica un Prenotazione", + "notFound": "No Prenotaziones found" + }, + "created": "È stato generato un nuovo Prenotazione con identificatore { param }", + "updated": "È stato aggiornato Prenotazione identificato da { param }", + "deleted": "È stato eliminato Prenotazione con identificatore { param }", + "delete": { + "question": "Sei sicuro di volere eliminare Prenotazione { id }?" + }, + "detail": { + "title": "Prenotazione" + }, + "id": "ID", + "oraInizio": "Ora Inizio", + "oraFine": "Ora Fine", + "stato": "Stato", + "motivoEvento": "Motivo Evento", + "numeroPartecipanti": "Numero Partecipanti", + "noteUtente": "Note Utente", + "conferma": "Conferma", + "utente": "Utente", + "struttura": "Struttura" + } + } +} diff --git a/src/main/webapp/i18n/it/ruolo.json b/src/main/webapp/i18n/it/ruolo.json new file mode 100644 index 0000000..20589f2 --- /dev/null +++ b/src/main/webapp/i18n/it/ruolo.json @@ -0,0 +1,10 @@ +{ + "smartbookingApp": { + "Ruolo": { + "null": "", + "USER": "USER", + "INCARICATO": "INCARICATO", + "ADMIN": "ADMIN" + } + } +} diff --git a/src/main/webapp/i18n/it/statoPrenotazione.json b/src/main/webapp/i18n/it/statoPrenotazione.json new file mode 100644 index 0000000..d4314ba --- /dev/null +++ b/src/main/webapp/i18n/it/statoPrenotazione.json @@ -0,0 +1,11 @@ +{ + "smartbookingApp": { + "StatoPrenotazione": { + "null": "", + "RICHIESTA": "RICHIESTA", + "CONFERMATA": "CONFERMATA", + "RIFIUTATA": "RIFIUTATA", + "ANNULLATA": "ANNULLATA" + } + } +} diff --git a/src/main/webapp/i18n/it/struttura.json b/src/main/webapp/i18n/it/struttura.json new file mode 100644 index 0000000..018fab2 --- /dev/null +++ b/src/main/webapp/i18n/it/struttura.json @@ -0,0 +1,33 @@ +{ + "smartbookingApp": { + "struttura": { + "home": { + "title": "Strutturas", + "refreshListLabel": "Refresh list", + "createLabel": "Genera un nuovo Struttura", + "createOrEditLabel": "Genera o modifica un Struttura", + "notFound": "No Strutturas found" + }, + "created": "È stato generato un nuovo Struttura con identificatore { param }", + "updated": "È stato aggiornato Struttura identificato da { param }", + "deleted": "È stato eliminato Struttura con identificatore { param }", + "delete": { + "question": "Sei sicuro di volere eliminare Struttura { id }?" + }, + "detail": { + "title": "Struttura" + }, + "id": "ID", + "nome": "Nome", + "descrizione": "Descrizione", + "indirizzo": "Indirizzo", + "capienzaMax": "Capienza Max", + "attiva": "Attiva", + "fotoUrl": "Foto Url", + "createdAt": "Created At", + "updatedAt": "Updated At", + "disponibilita": "Disponibilita", + "moduliLiberatorie": "Moduli Liberatorie" + } + } +} diff --git a/src/main/webapp/i18n/it/tipoCanaleNotifica.json b/src/main/webapp/i18n/it/tipoCanaleNotifica.json new file mode 100644 index 0000000..0f777af --- /dev/null +++ b/src/main/webapp/i18n/it/tipoCanaleNotifica.json @@ -0,0 +1,10 @@ +{ + "smartbookingApp": { + "TipoCanaleNotifica": { + "null": "", + "EMAIL": "EMAIL", + "WHATSAPP": "WHATSAPP", + "SISTEMA": "SISTEMA" + } + } +} diff --git a/src/main/webapp/i18n/it/tipoConferma.json b/src/main/webapp/i18n/it/tipoConferma.json new file mode 100644 index 0000000..eebcd2a --- /dev/null +++ b/src/main/webapp/i18n/it/tipoConferma.json @@ -0,0 +1,9 @@ +{ + "smartbookingApp": { + "TipoConferma": { + "null": "", + "CONFERMATA": "CONFERMATA", + "RIFIUTATA": "RIFIUTATA" + } + } +} diff --git a/src/main/webapp/i18n/it/tipoDisponibilita.json b/src/main/webapp/i18n/it/tipoDisponibilita.json new file mode 100644 index 0000000..3823738 --- /dev/null +++ b/src/main/webapp/i18n/it/tipoDisponibilita.json @@ -0,0 +1,9 @@ +{ + "smartbookingApp": { + "TipoDisponibilita": { + "null": "", + "DISPONIBILE": "DISPONIBILE", + "CHIUSURA": "CHIUSURA" + } + } +} diff --git a/src/main/webapp/i18n/it/tipoEntita.json b/src/main/webapp/i18n/it/tipoEntita.json new file mode 100644 index 0000000..7668aec --- /dev/null +++ b/src/main/webapp/i18n/it/tipoEntita.json @@ -0,0 +1,9 @@ +{ + "smartbookingApp": { + "TipoEntita": { + "null": "", + "PRENOTAZIONE": "PRENOTAZIONE", + "CONFERMA": "CONFERMA" + } + } +} diff --git a/src/main/webapp/i18n/it/tipoEventoNotifica.json b/src/main/webapp/i18n/it/tipoEventoNotifica.json new file mode 100644 index 0000000..22383c1 --- /dev/null +++ b/src/main/webapp/i18n/it/tipoEventoNotifica.json @@ -0,0 +1,12 @@ +{ + "smartbookingApp": { + "TipoEventoNotifica": { + "null": "", + "RICHIESTA_CREATA": "RICHIESTA_CREATA", + "PRENOTAZIONE_CONFERMATA": "PRENOTAZIONE_CONFERMATA", + "PRENOTAZIONE_RIFIUTATA": "PRENOTAZIONE_RIFIUTATA", + "REMINDER": "REMINDER", + "ANNULLAMENTO": "ANNULLAMENTO" + } + } +} diff --git a/src/main/webapp/i18n/it/utenteApp.json b/src/main/webapp/i18n/it/utenteApp.json new file mode 100644 index 0000000..f14f8cf --- /dev/null +++ b/src/main/webapp/i18n/it/utenteApp.json @@ -0,0 +1,39 @@ +{ + "smartbookingApp": { + "utenteApp": { + "home": { + "title": "UtenteApps", + "refreshListLabel": "Refresh list", + "createLabel": "Genera un nuovo Utente App", + "createOrEditLabel": "Genera o modifica un Utente App", + "notFound": "No Utente Apps found" + }, + "created": "È stato generato un nuovo Utente App con identificatore { param }", + "updated": "È stato aggiornato Utente App identificato da { param }", + "deleted": "È stato eliminato Utente App con identificatore { param }", + "delete": { + "question": "Sei sicuro di volere eliminare Utente App { id }?" + }, + "detail": { + "title": "Utente App" + }, + "id": "ID", + "username": "Username", + "email": "Email", + "telefono": "Telefono", + "ruolo": "Ruolo", + "attivo": "Attivo", + "nome": "Nome", + "cognome": "Cognome", + "luogoNascita": "Luogo Nascita", + "dataNascita": "Data Nascita", + "residente": "Residente", + "societa": "Societa", + "sede": "Sede", + "codfiscale": "Codfiscale", + "telefonoSoc": "Telefono Soc", + "emailSoc": "Email Soc", + "liberatorie": "Liberatorie" + } + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/AuditLogAsserts.java b/src/test/java/it/sw/pa/comune/artegna/domain/AuditLogAsserts.java new file mode 100644 index 0000000..30ddbc6 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/AuditLogAsserts.java @@ -0,0 +1,69 @@ +package it.sw.pa.comune.artegna.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AuditLogAsserts { + + /** + * Asserts that the entity has all properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertAuditLogAllPropertiesEquals(AuditLog expected, AuditLog actual) { + assertAuditLogAutoGeneratedPropertiesEquals(expected, actual); + assertAuditLogAllUpdatablePropertiesEquals(expected, actual); + } + + /** + * Asserts that the entity has all updatable properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertAuditLogAllUpdatablePropertiesEquals(AuditLog expected, AuditLog actual) { + assertAuditLogUpdatableFieldsEquals(expected, actual); + assertAuditLogUpdatableRelationshipsEquals(expected, actual); + } + + /** + * Asserts that the entity has all the auto generated properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertAuditLogAutoGeneratedPropertiesEquals(AuditLog expected, AuditLog actual) { + assertThat(actual) + .as("Verify AuditLog auto generated properties") + .satisfies(a -> assertThat(a.getId()).as("check id").isEqualTo(expected.getId())); + } + + /** + * Asserts that the entity has all the updatable fields set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertAuditLogUpdatableFieldsEquals(AuditLog expected, AuditLog actual) { + assertThat(actual) + .as("Verify AuditLog relevant properties") + .satisfies(a -> assertThat(a.getEntitaTipo()).as("check entitaTipo").isEqualTo(expected.getEntitaTipo())) + .satisfies(a -> assertThat(a.getEntitaId()).as("check entitaId").isEqualTo(expected.getEntitaId())) + .satisfies(a -> assertThat(a.getAzione()).as("check azione").isEqualTo(expected.getAzione())) + .satisfies(a -> assertThat(a.getDettagli()).as("check dettagli").isEqualTo(expected.getDettagli())) + .satisfies(a -> assertThat(a.getIpAddress()).as("check ipAddress").isEqualTo(expected.getIpAddress())) + .satisfies(a -> assertThat(a.getCreatedAt()).as("check createdAt").isEqualTo(expected.getCreatedAt())); + } + + /** + * Asserts that the entity has all the updatable relationships set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertAuditLogUpdatableRelationshipsEquals(AuditLog expected, AuditLog actual) { + assertThat(actual) + .as("Verify AuditLog relationships") + .satisfies(a -> assertThat(a.getUtente()).as("check utente").isEqualTo(expected.getUtente())); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/AuditLogTest.java b/src/test/java/it/sw/pa/comune/artegna/domain/AuditLogTest.java new file mode 100644 index 0000000..ea0c0bf --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/AuditLogTest.java @@ -0,0 +1,37 @@ +package it.sw.pa.comune.artegna.domain; + +import static it.sw.pa.comune.artegna.domain.AuditLogTestSamples.*; +import static it.sw.pa.comune.artegna.domain.UtenteAppTestSamples.*; +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class AuditLogTest { + + @Test + void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(AuditLog.class); + AuditLog auditLog1 = getAuditLogSample1(); + AuditLog auditLog2 = new AuditLog(); + assertThat(auditLog1).isNotEqualTo(auditLog2); + + auditLog2.setId(auditLog1.getId()); + assertThat(auditLog1).isEqualTo(auditLog2); + + auditLog2 = getAuditLogSample2(); + assertThat(auditLog1).isNotEqualTo(auditLog2); + } + + @Test + void utenteTest() { + AuditLog auditLog = getAuditLogRandomSampleGenerator(); + UtenteApp utenteAppBack = getUtenteAppRandomSampleGenerator(); + + auditLog.setUtente(utenteAppBack); + assertThat(auditLog.getUtente()).isEqualTo(utenteAppBack); + + auditLog.utente(null); + assertThat(auditLog.getUtente()).isNull(); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/AuditLogTestSamples.java b/src/test/java/it/sw/pa/comune/artegna/domain/AuditLogTestSamples.java new file mode 100644 index 0000000..3d0eab2 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/AuditLogTestSamples.java @@ -0,0 +1,27 @@ +package it.sw.pa.comune.artegna.domain; + +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicLong; + +public class AuditLogTestSamples { + + private static final Random random = new Random(); + private static final AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + public static AuditLog getAuditLogSample1() { + return new AuditLog().id(1L).entitaId(1L).dettagli("dettagli1").ipAddress("ipAddress1"); + } + + public static AuditLog getAuditLogSample2() { + return new AuditLog().id(2L).entitaId(2L).dettagli("dettagli2").ipAddress("ipAddress2"); + } + + public static AuditLog getAuditLogRandomSampleGenerator() { + return new AuditLog() + .id(longCount.incrementAndGet()) + .entitaId(longCount.incrementAndGet()) + .dettagli(UUID.randomUUID().toString()) + .ipAddress(UUID.randomUUID().toString()); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/ConfermaAsserts.java b/src/test/java/it/sw/pa/comune/artegna/domain/ConfermaAsserts.java new file mode 100644 index 0000000..d2c61f1 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/ConfermaAsserts.java @@ -0,0 +1,65 @@ +package it.sw.pa.comune.artegna.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ConfermaAsserts { + + /** + * Asserts that the entity has all properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertConfermaAllPropertiesEquals(Conferma expected, Conferma actual) { + assertConfermaAutoGeneratedPropertiesEquals(expected, actual); + assertConfermaAllUpdatablePropertiesEquals(expected, actual); + } + + /** + * Asserts that the entity has all updatable properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertConfermaAllUpdatablePropertiesEquals(Conferma expected, Conferma actual) { + assertConfermaUpdatableFieldsEquals(expected, actual); + assertConfermaUpdatableRelationshipsEquals(expected, actual); + } + + /** + * Asserts that the entity has all the auto generated properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertConfermaAutoGeneratedPropertiesEquals(Conferma expected, Conferma actual) { + assertThat(actual) + .as("Verify Conferma auto generated properties") + .satisfies(a -> assertThat(a.getId()).as("check id").isEqualTo(expected.getId())); + } + + /** + * Asserts that the entity has all the updatable fields set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertConfermaUpdatableFieldsEquals(Conferma expected, Conferma actual) { + assertThat(actual) + .as("Verify Conferma relevant properties") + .satisfies(a -> assertThat(a.getMotivoConferma()).as("check motivoConferma").isEqualTo(expected.getMotivoConferma())) + .satisfies(a -> assertThat(a.getTipoConferma()).as("check tipoConferma").isEqualTo(expected.getTipoConferma())); + } + + /** + * Asserts that the entity has all the updatable relationships set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertConfermaUpdatableRelationshipsEquals(Conferma expected, Conferma actual) { + assertThat(actual) + .as("Verify Conferma relationships") + .satisfies(a -> assertThat(a.getConfermataDa()).as("check confermataDa").isEqualTo(expected.getConfermataDa())); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/ConfermaTest.java b/src/test/java/it/sw/pa/comune/artegna/domain/ConfermaTest.java new file mode 100644 index 0000000..1e41043 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/ConfermaTest.java @@ -0,0 +1,52 @@ +package it.sw.pa.comune.artegna.domain; + +import static it.sw.pa.comune.artegna.domain.ConfermaTestSamples.*; +import static it.sw.pa.comune.artegna.domain.PrenotazioneTestSamples.*; +import static it.sw.pa.comune.artegna.domain.UtenteAppTestSamples.*; +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class ConfermaTest { + + @Test + void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Conferma.class); + Conferma conferma1 = getConfermaSample1(); + Conferma conferma2 = new Conferma(); + assertThat(conferma1).isNotEqualTo(conferma2); + + conferma2.setId(conferma1.getId()); + assertThat(conferma1).isEqualTo(conferma2); + + conferma2 = getConfermaSample2(); + assertThat(conferma1).isNotEqualTo(conferma2); + } + + @Test + void confermataDaTest() { + Conferma conferma = getConfermaRandomSampleGenerator(); + UtenteApp utenteAppBack = getUtenteAppRandomSampleGenerator(); + + conferma.setConfermataDa(utenteAppBack); + assertThat(conferma.getConfermataDa()).isEqualTo(utenteAppBack); + + conferma.confermataDa(null); + assertThat(conferma.getConfermataDa()).isNull(); + } + + @Test + void prenotazioneTest() { + Conferma conferma = getConfermaRandomSampleGenerator(); + Prenotazione prenotazioneBack = getPrenotazioneRandomSampleGenerator(); + + conferma.setPrenotazione(prenotazioneBack); + assertThat(conferma.getPrenotazione()).isEqualTo(prenotazioneBack); + assertThat(prenotazioneBack.getConferma()).isEqualTo(conferma); + + conferma.prenotazione(null); + assertThat(conferma.getPrenotazione()).isNull(); + assertThat(prenotazioneBack.getConferma()).isNull(); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/ConfermaTestSamples.java b/src/test/java/it/sw/pa/comune/artegna/domain/ConfermaTestSamples.java new file mode 100644 index 0000000..9347638 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/ConfermaTestSamples.java @@ -0,0 +1,23 @@ +package it.sw.pa.comune.artegna.domain; + +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicLong; + +public class ConfermaTestSamples { + + private static final Random random = new Random(); + private static final AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + public static Conferma getConfermaSample1() { + return new Conferma().id(1L).motivoConferma("motivoConferma1"); + } + + public static Conferma getConfermaSample2() { + return new Conferma().id(2L).motivoConferma("motivoConferma2"); + } + + public static Conferma getConfermaRandomSampleGenerator() { + return new Conferma().id(longCount.incrementAndGet()).motivoConferma(UUID.randomUUID().toString()); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/DisponibilitaAsserts.java b/src/test/java/it/sw/pa/comune/artegna/domain/DisponibilitaAsserts.java new file mode 100644 index 0000000..32cb741 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/DisponibilitaAsserts.java @@ -0,0 +1,71 @@ +package it.sw.pa.comune.artegna.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DisponibilitaAsserts { + + /** + * Asserts that the entity has all properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertDisponibilitaAllPropertiesEquals(Disponibilita expected, Disponibilita actual) { + assertDisponibilitaAutoGeneratedPropertiesEquals(expected, actual); + assertDisponibilitaAllUpdatablePropertiesEquals(expected, actual); + } + + /** + * Asserts that the entity has all updatable properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertDisponibilitaAllUpdatablePropertiesEquals(Disponibilita expected, Disponibilita actual) { + assertDisponibilitaUpdatableFieldsEquals(expected, actual); + assertDisponibilitaUpdatableRelationshipsEquals(expected, actual); + } + + /** + * Asserts that the entity has all the auto generated properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertDisponibilitaAutoGeneratedPropertiesEquals(Disponibilita expected, Disponibilita actual) { + assertThat(actual) + .as("Verify Disponibilita auto generated properties") + .satisfies(a -> assertThat(a.getId()).as("check id").isEqualTo(expected.getId())); + } + + /** + * Asserts that the entity has all the updatable fields set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertDisponibilitaUpdatableFieldsEquals(Disponibilita expected, Disponibilita actual) { + assertThat(actual) + .as("Verify Disponibilita relevant properties") + .satisfies(a -> assertThat(a.getGiornoSettimana()).as("check giornoSettimana").isEqualTo(expected.getGiornoSettimana())) + .satisfies(a -> assertThat(a.getDataSpecifica()).as("check dataSpecifica").isEqualTo(expected.getDataSpecifica())) + .satisfies(a -> assertThat(a.getOraInizio()).as("check oraInizio").isEqualTo(expected.getOraInizio())) + .satisfies(a -> assertThat(a.getOraFine()).as("check oraFine").isEqualTo(expected.getOraFine())) + .satisfies(a -> assertThat(a.getOrarioInizio()).as("check orarioInizio").isEqualTo(expected.getOrarioInizio())) + .satisfies(a -> assertThat(a.getOrarioFine()).as("check orarioFine").isEqualTo(expected.getOrarioFine())) + .satisfies(a -> assertThat(a.getTipo()).as("check tipo").isEqualTo(expected.getTipo())) + .satisfies(a -> assertThat(a.getNote()).as("check note").isEqualTo(expected.getNote())); + } + + /** + * Asserts that the entity has all the updatable relationships set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertDisponibilitaUpdatableRelationshipsEquals(Disponibilita expected, Disponibilita actual) { + assertThat(actual) + .as("Verify Disponibilita relationships") + .satisfies(a -> assertThat(a.getStruttura()).as("check struttura").isEqualTo(expected.getStruttura())); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/DisponibilitaTest.java b/src/test/java/it/sw/pa/comune/artegna/domain/DisponibilitaTest.java new file mode 100644 index 0000000..e3e44be --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/DisponibilitaTest.java @@ -0,0 +1,37 @@ +package it.sw.pa.comune.artegna.domain; + +import static it.sw.pa.comune.artegna.domain.DisponibilitaTestSamples.*; +import static it.sw.pa.comune.artegna.domain.StrutturaTestSamples.*; +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class DisponibilitaTest { + + @Test + void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Disponibilita.class); + Disponibilita disponibilita1 = getDisponibilitaSample1(); + Disponibilita disponibilita2 = new Disponibilita(); + assertThat(disponibilita1).isNotEqualTo(disponibilita2); + + disponibilita2.setId(disponibilita1.getId()); + assertThat(disponibilita1).isEqualTo(disponibilita2); + + disponibilita2 = getDisponibilitaSample2(); + assertThat(disponibilita1).isNotEqualTo(disponibilita2); + } + + @Test + void strutturaTest() { + Disponibilita disponibilita = getDisponibilitaRandomSampleGenerator(); + Struttura strutturaBack = getStrutturaRandomSampleGenerator(); + + disponibilita.setStruttura(strutturaBack); + assertThat(disponibilita.getStruttura()).isEqualTo(strutturaBack); + + disponibilita.struttura(null); + assertThat(disponibilita.getStruttura()).isNull(); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/DisponibilitaTestSamples.java b/src/test/java/it/sw/pa/comune/artegna/domain/DisponibilitaTestSamples.java new file mode 100644 index 0000000..7659347 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/DisponibilitaTestSamples.java @@ -0,0 +1,27 @@ +package it.sw.pa.comune.artegna.domain; + +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicLong; + +public class DisponibilitaTestSamples { + + private static final Random random = new Random(); + private static final AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + public static Disponibilita getDisponibilitaSample1() { + return new Disponibilita().id(1L).orarioInizio("orarioInizio1").orarioFine("orarioFine1").note("note1"); + } + + public static Disponibilita getDisponibilitaSample2() { + return new Disponibilita().id(2L).orarioInizio("orarioInizio2").orarioFine("orarioFine2").note("note2"); + } + + public static Disponibilita getDisponibilitaRandomSampleGenerator() { + return new Disponibilita() + .id(longCount.incrementAndGet()) + .orarioInizio(UUID.randomUUID().toString()) + .orarioFine(UUID.randomUUID().toString()) + .note(UUID.randomUUID().toString()); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/LiberatoriaAsserts.java b/src/test/java/it/sw/pa/comune/artegna/domain/LiberatoriaAsserts.java new file mode 100644 index 0000000..e04ef37 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/LiberatoriaAsserts.java @@ -0,0 +1,67 @@ +package it.sw.pa.comune.artegna.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +public class LiberatoriaAsserts { + + /** + * Asserts that the entity has all properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertLiberatoriaAllPropertiesEquals(Liberatoria expected, Liberatoria actual) { + assertLiberatoriaAutoGeneratedPropertiesEquals(expected, actual); + assertLiberatoriaAllUpdatablePropertiesEquals(expected, actual); + } + + /** + * Asserts that the entity has all updatable properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertLiberatoriaAllUpdatablePropertiesEquals(Liberatoria expected, Liberatoria actual) { + assertLiberatoriaUpdatableFieldsEquals(expected, actual); + assertLiberatoriaUpdatableRelationshipsEquals(expected, actual); + } + + /** + * Asserts that the entity has all the auto generated properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertLiberatoriaAutoGeneratedPropertiesEquals(Liberatoria expected, Liberatoria actual) { + assertThat(actual) + .as("Verify Liberatoria auto generated properties") + .satisfies(a -> assertThat(a.getId()).as("check id").isEqualTo(expected.getId())); + } + + /** + * Asserts that the entity has all the updatable fields set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertLiberatoriaUpdatableFieldsEquals(Liberatoria expected, Liberatoria actual) { + assertThat(actual) + .as("Verify Liberatoria relevant properties") + .satisfies(a -> assertThat(a.getAccettata()).as("check accettata").isEqualTo(expected.getAccettata())); + } + + /** + * Asserts that the entity has all the updatable relationships set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertLiberatoriaUpdatableRelationshipsEquals(Liberatoria expected, Liberatoria actual) { + assertThat(actual) + .as("Verify Liberatoria relationships") + .satisfies(a -> assertThat(a.getUtente()).as("check utente").isEqualTo(expected.getUtente())) + .satisfies(a -> + assertThat(a.getModelloLiberatoria()).as("check modelloLiberatoria").isEqualTo(expected.getModelloLiberatoria()) + ); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/LiberatoriaTest.java b/src/test/java/it/sw/pa/comune/artegna/domain/LiberatoriaTest.java new file mode 100644 index 0000000..044e977 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/LiberatoriaTest.java @@ -0,0 +1,50 @@ +package it.sw.pa.comune.artegna.domain; + +import static it.sw.pa.comune.artegna.domain.LiberatoriaTestSamples.*; +import static it.sw.pa.comune.artegna.domain.ModelloLiberatoriaTestSamples.*; +import static it.sw.pa.comune.artegna.domain.UtenteAppTestSamples.*; +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class LiberatoriaTest { + + @Test + void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Liberatoria.class); + Liberatoria liberatoria1 = getLiberatoriaSample1(); + Liberatoria liberatoria2 = new Liberatoria(); + assertThat(liberatoria1).isNotEqualTo(liberatoria2); + + liberatoria2.setId(liberatoria1.getId()); + assertThat(liberatoria1).isEqualTo(liberatoria2); + + liberatoria2 = getLiberatoriaSample2(); + assertThat(liberatoria1).isNotEqualTo(liberatoria2); + } + + @Test + void utenteTest() { + Liberatoria liberatoria = getLiberatoriaRandomSampleGenerator(); + UtenteApp utenteAppBack = getUtenteAppRandomSampleGenerator(); + + liberatoria.setUtente(utenteAppBack); + assertThat(liberatoria.getUtente()).isEqualTo(utenteAppBack); + + liberatoria.utente(null); + assertThat(liberatoria.getUtente()).isNull(); + } + + @Test + void modelloLiberatoriaTest() { + Liberatoria liberatoria = getLiberatoriaRandomSampleGenerator(); + ModelloLiberatoria modelloLiberatoriaBack = getModelloLiberatoriaRandomSampleGenerator(); + + liberatoria.setModelloLiberatoria(modelloLiberatoriaBack); + assertThat(liberatoria.getModelloLiberatoria()).isEqualTo(modelloLiberatoriaBack); + + liberatoria.modelloLiberatoria(null); + assertThat(liberatoria.getModelloLiberatoria()).isNull(); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/LiberatoriaTestSamples.java b/src/test/java/it/sw/pa/comune/artegna/domain/LiberatoriaTestSamples.java new file mode 100644 index 0000000..9daf255 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/LiberatoriaTestSamples.java @@ -0,0 +1,22 @@ +package it.sw.pa.comune.artegna.domain; + +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; + +public class LiberatoriaTestSamples { + + private static final Random random = new Random(); + private static final AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + public static Liberatoria getLiberatoriaSample1() { + return new Liberatoria().id(1L); + } + + public static Liberatoria getLiberatoriaSample2() { + return new Liberatoria().id(2L); + } + + public static Liberatoria getLiberatoriaRandomSampleGenerator() { + return new Liberatoria().id(longCount.incrementAndGet()); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/MessaggioAsserts.java b/src/test/java/it/sw/pa/comune/artegna/domain/MessaggioAsserts.java new file mode 100644 index 0000000..632d604 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/MessaggioAsserts.java @@ -0,0 +1,66 @@ +package it.sw.pa.comune.artegna.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MessaggioAsserts { + + /** + * Asserts that the entity has all properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertMessaggioAllPropertiesEquals(Messaggio expected, Messaggio actual) { + assertMessaggioAutoGeneratedPropertiesEquals(expected, actual); + assertMessaggioAllUpdatablePropertiesEquals(expected, actual); + } + + /** + * Asserts that the entity has all updatable properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertMessaggioAllUpdatablePropertiesEquals(Messaggio expected, Messaggio actual) { + assertMessaggioUpdatableFieldsEquals(expected, actual); + assertMessaggioUpdatableRelationshipsEquals(expected, actual); + } + + /** + * Asserts that the entity has all the auto generated properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertMessaggioAutoGeneratedPropertiesEquals(Messaggio expected, Messaggio actual) { + assertThat(actual) + .as("Verify Messaggio auto generated properties") + .satisfies(a -> assertThat(a.getId()).as("check id").isEqualTo(expected.getId())); + } + + /** + * Asserts that the entity has all the updatable fields set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertMessaggioUpdatableFieldsEquals(Messaggio expected, Messaggio actual) { + assertThat(actual) + .as("Verify Messaggio relevant properties") + .satisfies(a -> assertThat(a.getSpedito()).as("check spedito").isEqualTo(expected.getSpedito())) + .satisfies(a -> assertThat(a.getTesto()).as("check testo").isEqualTo(expected.getTesto())) + .satisfies(a -> assertThat(a.getLetto()).as("check letto").isEqualTo(expected.getLetto())); + } + + /** + * Asserts that the entity has all the updatable relationships set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertMessaggioUpdatableRelationshipsEquals(Messaggio expected, Messaggio actual) { + assertThat(actual) + .as("Verify Messaggio relationships") + .satisfies(a -> assertThat(a.getUtente()).as("check utente").isEqualTo(expected.getUtente())); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/MessaggioTest.java b/src/test/java/it/sw/pa/comune/artegna/domain/MessaggioTest.java new file mode 100644 index 0000000..b77c0ec --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/MessaggioTest.java @@ -0,0 +1,37 @@ +package it.sw.pa.comune.artegna.domain; + +import static it.sw.pa.comune.artegna.domain.MessaggioTestSamples.*; +import static it.sw.pa.comune.artegna.domain.UtenteAppTestSamples.*; +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class MessaggioTest { + + @Test + void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Messaggio.class); + Messaggio messaggio1 = getMessaggioSample1(); + Messaggio messaggio2 = new Messaggio(); + assertThat(messaggio1).isNotEqualTo(messaggio2); + + messaggio2.setId(messaggio1.getId()); + assertThat(messaggio1).isEqualTo(messaggio2); + + messaggio2 = getMessaggioSample2(); + assertThat(messaggio1).isNotEqualTo(messaggio2); + } + + @Test + void utenteTest() { + Messaggio messaggio = getMessaggioRandomSampleGenerator(); + UtenteApp utenteAppBack = getUtenteAppRandomSampleGenerator(); + + messaggio.setUtente(utenteAppBack); + assertThat(messaggio.getUtente()).isEqualTo(utenteAppBack); + + messaggio.utente(null); + assertThat(messaggio.getUtente()).isNull(); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/MessaggioTestSamples.java b/src/test/java/it/sw/pa/comune/artegna/domain/MessaggioTestSamples.java new file mode 100644 index 0000000..f6ca00d --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/MessaggioTestSamples.java @@ -0,0 +1,23 @@ +package it.sw.pa.comune.artegna.domain; + +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicLong; + +public class MessaggioTestSamples { + + private static final Random random = new Random(); + private static final AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + public static Messaggio getMessaggioSample1() { + return new Messaggio().id(1L).testo("testo1"); + } + + public static Messaggio getMessaggioSample2() { + return new Messaggio().id(2L).testo("testo2"); + } + + public static Messaggio getMessaggioRandomSampleGenerator() { + return new Messaggio().id(longCount.incrementAndGet()).testo(UUID.randomUUID().toString()); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoriaAsserts.java b/src/test/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoriaAsserts.java new file mode 100644 index 0000000..c966ecf --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoriaAsserts.java @@ -0,0 +1,71 @@ +package it.sw.pa.comune.artegna.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ModelloLiberatoriaAsserts { + + /** + * Asserts that the entity has all properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertModelloLiberatoriaAllPropertiesEquals(ModelloLiberatoria expected, ModelloLiberatoria actual) { + assertModelloLiberatoriaAutoGeneratedPropertiesEquals(expected, actual); + assertModelloLiberatoriaAllUpdatablePropertiesEquals(expected, actual); + } + + /** + * Asserts that the entity has all updatable properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertModelloLiberatoriaAllUpdatablePropertiesEquals(ModelloLiberatoria expected, ModelloLiberatoria actual) { + assertModelloLiberatoriaUpdatableFieldsEquals(expected, actual); + assertModelloLiberatoriaUpdatableRelationshipsEquals(expected, actual); + } + + /** + * Asserts that the entity has all the auto generated properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertModelloLiberatoriaAutoGeneratedPropertiesEquals(ModelloLiberatoria expected, ModelloLiberatoria actual) { + assertThat(actual) + .as("Verify ModelloLiberatoria auto generated properties") + .satisfies(a -> assertThat(a.getId()).as("check id").isEqualTo(expected.getId())); + } + + /** + * Asserts that the entity has all the updatable fields set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertModelloLiberatoriaUpdatableFieldsEquals(ModelloLiberatoria expected, ModelloLiberatoria actual) { + assertThat(actual) + .as("Verify ModelloLiberatoria relevant properties") + .satisfies(a -> assertThat(a.getNome()).as("check nome").isEqualTo(expected.getNome())) + .satisfies(a -> assertThat(a.getTesto()).as("check testo").isEqualTo(expected.getTesto())) + .satisfies(a -> assertThat(a.getDocumento()).as("check documento").isEqualTo(expected.getDocumento())) + .satisfies(a -> + assertThat(a.getDocumentoContentType()).as("check documento content type").isEqualTo(expected.getDocumentoContentType()) + ) + .satisfies(a -> assertThat(a.getValidoDal()).as("check validoDal").isEqualTo(expected.getValidoDal())) + .satisfies(a -> assertThat(a.getValidoAl()).as("check validoAl").isEqualTo(expected.getValidoAl())); + } + + /** + * Asserts that the entity has all the updatable relationships set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertModelloLiberatoriaUpdatableRelationshipsEquals(ModelloLiberatoria expected, ModelloLiberatoria actual) { + assertThat(actual) + .as("Verify ModelloLiberatoria relationships") + .satisfies(a -> assertThat(a.getStruttura()).as("check struttura").isEqualTo(expected.getStruttura())); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoriaTest.java b/src/test/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoriaTest.java new file mode 100644 index 0000000..916b5aa --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoriaTest.java @@ -0,0 +1,37 @@ +package it.sw.pa.comune.artegna.domain; + +import static it.sw.pa.comune.artegna.domain.ModelloLiberatoriaTestSamples.*; +import static it.sw.pa.comune.artegna.domain.StrutturaTestSamples.*; +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class ModelloLiberatoriaTest { + + @Test + void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(ModelloLiberatoria.class); + ModelloLiberatoria modelloLiberatoria1 = getModelloLiberatoriaSample1(); + ModelloLiberatoria modelloLiberatoria2 = new ModelloLiberatoria(); + assertThat(modelloLiberatoria1).isNotEqualTo(modelloLiberatoria2); + + modelloLiberatoria2.setId(modelloLiberatoria1.getId()); + assertThat(modelloLiberatoria1).isEqualTo(modelloLiberatoria2); + + modelloLiberatoria2 = getModelloLiberatoriaSample2(); + assertThat(modelloLiberatoria1).isNotEqualTo(modelloLiberatoria2); + } + + @Test + void strutturaTest() { + ModelloLiberatoria modelloLiberatoria = getModelloLiberatoriaRandomSampleGenerator(); + Struttura strutturaBack = getStrutturaRandomSampleGenerator(); + + modelloLiberatoria.setStruttura(strutturaBack); + assertThat(modelloLiberatoria.getStruttura()).isEqualTo(strutturaBack); + + modelloLiberatoria.struttura(null); + assertThat(modelloLiberatoria.getStruttura()).isNull(); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoriaTestSamples.java b/src/test/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoriaTestSamples.java new file mode 100644 index 0000000..0964b43 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/ModelloLiberatoriaTestSamples.java @@ -0,0 +1,26 @@ +package it.sw.pa.comune.artegna.domain; + +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicLong; + +public class ModelloLiberatoriaTestSamples { + + private static final Random random = new Random(); + private static final AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + public static ModelloLiberatoria getModelloLiberatoriaSample1() { + return new ModelloLiberatoria().id(1L).nome("nome1").testo("testo1"); + } + + public static ModelloLiberatoria getModelloLiberatoriaSample2() { + return new ModelloLiberatoria().id(2L).nome("nome2").testo("testo2"); + } + + public static ModelloLiberatoria getModelloLiberatoriaRandomSampleGenerator() { + return new ModelloLiberatoria() + .id(longCount.incrementAndGet()) + .nome(UUID.randomUUID().toString()) + .testo(UUID.randomUUID().toString()); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/NotificaAsserts.java b/src/test/java/it/sw/pa/comune/artegna/domain/NotificaAsserts.java new file mode 100644 index 0000000..d488c18 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/NotificaAsserts.java @@ -0,0 +1,70 @@ +package it.sw.pa.comune.artegna.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +public class NotificaAsserts { + + /** + * Asserts that the entity has all properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertNotificaAllPropertiesEquals(Notifica expected, Notifica actual) { + assertNotificaAutoGeneratedPropertiesEquals(expected, actual); + assertNotificaAllUpdatablePropertiesEquals(expected, actual); + } + + /** + * Asserts that the entity has all updatable properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertNotificaAllUpdatablePropertiesEquals(Notifica expected, Notifica actual) { + assertNotificaUpdatableFieldsEquals(expected, actual); + assertNotificaUpdatableRelationshipsEquals(expected, actual); + } + + /** + * Asserts that the entity has all the auto generated properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertNotificaAutoGeneratedPropertiesEquals(Notifica expected, Notifica actual) { + assertThat(actual) + .as("Verify Notifica auto generated properties") + .satisfies(a -> assertThat(a.getId()).as("check id").isEqualTo(expected.getId())); + } + + /** + * Asserts that the entity has all the updatable fields set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertNotificaUpdatableFieldsEquals(Notifica expected, Notifica actual) { + assertThat(actual) + .as("Verify Notifica relevant properties") + .satisfies(a -> assertThat(a.getTipoCanale()).as("check tipoCanale").isEqualTo(expected.getTipoCanale())) + .satisfies(a -> assertThat(a.getTipoEvento()).as("check tipoEvento").isEqualTo(expected.getTipoEvento())) + .satisfies(a -> assertThat(a.getMessaggio()).as("check messaggio").isEqualTo(expected.getMessaggio())) + .satisfies(a -> assertThat(a.getInviata()).as("check inviata").isEqualTo(expected.getInviata())) + .satisfies(a -> assertThat(a.getInviataAt()).as("check inviataAt").isEqualTo(expected.getInviataAt())) + .satisfies(a -> assertThat(a.getErrore()).as("check errore").isEqualTo(expected.getErrore())) + .satisfies(a -> assertThat(a.getCreatedAt()).as("check createdAt").isEqualTo(expected.getCreatedAt())); + } + + /** + * Asserts that the entity has all the updatable relationships set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertNotificaUpdatableRelationshipsEquals(Notifica expected, Notifica actual) { + assertThat(actual) + .as("Verify Notifica relationships") + .satisfies(a -> assertThat(a.getConferma()).as("check conferma").isEqualTo(expected.getConferma())); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/NotificaTest.java b/src/test/java/it/sw/pa/comune/artegna/domain/NotificaTest.java new file mode 100644 index 0000000..a6ad637 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/NotificaTest.java @@ -0,0 +1,37 @@ +package it.sw.pa.comune.artegna.domain; + +import static it.sw.pa.comune.artegna.domain.ConfermaTestSamples.*; +import static it.sw.pa.comune.artegna.domain.NotificaTestSamples.*; +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class NotificaTest { + + @Test + void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Notifica.class); + Notifica notifica1 = getNotificaSample1(); + Notifica notifica2 = new Notifica(); + assertThat(notifica1).isNotEqualTo(notifica2); + + notifica2.setId(notifica1.getId()); + assertThat(notifica1).isEqualTo(notifica2); + + notifica2 = getNotificaSample2(); + assertThat(notifica1).isNotEqualTo(notifica2); + } + + @Test + void confermaTest() { + Notifica notifica = getNotificaRandomSampleGenerator(); + Conferma confermaBack = getConfermaRandomSampleGenerator(); + + notifica.setConferma(confermaBack); + assertThat(notifica.getConferma()).isEqualTo(confermaBack); + + notifica.conferma(null); + assertThat(notifica.getConferma()).isNull(); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/NotificaTestSamples.java b/src/test/java/it/sw/pa/comune/artegna/domain/NotificaTestSamples.java new file mode 100644 index 0000000..ac90bde --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/NotificaTestSamples.java @@ -0,0 +1,23 @@ +package it.sw.pa.comune.artegna.domain; + +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicLong; + +public class NotificaTestSamples { + + private static final Random random = new Random(); + private static final AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + public static Notifica getNotificaSample1() { + return new Notifica().id(1L).messaggio("messaggio1").errore("errore1"); + } + + public static Notifica getNotificaSample2() { + return new Notifica().id(2L).messaggio("messaggio2").errore("errore2"); + } + + public static Notifica getNotificaRandomSampleGenerator() { + return new Notifica().id(longCount.incrementAndGet()).messaggio(UUID.randomUUID().toString()).errore(UUID.randomUUID().toString()); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/PrenotazioneAsserts.java b/src/test/java/it/sw/pa/comune/artegna/domain/PrenotazioneAsserts.java new file mode 100644 index 0000000..ae20fa2 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/PrenotazioneAsserts.java @@ -0,0 +1,73 @@ +package it.sw.pa.comune.artegna.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PrenotazioneAsserts { + + /** + * Asserts that the entity has all properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertPrenotazioneAllPropertiesEquals(Prenotazione expected, Prenotazione actual) { + assertPrenotazioneAutoGeneratedPropertiesEquals(expected, actual); + assertPrenotazioneAllUpdatablePropertiesEquals(expected, actual); + } + + /** + * Asserts that the entity has all updatable properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertPrenotazioneAllUpdatablePropertiesEquals(Prenotazione expected, Prenotazione actual) { + assertPrenotazioneUpdatableFieldsEquals(expected, actual); + assertPrenotazioneUpdatableRelationshipsEquals(expected, actual); + } + + /** + * Asserts that the entity has all the auto generated properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertPrenotazioneAutoGeneratedPropertiesEquals(Prenotazione expected, Prenotazione actual) { + assertThat(actual) + .as("Verify Prenotazione auto generated properties") + .satisfies(a -> assertThat(a.getId()).as("check id").isEqualTo(expected.getId())); + } + + /** + * Asserts that the entity has all the updatable fields set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertPrenotazioneUpdatableFieldsEquals(Prenotazione expected, Prenotazione actual) { + assertThat(actual) + .as("Verify Prenotazione relevant properties") + .satisfies(a -> assertThat(a.getOraInizio()).as("check oraInizio").isEqualTo(expected.getOraInizio())) + .satisfies(a -> assertThat(a.getOraFine()).as("check oraFine").isEqualTo(expected.getOraFine())) + .satisfies(a -> assertThat(a.getStato()).as("check stato").isEqualTo(expected.getStato())) + .satisfies(a -> assertThat(a.getMotivoEvento()).as("check motivoEvento").isEqualTo(expected.getMotivoEvento())) + .satisfies(a -> + assertThat(a.getNumeroPartecipanti()).as("check numeroPartecipanti").isEqualTo(expected.getNumeroPartecipanti()) + ) + .satisfies(a -> assertThat(a.getNoteUtente()).as("check noteUtente").isEqualTo(expected.getNoteUtente())); + } + + /** + * Asserts that the entity has all the updatable relationships set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertPrenotazioneUpdatableRelationshipsEquals(Prenotazione expected, Prenotazione actual) { + assertThat(actual) + .as("Verify Prenotazione relationships") + .satisfies(a -> assertThat(a.getConferma()).as("check conferma").isEqualTo(expected.getConferma())) + .satisfies(a -> assertThat(a.getUtente()).as("check utente").isEqualTo(expected.getUtente())) + .satisfies(a -> assertThat(a.getStruttura()).as("check struttura").isEqualTo(expected.getStruttura())); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/PrenotazioneTest.java b/src/test/java/it/sw/pa/comune/artegna/domain/PrenotazioneTest.java new file mode 100644 index 0000000..1be7d8c --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/PrenotazioneTest.java @@ -0,0 +1,63 @@ +package it.sw.pa.comune.artegna.domain; + +import static it.sw.pa.comune.artegna.domain.ConfermaTestSamples.*; +import static it.sw.pa.comune.artegna.domain.PrenotazioneTestSamples.*; +import static it.sw.pa.comune.artegna.domain.StrutturaTestSamples.*; +import static it.sw.pa.comune.artegna.domain.UtenteAppTestSamples.*; +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class PrenotazioneTest { + + @Test + void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Prenotazione.class); + Prenotazione prenotazione1 = getPrenotazioneSample1(); + Prenotazione prenotazione2 = new Prenotazione(); + assertThat(prenotazione1).isNotEqualTo(prenotazione2); + + prenotazione2.setId(prenotazione1.getId()); + assertThat(prenotazione1).isEqualTo(prenotazione2); + + prenotazione2 = getPrenotazioneSample2(); + assertThat(prenotazione1).isNotEqualTo(prenotazione2); + } + + @Test + void confermaTest() { + Prenotazione prenotazione = getPrenotazioneRandomSampleGenerator(); + Conferma confermaBack = getConfermaRandomSampleGenerator(); + + prenotazione.setConferma(confermaBack); + assertThat(prenotazione.getConferma()).isEqualTo(confermaBack); + + prenotazione.conferma(null); + assertThat(prenotazione.getConferma()).isNull(); + } + + @Test + void utenteTest() { + Prenotazione prenotazione = getPrenotazioneRandomSampleGenerator(); + UtenteApp utenteAppBack = getUtenteAppRandomSampleGenerator(); + + prenotazione.setUtente(utenteAppBack); + assertThat(prenotazione.getUtente()).isEqualTo(utenteAppBack); + + prenotazione.utente(null); + assertThat(prenotazione.getUtente()).isNull(); + } + + @Test + void strutturaTest() { + Prenotazione prenotazione = getPrenotazioneRandomSampleGenerator(); + Struttura strutturaBack = getStrutturaRandomSampleGenerator(); + + prenotazione.setStruttura(strutturaBack); + assertThat(prenotazione.getStruttura()).isEqualTo(strutturaBack); + + prenotazione.struttura(null); + assertThat(prenotazione.getStruttura()).isNull(); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/PrenotazioneTestSamples.java b/src/test/java/it/sw/pa/comune/artegna/domain/PrenotazioneTestSamples.java new file mode 100644 index 0000000..f9ace77 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/PrenotazioneTestSamples.java @@ -0,0 +1,29 @@ +package it.sw.pa.comune.artegna.domain; + +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; + +public class PrenotazioneTestSamples { + + private static final Random random = new Random(); + private static final AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + private static final AtomicInteger intCount = new AtomicInteger(random.nextInt() + (2 * Short.MAX_VALUE)); + + public static Prenotazione getPrenotazioneSample1() { + return new Prenotazione().id(1L).motivoEvento("motivoEvento1").numeroPartecipanti(1).noteUtente("noteUtente1"); + } + + public static Prenotazione getPrenotazioneSample2() { + return new Prenotazione().id(2L).motivoEvento("motivoEvento2").numeroPartecipanti(2).noteUtente("noteUtente2"); + } + + public static Prenotazione getPrenotazioneRandomSampleGenerator() { + return new Prenotazione() + .id(longCount.incrementAndGet()) + .motivoEvento(UUID.randomUUID().toString()) + .numeroPartecipanti(intCount.incrementAndGet()) + .noteUtente(UUID.randomUUID().toString()); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/StrutturaAsserts.java b/src/test/java/it/sw/pa/comune/artegna/domain/StrutturaAsserts.java new file mode 100644 index 0000000..cfe7bde --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/StrutturaAsserts.java @@ -0,0 +1,69 @@ +package it.sw.pa.comune.artegna.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +public class StrutturaAsserts { + + /** + * Asserts that the entity has all properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertStrutturaAllPropertiesEquals(Struttura expected, Struttura actual) { + assertStrutturaAutoGeneratedPropertiesEquals(expected, actual); + assertStrutturaAllUpdatablePropertiesEquals(expected, actual); + } + + /** + * Asserts that the entity has all updatable properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertStrutturaAllUpdatablePropertiesEquals(Struttura expected, Struttura actual) { + assertStrutturaUpdatableFieldsEquals(expected, actual); + assertStrutturaUpdatableRelationshipsEquals(expected, actual); + } + + /** + * Asserts that the entity has all the auto generated properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertStrutturaAutoGeneratedPropertiesEquals(Struttura expected, Struttura actual) { + assertThat(actual) + .as("Verify Struttura auto generated properties") + .satisfies(a -> assertThat(a.getId()).as("check id").isEqualTo(expected.getId())); + } + + /** + * Asserts that the entity has all the updatable fields set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertStrutturaUpdatableFieldsEquals(Struttura expected, Struttura actual) { + assertThat(actual) + .as("Verify Struttura relevant properties") + .satisfies(a -> assertThat(a.getNome()).as("check nome").isEqualTo(expected.getNome())) + .satisfies(a -> assertThat(a.getDescrizione()).as("check descrizione").isEqualTo(expected.getDescrizione())) + .satisfies(a -> assertThat(a.getIndirizzo()).as("check indirizzo").isEqualTo(expected.getIndirizzo())) + .satisfies(a -> assertThat(a.getCapienzaMax()).as("check capienzaMax").isEqualTo(expected.getCapienzaMax())) + .satisfies(a -> assertThat(a.getAttiva()).as("check attiva").isEqualTo(expected.getAttiva())) + .satisfies(a -> assertThat(a.getFotoUrl()).as("check fotoUrl").isEqualTo(expected.getFotoUrl())) + .satisfies(a -> assertThat(a.getCreatedAt()).as("check createdAt").isEqualTo(expected.getCreatedAt())) + .satisfies(a -> assertThat(a.getUpdatedAt()).as("check updatedAt").isEqualTo(expected.getUpdatedAt())); + } + + /** + * Asserts that the entity has all the updatable relationships set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertStrutturaUpdatableRelationshipsEquals(Struttura expected, Struttura actual) { + // empty method + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/StrutturaTest.java b/src/test/java/it/sw/pa/comune/artegna/domain/StrutturaTest.java new file mode 100644 index 0000000..353d421 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/StrutturaTest.java @@ -0,0 +1,72 @@ +package it.sw.pa.comune.artegna.domain; + +import static it.sw.pa.comune.artegna.domain.DisponibilitaTestSamples.*; +import static it.sw.pa.comune.artegna.domain.ModelloLiberatoriaTestSamples.*; +import static it.sw.pa.comune.artegna.domain.StrutturaTestSamples.*; +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import java.util.HashSet; +import java.util.Set; +import org.junit.jupiter.api.Test; + +class StrutturaTest { + + @Test + void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Struttura.class); + Struttura struttura1 = getStrutturaSample1(); + Struttura struttura2 = new Struttura(); + assertThat(struttura1).isNotEqualTo(struttura2); + + struttura2.setId(struttura1.getId()); + assertThat(struttura1).isEqualTo(struttura2); + + struttura2 = getStrutturaSample2(); + assertThat(struttura1).isNotEqualTo(struttura2); + } + + @Test + void disponibilitaTest() { + Struttura struttura = getStrutturaRandomSampleGenerator(); + Disponibilita disponibilitaBack = getDisponibilitaRandomSampleGenerator(); + + struttura.addDisponibilita(disponibilitaBack); + assertThat(struttura.getDisponibilitas()).containsOnly(disponibilitaBack); + assertThat(disponibilitaBack.getStruttura()).isEqualTo(struttura); + + struttura.removeDisponibilita(disponibilitaBack); + assertThat(struttura.getDisponibilitas()).doesNotContain(disponibilitaBack); + assertThat(disponibilitaBack.getStruttura()).isNull(); + + struttura.disponibilitas(new HashSet<>(Set.of(disponibilitaBack))); + assertThat(struttura.getDisponibilitas()).containsOnly(disponibilitaBack); + assertThat(disponibilitaBack.getStruttura()).isEqualTo(struttura); + + struttura.setDisponibilitas(new HashSet<>()); + assertThat(struttura.getDisponibilitas()).doesNotContain(disponibilitaBack); + assertThat(disponibilitaBack.getStruttura()).isNull(); + } + + @Test + void moduliLiberatorieTest() { + Struttura struttura = getStrutturaRandomSampleGenerator(); + ModelloLiberatoria modelloLiberatoriaBack = getModelloLiberatoriaRandomSampleGenerator(); + + struttura.addModuliLiberatorie(modelloLiberatoriaBack); + assertThat(struttura.getModuliLiberatories()).containsOnly(modelloLiberatoriaBack); + assertThat(modelloLiberatoriaBack.getStruttura()).isEqualTo(struttura); + + struttura.removeModuliLiberatorie(modelloLiberatoriaBack); + assertThat(struttura.getModuliLiberatories()).doesNotContain(modelloLiberatoriaBack); + assertThat(modelloLiberatoriaBack.getStruttura()).isNull(); + + struttura.moduliLiberatories(new HashSet<>(Set.of(modelloLiberatoriaBack))); + assertThat(struttura.getModuliLiberatories()).containsOnly(modelloLiberatoriaBack); + assertThat(modelloLiberatoriaBack.getStruttura()).isEqualTo(struttura); + + struttura.setModuliLiberatories(new HashSet<>()); + assertThat(struttura.getModuliLiberatories()).doesNotContain(modelloLiberatoriaBack); + assertThat(modelloLiberatoriaBack.getStruttura()).isNull(); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/StrutturaTestSamples.java b/src/test/java/it/sw/pa/comune/artegna/domain/StrutturaTestSamples.java new file mode 100644 index 0000000..357a404 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/StrutturaTestSamples.java @@ -0,0 +1,31 @@ +package it.sw.pa.comune.artegna.domain; + +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; + +public class StrutturaTestSamples { + + private static final Random random = new Random(); + private static final AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + private static final AtomicInteger intCount = new AtomicInteger(random.nextInt() + (2 * Short.MAX_VALUE)); + + public static Struttura getStrutturaSample1() { + return new Struttura().id(1L).nome("nome1").descrizione("descrizione1").indirizzo("indirizzo1").capienzaMax(1).fotoUrl("fotoUrl1"); + } + + public static Struttura getStrutturaSample2() { + return new Struttura().id(2L).nome("nome2").descrizione("descrizione2").indirizzo("indirizzo2").capienzaMax(2).fotoUrl("fotoUrl2"); + } + + public static Struttura getStrutturaRandomSampleGenerator() { + return new Struttura() + .id(longCount.incrementAndGet()) + .nome(UUID.randomUUID().toString()) + .descrizione(UUID.randomUUID().toString()) + .indirizzo(UUID.randomUUID().toString()) + .capienzaMax(intCount.incrementAndGet()) + .fotoUrl(UUID.randomUUID().toString()); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/UtenteAppAsserts.java b/src/test/java/it/sw/pa/comune/artegna/domain/UtenteAppAsserts.java new file mode 100644 index 0000000..96afcdf --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/UtenteAppAsserts.java @@ -0,0 +1,76 @@ +package it.sw.pa.comune.artegna.domain; + +import static org.assertj.core.api.Assertions.assertThat; + +public class UtenteAppAsserts { + + /** + * Asserts that the entity has all properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertUtenteAppAllPropertiesEquals(UtenteApp expected, UtenteApp actual) { + assertUtenteAppAutoGeneratedPropertiesEquals(expected, actual); + assertUtenteAppAllUpdatablePropertiesEquals(expected, actual); + } + + /** + * Asserts that the entity has all updatable properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertUtenteAppAllUpdatablePropertiesEquals(UtenteApp expected, UtenteApp actual) { + assertUtenteAppUpdatableFieldsEquals(expected, actual); + assertUtenteAppUpdatableRelationshipsEquals(expected, actual); + } + + /** + * Asserts that the entity has all the auto generated properties (fields/relationships) set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertUtenteAppAutoGeneratedPropertiesEquals(UtenteApp expected, UtenteApp actual) { + assertThat(actual) + .as("Verify UtenteApp auto generated properties") + .satisfies(a -> assertThat(a.getId()).as("check id").isEqualTo(expected.getId())); + } + + /** + * Asserts that the entity has all the updatable fields set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertUtenteAppUpdatableFieldsEquals(UtenteApp expected, UtenteApp actual) { + assertThat(actual) + .as("Verify UtenteApp relevant properties") + .satisfies(a -> assertThat(a.getUsername()).as("check username").isEqualTo(expected.getUsername())) + .satisfies(a -> assertThat(a.getEmail()).as("check email").isEqualTo(expected.getEmail())) + .satisfies(a -> assertThat(a.getTelefono()).as("check telefono").isEqualTo(expected.getTelefono())) + .satisfies(a -> assertThat(a.getRuolo()).as("check ruolo").isEqualTo(expected.getRuolo())) + .satisfies(a -> assertThat(a.getAttivo()).as("check attivo").isEqualTo(expected.getAttivo())) + .satisfies(a -> assertThat(a.getNome()).as("check nome").isEqualTo(expected.getNome())) + .satisfies(a -> assertThat(a.getCognome()).as("check cognome").isEqualTo(expected.getCognome())) + .satisfies(a -> assertThat(a.getLuogoNascita()).as("check luogoNascita").isEqualTo(expected.getLuogoNascita())) + .satisfies(a -> assertThat(a.getDataNascita()).as("check dataNascita").isEqualTo(expected.getDataNascita())) + .satisfies(a -> assertThat(a.getResidente()).as("check residente").isEqualTo(expected.getResidente())) + .satisfies(a -> assertThat(a.getSocieta()).as("check societa").isEqualTo(expected.getSocieta())) + .satisfies(a -> assertThat(a.getSede()).as("check sede").isEqualTo(expected.getSede())) + .satisfies(a -> assertThat(a.getCodfiscale()).as("check codfiscale").isEqualTo(expected.getCodfiscale())) + .satisfies(a -> assertThat(a.getTelefonoSoc()).as("check telefonoSoc").isEqualTo(expected.getTelefonoSoc())) + .satisfies(a -> assertThat(a.getEmailSoc()).as("check emailSoc").isEqualTo(expected.getEmailSoc())); + } + + /** + * Asserts that the entity has all the updatable relationships set. + * + * @param expected the expected entity + * @param actual the actual entity + */ + public static void assertUtenteAppUpdatableRelationshipsEquals(UtenteApp expected, UtenteApp actual) { + // empty method + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/UtenteAppTest.java b/src/test/java/it/sw/pa/comune/artegna/domain/UtenteAppTest.java new file mode 100644 index 0000000..6192bae --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/UtenteAppTest.java @@ -0,0 +1,49 @@ +package it.sw.pa.comune.artegna.domain; + +import static it.sw.pa.comune.artegna.domain.LiberatoriaTestSamples.*; +import static it.sw.pa.comune.artegna.domain.UtenteAppTestSamples.*; +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import java.util.HashSet; +import java.util.Set; +import org.junit.jupiter.api.Test; + +class UtenteAppTest { + + @Test + void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(UtenteApp.class); + UtenteApp utenteApp1 = getUtenteAppSample1(); + UtenteApp utenteApp2 = new UtenteApp(); + assertThat(utenteApp1).isNotEqualTo(utenteApp2); + + utenteApp2.setId(utenteApp1.getId()); + assertThat(utenteApp1).isEqualTo(utenteApp2); + + utenteApp2 = getUtenteAppSample2(); + assertThat(utenteApp1).isNotEqualTo(utenteApp2); + } + + @Test + void liberatorieTest() { + UtenteApp utenteApp = getUtenteAppRandomSampleGenerator(); + Liberatoria liberatoriaBack = getLiberatoriaRandomSampleGenerator(); + + utenteApp.addLiberatorie(liberatoriaBack); + assertThat(utenteApp.getLiberatories()).containsOnly(liberatoriaBack); + assertThat(liberatoriaBack.getUtente()).isEqualTo(utenteApp); + + utenteApp.removeLiberatorie(liberatoriaBack); + assertThat(utenteApp.getLiberatories()).doesNotContain(liberatoriaBack); + assertThat(liberatoriaBack.getUtente()).isNull(); + + utenteApp.liberatories(new HashSet<>(Set.of(liberatoriaBack))); + assertThat(utenteApp.getLiberatories()).containsOnly(liberatoriaBack); + assertThat(liberatoriaBack.getUtente()).isEqualTo(utenteApp); + + utenteApp.setLiberatories(new HashSet<>()); + assertThat(utenteApp.getLiberatories()).doesNotContain(liberatoriaBack); + assertThat(liberatoriaBack.getUtente()).isNull(); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/domain/UtenteAppTestSamples.java b/src/test/java/it/sw/pa/comune/artegna/domain/UtenteAppTestSamples.java new file mode 100644 index 0000000..6918b7f --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/domain/UtenteAppTestSamples.java @@ -0,0 +1,65 @@ +package it.sw.pa.comune.artegna.domain; + +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicLong; + +public class UtenteAppTestSamples { + + private static final Random random = new Random(); + private static final AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + public static UtenteApp getUtenteAppSample1() { + return new UtenteApp() + .id(1L) + .username("username1") + .email("email1") + .telefono("telefono1") + .nome("nome1") + .cognome("cognome1") + .luogoNascita("luogoNascita1") + .dataNascita("dataNascita1") + .residente("residente1") + .societa("societa1") + .sede("sede1") + .codfiscale("codfiscale1") + .telefonoSoc("telefonoSoc1") + .emailSoc("emailSoc1"); + } + + public static UtenteApp getUtenteAppSample2() { + return new UtenteApp() + .id(2L) + .username("username2") + .email("email2") + .telefono("telefono2") + .nome("nome2") + .cognome("cognome2") + .luogoNascita("luogoNascita2") + .dataNascita("dataNascita2") + .residente("residente2") + .societa("societa2") + .sede("sede2") + .codfiscale("codfiscale2") + .telefonoSoc("telefonoSoc2") + .emailSoc("emailSoc2"); + } + + public static UtenteApp getUtenteAppRandomSampleGenerator() { + return new UtenteApp() + .id(longCount.incrementAndGet()) + .username(UUID.randomUUID().toString()) + .email(UUID.randomUUID().toString()) + .telefono(UUID.randomUUID().toString()) + .nome(UUID.randomUUID().toString()) + .cognome(UUID.randomUUID().toString()) + .luogoNascita(UUID.randomUUID().toString()) + .dataNascita(UUID.randomUUID().toString()) + .residente(UUID.randomUUID().toString()) + .societa(UUID.randomUUID().toString()) + .sede(UUID.randomUUID().toString()) + .codfiscale(UUID.randomUUID().toString()) + .telefonoSoc(UUID.randomUUID().toString()) + .emailSoc(UUID.randomUUID().toString()); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/criteria/AuditLogCriteriaTest.java b/src/test/java/it/sw/pa/comune/artegna/service/criteria/AuditLogCriteriaTest.java new file mode 100644 index 0000000..842f47a --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/criteria/AuditLogCriteriaTest.java @@ -0,0 +1,120 @@ +package it.sw.pa.comune.artegna.service.criteria; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.function.Function; +import org.assertj.core.api.Condition; +import org.junit.jupiter.api.Test; + +class AuditLogCriteriaTest { + + @Test + void newAuditLogCriteriaHasAllFiltersNullTest() { + var auditLogCriteria = new AuditLogCriteria(); + assertThat(auditLogCriteria).is(criteriaFiltersAre(Objects::isNull)); + } + + @Test + void auditLogCriteriaFluentMethodsCreatesFiltersTest() { + var auditLogCriteria = new AuditLogCriteria(); + + setAllFilters(auditLogCriteria); + + assertThat(auditLogCriteria).is(criteriaFiltersAre(Objects::nonNull)); + } + + @Test + void auditLogCriteriaCopyCreatesNullFilterTest() { + var auditLogCriteria = new AuditLogCriteria(); + var copy = auditLogCriteria.copy(); + + assertThat(auditLogCriteria).satisfies( + criteria -> + assertThat(criteria).is( + copyFiltersAre(copy, (a, b) -> (a == null || a instanceof Boolean) ? a == b : (a != b && a.equals(b))) + ), + criteria -> assertThat(criteria).isEqualTo(copy), + criteria -> assertThat(criteria).hasSameHashCodeAs(copy) + ); + + assertThat(copy).satisfies( + criteria -> assertThat(criteria).is(criteriaFiltersAre(Objects::isNull)), + criteria -> assertThat(criteria).isEqualTo(auditLogCriteria) + ); + } + + @Test + void auditLogCriteriaCopyDuplicatesEveryExistingFilterTest() { + var auditLogCriteria = new AuditLogCriteria(); + setAllFilters(auditLogCriteria); + + var copy = auditLogCriteria.copy(); + + assertThat(auditLogCriteria).satisfies( + criteria -> + assertThat(criteria).is( + copyFiltersAre(copy, (a, b) -> (a == null || a instanceof Boolean) ? a == b : (a != b && a.equals(b))) + ), + criteria -> assertThat(criteria).isEqualTo(copy), + criteria -> assertThat(criteria).hasSameHashCodeAs(copy) + ); + + assertThat(copy).satisfies( + criteria -> assertThat(criteria).is(criteriaFiltersAre(Objects::nonNull)), + criteria -> assertThat(criteria).isEqualTo(auditLogCriteria) + ); + } + + @Test + void toStringVerifier() { + var auditLogCriteria = new AuditLogCriteria(); + + assertThat(auditLogCriteria).hasToString("AuditLogCriteria{}"); + } + + private static void setAllFilters(AuditLogCriteria auditLogCriteria) { + auditLogCriteria.id(); + auditLogCriteria.entitaTipo(); + auditLogCriteria.entitaId(); + auditLogCriteria.azione(); + auditLogCriteria.dettagli(); + auditLogCriteria.ipAddress(); + auditLogCriteria.createdAt(); + auditLogCriteria.utenteId(); + auditLogCriteria.distinct(); + } + + private static Condition criteriaFiltersAre(Function condition) { + return new Condition<>( + criteria -> + condition.apply(criteria.getId()) && + condition.apply(criteria.getEntitaTipo()) && + condition.apply(criteria.getEntitaId()) && + condition.apply(criteria.getAzione()) && + condition.apply(criteria.getDettagli()) && + condition.apply(criteria.getIpAddress()) && + condition.apply(criteria.getCreatedAt()) && + condition.apply(criteria.getUtenteId()) && + condition.apply(criteria.getDistinct()), + "every filter matches" + ); + } + + private static Condition copyFiltersAre(AuditLogCriteria copy, BiFunction condition) { + return new Condition<>( + criteria -> + condition.apply(criteria.getId(), copy.getId()) && + condition.apply(criteria.getEntitaTipo(), copy.getEntitaTipo()) && + condition.apply(criteria.getEntitaId(), copy.getEntitaId()) && + condition.apply(criteria.getAzione(), copy.getAzione()) && + condition.apply(criteria.getDettagli(), copy.getDettagli()) && + condition.apply(criteria.getIpAddress(), copy.getIpAddress()) && + condition.apply(criteria.getCreatedAt(), copy.getCreatedAt()) && + condition.apply(criteria.getUtenteId(), copy.getUtenteId()) && + condition.apply(criteria.getDistinct(), copy.getDistinct()), + "every filter matches" + ); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/criteria/ConfermaCriteriaTest.java b/src/test/java/it/sw/pa/comune/artegna/service/criteria/ConfermaCriteriaTest.java new file mode 100644 index 0000000..86fc660 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/criteria/ConfermaCriteriaTest.java @@ -0,0 +1,111 @@ +package it.sw.pa.comune.artegna.service.criteria; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.function.Function; +import org.assertj.core.api.Condition; +import org.junit.jupiter.api.Test; + +class ConfermaCriteriaTest { + + @Test + void newConfermaCriteriaHasAllFiltersNullTest() { + var confermaCriteria = new ConfermaCriteria(); + assertThat(confermaCriteria).is(criteriaFiltersAre(Objects::isNull)); + } + + @Test + void confermaCriteriaFluentMethodsCreatesFiltersTest() { + var confermaCriteria = new ConfermaCriteria(); + + setAllFilters(confermaCriteria); + + assertThat(confermaCriteria).is(criteriaFiltersAre(Objects::nonNull)); + } + + @Test + void confermaCriteriaCopyCreatesNullFilterTest() { + var confermaCriteria = new ConfermaCriteria(); + var copy = confermaCriteria.copy(); + + assertThat(confermaCriteria).satisfies( + criteria -> + assertThat(criteria).is( + copyFiltersAre(copy, (a, b) -> (a == null || a instanceof Boolean) ? a == b : (a != b && a.equals(b))) + ), + criteria -> assertThat(criteria).isEqualTo(copy), + criteria -> assertThat(criteria).hasSameHashCodeAs(copy) + ); + + assertThat(copy).satisfies( + criteria -> assertThat(criteria).is(criteriaFiltersAre(Objects::isNull)), + criteria -> assertThat(criteria).isEqualTo(confermaCriteria) + ); + } + + @Test + void confermaCriteriaCopyDuplicatesEveryExistingFilterTest() { + var confermaCriteria = new ConfermaCriteria(); + setAllFilters(confermaCriteria); + + var copy = confermaCriteria.copy(); + + assertThat(confermaCriteria).satisfies( + criteria -> + assertThat(criteria).is( + copyFiltersAre(copy, (a, b) -> (a == null || a instanceof Boolean) ? a == b : (a != b && a.equals(b))) + ), + criteria -> assertThat(criteria).isEqualTo(copy), + criteria -> assertThat(criteria).hasSameHashCodeAs(copy) + ); + + assertThat(copy).satisfies( + criteria -> assertThat(criteria).is(criteriaFiltersAre(Objects::nonNull)), + criteria -> assertThat(criteria).isEqualTo(confermaCriteria) + ); + } + + @Test + void toStringVerifier() { + var confermaCriteria = new ConfermaCriteria(); + + assertThat(confermaCriteria).hasToString("ConfermaCriteria{}"); + } + + private static void setAllFilters(ConfermaCriteria confermaCriteria) { + confermaCriteria.id(); + confermaCriteria.motivoConferma(); + confermaCriteria.tipoConferma(); + confermaCriteria.confermataDaId(); + confermaCriteria.prenotazioneId(); + confermaCriteria.distinct(); + } + + private static Condition criteriaFiltersAre(Function condition) { + return new Condition<>( + criteria -> + condition.apply(criteria.getId()) && + condition.apply(criteria.getMotivoConferma()) && + condition.apply(criteria.getTipoConferma()) && + condition.apply(criteria.getConfermataDaId()) && + condition.apply(criteria.getPrenotazioneId()) && + condition.apply(criteria.getDistinct()), + "every filter matches" + ); + } + + private static Condition copyFiltersAre(ConfermaCriteria copy, BiFunction condition) { + return new Condition<>( + criteria -> + condition.apply(criteria.getId(), copy.getId()) && + condition.apply(criteria.getMotivoConferma(), copy.getMotivoConferma()) && + condition.apply(criteria.getTipoConferma(), copy.getTipoConferma()) && + condition.apply(criteria.getConfermataDaId(), copy.getConfermataDaId()) && + condition.apply(criteria.getPrenotazioneId(), copy.getPrenotazioneId()) && + condition.apply(criteria.getDistinct(), copy.getDistinct()), + "every filter matches" + ); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/criteria/NotificaCriteriaTest.java b/src/test/java/it/sw/pa/comune/artegna/service/criteria/NotificaCriteriaTest.java new file mode 100644 index 0000000..6bb3ed5 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/criteria/NotificaCriteriaTest.java @@ -0,0 +1,123 @@ +package it.sw.pa.comune.artegna.service.criteria; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.function.Function; +import org.assertj.core.api.Condition; +import org.junit.jupiter.api.Test; + +class NotificaCriteriaTest { + + @Test + void newNotificaCriteriaHasAllFiltersNullTest() { + var notificaCriteria = new NotificaCriteria(); + assertThat(notificaCriteria).is(criteriaFiltersAre(Objects::isNull)); + } + + @Test + void notificaCriteriaFluentMethodsCreatesFiltersTest() { + var notificaCriteria = new NotificaCriteria(); + + setAllFilters(notificaCriteria); + + assertThat(notificaCriteria).is(criteriaFiltersAre(Objects::nonNull)); + } + + @Test + void notificaCriteriaCopyCreatesNullFilterTest() { + var notificaCriteria = new NotificaCriteria(); + var copy = notificaCriteria.copy(); + + assertThat(notificaCriteria).satisfies( + criteria -> + assertThat(criteria).is( + copyFiltersAre(copy, (a, b) -> (a == null || a instanceof Boolean) ? a == b : (a != b && a.equals(b))) + ), + criteria -> assertThat(criteria).isEqualTo(copy), + criteria -> assertThat(criteria).hasSameHashCodeAs(copy) + ); + + assertThat(copy).satisfies( + criteria -> assertThat(criteria).is(criteriaFiltersAre(Objects::isNull)), + criteria -> assertThat(criteria).isEqualTo(notificaCriteria) + ); + } + + @Test + void notificaCriteriaCopyDuplicatesEveryExistingFilterTest() { + var notificaCriteria = new NotificaCriteria(); + setAllFilters(notificaCriteria); + + var copy = notificaCriteria.copy(); + + assertThat(notificaCriteria).satisfies( + criteria -> + assertThat(criteria).is( + copyFiltersAre(copy, (a, b) -> (a == null || a instanceof Boolean) ? a == b : (a != b && a.equals(b))) + ), + criteria -> assertThat(criteria).isEqualTo(copy), + criteria -> assertThat(criteria).hasSameHashCodeAs(copy) + ); + + assertThat(copy).satisfies( + criteria -> assertThat(criteria).is(criteriaFiltersAre(Objects::nonNull)), + criteria -> assertThat(criteria).isEqualTo(notificaCriteria) + ); + } + + @Test + void toStringVerifier() { + var notificaCriteria = new NotificaCriteria(); + + assertThat(notificaCriteria).hasToString("NotificaCriteria{}"); + } + + private static void setAllFilters(NotificaCriteria notificaCriteria) { + notificaCriteria.id(); + notificaCriteria.tipoCanale(); + notificaCriteria.tipoEvento(); + notificaCriteria.messaggio(); + notificaCriteria.inviata(); + notificaCriteria.inviataAt(); + notificaCriteria.errore(); + notificaCriteria.createdAt(); + notificaCriteria.confermaId(); + notificaCriteria.distinct(); + } + + private static Condition criteriaFiltersAre(Function condition) { + return new Condition<>( + criteria -> + condition.apply(criteria.getId()) && + condition.apply(criteria.getTipoCanale()) && + condition.apply(criteria.getTipoEvento()) && + condition.apply(criteria.getMessaggio()) && + condition.apply(criteria.getInviata()) && + condition.apply(criteria.getInviataAt()) && + condition.apply(criteria.getErrore()) && + condition.apply(criteria.getCreatedAt()) && + condition.apply(criteria.getConfermaId()) && + condition.apply(criteria.getDistinct()), + "every filter matches" + ); + } + + private static Condition copyFiltersAre(NotificaCriteria copy, BiFunction condition) { + return new Condition<>( + criteria -> + condition.apply(criteria.getId(), copy.getId()) && + condition.apply(criteria.getTipoCanale(), copy.getTipoCanale()) && + condition.apply(criteria.getTipoEvento(), copy.getTipoEvento()) && + condition.apply(criteria.getMessaggio(), copy.getMessaggio()) && + condition.apply(criteria.getInviata(), copy.getInviata()) && + condition.apply(criteria.getInviataAt(), copy.getInviataAt()) && + condition.apply(criteria.getErrore(), copy.getErrore()) && + condition.apply(criteria.getCreatedAt(), copy.getCreatedAt()) && + condition.apply(criteria.getConfermaId(), copy.getConfermaId()) && + condition.apply(criteria.getDistinct(), copy.getDistinct()), + "every filter matches" + ); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/criteria/PrenotazioneCriteriaTest.java b/src/test/java/it/sw/pa/comune/artegna/service/criteria/PrenotazioneCriteriaTest.java new file mode 100644 index 0000000..e7d472a --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/criteria/PrenotazioneCriteriaTest.java @@ -0,0 +1,129 @@ +package it.sw.pa.comune.artegna.service.criteria; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.function.Function; +import org.assertj.core.api.Condition; +import org.junit.jupiter.api.Test; + +class PrenotazioneCriteriaTest { + + @Test + void newPrenotazioneCriteriaHasAllFiltersNullTest() { + var prenotazioneCriteria = new PrenotazioneCriteria(); + assertThat(prenotazioneCriteria).is(criteriaFiltersAre(Objects::isNull)); + } + + @Test + void prenotazioneCriteriaFluentMethodsCreatesFiltersTest() { + var prenotazioneCriteria = new PrenotazioneCriteria(); + + setAllFilters(prenotazioneCriteria); + + assertThat(prenotazioneCriteria).is(criteriaFiltersAre(Objects::nonNull)); + } + + @Test + void prenotazioneCriteriaCopyCreatesNullFilterTest() { + var prenotazioneCriteria = new PrenotazioneCriteria(); + var copy = prenotazioneCriteria.copy(); + + assertThat(prenotazioneCriteria).satisfies( + criteria -> + assertThat(criteria).is( + copyFiltersAre(copy, (a, b) -> (a == null || a instanceof Boolean) ? a == b : (a != b && a.equals(b))) + ), + criteria -> assertThat(criteria).isEqualTo(copy), + criteria -> assertThat(criteria).hasSameHashCodeAs(copy) + ); + + assertThat(copy).satisfies( + criteria -> assertThat(criteria).is(criteriaFiltersAre(Objects::isNull)), + criteria -> assertThat(criteria).isEqualTo(prenotazioneCriteria) + ); + } + + @Test + void prenotazioneCriteriaCopyDuplicatesEveryExistingFilterTest() { + var prenotazioneCriteria = new PrenotazioneCriteria(); + setAllFilters(prenotazioneCriteria); + + var copy = prenotazioneCriteria.copy(); + + assertThat(prenotazioneCriteria).satisfies( + criteria -> + assertThat(criteria).is( + copyFiltersAre(copy, (a, b) -> (a == null || a instanceof Boolean) ? a == b : (a != b && a.equals(b))) + ), + criteria -> assertThat(criteria).isEqualTo(copy), + criteria -> assertThat(criteria).hasSameHashCodeAs(copy) + ); + + assertThat(copy).satisfies( + criteria -> assertThat(criteria).is(criteriaFiltersAre(Objects::nonNull)), + criteria -> assertThat(criteria).isEqualTo(prenotazioneCriteria) + ); + } + + @Test + void toStringVerifier() { + var prenotazioneCriteria = new PrenotazioneCriteria(); + + assertThat(prenotazioneCriteria).hasToString("PrenotazioneCriteria{}"); + } + + private static void setAllFilters(PrenotazioneCriteria prenotazioneCriteria) { + prenotazioneCriteria.id(); + prenotazioneCriteria.oraInizio(); + prenotazioneCriteria.oraFine(); + prenotazioneCriteria.stato(); + prenotazioneCriteria.motivoEvento(); + prenotazioneCriteria.numeroPartecipanti(); + prenotazioneCriteria.noteUtente(); + prenotazioneCriteria.confermaId(); + prenotazioneCriteria.utenteId(); + prenotazioneCriteria.strutturaId(); + prenotazioneCriteria.distinct(); + } + + private static Condition criteriaFiltersAre(Function condition) { + return new Condition<>( + criteria -> + condition.apply(criteria.getId()) && + condition.apply(criteria.getOraInizio()) && + condition.apply(criteria.getOraFine()) && + condition.apply(criteria.getStato()) && + condition.apply(criteria.getMotivoEvento()) && + condition.apply(criteria.getNumeroPartecipanti()) && + condition.apply(criteria.getNoteUtente()) && + condition.apply(criteria.getConfermaId()) && + condition.apply(criteria.getUtenteId()) && + condition.apply(criteria.getStrutturaId()) && + condition.apply(criteria.getDistinct()), + "every filter matches" + ); + } + + private static Condition copyFiltersAre( + PrenotazioneCriteria copy, + BiFunction condition + ) { + return new Condition<>( + criteria -> + condition.apply(criteria.getId(), copy.getId()) && + condition.apply(criteria.getOraInizio(), copy.getOraInizio()) && + condition.apply(criteria.getOraFine(), copy.getOraFine()) && + condition.apply(criteria.getStato(), copy.getStato()) && + condition.apply(criteria.getMotivoEvento(), copy.getMotivoEvento()) && + condition.apply(criteria.getNumeroPartecipanti(), copy.getNumeroPartecipanti()) && + condition.apply(criteria.getNoteUtente(), copy.getNoteUtente()) && + condition.apply(criteria.getConfermaId(), copy.getConfermaId()) && + condition.apply(criteria.getUtenteId(), copy.getUtenteId()) && + condition.apply(criteria.getStrutturaId(), copy.getStrutturaId()) && + condition.apply(criteria.getDistinct(), copy.getDistinct()), + "every filter matches" + ); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/criteria/StrutturaCriteriaTest.java b/src/test/java/it/sw/pa/comune/artegna/service/criteria/StrutturaCriteriaTest.java new file mode 100644 index 0000000..0270426 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/criteria/StrutturaCriteriaTest.java @@ -0,0 +1,129 @@ +package it.sw.pa.comune.artegna.service.criteria; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.function.Function; +import org.assertj.core.api.Condition; +import org.junit.jupiter.api.Test; + +class StrutturaCriteriaTest { + + @Test + void newStrutturaCriteriaHasAllFiltersNullTest() { + var strutturaCriteria = new StrutturaCriteria(); + assertThat(strutturaCriteria).is(criteriaFiltersAre(Objects::isNull)); + } + + @Test + void strutturaCriteriaFluentMethodsCreatesFiltersTest() { + var strutturaCriteria = new StrutturaCriteria(); + + setAllFilters(strutturaCriteria); + + assertThat(strutturaCriteria).is(criteriaFiltersAre(Objects::nonNull)); + } + + @Test + void strutturaCriteriaCopyCreatesNullFilterTest() { + var strutturaCriteria = new StrutturaCriteria(); + var copy = strutturaCriteria.copy(); + + assertThat(strutturaCriteria).satisfies( + criteria -> + assertThat(criteria).is( + copyFiltersAre(copy, (a, b) -> (a == null || a instanceof Boolean) ? a == b : (a != b && a.equals(b))) + ), + criteria -> assertThat(criteria).isEqualTo(copy), + criteria -> assertThat(criteria).hasSameHashCodeAs(copy) + ); + + assertThat(copy).satisfies( + criteria -> assertThat(criteria).is(criteriaFiltersAre(Objects::isNull)), + criteria -> assertThat(criteria).isEqualTo(strutturaCriteria) + ); + } + + @Test + void strutturaCriteriaCopyDuplicatesEveryExistingFilterTest() { + var strutturaCriteria = new StrutturaCriteria(); + setAllFilters(strutturaCriteria); + + var copy = strutturaCriteria.copy(); + + assertThat(strutturaCriteria).satisfies( + criteria -> + assertThat(criteria).is( + copyFiltersAre(copy, (a, b) -> (a == null || a instanceof Boolean) ? a == b : (a != b && a.equals(b))) + ), + criteria -> assertThat(criteria).isEqualTo(copy), + criteria -> assertThat(criteria).hasSameHashCodeAs(copy) + ); + + assertThat(copy).satisfies( + criteria -> assertThat(criteria).is(criteriaFiltersAre(Objects::nonNull)), + criteria -> assertThat(criteria).isEqualTo(strutturaCriteria) + ); + } + + @Test + void toStringVerifier() { + var strutturaCriteria = new StrutturaCriteria(); + + assertThat(strutturaCriteria).hasToString("StrutturaCriteria{}"); + } + + private static void setAllFilters(StrutturaCriteria strutturaCriteria) { + strutturaCriteria.id(); + strutturaCriteria.nome(); + strutturaCriteria.descrizione(); + strutturaCriteria.indirizzo(); + strutturaCriteria.capienzaMax(); + strutturaCriteria.attiva(); + strutturaCriteria.fotoUrl(); + strutturaCriteria.createdAt(); + strutturaCriteria.updatedAt(); + strutturaCriteria.disponibilitaId(); + strutturaCriteria.moduliLiberatorieId(); + strutturaCriteria.distinct(); + } + + private static Condition criteriaFiltersAre(Function condition) { + return new Condition<>( + criteria -> + condition.apply(criteria.getId()) && + condition.apply(criteria.getNome()) && + condition.apply(criteria.getDescrizione()) && + condition.apply(criteria.getIndirizzo()) && + condition.apply(criteria.getCapienzaMax()) && + condition.apply(criteria.getAttiva()) && + condition.apply(criteria.getFotoUrl()) && + condition.apply(criteria.getCreatedAt()) && + condition.apply(criteria.getUpdatedAt()) && + condition.apply(criteria.getDisponibilitaId()) && + condition.apply(criteria.getModuliLiberatorieId()) && + condition.apply(criteria.getDistinct()), + "every filter matches" + ); + } + + private static Condition copyFiltersAre(StrutturaCriteria copy, BiFunction condition) { + return new Condition<>( + criteria -> + condition.apply(criteria.getId(), copy.getId()) && + condition.apply(criteria.getNome(), copy.getNome()) && + condition.apply(criteria.getDescrizione(), copy.getDescrizione()) && + condition.apply(criteria.getIndirizzo(), copy.getIndirizzo()) && + condition.apply(criteria.getCapienzaMax(), copy.getCapienzaMax()) && + condition.apply(criteria.getAttiva(), copy.getAttiva()) && + condition.apply(criteria.getFotoUrl(), copy.getFotoUrl()) && + condition.apply(criteria.getCreatedAt(), copy.getCreatedAt()) && + condition.apply(criteria.getUpdatedAt(), copy.getUpdatedAt()) && + condition.apply(criteria.getDisponibilitaId(), copy.getDisponibilitaId()) && + condition.apply(criteria.getModuliLiberatorieId(), copy.getModuliLiberatorieId()) && + condition.apply(criteria.getDistinct(), copy.getDistinct()), + "every filter matches" + ); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/dto/AuditLogDTOTest.java b/src/test/java/it/sw/pa/comune/artegna/service/dto/AuditLogDTOTest.java new file mode 100644 index 0000000..7896393 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/dto/AuditLogDTOTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.dto; + +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class AuditLogDTOTest { + + @Test + void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(AuditLogDTO.class); + AuditLogDTO auditLogDTO1 = new AuditLogDTO(); + auditLogDTO1.setId(1L); + AuditLogDTO auditLogDTO2 = new AuditLogDTO(); + assertThat(auditLogDTO1).isNotEqualTo(auditLogDTO2); + auditLogDTO2.setId(auditLogDTO1.getId()); + assertThat(auditLogDTO1).isEqualTo(auditLogDTO2); + auditLogDTO2.setId(2L); + assertThat(auditLogDTO1).isNotEqualTo(auditLogDTO2); + auditLogDTO1.setId(null); + assertThat(auditLogDTO1).isNotEqualTo(auditLogDTO2); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/dto/ConfermaDTOTest.java b/src/test/java/it/sw/pa/comune/artegna/service/dto/ConfermaDTOTest.java new file mode 100644 index 0000000..3b6bbae --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/dto/ConfermaDTOTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.dto; + +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class ConfermaDTOTest { + + @Test + void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(ConfermaDTO.class); + ConfermaDTO confermaDTO1 = new ConfermaDTO(); + confermaDTO1.setId(1L); + ConfermaDTO confermaDTO2 = new ConfermaDTO(); + assertThat(confermaDTO1).isNotEqualTo(confermaDTO2); + confermaDTO2.setId(confermaDTO1.getId()); + assertThat(confermaDTO1).isEqualTo(confermaDTO2); + confermaDTO2.setId(2L); + assertThat(confermaDTO1).isNotEqualTo(confermaDTO2); + confermaDTO1.setId(null); + assertThat(confermaDTO1).isNotEqualTo(confermaDTO2); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/dto/DisponibilitaDTOTest.java b/src/test/java/it/sw/pa/comune/artegna/service/dto/DisponibilitaDTOTest.java new file mode 100644 index 0000000..9403188 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/dto/DisponibilitaDTOTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.dto; + +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class DisponibilitaDTOTest { + + @Test + void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(DisponibilitaDTO.class); + DisponibilitaDTO disponibilitaDTO1 = new DisponibilitaDTO(); + disponibilitaDTO1.setId(1L); + DisponibilitaDTO disponibilitaDTO2 = new DisponibilitaDTO(); + assertThat(disponibilitaDTO1).isNotEqualTo(disponibilitaDTO2); + disponibilitaDTO2.setId(disponibilitaDTO1.getId()); + assertThat(disponibilitaDTO1).isEqualTo(disponibilitaDTO2); + disponibilitaDTO2.setId(2L); + assertThat(disponibilitaDTO1).isNotEqualTo(disponibilitaDTO2); + disponibilitaDTO1.setId(null); + assertThat(disponibilitaDTO1).isNotEqualTo(disponibilitaDTO2); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/dto/LiberatoriaDTOTest.java b/src/test/java/it/sw/pa/comune/artegna/service/dto/LiberatoriaDTOTest.java new file mode 100644 index 0000000..322ebb0 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/dto/LiberatoriaDTOTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.dto; + +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class LiberatoriaDTOTest { + + @Test + void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(LiberatoriaDTO.class); + LiberatoriaDTO liberatoriaDTO1 = new LiberatoriaDTO(); + liberatoriaDTO1.setId(1L); + LiberatoriaDTO liberatoriaDTO2 = new LiberatoriaDTO(); + assertThat(liberatoriaDTO1).isNotEqualTo(liberatoriaDTO2); + liberatoriaDTO2.setId(liberatoriaDTO1.getId()); + assertThat(liberatoriaDTO1).isEqualTo(liberatoriaDTO2); + liberatoriaDTO2.setId(2L); + assertThat(liberatoriaDTO1).isNotEqualTo(liberatoriaDTO2); + liberatoriaDTO1.setId(null); + assertThat(liberatoriaDTO1).isNotEqualTo(liberatoriaDTO2); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/dto/MessaggioDTOTest.java b/src/test/java/it/sw/pa/comune/artegna/service/dto/MessaggioDTOTest.java new file mode 100644 index 0000000..adac0c7 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/dto/MessaggioDTOTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.dto; + +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class MessaggioDTOTest { + + @Test + void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(MessaggioDTO.class); + MessaggioDTO messaggioDTO1 = new MessaggioDTO(); + messaggioDTO1.setId(1L); + MessaggioDTO messaggioDTO2 = new MessaggioDTO(); + assertThat(messaggioDTO1).isNotEqualTo(messaggioDTO2); + messaggioDTO2.setId(messaggioDTO1.getId()); + assertThat(messaggioDTO1).isEqualTo(messaggioDTO2); + messaggioDTO2.setId(2L); + assertThat(messaggioDTO1).isNotEqualTo(messaggioDTO2); + messaggioDTO1.setId(null); + assertThat(messaggioDTO1).isNotEqualTo(messaggioDTO2); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/dto/ModelloLiberatoriaDTOTest.java b/src/test/java/it/sw/pa/comune/artegna/service/dto/ModelloLiberatoriaDTOTest.java new file mode 100644 index 0000000..8a052d9 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/dto/ModelloLiberatoriaDTOTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.dto; + +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class ModelloLiberatoriaDTOTest { + + @Test + void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(ModelloLiberatoriaDTO.class); + ModelloLiberatoriaDTO modelloLiberatoriaDTO1 = new ModelloLiberatoriaDTO(); + modelloLiberatoriaDTO1.setId(1L); + ModelloLiberatoriaDTO modelloLiberatoriaDTO2 = new ModelloLiberatoriaDTO(); + assertThat(modelloLiberatoriaDTO1).isNotEqualTo(modelloLiberatoriaDTO2); + modelloLiberatoriaDTO2.setId(modelloLiberatoriaDTO1.getId()); + assertThat(modelloLiberatoriaDTO1).isEqualTo(modelloLiberatoriaDTO2); + modelloLiberatoriaDTO2.setId(2L); + assertThat(modelloLiberatoriaDTO1).isNotEqualTo(modelloLiberatoriaDTO2); + modelloLiberatoriaDTO1.setId(null); + assertThat(modelloLiberatoriaDTO1).isNotEqualTo(modelloLiberatoriaDTO2); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/dto/NotificaDTOTest.java b/src/test/java/it/sw/pa/comune/artegna/service/dto/NotificaDTOTest.java new file mode 100644 index 0000000..0d787b8 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/dto/NotificaDTOTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.dto; + +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class NotificaDTOTest { + + @Test + void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(NotificaDTO.class); + NotificaDTO notificaDTO1 = new NotificaDTO(); + notificaDTO1.setId(1L); + NotificaDTO notificaDTO2 = new NotificaDTO(); + assertThat(notificaDTO1).isNotEqualTo(notificaDTO2); + notificaDTO2.setId(notificaDTO1.getId()); + assertThat(notificaDTO1).isEqualTo(notificaDTO2); + notificaDTO2.setId(2L); + assertThat(notificaDTO1).isNotEqualTo(notificaDTO2); + notificaDTO1.setId(null); + assertThat(notificaDTO1).isNotEqualTo(notificaDTO2); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/dto/PrenotazioneDTOTest.java b/src/test/java/it/sw/pa/comune/artegna/service/dto/PrenotazioneDTOTest.java new file mode 100644 index 0000000..d534355 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/dto/PrenotazioneDTOTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.dto; + +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class PrenotazioneDTOTest { + + @Test + void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(PrenotazioneDTO.class); + PrenotazioneDTO prenotazioneDTO1 = new PrenotazioneDTO(); + prenotazioneDTO1.setId(1L); + PrenotazioneDTO prenotazioneDTO2 = new PrenotazioneDTO(); + assertThat(prenotazioneDTO1).isNotEqualTo(prenotazioneDTO2); + prenotazioneDTO2.setId(prenotazioneDTO1.getId()); + assertThat(prenotazioneDTO1).isEqualTo(prenotazioneDTO2); + prenotazioneDTO2.setId(2L); + assertThat(prenotazioneDTO1).isNotEqualTo(prenotazioneDTO2); + prenotazioneDTO1.setId(null); + assertThat(prenotazioneDTO1).isNotEqualTo(prenotazioneDTO2); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/dto/StrutturaDTOTest.java b/src/test/java/it/sw/pa/comune/artegna/service/dto/StrutturaDTOTest.java new file mode 100644 index 0000000..205e39b --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/dto/StrutturaDTOTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.dto; + +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class StrutturaDTOTest { + + @Test + void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(StrutturaDTO.class); + StrutturaDTO strutturaDTO1 = new StrutturaDTO(); + strutturaDTO1.setId(1L); + StrutturaDTO strutturaDTO2 = new StrutturaDTO(); + assertThat(strutturaDTO1).isNotEqualTo(strutturaDTO2); + strutturaDTO2.setId(strutturaDTO1.getId()); + assertThat(strutturaDTO1).isEqualTo(strutturaDTO2); + strutturaDTO2.setId(2L); + assertThat(strutturaDTO1).isNotEqualTo(strutturaDTO2); + strutturaDTO1.setId(null); + assertThat(strutturaDTO1).isNotEqualTo(strutturaDTO2); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/dto/UtenteAppDTOTest.java b/src/test/java/it/sw/pa/comune/artegna/service/dto/UtenteAppDTOTest.java new file mode 100644 index 0000000..3047956 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/dto/UtenteAppDTOTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.dto; + +import static org.assertj.core.api.Assertions.assertThat; + +import it.sw.pa.comune.artegna.web.rest.TestUtil; +import org.junit.jupiter.api.Test; + +class UtenteAppDTOTest { + + @Test + void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(UtenteAppDTO.class); + UtenteAppDTO utenteAppDTO1 = new UtenteAppDTO(); + utenteAppDTO1.setId(1L); + UtenteAppDTO utenteAppDTO2 = new UtenteAppDTO(); + assertThat(utenteAppDTO1).isNotEqualTo(utenteAppDTO2); + utenteAppDTO2.setId(utenteAppDTO1.getId()); + assertThat(utenteAppDTO1).isEqualTo(utenteAppDTO2); + utenteAppDTO2.setId(2L); + assertThat(utenteAppDTO1).isNotEqualTo(utenteAppDTO2); + utenteAppDTO1.setId(null); + assertThat(utenteAppDTO1).isNotEqualTo(utenteAppDTO2); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/mapper/AuditLogMapperTest.java b/src/test/java/it/sw/pa/comune/artegna/service/mapper/AuditLogMapperTest.java new file mode 100644 index 0000000..c0423c3 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/mapper/AuditLogMapperTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import static it.sw.pa.comune.artegna.domain.AuditLogAsserts.*; +import static it.sw.pa.comune.artegna.domain.AuditLogTestSamples.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class AuditLogMapperTest { + + private AuditLogMapper auditLogMapper; + + @BeforeEach + void setUp() { + auditLogMapper = new AuditLogMapperImpl(); + } + + @Test + void shouldConvertToDtoAndBack() { + var expected = getAuditLogSample1(); + var actual = auditLogMapper.toEntity(auditLogMapper.toDto(expected)); + assertAuditLogAllPropertiesEquals(expected, actual); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/mapper/ConfermaMapperTest.java b/src/test/java/it/sw/pa/comune/artegna/service/mapper/ConfermaMapperTest.java new file mode 100644 index 0000000..67fbbe8 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/mapper/ConfermaMapperTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import static it.sw.pa.comune.artegna.domain.ConfermaAsserts.*; +import static it.sw.pa.comune.artegna.domain.ConfermaTestSamples.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class ConfermaMapperTest { + + private ConfermaMapper confermaMapper; + + @BeforeEach + void setUp() { + confermaMapper = new ConfermaMapperImpl(); + } + + @Test + void shouldConvertToDtoAndBack() { + var expected = getConfermaSample1(); + var actual = confermaMapper.toEntity(confermaMapper.toDto(expected)); + assertConfermaAllPropertiesEquals(expected, actual); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/mapper/DisponibilitaMapperTest.java b/src/test/java/it/sw/pa/comune/artegna/service/mapper/DisponibilitaMapperTest.java new file mode 100644 index 0000000..29b53b4 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/mapper/DisponibilitaMapperTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import static it.sw.pa.comune.artegna.domain.DisponibilitaAsserts.*; +import static it.sw.pa.comune.artegna.domain.DisponibilitaTestSamples.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class DisponibilitaMapperTest { + + private DisponibilitaMapper disponibilitaMapper; + + @BeforeEach + void setUp() { + disponibilitaMapper = new DisponibilitaMapperImpl(); + } + + @Test + void shouldConvertToDtoAndBack() { + var expected = getDisponibilitaSample1(); + var actual = disponibilitaMapper.toEntity(disponibilitaMapper.toDto(expected)); + assertDisponibilitaAllPropertiesEquals(expected, actual); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/mapper/LiberatoriaMapperTest.java b/src/test/java/it/sw/pa/comune/artegna/service/mapper/LiberatoriaMapperTest.java new file mode 100644 index 0000000..75c1c2d --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/mapper/LiberatoriaMapperTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import static it.sw.pa.comune.artegna.domain.LiberatoriaAsserts.*; +import static it.sw.pa.comune.artegna.domain.LiberatoriaTestSamples.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class LiberatoriaMapperTest { + + private LiberatoriaMapper liberatoriaMapper; + + @BeforeEach + void setUp() { + liberatoriaMapper = new LiberatoriaMapperImpl(); + } + + @Test + void shouldConvertToDtoAndBack() { + var expected = getLiberatoriaSample1(); + var actual = liberatoriaMapper.toEntity(liberatoriaMapper.toDto(expected)); + assertLiberatoriaAllPropertiesEquals(expected, actual); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/mapper/MessaggioMapperTest.java b/src/test/java/it/sw/pa/comune/artegna/service/mapper/MessaggioMapperTest.java new file mode 100644 index 0000000..108dff9 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/mapper/MessaggioMapperTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import static it.sw.pa.comune.artegna.domain.MessaggioAsserts.*; +import static it.sw.pa.comune.artegna.domain.MessaggioTestSamples.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class MessaggioMapperTest { + + private MessaggioMapper messaggioMapper; + + @BeforeEach + void setUp() { + messaggioMapper = new MessaggioMapperImpl(); + } + + @Test + void shouldConvertToDtoAndBack() { + var expected = getMessaggioSample1(); + var actual = messaggioMapper.toEntity(messaggioMapper.toDto(expected)); + assertMessaggioAllPropertiesEquals(expected, actual); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/mapper/ModelloLiberatoriaMapperTest.java b/src/test/java/it/sw/pa/comune/artegna/service/mapper/ModelloLiberatoriaMapperTest.java new file mode 100644 index 0000000..01f5ff4 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/mapper/ModelloLiberatoriaMapperTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import static it.sw.pa.comune.artegna.domain.ModelloLiberatoriaAsserts.*; +import static it.sw.pa.comune.artegna.domain.ModelloLiberatoriaTestSamples.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class ModelloLiberatoriaMapperTest { + + private ModelloLiberatoriaMapper modelloLiberatoriaMapper; + + @BeforeEach + void setUp() { + modelloLiberatoriaMapper = new ModelloLiberatoriaMapperImpl(); + } + + @Test + void shouldConvertToDtoAndBack() { + var expected = getModelloLiberatoriaSample1(); + var actual = modelloLiberatoriaMapper.toEntity(modelloLiberatoriaMapper.toDto(expected)); + assertModelloLiberatoriaAllPropertiesEquals(expected, actual); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/mapper/NotificaMapperTest.java b/src/test/java/it/sw/pa/comune/artegna/service/mapper/NotificaMapperTest.java new file mode 100644 index 0000000..fc32426 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/mapper/NotificaMapperTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import static it.sw.pa.comune.artegna.domain.NotificaAsserts.*; +import static it.sw.pa.comune.artegna.domain.NotificaTestSamples.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class NotificaMapperTest { + + private NotificaMapper notificaMapper; + + @BeforeEach + void setUp() { + notificaMapper = new NotificaMapperImpl(); + } + + @Test + void shouldConvertToDtoAndBack() { + var expected = getNotificaSample1(); + var actual = notificaMapper.toEntity(notificaMapper.toDto(expected)); + assertNotificaAllPropertiesEquals(expected, actual); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/mapper/PrenotazioneMapperTest.java b/src/test/java/it/sw/pa/comune/artegna/service/mapper/PrenotazioneMapperTest.java new file mode 100644 index 0000000..d8c73c0 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/mapper/PrenotazioneMapperTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import static it.sw.pa.comune.artegna.domain.PrenotazioneAsserts.*; +import static it.sw.pa.comune.artegna.domain.PrenotazioneTestSamples.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class PrenotazioneMapperTest { + + private PrenotazioneMapper prenotazioneMapper; + + @BeforeEach + void setUp() { + prenotazioneMapper = new PrenotazioneMapperImpl(); + } + + @Test + void shouldConvertToDtoAndBack() { + var expected = getPrenotazioneSample1(); + var actual = prenotazioneMapper.toEntity(prenotazioneMapper.toDto(expected)); + assertPrenotazioneAllPropertiesEquals(expected, actual); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/mapper/StrutturaMapperTest.java b/src/test/java/it/sw/pa/comune/artegna/service/mapper/StrutturaMapperTest.java new file mode 100644 index 0000000..948dcaf --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/mapper/StrutturaMapperTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import static it.sw.pa.comune.artegna.domain.StrutturaAsserts.*; +import static it.sw.pa.comune.artegna.domain.StrutturaTestSamples.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class StrutturaMapperTest { + + private StrutturaMapper strutturaMapper; + + @BeforeEach + void setUp() { + strutturaMapper = new StrutturaMapperImpl(); + } + + @Test + void shouldConvertToDtoAndBack() { + var expected = getStrutturaSample1(); + var actual = strutturaMapper.toEntity(strutturaMapper.toDto(expected)); + assertStrutturaAllPropertiesEquals(expected, actual); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/service/mapper/UtenteAppMapperTest.java b/src/test/java/it/sw/pa/comune/artegna/service/mapper/UtenteAppMapperTest.java new file mode 100644 index 0000000..8eebee9 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/service/mapper/UtenteAppMapperTest.java @@ -0,0 +1,24 @@ +package it.sw.pa.comune.artegna.service.mapper; + +import static it.sw.pa.comune.artegna.domain.UtenteAppAsserts.*; +import static it.sw.pa.comune.artegna.domain.UtenteAppTestSamples.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class UtenteAppMapperTest { + + private UtenteAppMapper utenteAppMapper; + + @BeforeEach + void setUp() { + utenteAppMapper = new UtenteAppMapperImpl(); + } + + @Test + void shouldConvertToDtoAndBack() { + var expected = getUtenteAppSample1(); + var actual = utenteAppMapper.toEntity(utenteAppMapper.toDto(expected)); + assertUtenteAppAllPropertiesEquals(expected, actual); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/web/rest/AuditLogResourceIT.java b/src/test/java/it/sw/pa/comune/artegna/web/rest/AuditLogResourceIT.java new file mode 100644 index 0000000..12c0988 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/web/rest/AuditLogResourceIT.java @@ -0,0 +1,876 @@ +package it.sw.pa.comune.artegna.web.rest; + +import static it.sw.pa.comune.artegna.domain.AuditLogAsserts.*; +import static it.sw.pa.comune.artegna.web.rest.TestUtil.createUpdateProxyForBean; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.mockito.Mockito.*; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import it.sw.pa.comune.artegna.IntegrationTest; +import it.sw.pa.comune.artegna.domain.AuditLog; +import it.sw.pa.comune.artegna.domain.UtenteApp; +import it.sw.pa.comune.artegna.domain.enumeration.AzioneAudit; +import it.sw.pa.comune.artegna.domain.enumeration.TipoEntita; +import it.sw.pa.comune.artegna.repository.AuditLogRepository; +import it.sw.pa.comune.artegna.service.AuditLogService; +import it.sw.pa.comune.artegna.service.dto.AuditLogDTO; +import it.sw.pa.comune.artegna.service.mapper.AuditLogMapper; +import jakarta.persistence.EntityManager; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +/** + * Integration tests for the {@link AuditLogResource} REST controller. + */ +@IntegrationTest +@ExtendWith(MockitoExtension.class) +@AutoConfigureMockMvc +@WithMockUser +class AuditLogResourceIT { + + private static final TipoEntita DEFAULT_ENTITA_TIPO = TipoEntita.PRENOTAZIONE; + private static final TipoEntita UPDATED_ENTITA_TIPO = TipoEntita.CONFERMA; + + private static final Long DEFAULT_ENTITA_ID = 1L; + private static final Long UPDATED_ENTITA_ID = 2L; + private static final Long SMALLER_ENTITA_ID = 1L - 1L; + + private static final AzioneAudit DEFAULT_AZIONE = AzioneAudit.CREATE; + private static final AzioneAudit UPDATED_AZIONE = AzioneAudit.UPDATE; + + private static final String DEFAULT_DETTAGLI = "AAAAAAAAAA"; + private static final String UPDATED_DETTAGLI = "BBBBBBBBBB"; + + private static final String DEFAULT_IP_ADDRESS = "AAAAAAAAAA"; + private static final String UPDATED_IP_ADDRESS = "BBBBBBBBBB"; + + private static final Instant DEFAULT_CREATED_AT = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_CREATED_AT = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final String ENTITY_API_URL = "/api/audit-logs"; + private static final String ENTITY_API_URL_ID = ENTITY_API_URL + "/{id}"; + + private static Random random = new Random(); + private static AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + @Autowired + private ObjectMapper om; + + @Autowired + private AuditLogRepository auditLogRepository; + + @Mock + private AuditLogRepository auditLogRepositoryMock; + + @Autowired + private AuditLogMapper auditLogMapper; + + @Mock + private AuditLogService auditLogServiceMock; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restAuditLogMockMvc; + + private AuditLog auditLog; + + private AuditLog insertedAuditLog; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static AuditLog createEntity() { + return new AuditLog() + .entitaTipo(DEFAULT_ENTITA_TIPO) + .entitaId(DEFAULT_ENTITA_ID) + .azione(DEFAULT_AZIONE) + .dettagli(DEFAULT_DETTAGLI) + .ipAddress(DEFAULT_IP_ADDRESS) + .createdAt(DEFAULT_CREATED_AT); + } + + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static AuditLog createUpdatedEntity() { + return new AuditLog() + .entitaTipo(UPDATED_ENTITA_TIPO) + .entitaId(UPDATED_ENTITA_ID) + .azione(UPDATED_AZIONE) + .dettagli(UPDATED_DETTAGLI) + .ipAddress(UPDATED_IP_ADDRESS) + .createdAt(UPDATED_CREATED_AT); + } + + @BeforeEach + void initTest() { + auditLog = createEntity(); + } + + @AfterEach + void cleanup() { + if (insertedAuditLog != null) { + auditLogRepository.delete(insertedAuditLog); + insertedAuditLog = null; + } + } + + @Test + @Transactional + void createAuditLog() throws Exception { + long databaseSizeBeforeCreate = getRepositoryCount(); + // Create the AuditLog + AuditLogDTO auditLogDTO = auditLogMapper.toDto(auditLog); + var returnedAuditLogDTO = om.readValue( + restAuditLogMockMvc + .perform( + post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(auditLogDTO)) + ) + .andExpect(status().isCreated()) + .andReturn() + .getResponse() + .getContentAsString(), + AuditLogDTO.class + ); + + // Validate the AuditLog in the database + assertIncrementedRepositoryCount(databaseSizeBeforeCreate); + var returnedAuditLog = auditLogMapper.toEntity(returnedAuditLogDTO); + assertAuditLogUpdatableFieldsEquals(returnedAuditLog, getPersistedAuditLog(returnedAuditLog)); + + insertedAuditLog = returnedAuditLog; + } + + @Test + @Transactional + void createAuditLogWithExistingId() throws Exception { + // Create the AuditLog with an existing ID + auditLog.setId(1L); + AuditLogDTO auditLogDTO = auditLogMapper.toDto(auditLog); + + long databaseSizeBeforeCreate = getRepositoryCount(); + + // An entity with an existing ID cannot be created, so this API call must fail + restAuditLogMockMvc + .perform(post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(auditLogDTO))) + .andExpect(status().isBadRequest()); + + // Validate the AuditLog in the database + assertSameRepositoryCount(databaseSizeBeforeCreate); + } + + @Test + @Transactional + void getAllAuditLogs() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList + restAuditLogMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(auditLog.getId().intValue()))) + .andExpect(jsonPath("$.[*].entitaTipo").value(hasItem(DEFAULT_ENTITA_TIPO.toString()))) + .andExpect(jsonPath("$.[*].entitaId").value(hasItem(DEFAULT_ENTITA_ID.intValue()))) + .andExpect(jsonPath("$.[*].azione").value(hasItem(DEFAULT_AZIONE.toString()))) + .andExpect(jsonPath("$.[*].dettagli").value(hasItem(DEFAULT_DETTAGLI))) + .andExpect(jsonPath("$.[*].ipAddress").value(hasItem(DEFAULT_IP_ADDRESS))) + .andExpect(jsonPath("$.[*].createdAt").value(hasItem(DEFAULT_CREATED_AT.toString()))); + } + + @SuppressWarnings({ "unchecked" }) + void getAllAuditLogsWithEagerRelationshipsIsEnabled() throws Exception { + when(auditLogServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restAuditLogMockMvc.perform(get(ENTITY_API_URL + "?eagerload=true")).andExpect(status().isOk()); + + verify(auditLogServiceMock, times(1)).findAllWithEagerRelationships(any()); + } + + @SuppressWarnings({ "unchecked" }) + void getAllAuditLogsWithEagerRelationshipsIsNotEnabled() throws Exception { + when(auditLogServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restAuditLogMockMvc.perform(get(ENTITY_API_URL + "?eagerload=false")).andExpect(status().isOk()); + verify(auditLogRepositoryMock, times(1)).findAll(any(Pageable.class)); + } + + @Test + @Transactional + void getAuditLog() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get the auditLog + restAuditLogMockMvc + .perform(get(ENTITY_API_URL_ID, auditLog.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(auditLog.getId().intValue())) + .andExpect(jsonPath("$.entitaTipo").value(DEFAULT_ENTITA_TIPO.toString())) + .andExpect(jsonPath("$.entitaId").value(DEFAULT_ENTITA_ID.intValue())) + .andExpect(jsonPath("$.azione").value(DEFAULT_AZIONE.toString())) + .andExpect(jsonPath("$.dettagli").value(DEFAULT_DETTAGLI)) + .andExpect(jsonPath("$.ipAddress").value(DEFAULT_IP_ADDRESS)) + .andExpect(jsonPath("$.createdAt").value(DEFAULT_CREATED_AT.toString())); + } + + @Test + @Transactional + void getAuditLogsByIdFiltering() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + Long id = auditLog.getId(); + + defaultAuditLogFiltering("id.equals=" + id, "id.notEquals=" + id); + + defaultAuditLogFiltering("id.greaterThanOrEqual=" + id, "id.greaterThan=" + id); + + defaultAuditLogFiltering("id.lessThanOrEqual=" + id, "id.lessThan=" + id); + } + + @Test + @Transactional + void getAllAuditLogsByEntitaTipoIsEqualToSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where entitaTipo equals to + defaultAuditLogFiltering("entitaTipo.equals=" + DEFAULT_ENTITA_TIPO, "entitaTipo.equals=" + UPDATED_ENTITA_TIPO); + } + + @Test + @Transactional + void getAllAuditLogsByEntitaTipoIsInShouldWork() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where entitaTipo in + defaultAuditLogFiltering( + "entitaTipo.in=" + DEFAULT_ENTITA_TIPO + "," + UPDATED_ENTITA_TIPO, + "entitaTipo.in=" + UPDATED_ENTITA_TIPO + ); + } + + @Test + @Transactional + void getAllAuditLogsByEntitaTipoIsNullOrNotNull() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where entitaTipo is not null + defaultAuditLogFiltering("entitaTipo.specified=true", "entitaTipo.specified=false"); + } + + @Test + @Transactional + void getAllAuditLogsByEntitaIdIsEqualToSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where entitaId equals to + defaultAuditLogFiltering("entitaId.equals=" + DEFAULT_ENTITA_ID, "entitaId.equals=" + UPDATED_ENTITA_ID); + } + + @Test + @Transactional + void getAllAuditLogsByEntitaIdIsInShouldWork() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where entitaId in + defaultAuditLogFiltering("entitaId.in=" + DEFAULT_ENTITA_ID + "," + UPDATED_ENTITA_ID, "entitaId.in=" + UPDATED_ENTITA_ID); + } + + @Test + @Transactional + void getAllAuditLogsByEntitaIdIsNullOrNotNull() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where entitaId is not null + defaultAuditLogFiltering("entitaId.specified=true", "entitaId.specified=false"); + } + + @Test + @Transactional + void getAllAuditLogsByEntitaIdIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where entitaId is greater than or equal to + defaultAuditLogFiltering("entitaId.greaterThanOrEqual=" + DEFAULT_ENTITA_ID, "entitaId.greaterThanOrEqual=" + UPDATED_ENTITA_ID); + } + + @Test + @Transactional + void getAllAuditLogsByEntitaIdIsLessThanOrEqualToSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where entitaId is less than or equal to + defaultAuditLogFiltering("entitaId.lessThanOrEqual=" + DEFAULT_ENTITA_ID, "entitaId.lessThanOrEqual=" + SMALLER_ENTITA_ID); + } + + @Test + @Transactional + void getAllAuditLogsByEntitaIdIsLessThanSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where entitaId is less than + defaultAuditLogFiltering("entitaId.lessThan=" + UPDATED_ENTITA_ID, "entitaId.lessThan=" + DEFAULT_ENTITA_ID); + } + + @Test + @Transactional + void getAllAuditLogsByEntitaIdIsGreaterThanSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where entitaId is greater than + defaultAuditLogFiltering("entitaId.greaterThan=" + SMALLER_ENTITA_ID, "entitaId.greaterThan=" + DEFAULT_ENTITA_ID); + } + + @Test + @Transactional + void getAllAuditLogsByAzioneIsEqualToSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where azione equals to + defaultAuditLogFiltering("azione.equals=" + DEFAULT_AZIONE, "azione.equals=" + UPDATED_AZIONE); + } + + @Test + @Transactional + void getAllAuditLogsByAzioneIsInShouldWork() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where azione in + defaultAuditLogFiltering("azione.in=" + DEFAULT_AZIONE + "," + UPDATED_AZIONE, "azione.in=" + UPDATED_AZIONE); + } + + @Test + @Transactional + void getAllAuditLogsByAzioneIsNullOrNotNull() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where azione is not null + defaultAuditLogFiltering("azione.specified=true", "azione.specified=false"); + } + + @Test + @Transactional + void getAllAuditLogsByDettagliIsEqualToSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where dettagli equals to + defaultAuditLogFiltering("dettagli.equals=" + DEFAULT_DETTAGLI, "dettagli.equals=" + UPDATED_DETTAGLI); + } + + @Test + @Transactional + void getAllAuditLogsByDettagliIsInShouldWork() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where dettagli in + defaultAuditLogFiltering("dettagli.in=" + DEFAULT_DETTAGLI + "," + UPDATED_DETTAGLI, "dettagli.in=" + UPDATED_DETTAGLI); + } + + @Test + @Transactional + void getAllAuditLogsByDettagliIsNullOrNotNull() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where dettagli is not null + defaultAuditLogFiltering("dettagli.specified=true", "dettagli.specified=false"); + } + + @Test + @Transactional + void getAllAuditLogsByDettagliContainsSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where dettagli contains + defaultAuditLogFiltering("dettagli.contains=" + DEFAULT_DETTAGLI, "dettagli.contains=" + UPDATED_DETTAGLI); + } + + @Test + @Transactional + void getAllAuditLogsByDettagliNotContainsSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where dettagli does not contain + defaultAuditLogFiltering("dettagli.doesNotContain=" + UPDATED_DETTAGLI, "dettagli.doesNotContain=" + DEFAULT_DETTAGLI); + } + + @Test + @Transactional + void getAllAuditLogsByIpAddressIsEqualToSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where ipAddress equals to + defaultAuditLogFiltering("ipAddress.equals=" + DEFAULT_IP_ADDRESS, "ipAddress.equals=" + UPDATED_IP_ADDRESS); + } + + @Test + @Transactional + void getAllAuditLogsByIpAddressIsInShouldWork() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where ipAddress in + defaultAuditLogFiltering("ipAddress.in=" + DEFAULT_IP_ADDRESS + "," + UPDATED_IP_ADDRESS, "ipAddress.in=" + UPDATED_IP_ADDRESS); + } + + @Test + @Transactional + void getAllAuditLogsByIpAddressIsNullOrNotNull() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where ipAddress is not null + defaultAuditLogFiltering("ipAddress.specified=true", "ipAddress.specified=false"); + } + + @Test + @Transactional + void getAllAuditLogsByIpAddressContainsSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where ipAddress contains + defaultAuditLogFiltering("ipAddress.contains=" + DEFAULT_IP_ADDRESS, "ipAddress.contains=" + UPDATED_IP_ADDRESS); + } + + @Test + @Transactional + void getAllAuditLogsByIpAddressNotContainsSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where ipAddress does not contain + defaultAuditLogFiltering("ipAddress.doesNotContain=" + UPDATED_IP_ADDRESS, "ipAddress.doesNotContain=" + DEFAULT_IP_ADDRESS); + } + + @Test + @Transactional + void getAllAuditLogsByCreatedAtIsEqualToSomething() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where createdAt equals to + defaultAuditLogFiltering("createdAt.equals=" + DEFAULT_CREATED_AT, "createdAt.equals=" + UPDATED_CREATED_AT); + } + + @Test + @Transactional + void getAllAuditLogsByCreatedAtIsInShouldWork() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where createdAt in + defaultAuditLogFiltering("createdAt.in=" + DEFAULT_CREATED_AT + "," + UPDATED_CREATED_AT, "createdAt.in=" + UPDATED_CREATED_AT); + } + + @Test + @Transactional + void getAllAuditLogsByCreatedAtIsNullOrNotNull() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + // Get all the auditLogList where createdAt is not null + defaultAuditLogFiltering("createdAt.specified=true", "createdAt.specified=false"); + } + + @Test + @Transactional + void getAllAuditLogsByUtenteIsEqualToSomething() throws Exception { + UtenteApp utente; + if (TestUtil.findAll(em, UtenteApp.class).isEmpty()) { + auditLogRepository.saveAndFlush(auditLog); + utente = UtenteAppResourceIT.createEntity(); + } else { + utente = TestUtil.findAll(em, UtenteApp.class).get(0); + } + em.persist(utente); + em.flush(); + auditLog.setUtente(utente); + auditLogRepository.saveAndFlush(auditLog); + Long utenteId = utente.getId(); + // Get all the auditLogList where utente equals to utenteId + defaultAuditLogShouldBeFound("utenteId.equals=" + utenteId); + + // Get all the auditLogList where utente equals to (utenteId + 1) + defaultAuditLogShouldNotBeFound("utenteId.equals=" + (utenteId + 1)); + } + + private void defaultAuditLogFiltering(String shouldBeFound, String shouldNotBeFound) throws Exception { + defaultAuditLogShouldBeFound(shouldBeFound); + defaultAuditLogShouldNotBeFound(shouldNotBeFound); + } + + /** + * Executes the search, and checks that the default entity is returned. + */ + private void defaultAuditLogShouldBeFound(String filter) throws Exception { + restAuditLogMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(auditLog.getId().intValue()))) + .andExpect(jsonPath("$.[*].entitaTipo").value(hasItem(DEFAULT_ENTITA_TIPO.toString()))) + .andExpect(jsonPath("$.[*].entitaId").value(hasItem(DEFAULT_ENTITA_ID.intValue()))) + .andExpect(jsonPath("$.[*].azione").value(hasItem(DEFAULT_AZIONE.toString()))) + .andExpect(jsonPath("$.[*].dettagli").value(hasItem(DEFAULT_DETTAGLI))) + .andExpect(jsonPath("$.[*].ipAddress").value(hasItem(DEFAULT_IP_ADDRESS))) + .andExpect(jsonPath("$.[*].createdAt").value(hasItem(DEFAULT_CREATED_AT.toString()))); + + // Check, that the count call also returns 1 + restAuditLogMockMvc + .perform(get(ENTITY_API_URL + "/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(content().string("1")); + } + + /** + * Executes the search, and checks that the default entity is not returned. + */ + private void defaultAuditLogShouldNotBeFound(String filter) throws Exception { + restAuditLogMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$").isArray()) + .andExpect(jsonPath("$").isEmpty()); + + // Check, that the count call also returns 0 + restAuditLogMockMvc + .perform(get(ENTITY_API_URL + "/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(content().string("0")); + } + + @Test + @Transactional + void getNonExistingAuditLog() throws Exception { + // Get the auditLog + restAuditLogMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound()); + } + + @Test + @Transactional + void putExistingAuditLog() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the auditLog + AuditLog updatedAuditLog = auditLogRepository.findById(auditLog.getId()).orElseThrow(); + // Disconnect from session so that the updates on updatedAuditLog are not directly saved in db + em.detach(updatedAuditLog); + updatedAuditLog + .entitaTipo(UPDATED_ENTITA_TIPO) + .entitaId(UPDATED_ENTITA_ID) + .azione(UPDATED_AZIONE) + .dettagli(UPDATED_DETTAGLI) + .ipAddress(UPDATED_IP_ADDRESS) + .createdAt(UPDATED_CREATED_AT); + AuditLogDTO auditLogDTO = auditLogMapper.toDto(updatedAuditLog); + + restAuditLogMockMvc + .perform( + put(ENTITY_API_URL_ID, auditLogDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(auditLogDTO)) + ) + .andExpect(status().isOk()); + + // Validate the AuditLog in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertPersistedAuditLogToMatchAllProperties(updatedAuditLog); + } + + @Test + @Transactional + void putNonExistingAuditLog() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + auditLog.setId(longCount.incrementAndGet()); + + // Create the AuditLog + AuditLogDTO auditLogDTO = auditLogMapper.toDto(auditLog); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restAuditLogMockMvc + .perform( + put(ENTITY_API_URL_ID, auditLogDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(auditLogDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the AuditLog in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithIdMismatchAuditLog() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + auditLog.setId(longCount.incrementAndGet()); + + // Create the AuditLog + AuditLogDTO auditLogDTO = auditLogMapper.toDto(auditLog); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restAuditLogMockMvc + .perform( + put(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(auditLogDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the AuditLog in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithMissingIdPathParamAuditLog() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + auditLog.setId(longCount.incrementAndGet()); + + // Create the AuditLog + AuditLogDTO auditLogDTO = auditLogMapper.toDto(auditLog); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restAuditLogMockMvc + .perform(put(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(auditLogDTO))) + .andExpect(status().isMethodNotAllowed()); + + // Validate the AuditLog in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void partialUpdateAuditLogWithPatch() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the auditLog using partial update + AuditLog partialUpdatedAuditLog = new AuditLog(); + partialUpdatedAuditLog.setId(auditLog.getId()); + + partialUpdatedAuditLog.entitaTipo(UPDATED_ENTITA_TIPO); + + restAuditLogMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedAuditLog.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedAuditLog)) + ) + .andExpect(status().isOk()); + + // Validate the AuditLog in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertAuditLogUpdatableFieldsEquals(createUpdateProxyForBean(partialUpdatedAuditLog, auditLog), getPersistedAuditLog(auditLog)); + } + + @Test + @Transactional + void fullUpdateAuditLogWithPatch() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the auditLog using partial update + AuditLog partialUpdatedAuditLog = new AuditLog(); + partialUpdatedAuditLog.setId(auditLog.getId()); + + partialUpdatedAuditLog + .entitaTipo(UPDATED_ENTITA_TIPO) + .entitaId(UPDATED_ENTITA_ID) + .azione(UPDATED_AZIONE) + .dettagli(UPDATED_DETTAGLI) + .ipAddress(UPDATED_IP_ADDRESS) + .createdAt(UPDATED_CREATED_AT); + + restAuditLogMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedAuditLog.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedAuditLog)) + ) + .andExpect(status().isOk()); + + // Validate the AuditLog in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertAuditLogUpdatableFieldsEquals(partialUpdatedAuditLog, getPersistedAuditLog(partialUpdatedAuditLog)); + } + + @Test + @Transactional + void patchNonExistingAuditLog() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + auditLog.setId(longCount.incrementAndGet()); + + // Create the AuditLog + AuditLogDTO auditLogDTO = auditLogMapper.toDto(auditLog); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restAuditLogMockMvc + .perform( + patch(ENTITY_API_URL_ID, auditLogDTO.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(auditLogDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the AuditLog in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithIdMismatchAuditLog() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + auditLog.setId(longCount.incrementAndGet()); + + // Create the AuditLog + AuditLogDTO auditLogDTO = auditLogMapper.toDto(auditLog); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restAuditLogMockMvc + .perform( + patch(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(auditLogDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the AuditLog in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithMissingIdPathParamAuditLog() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + auditLog.setId(longCount.incrementAndGet()); + + // Create the AuditLog + AuditLogDTO auditLogDTO = auditLogMapper.toDto(auditLog); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restAuditLogMockMvc + .perform( + patch(ENTITY_API_URL).with(csrf()).contentType("application/merge-patch+json").content(om.writeValueAsBytes(auditLogDTO)) + ) + .andExpect(status().isMethodNotAllowed()); + + // Validate the AuditLog in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void deleteAuditLog() throws Exception { + // Initialize the database + insertedAuditLog = auditLogRepository.saveAndFlush(auditLog); + + long databaseSizeBeforeDelete = getRepositoryCount(); + + // Delete the auditLog + restAuditLogMockMvc + .perform(delete(ENTITY_API_URL_ID, auditLog.getId()).with(csrf()).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + assertDecrementedRepositoryCount(databaseSizeBeforeDelete); + } + + protected long getRepositoryCount() { + return auditLogRepository.count(); + } + + protected void assertIncrementedRepositoryCount(long countBefore) { + assertThat(countBefore + 1).isEqualTo(getRepositoryCount()); + } + + protected void assertDecrementedRepositoryCount(long countBefore) { + assertThat(countBefore - 1).isEqualTo(getRepositoryCount()); + } + + protected void assertSameRepositoryCount(long countBefore) { + assertThat(countBefore).isEqualTo(getRepositoryCount()); + } + + protected AuditLog getPersistedAuditLog(AuditLog auditLog) { + return auditLogRepository.findById(auditLog.getId()).orElseThrow(); + } + + protected void assertPersistedAuditLogToMatchAllProperties(AuditLog expectedAuditLog) { + assertAuditLogAllPropertiesEquals(expectedAuditLog, getPersistedAuditLog(expectedAuditLog)); + } + + protected void assertPersistedAuditLogToMatchUpdatableProperties(AuditLog expectedAuditLog) { + assertAuditLogAllUpdatablePropertiesEquals(expectedAuditLog, getPersistedAuditLog(expectedAuditLog)); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/web/rest/ConfermaResourceIT.java b/src/test/java/it/sw/pa/comune/artegna/web/rest/ConfermaResourceIT.java new file mode 100644 index 0000000..01e6f3d --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/web/rest/ConfermaResourceIT.java @@ -0,0 +1,653 @@ +package it.sw.pa.comune.artegna.web.rest; + +import static it.sw.pa.comune.artegna.domain.ConfermaAsserts.*; +import static it.sw.pa.comune.artegna.web.rest.TestUtil.createUpdateProxyForBean; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.mockito.Mockito.*; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import it.sw.pa.comune.artegna.IntegrationTest; +import it.sw.pa.comune.artegna.domain.Conferma; +import it.sw.pa.comune.artegna.domain.UtenteApp; +import it.sw.pa.comune.artegna.domain.enumeration.TipoConferma; +import it.sw.pa.comune.artegna.repository.ConfermaRepository; +import it.sw.pa.comune.artegna.service.ConfermaService; +import it.sw.pa.comune.artegna.service.dto.ConfermaDTO; +import it.sw.pa.comune.artegna.service.mapper.ConfermaMapper; +import jakarta.persistence.EntityManager; +import java.util.ArrayList; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +/** + * Integration tests for the {@link ConfermaResource} REST controller. + */ +@IntegrationTest +@ExtendWith(MockitoExtension.class) +@AutoConfigureMockMvc +@WithMockUser +class ConfermaResourceIT { + + private static final String DEFAULT_MOTIVO_CONFERMA = "AAAAAAAAAA"; + private static final String UPDATED_MOTIVO_CONFERMA = "BBBBBBBBBB"; + + private static final TipoConferma DEFAULT_TIPO_CONFERMA = TipoConferma.CONFERMATA; + private static final TipoConferma UPDATED_TIPO_CONFERMA = TipoConferma.RIFIUTATA; + + private static final String ENTITY_API_URL = "/api/confermas"; + private static final String ENTITY_API_URL_ID = ENTITY_API_URL + "/{id}"; + + private static Random random = new Random(); + private static AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + @Autowired + private ObjectMapper om; + + @Autowired + private ConfermaRepository confermaRepository; + + @Mock + private ConfermaRepository confermaRepositoryMock; + + @Autowired + private ConfermaMapper confermaMapper; + + @Mock + private ConfermaService confermaServiceMock; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restConfermaMockMvc; + + private Conferma conferma; + + private Conferma insertedConferma; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Conferma createEntity() { + return new Conferma().motivoConferma(DEFAULT_MOTIVO_CONFERMA).tipoConferma(DEFAULT_TIPO_CONFERMA); + } + + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Conferma createUpdatedEntity() { + return new Conferma().motivoConferma(UPDATED_MOTIVO_CONFERMA).tipoConferma(UPDATED_TIPO_CONFERMA); + } + + @BeforeEach + void initTest() { + conferma = createEntity(); + } + + @AfterEach + void cleanup() { + if (insertedConferma != null) { + confermaRepository.delete(insertedConferma); + insertedConferma = null; + } + } + + @Test + @Transactional + void createConferma() throws Exception { + long databaseSizeBeforeCreate = getRepositoryCount(); + // Create the Conferma + ConfermaDTO confermaDTO = confermaMapper.toDto(conferma); + var returnedConfermaDTO = om.readValue( + restConfermaMockMvc + .perform( + post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(confermaDTO)) + ) + .andExpect(status().isCreated()) + .andReturn() + .getResponse() + .getContentAsString(), + ConfermaDTO.class + ); + + // Validate the Conferma in the database + assertIncrementedRepositoryCount(databaseSizeBeforeCreate); + var returnedConferma = confermaMapper.toEntity(returnedConfermaDTO); + assertConfermaUpdatableFieldsEquals(returnedConferma, getPersistedConferma(returnedConferma)); + + insertedConferma = returnedConferma; + } + + @Test + @Transactional + void createConfermaWithExistingId() throws Exception { + // Create the Conferma with an existing ID + conferma.setId(1L); + ConfermaDTO confermaDTO = confermaMapper.toDto(conferma); + + long databaseSizeBeforeCreate = getRepositoryCount(); + + // An entity with an existing ID cannot be created, so this API call must fail + restConfermaMockMvc + .perform(post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(confermaDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Conferma in the database + assertSameRepositoryCount(databaseSizeBeforeCreate); + } + + @Test + @Transactional + void getAllConfermas() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + // Get all the confermaList + restConfermaMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(conferma.getId().intValue()))) + .andExpect(jsonPath("$.[*].motivoConferma").value(hasItem(DEFAULT_MOTIVO_CONFERMA))) + .andExpect(jsonPath("$.[*].tipoConferma").value(hasItem(DEFAULT_TIPO_CONFERMA.toString()))); + } + + @SuppressWarnings({ "unchecked" }) + void getAllConfermasWithEagerRelationshipsIsEnabled() throws Exception { + when(confermaServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restConfermaMockMvc.perform(get(ENTITY_API_URL + "?eagerload=true")).andExpect(status().isOk()); + + verify(confermaServiceMock, times(1)).findAllWithEagerRelationships(any()); + } + + @SuppressWarnings({ "unchecked" }) + void getAllConfermasWithEagerRelationshipsIsNotEnabled() throws Exception { + when(confermaServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restConfermaMockMvc.perform(get(ENTITY_API_URL + "?eagerload=false")).andExpect(status().isOk()); + verify(confermaRepositoryMock, times(1)).findAll(any(Pageable.class)); + } + + @Test + @Transactional + void getConferma() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + // Get the conferma + restConfermaMockMvc + .perform(get(ENTITY_API_URL_ID, conferma.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(conferma.getId().intValue())) + .andExpect(jsonPath("$.motivoConferma").value(DEFAULT_MOTIVO_CONFERMA)) + .andExpect(jsonPath("$.tipoConferma").value(DEFAULT_TIPO_CONFERMA.toString())); + } + + @Test + @Transactional + void getConfermasByIdFiltering() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + Long id = conferma.getId(); + + defaultConfermaFiltering("id.equals=" + id, "id.notEquals=" + id); + + defaultConfermaFiltering("id.greaterThanOrEqual=" + id, "id.greaterThan=" + id); + + defaultConfermaFiltering("id.lessThanOrEqual=" + id, "id.lessThan=" + id); + } + + @Test + @Transactional + void getAllConfermasByMotivoConfermaIsEqualToSomething() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + // Get all the confermaList where motivoConferma equals to + defaultConfermaFiltering("motivoConferma.equals=" + DEFAULT_MOTIVO_CONFERMA, "motivoConferma.equals=" + UPDATED_MOTIVO_CONFERMA); + } + + @Test + @Transactional + void getAllConfermasByMotivoConfermaIsInShouldWork() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + // Get all the confermaList where motivoConferma in + defaultConfermaFiltering( + "motivoConferma.in=" + DEFAULT_MOTIVO_CONFERMA + "," + UPDATED_MOTIVO_CONFERMA, + "motivoConferma.in=" + UPDATED_MOTIVO_CONFERMA + ); + } + + @Test + @Transactional + void getAllConfermasByMotivoConfermaIsNullOrNotNull() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + // Get all the confermaList where motivoConferma is not null + defaultConfermaFiltering("motivoConferma.specified=true", "motivoConferma.specified=false"); + } + + @Test + @Transactional + void getAllConfermasByMotivoConfermaContainsSomething() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + // Get all the confermaList where motivoConferma contains + defaultConfermaFiltering( + "motivoConferma.contains=" + DEFAULT_MOTIVO_CONFERMA, + "motivoConferma.contains=" + UPDATED_MOTIVO_CONFERMA + ); + } + + @Test + @Transactional + void getAllConfermasByMotivoConfermaNotContainsSomething() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + // Get all the confermaList where motivoConferma does not contain + defaultConfermaFiltering( + "motivoConferma.doesNotContain=" + UPDATED_MOTIVO_CONFERMA, + "motivoConferma.doesNotContain=" + DEFAULT_MOTIVO_CONFERMA + ); + } + + @Test + @Transactional + void getAllConfermasByTipoConfermaIsEqualToSomething() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + // Get all the confermaList where tipoConferma equals to + defaultConfermaFiltering("tipoConferma.equals=" + DEFAULT_TIPO_CONFERMA, "tipoConferma.equals=" + UPDATED_TIPO_CONFERMA); + } + + @Test + @Transactional + void getAllConfermasByTipoConfermaIsInShouldWork() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + // Get all the confermaList where tipoConferma in + defaultConfermaFiltering( + "tipoConferma.in=" + DEFAULT_TIPO_CONFERMA + "," + UPDATED_TIPO_CONFERMA, + "tipoConferma.in=" + UPDATED_TIPO_CONFERMA + ); + } + + @Test + @Transactional + void getAllConfermasByTipoConfermaIsNullOrNotNull() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + // Get all the confermaList where tipoConferma is not null + defaultConfermaFiltering("tipoConferma.specified=true", "tipoConferma.specified=false"); + } + + @Test + @Transactional + void getAllConfermasByConfermataDaIsEqualToSomething() throws Exception { + UtenteApp confermataDa; + if (TestUtil.findAll(em, UtenteApp.class).isEmpty()) { + confermaRepository.saveAndFlush(conferma); + confermataDa = UtenteAppResourceIT.createEntity(); + } else { + confermataDa = TestUtil.findAll(em, UtenteApp.class).get(0); + } + em.persist(confermataDa); + em.flush(); + conferma.setConfermataDa(confermataDa); + confermaRepository.saveAndFlush(conferma); + Long confermataDaId = confermataDa.getId(); + // Get all the confermaList where confermataDa equals to confermataDaId + defaultConfermaShouldBeFound("confermataDaId.equals=" + confermataDaId); + + // Get all the confermaList where confermataDa equals to (confermataDaId + 1) + defaultConfermaShouldNotBeFound("confermataDaId.equals=" + (confermataDaId + 1)); + } + + private void defaultConfermaFiltering(String shouldBeFound, String shouldNotBeFound) throws Exception { + defaultConfermaShouldBeFound(shouldBeFound); + defaultConfermaShouldNotBeFound(shouldNotBeFound); + } + + /** + * Executes the search, and checks that the default entity is returned. + */ + private void defaultConfermaShouldBeFound(String filter) throws Exception { + restConfermaMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(conferma.getId().intValue()))) + .andExpect(jsonPath("$.[*].motivoConferma").value(hasItem(DEFAULT_MOTIVO_CONFERMA))) + .andExpect(jsonPath("$.[*].tipoConferma").value(hasItem(DEFAULT_TIPO_CONFERMA.toString()))); + + // Check, that the count call also returns 1 + restConfermaMockMvc + .perform(get(ENTITY_API_URL + "/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(content().string("1")); + } + + /** + * Executes the search, and checks that the default entity is not returned. + */ + private void defaultConfermaShouldNotBeFound(String filter) throws Exception { + restConfermaMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$").isArray()) + .andExpect(jsonPath("$").isEmpty()); + + // Check, that the count call also returns 0 + restConfermaMockMvc + .perform(get(ENTITY_API_URL + "/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(content().string("0")); + } + + @Test + @Transactional + void getNonExistingConferma() throws Exception { + // Get the conferma + restConfermaMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound()); + } + + @Test + @Transactional + void putExistingConferma() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the conferma + Conferma updatedConferma = confermaRepository.findById(conferma.getId()).orElseThrow(); + // Disconnect from session so that the updates on updatedConferma are not directly saved in db + em.detach(updatedConferma); + updatedConferma.motivoConferma(UPDATED_MOTIVO_CONFERMA).tipoConferma(UPDATED_TIPO_CONFERMA); + ConfermaDTO confermaDTO = confermaMapper.toDto(updatedConferma); + + restConfermaMockMvc + .perform( + put(ENTITY_API_URL_ID, confermaDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(confermaDTO)) + ) + .andExpect(status().isOk()); + + // Validate the Conferma in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertPersistedConfermaToMatchAllProperties(updatedConferma); + } + + @Test + @Transactional + void putNonExistingConferma() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + conferma.setId(longCount.incrementAndGet()); + + // Create the Conferma + ConfermaDTO confermaDTO = confermaMapper.toDto(conferma); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restConfermaMockMvc + .perform( + put(ENTITY_API_URL_ID, confermaDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(confermaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Conferma in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithIdMismatchConferma() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + conferma.setId(longCount.incrementAndGet()); + + // Create the Conferma + ConfermaDTO confermaDTO = confermaMapper.toDto(conferma); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restConfermaMockMvc + .perform( + put(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(confermaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Conferma in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithMissingIdPathParamConferma() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + conferma.setId(longCount.incrementAndGet()); + + // Create the Conferma + ConfermaDTO confermaDTO = confermaMapper.toDto(conferma); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restConfermaMockMvc + .perform(put(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(confermaDTO))) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Conferma in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void partialUpdateConfermaWithPatch() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the conferma using partial update + Conferma partialUpdatedConferma = new Conferma(); + partialUpdatedConferma.setId(conferma.getId()); + + partialUpdatedConferma.tipoConferma(UPDATED_TIPO_CONFERMA); + + restConfermaMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedConferma.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedConferma)) + ) + .andExpect(status().isOk()); + + // Validate the Conferma in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertConfermaUpdatableFieldsEquals(createUpdateProxyForBean(partialUpdatedConferma, conferma), getPersistedConferma(conferma)); + } + + @Test + @Transactional + void fullUpdateConfermaWithPatch() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the conferma using partial update + Conferma partialUpdatedConferma = new Conferma(); + partialUpdatedConferma.setId(conferma.getId()); + + partialUpdatedConferma.motivoConferma(UPDATED_MOTIVO_CONFERMA).tipoConferma(UPDATED_TIPO_CONFERMA); + + restConfermaMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedConferma.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedConferma)) + ) + .andExpect(status().isOk()); + + // Validate the Conferma in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertConfermaUpdatableFieldsEquals(partialUpdatedConferma, getPersistedConferma(partialUpdatedConferma)); + } + + @Test + @Transactional + void patchNonExistingConferma() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + conferma.setId(longCount.incrementAndGet()); + + // Create the Conferma + ConfermaDTO confermaDTO = confermaMapper.toDto(conferma); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restConfermaMockMvc + .perform( + patch(ENTITY_API_URL_ID, confermaDTO.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(confermaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Conferma in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithIdMismatchConferma() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + conferma.setId(longCount.incrementAndGet()); + + // Create the Conferma + ConfermaDTO confermaDTO = confermaMapper.toDto(conferma); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restConfermaMockMvc + .perform( + patch(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(confermaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Conferma in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithMissingIdPathParamConferma() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + conferma.setId(longCount.incrementAndGet()); + + // Create the Conferma + ConfermaDTO confermaDTO = confermaMapper.toDto(conferma); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restConfermaMockMvc + .perform( + patch(ENTITY_API_URL).with(csrf()).contentType("application/merge-patch+json").content(om.writeValueAsBytes(confermaDTO)) + ) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Conferma in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void deleteConferma() throws Exception { + // Initialize the database + insertedConferma = confermaRepository.saveAndFlush(conferma); + + long databaseSizeBeforeDelete = getRepositoryCount(); + + // Delete the conferma + restConfermaMockMvc + .perform(delete(ENTITY_API_URL_ID, conferma.getId()).with(csrf()).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + assertDecrementedRepositoryCount(databaseSizeBeforeDelete); + } + + protected long getRepositoryCount() { + return confermaRepository.count(); + } + + protected void assertIncrementedRepositoryCount(long countBefore) { + assertThat(countBefore + 1).isEqualTo(getRepositoryCount()); + } + + protected void assertDecrementedRepositoryCount(long countBefore) { + assertThat(countBefore - 1).isEqualTo(getRepositoryCount()); + } + + protected void assertSameRepositoryCount(long countBefore) { + assertThat(countBefore).isEqualTo(getRepositoryCount()); + } + + protected Conferma getPersistedConferma(Conferma conferma) { + return confermaRepository.findById(conferma.getId()).orElseThrow(); + } + + protected void assertPersistedConfermaToMatchAllProperties(Conferma expectedConferma) { + assertConfermaAllPropertiesEquals(expectedConferma, getPersistedConferma(expectedConferma)); + } + + protected void assertPersistedConfermaToMatchUpdatableProperties(Conferma expectedConferma) { + assertConfermaAllUpdatablePropertiesEquals(expectedConferma, getPersistedConferma(expectedConferma)); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/web/rest/DisponibilitaResourceIT.java b/src/test/java/it/sw/pa/comune/artegna/web/rest/DisponibilitaResourceIT.java new file mode 100644 index 0000000..5c7d543 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/web/rest/DisponibilitaResourceIT.java @@ -0,0 +1,564 @@ +package it.sw.pa.comune.artegna.web.rest; + +import static it.sw.pa.comune.artegna.domain.DisponibilitaAsserts.*; +import static it.sw.pa.comune.artegna.web.rest.TestUtil.createUpdateProxyForBean; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.mockito.Mockito.*; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import it.sw.pa.comune.artegna.IntegrationTest; +import it.sw.pa.comune.artegna.domain.Disponibilita; +import it.sw.pa.comune.artegna.domain.enumeration.GiornoSettimana; +import it.sw.pa.comune.artegna.domain.enumeration.TipoDisponibilita; +import it.sw.pa.comune.artegna.repository.DisponibilitaRepository; +import it.sw.pa.comune.artegna.service.DisponibilitaService; +import it.sw.pa.comune.artegna.service.dto.DisponibilitaDTO; +import it.sw.pa.comune.artegna.service.mapper.DisponibilitaMapper; +import jakarta.persistence.EntityManager; +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +/** + * Integration tests for the {@link DisponibilitaResource} REST controller. + */ +@IntegrationTest +@ExtendWith(MockitoExtension.class) +@AutoConfigureMockMvc +@WithMockUser +class DisponibilitaResourceIT { + + private static final GiornoSettimana DEFAULT_GIORNO_SETTIMANA = GiornoSettimana.LUNEDI; + private static final GiornoSettimana UPDATED_GIORNO_SETTIMANA = GiornoSettimana.MARTEDI; + + private static final LocalDate DEFAULT_DATA_SPECIFICA = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_DATA_SPECIFICA = LocalDate.now(ZoneId.systemDefault()); + + private static final Instant DEFAULT_ORA_INIZIO = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_ORA_INIZIO = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final Instant DEFAULT_ORA_FINE = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_ORA_FINE = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final String DEFAULT_ORARIO_INIZIO = "AAAAAAAAAA"; + private static final String UPDATED_ORARIO_INIZIO = "BBBBBBBBBB"; + + private static final String DEFAULT_ORARIO_FINE = "AAAAAAAAAA"; + private static final String UPDATED_ORARIO_FINE = "BBBBBBBBBB"; + + private static final TipoDisponibilita DEFAULT_TIPO = TipoDisponibilita.DISPONIBILE; + private static final TipoDisponibilita UPDATED_TIPO = TipoDisponibilita.CHIUSURA; + + private static final String DEFAULT_NOTE = "AAAAAAAAAA"; + private static final String UPDATED_NOTE = "BBBBBBBBBB"; + + private static final String ENTITY_API_URL = "/api/disponibilitas"; + private static final String ENTITY_API_URL_ID = ENTITY_API_URL + "/{id}"; + + private static Random random = new Random(); + private static AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + @Autowired + private ObjectMapper om; + + @Autowired + private DisponibilitaRepository disponibilitaRepository; + + @Mock + private DisponibilitaRepository disponibilitaRepositoryMock; + + @Autowired + private DisponibilitaMapper disponibilitaMapper; + + @Mock + private DisponibilitaService disponibilitaServiceMock; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restDisponibilitaMockMvc; + + private Disponibilita disponibilita; + + private Disponibilita insertedDisponibilita; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Disponibilita createEntity() { + return new Disponibilita() + .giornoSettimana(DEFAULT_GIORNO_SETTIMANA) + .dataSpecifica(DEFAULT_DATA_SPECIFICA) + .oraInizio(DEFAULT_ORA_INIZIO) + .oraFine(DEFAULT_ORA_FINE) + .orarioInizio(DEFAULT_ORARIO_INIZIO) + .orarioFine(DEFAULT_ORARIO_FINE) + .tipo(DEFAULT_TIPO) + .note(DEFAULT_NOTE); + } + + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Disponibilita createUpdatedEntity() { + return new Disponibilita() + .giornoSettimana(UPDATED_GIORNO_SETTIMANA) + .dataSpecifica(UPDATED_DATA_SPECIFICA) + .oraInizio(UPDATED_ORA_INIZIO) + .oraFine(UPDATED_ORA_FINE) + .orarioInizio(UPDATED_ORARIO_INIZIO) + .orarioFine(UPDATED_ORARIO_FINE) + .tipo(UPDATED_TIPO) + .note(UPDATED_NOTE); + } + + @BeforeEach + void initTest() { + disponibilita = createEntity(); + } + + @AfterEach + void cleanup() { + if (insertedDisponibilita != null) { + disponibilitaRepository.delete(insertedDisponibilita); + insertedDisponibilita = null; + } + } + + @Test + @Transactional + void createDisponibilita() throws Exception { + long databaseSizeBeforeCreate = getRepositoryCount(); + // Create the Disponibilita + DisponibilitaDTO disponibilitaDTO = disponibilitaMapper.toDto(disponibilita); + var returnedDisponibilitaDTO = om.readValue( + restDisponibilitaMockMvc + .perform( + post(ENTITY_API_URL) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(disponibilitaDTO)) + ) + .andExpect(status().isCreated()) + .andReturn() + .getResponse() + .getContentAsString(), + DisponibilitaDTO.class + ); + + // Validate the Disponibilita in the database + assertIncrementedRepositoryCount(databaseSizeBeforeCreate); + var returnedDisponibilita = disponibilitaMapper.toEntity(returnedDisponibilitaDTO); + assertDisponibilitaUpdatableFieldsEquals(returnedDisponibilita, getPersistedDisponibilita(returnedDisponibilita)); + + insertedDisponibilita = returnedDisponibilita; + } + + @Test + @Transactional + void createDisponibilitaWithExistingId() throws Exception { + // Create the Disponibilita with an existing ID + disponibilita.setId(1L); + DisponibilitaDTO disponibilitaDTO = disponibilitaMapper.toDto(disponibilita); + + long databaseSizeBeforeCreate = getRepositoryCount(); + + // An entity with an existing ID cannot be created, so this API call must fail + restDisponibilitaMockMvc + .perform( + post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(disponibilitaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Disponibilita in the database + assertSameRepositoryCount(databaseSizeBeforeCreate); + } + + @Test + @Transactional + void getAllDisponibilitas() throws Exception { + // Initialize the database + insertedDisponibilita = disponibilitaRepository.saveAndFlush(disponibilita); + + // Get all the disponibilitaList + restDisponibilitaMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(disponibilita.getId().intValue()))) + .andExpect(jsonPath("$.[*].giornoSettimana").value(hasItem(DEFAULT_GIORNO_SETTIMANA.toString()))) + .andExpect(jsonPath("$.[*].dataSpecifica").value(hasItem(DEFAULT_DATA_SPECIFICA.toString()))) + .andExpect(jsonPath("$.[*].oraInizio").value(hasItem(DEFAULT_ORA_INIZIO.toString()))) + .andExpect(jsonPath("$.[*].oraFine").value(hasItem(DEFAULT_ORA_FINE.toString()))) + .andExpect(jsonPath("$.[*].orarioInizio").value(hasItem(DEFAULT_ORARIO_INIZIO))) + .andExpect(jsonPath("$.[*].orarioFine").value(hasItem(DEFAULT_ORARIO_FINE))) + .andExpect(jsonPath("$.[*].tipo").value(hasItem(DEFAULT_TIPO.toString()))) + .andExpect(jsonPath("$.[*].note").value(hasItem(DEFAULT_NOTE))); + } + + @SuppressWarnings({ "unchecked" }) + void getAllDisponibilitasWithEagerRelationshipsIsEnabled() throws Exception { + when(disponibilitaServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restDisponibilitaMockMvc.perform(get(ENTITY_API_URL + "?eagerload=true")).andExpect(status().isOk()); + + verify(disponibilitaServiceMock, times(1)).findAllWithEagerRelationships(any()); + } + + @SuppressWarnings({ "unchecked" }) + void getAllDisponibilitasWithEagerRelationshipsIsNotEnabled() throws Exception { + when(disponibilitaServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restDisponibilitaMockMvc.perform(get(ENTITY_API_URL + "?eagerload=false")).andExpect(status().isOk()); + verify(disponibilitaRepositoryMock, times(1)).findAll(any(Pageable.class)); + } + + @Test + @Transactional + void getDisponibilita() throws Exception { + // Initialize the database + insertedDisponibilita = disponibilitaRepository.saveAndFlush(disponibilita); + + // Get the disponibilita + restDisponibilitaMockMvc + .perform(get(ENTITY_API_URL_ID, disponibilita.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(disponibilita.getId().intValue())) + .andExpect(jsonPath("$.giornoSettimana").value(DEFAULT_GIORNO_SETTIMANA.toString())) + .andExpect(jsonPath("$.dataSpecifica").value(DEFAULT_DATA_SPECIFICA.toString())) + .andExpect(jsonPath("$.oraInizio").value(DEFAULT_ORA_INIZIO.toString())) + .andExpect(jsonPath("$.oraFine").value(DEFAULT_ORA_FINE.toString())) + .andExpect(jsonPath("$.orarioInizio").value(DEFAULT_ORARIO_INIZIO)) + .andExpect(jsonPath("$.orarioFine").value(DEFAULT_ORARIO_FINE)) + .andExpect(jsonPath("$.tipo").value(DEFAULT_TIPO.toString())) + .andExpect(jsonPath("$.note").value(DEFAULT_NOTE)); + } + + @Test + @Transactional + void getNonExistingDisponibilita() throws Exception { + // Get the disponibilita + restDisponibilitaMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound()); + } + + @Test + @Transactional + void putExistingDisponibilita() throws Exception { + // Initialize the database + insertedDisponibilita = disponibilitaRepository.saveAndFlush(disponibilita); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the disponibilita + Disponibilita updatedDisponibilita = disponibilitaRepository.findById(disponibilita.getId()).orElseThrow(); + // Disconnect from session so that the updates on updatedDisponibilita are not directly saved in db + em.detach(updatedDisponibilita); + updatedDisponibilita + .giornoSettimana(UPDATED_GIORNO_SETTIMANA) + .dataSpecifica(UPDATED_DATA_SPECIFICA) + .oraInizio(UPDATED_ORA_INIZIO) + .oraFine(UPDATED_ORA_FINE) + .orarioInizio(UPDATED_ORARIO_INIZIO) + .orarioFine(UPDATED_ORARIO_FINE) + .tipo(UPDATED_TIPO) + .note(UPDATED_NOTE); + DisponibilitaDTO disponibilitaDTO = disponibilitaMapper.toDto(updatedDisponibilita); + + restDisponibilitaMockMvc + .perform( + put(ENTITY_API_URL_ID, disponibilitaDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(disponibilitaDTO)) + ) + .andExpect(status().isOk()); + + // Validate the Disponibilita in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertPersistedDisponibilitaToMatchAllProperties(updatedDisponibilita); + } + + @Test + @Transactional + void putNonExistingDisponibilita() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + disponibilita.setId(longCount.incrementAndGet()); + + // Create the Disponibilita + DisponibilitaDTO disponibilitaDTO = disponibilitaMapper.toDto(disponibilita); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restDisponibilitaMockMvc + .perform( + put(ENTITY_API_URL_ID, disponibilitaDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(disponibilitaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Disponibilita in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithIdMismatchDisponibilita() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + disponibilita.setId(longCount.incrementAndGet()); + + // Create the Disponibilita + DisponibilitaDTO disponibilitaDTO = disponibilitaMapper.toDto(disponibilita); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restDisponibilitaMockMvc + .perform( + put(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(disponibilitaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Disponibilita in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithMissingIdPathParamDisponibilita() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + disponibilita.setId(longCount.incrementAndGet()); + + // Create the Disponibilita + DisponibilitaDTO disponibilitaDTO = disponibilitaMapper.toDto(disponibilita); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restDisponibilitaMockMvc + .perform( + put(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(disponibilitaDTO)) + ) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Disponibilita in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void partialUpdateDisponibilitaWithPatch() throws Exception { + // Initialize the database + insertedDisponibilita = disponibilitaRepository.saveAndFlush(disponibilita); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the disponibilita using partial update + Disponibilita partialUpdatedDisponibilita = new Disponibilita(); + partialUpdatedDisponibilita.setId(disponibilita.getId()); + + partialUpdatedDisponibilita + .dataSpecifica(UPDATED_DATA_SPECIFICA) + .oraFine(UPDATED_ORA_FINE) + .orarioInizio(UPDATED_ORARIO_INIZIO) + .orarioFine(UPDATED_ORARIO_FINE) + .tipo(UPDATED_TIPO); + + restDisponibilitaMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedDisponibilita.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedDisponibilita)) + ) + .andExpect(status().isOk()); + + // Validate the Disponibilita in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertDisponibilitaUpdatableFieldsEquals( + createUpdateProxyForBean(partialUpdatedDisponibilita, disponibilita), + getPersistedDisponibilita(disponibilita) + ); + } + + @Test + @Transactional + void fullUpdateDisponibilitaWithPatch() throws Exception { + // Initialize the database + insertedDisponibilita = disponibilitaRepository.saveAndFlush(disponibilita); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the disponibilita using partial update + Disponibilita partialUpdatedDisponibilita = new Disponibilita(); + partialUpdatedDisponibilita.setId(disponibilita.getId()); + + partialUpdatedDisponibilita + .giornoSettimana(UPDATED_GIORNO_SETTIMANA) + .dataSpecifica(UPDATED_DATA_SPECIFICA) + .oraInizio(UPDATED_ORA_INIZIO) + .oraFine(UPDATED_ORA_FINE) + .orarioInizio(UPDATED_ORARIO_INIZIO) + .orarioFine(UPDATED_ORARIO_FINE) + .tipo(UPDATED_TIPO) + .note(UPDATED_NOTE); + + restDisponibilitaMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedDisponibilita.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedDisponibilita)) + ) + .andExpect(status().isOk()); + + // Validate the Disponibilita in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertDisponibilitaUpdatableFieldsEquals(partialUpdatedDisponibilita, getPersistedDisponibilita(partialUpdatedDisponibilita)); + } + + @Test + @Transactional + void patchNonExistingDisponibilita() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + disponibilita.setId(longCount.incrementAndGet()); + + // Create the Disponibilita + DisponibilitaDTO disponibilitaDTO = disponibilitaMapper.toDto(disponibilita); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restDisponibilitaMockMvc + .perform( + patch(ENTITY_API_URL_ID, disponibilitaDTO.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(disponibilitaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Disponibilita in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithIdMismatchDisponibilita() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + disponibilita.setId(longCount.incrementAndGet()); + + // Create the Disponibilita + DisponibilitaDTO disponibilitaDTO = disponibilitaMapper.toDto(disponibilita); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restDisponibilitaMockMvc + .perform( + patch(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(disponibilitaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Disponibilita in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithMissingIdPathParamDisponibilita() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + disponibilita.setId(longCount.incrementAndGet()); + + // Create the Disponibilita + DisponibilitaDTO disponibilitaDTO = disponibilitaMapper.toDto(disponibilita); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restDisponibilitaMockMvc + .perform( + patch(ENTITY_API_URL) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(disponibilitaDTO)) + ) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Disponibilita in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void deleteDisponibilita() throws Exception { + // Initialize the database + insertedDisponibilita = disponibilitaRepository.saveAndFlush(disponibilita); + + long databaseSizeBeforeDelete = getRepositoryCount(); + + // Delete the disponibilita + restDisponibilitaMockMvc + .perform(delete(ENTITY_API_URL_ID, disponibilita.getId()).with(csrf()).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + assertDecrementedRepositoryCount(databaseSizeBeforeDelete); + } + + protected long getRepositoryCount() { + return disponibilitaRepository.count(); + } + + protected void assertIncrementedRepositoryCount(long countBefore) { + assertThat(countBefore + 1).isEqualTo(getRepositoryCount()); + } + + protected void assertDecrementedRepositoryCount(long countBefore) { + assertThat(countBefore - 1).isEqualTo(getRepositoryCount()); + } + + protected void assertSameRepositoryCount(long countBefore) { + assertThat(countBefore).isEqualTo(getRepositoryCount()); + } + + protected Disponibilita getPersistedDisponibilita(Disponibilita disponibilita) { + return disponibilitaRepository.findById(disponibilita.getId()).orElseThrow(); + } + + protected void assertPersistedDisponibilitaToMatchAllProperties(Disponibilita expectedDisponibilita) { + assertDisponibilitaAllPropertiesEquals(expectedDisponibilita, getPersistedDisponibilita(expectedDisponibilita)); + } + + protected void assertPersistedDisponibilitaToMatchUpdatableProperties(Disponibilita expectedDisponibilita) { + assertDisponibilitaAllUpdatablePropertiesEquals(expectedDisponibilita, getPersistedDisponibilita(expectedDisponibilita)); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/web/rest/LiberatoriaResourceIT.java b/src/test/java/it/sw/pa/comune/artegna/web/rest/LiberatoriaResourceIT.java new file mode 100644 index 0000000..4acf0d6 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/web/rest/LiberatoriaResourceIT.java @@ -0,0 +1,480 @@ +package it.sw.pa.comune.artegna.web.rest; + +import static it.sw.pa.comune.artegna.domain.LiberatoriaAsserts.*; +import static it.sw.pa.comune.artegna.web.rest.TestUtil.createUpdateProxyForBean; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.mockito.Mockito.*; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import it.sw.pa.comune.artegna.IntegrationTest; +import it.sw.pa.comune.artegna.domain.Liberatoria; +import it.sw.pa.comune.artegna.repository.LiberatoriaRepository; +import it.sw.pa.comune.artegna.service.LiberatoriaService; +import it.sw.pa.comune.artegna.service.dto.LiberatoriaDTO; +import it.sw.pa.comune.artegna.service.mapper.LiberatoriaMapper; +import jakarta.persistence.EntityManager; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +/** + * Integration tests for the {@link LiberatoriaResource} REST controller. + */ +@IntegrationTest +@ExtendWith(MockitoExtension.class) +@AutoConfigureMockMvc +@WithMockUser +class LiberatoriaResourceIT { + + private static final Instant DEFAULT_ACCETTATA = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_ACCETTATA = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final String ENTITY_API_URL = "/api/liberatorias"; + private static final String ENTITY_API_URL_ID = ENTITY_API_URL + "/{id}"; + + private static Random random = new Random(); + private static AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + @Autowired + private ObjectMapper om; + + @Autowired + private LiberatoriaRepository liberatoriaRepository; + + @Mock + private LiberatoriaRepository liberatoriaRepositoryMock; + + @Autowired + private LiberatoriaMapper liberatoriaMapper; + + @Mock + private LiberatoriaService liberatoriaServiceMock; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restLiberatoriaMockMvc; + + private Liberatoria liberatoria; + + private Liberatoria insertedLiberatoria; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Liberatoria createEntity() { + return new Liberatoria().accettata(DEFAULT_ACCETTATA); + } + + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Liberatoria createUpdatedEntity() { + return new Liberatoria().accettata(UPDATED_ACCETTATA); + } + + @BeforeEach + void initTest() { + liberatoria = createEntity(); + } + + @AfterEach + void cleanup() { + if (insertedLiberatoria != null) { + liberatoriaRepository.delete(insertedLiberatoria); + insertedLiberatoria = null; + } + } + + @Test + @Transactional + void createLiberatoria() throws Exception { + long databaseSizeBeforeCreate = getRepositoryCount(); + // Create the Liberatoria + LiberatoriaDTO liberatoriaDTO = liberatoriaMapper.toDto(liberatoria); + var returnedLiberatoriaDTO = om.readValue( + restLiberatoriaMockMvc + .perform( + post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(liberatoriaDTO)) + ) + .andExpect(status().isCreated()) + .andReturn() + .getResponse() + .getContentAsString(), + LiberatoriaDTO.class + ); + + // Validate the Liberatoria in the database + assertIncrementedRepositoryCount(databaseSizeBeforeCreate); + var returnedLiberatoria = liberatoriaMapper.toEntity(returnedLiberatoriaDTO); + assertLiberatoriaUpdatableFieldsEquals(returnedLiberatoria, getPersistedLiberatoria(returnedLiberatoria)); + + insertedLiberatoria = returnedLiberatoria; + } + + @Test + @Transactional + void createLiberatoriaWithExistingId() throws Exception { + // Create the Liberatoria with an existing ID + liberatoria.setId(1L); + LiberatoriaDTO liberatoriaDTO = liberatoriaMapper.toDto(liberatoria); + + long databaseSizeBeforeCreate = getRepositoryCount(); + + // An entity with an existing ID cannot be created, so this API call must fail + restLiberatoriaMockMvc + .perform( + post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(liberatoriaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Liberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeCreate); + } + + @Test + @Transactional + void getAllLiberatorias() throws Exception { + // Initialize the database + insertedLiberatoria = liberatoriaRepository.saveAndFlush(liberatoria); + + // Get all the liberatoriaList + restLiberatoriaMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(liberatoria.getId().intValue()))) + .andExpect(jsonPath("$.[*].accettata").value(hasItem(DEFAULT_ACCETTATA.toString()))); + } + + @SuppressWarnings({ "unchecked" }) + void getAllLiberatoriasWithEagerRelationshipsIsEnabled() throws Exception { + when(liberatoriaServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restLiberatoriaMockMvc.perform(get(ENTITY_API_URL + "?eagerload=true")).andExpect(status().isOk()); + + verify(liberatoriaServiceMock, times(1)).findAllWithEagerRelationships(any()); + } + + @SuppressWarnings({ "unchecked" }) + void getAllLiberatoriasWithEagerRelationshipsIsNotEnabled() throws Exception { + when(liberatoriaServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restLiberatoriaMockMvc.perform(get(ENTITY_API_URL + "?eagerload=false")).andExpect(status().isOk()); + verify(liberatoriaRepositoryMock, times(1)).findAll(any(Pageable.class)); + } + + @Test + @Transactional + void getLiberatoria() throws Exception { + // Initialize the database + insertedLiberatoria = liberatoriaRepository.saveAndFlush(liberatoria); + + // Get the liberatoria + restLiberatoriaMockMvc + .perform(get(ENTITY_API_URL_ID, liberatoria.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(liberatoria.getId().intValue())) + .andExpect(jsonPath("$.accettata").value(DEFAULT_ACCETTATA.toString())); + } + + @Test + @Transactional + void getNonExistingLiberatoria() throws Exception { + // Get the liberatoria + restLiberatoriaMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound()); + } + + @Test + @Transactional + void putExistingLiberatoria() throws Exception { + // Initialize the database + insertedLiberatoria = liberatoriaRepository.saveAndFlush(liberatoria); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the liberatoria + Liberatoria updatedLiberatoria = liberatoriaRepository.findById(liberatoria.getId()).orElseThrow(); + // Disconnect from session so that the updates on updatedLiberatoria are not directly saved in db + em.detach(updatedLiberatoria); + updatedLiberatoria.accettata(UPDATED_ACCETTATA); + LiberatoriaDTO liberatoriaDTO = liberatoriaMapper.toDto(updatedLiberatoria); + + restLiberatoriaMockMvc + .perform( + put(ENTITY_API_URL_ID, liberatoriaDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(liberatoriaDTO)) + ) + .andExpect(status().isOk()); + + // Validate the Liberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertPersistedLiberatoriaToMatchAllProperties(updatedLiberatoria); + } + + @Test + @Transactional + void putNonExistingLiberatoria() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + liberatoria.setId(longCount.incrementAndGet()); + + // Create the Liberatoria + LiberatoriaDTO liberatoriaDTO = liberatoriaMapper.toDto(liberatoria); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restLiberatoriaMockMvc + .perform( + put(ENTITY_API_URL_ID, liberatoriaDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(liberatoriaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Liberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithIdMismatchLiberatoria() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + liberatoria.setId(longCount.incrementAndGet()); + + // Create the Liberatoria + LiberatoriaDTO liberatoriaDTO = liberatoriaMapper.toDto(liberatoria); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restLiberatoriaMockMvc + .perform( + put(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(liberatoriaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Liberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithMissingIdPathParamLiberatoria() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + liberatoria.setId(longCount.incrementAndGet()); + + // Create the Liberatoria + LiberatoriaDTO liberatoriaDTO = liberatoriaMapper.toDto(liberatoria); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restLiberatoriaMockMvc + .perform(put(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(liberatoriaDTO))) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Liberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void partialUpdateLiberatoriaWithPatch() throws Exception { + // Initialize the database + insertedLiberatoria = liberatoriaRepository.saveAndFlush(liberatoria); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the liberatoria using partial update + Liberatoria partialUpdatedLiberatoria = new Liberatoria(); + partialUpdatedLiberatoria.setId(liberatoria.getId()); + + partialUpdatedLiberatoria.accettata(UPDATED_ACCETTATA); + + restLiberatoriaMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedLiberatoria.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedLiberatoria)) + ) + .andExpect(status().isOk()); + + // Validate the Liberatoria in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertLiberatoriaUpdatableFieldsEquals( + createUpdateProxyForBean(partialUpdatedLiberatoria, liberatoria), + getPersistedLiberatoria(liberatoria) + ); + } + + @Test + @Transactional + void fullUpdateLiberatoriaWithPatch() throws Exception { + // Initialize the database + insertedLiberatoria = liberatoriaRepository.saveAndFlush(liberatoria); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the liberatoria using partial update + Liberatoria partialUpdatedLiberatoria = new Liberatoria(); + partialUpdatedLiberatoria.setId(liberatoria.getId()); + + partialUpdatedLiberatoria.accettata(UPDATED_ACCETTATA); + + restLiberatoriaMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedLiberatoria.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedLiberatoria)) + ) + .andExpect(status().isOk()); + + // Validate the Liberatoria in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertLiberatoriaUpdatableFieldsEquals(partialUpdatedLiberatoria, getPersistedLiberatoria(partialUpdatedLiberatoria)); + } + + @Test + @Transactional + void patchNonExistingLiberatoria() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + liberatoria.setId(longCount.incrementAndGet()); + + // Create the Liberatoria + LiberatoriaDTO liberatoriaDTO = liberatoriaMapper.toDto(liberatoria); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restLiberatoriaMockMvc + .perform( + patch(ENTITY_API_URL_ID, liberatoriaDTO.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(liberatoriaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Liberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithIdMismatchLiberatoria() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + liberatoria.setId(longCount.incrementAndGet()); + + // Create the Liberatoria + LiberatoriaDTO liberatoriaDTO = liberatoriaMapper.toDto(liberatoria); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restLiberatoriaMockMvc + .perform( + patch(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(liberatoriaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Liberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithMissingIdPathParamLiberatoria() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + liberatoria.setId(longCount.incrementAndGet()); + + // Create the Liberatoria + LiberatoriaDTO liberatoriaDTO = liberatoriaMapper.toDto(liberatoria); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restLiberatoriaMockMvc + .perform( + patch(ENTITY_API_URL).with(csrf()).contentType("application/merge-patch+json").content(om.writeValueAsBytes(liberatoriaDTO)) + ) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Liberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void deleteLiberatoria() throws Exception { + // Initialize the database + insertedLiberatoria = liberatoriaRepository.saveAndFlush(liberatoria); + + long databaseSizeBeforeDelete = getRepositoryCount(); + + // Delete the liberatoria + restLiberatoriaMockMvc + .perform(delete(ENTITY_API_URL_ID, liberatoria.getId()).with(csrf()).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + assertDecrementedRepositoryCount(databaseSizeBeforeDelete); + } + + protected long getRepositoryCount() { + return liberatoriaRepository.count(); + } + + protected void assertIncrementedRepositoryCount(long countBefore) { + assertThat(countBefore + 1).isEqualTo(getRepositoryCount()); + } + + protected void assertDecrementedRepositoryCount(long countBefore) { + assertThat(countBefore - 1).isEqualTo(getRepositoryCount()); + } + + protected void assertSameRepositoryCount(long countBefore) { + assertThat(countBefore).isEqualTo(getRepositoryCount()); + } + + protected Liberatoria getPersistedLiberatoria(Liberatoria liberatoria) { + return liberatoriaRepository.findById(liberatoria.getId()).orElseThrow(); + } + + protected void assertPersistedLiberatoriaToMatchAllProperties(Liberatoria expectedLiberatoria) { + assertLiberatoriaAllPropertiesEquals(expectedLiberatoria, getPersistedLiberatoria(expectedLiberatoria)); + } + + protected void assertPersistedLiberatoriaToMatchUpdatableProperties(Liberatoria expectedLiberatoria) { + assertLiberatoriaAllUpdatablePropertiesEquals(expectedLiberatoria, getPersistedLiberatoria(expectedLiberatoria)); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/web/rest/MessaggioResourceIT.java b/src/test/java/it/sw/pa/comune/artegna/web/rest/MessaggioResourceIT.java new file mode 100644 index 0000000..5b7051e --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/web/rest/MessaggioResourceIT.java @@ -0,0 +1,488 @@ +package it.sw.pa.comune.artegna.web.rest; + +import static it.sw.pa.comune.artegna.domain.MessaggioAsserts.*; +import static it.sw.pa.comune.artegna.web.rest.TestUtil.createUpdateProxyForBean; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.mockito.Mockito.*; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import it.sw.pa.comune.artegna.IntegrationTest; +import it.sw.pa.comune.artegna.domain.Messaggio; +import it.sw.pa.comune.artegna.repository.MessaggioRepository; +import it.sw.pa.comune.artegna.service.MessaggioService; +import it.sw.pa.comune.artegna.service.dto.MessaggioDTO; +import it.sw.pa.comune.artegna.service.mapper.MessaggioMapper; +import jakarta.persistence.EntityManager; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +/** + * Integration tests for the {@link MessaggioResource} REST controller. + */ +@IntegrationTest +@ExtendWith(MockitoExtension.class) +@AutoConfigureMockMvc +@WithMockUser +class MessaggioResourceIT { + + private static final Instant DEFAULT_SPEDITO = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_SPEDITO = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final String DEFAULT_TESTO = "AAAAAAAAAA"; + private static final String UPDATED_TESTO = "BBBBBBBBBB"; + + private static final Instant DEFAULT_LETTO = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_LETTO = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final String ENTITY_API_URL = "/api/messaggios"; + private static final String ENTITY_API_URL_ID = ENTITY_API_URL + "/{id}"; + + private static Random random = new Random(); + private static AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + @Autowired + private ObjectMapper om; + + @Autowired + private MessaggioRepository messaggioRepository; + + @Mock + private MessaggioRepository messaggioRepositoryMock; + + @Autowired + private MessaggioMapper messaggioMapper; + + @Mock + private MessaggioService messaggioServiceMock; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restMessaggioMockMvc; + + private Messaggio messaggio; + + private Messaggio insertedMessaggio; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Messaggio createEntity() { + return new Messaggio().spedito(DEFAULT_SPEDITO).testo(DEFAULT_TESTO).letto(DEFAULT_LETTO); + } + + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Messaggio createUpdatedEntity() { + return new Messaggio().spedito(UPDATED_SPEDITO).testo(UPDATED_TESTO).letto(UPDATED_LETTO); + } + + @BeforeEach + void initTest() { + messaggio = createEntity(); + } + + @AfterEach + void cleanup() { + if (insertedMessaggio != null) { + messaggioRepository.delete(insertedMessaggio); + insertedMessaggio = null; + } + } + + @Test + @Transactional + void createMessaggio() throws Exception { + long databaseSizeBeforeCreate = getRepositoryCount(); + // Create the Messaggio + MessaggioDTO messaggioDTO = messaggioMapper.toDto(messaggio); + var returnedMessaggioDTO = om.readValue( + restMessaggioMockMvc + .perform( + post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(messaggioDTO)) + ) + .andExpect(status().isCreated()) + .andReturn() + .getResponse() + .getContentAsString(), + MessaggioDTO.class + ); + + // Validate the Messaggio in the database + assertIncrementedRepositoryCount(databaseSizeBeforeCreate); + var returnedMessaggio = messaggioMapper.toEntity(returnedMessaggioDTO); + assertMessaggioUpdatableFieldsEquals(returnedMessaggio, getPersistedMessaggio(returnedMessaggio)); + + insertedMessaggio = returnedMessaggio; + } + + @Test + @Transactional + void createMessaggioWithExistingId() throws Exception { + // Create the Messaggio with an existing ID + messaggio.setId(1L); + MessaggioDTO messaggioDTO = messaggioMapper.toDto(messaggio); + + long databaseSizeBeforeCreate = getRepositoryCount(); + + // An entity with an existing ID cannot be created, so this API call must fail + restMessaggioMockMvc + .perform(post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(messaggioDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Messaggio in the database + assertSameRepositoryCount(databaseSizeBeforeCreate); + } + + @Test + @Transactional + void getAllMessaggios() throws Exception { + // Initialize the database + insertedMessaggio = messaggioRepository.saveAndFlush(messaggio); + + // Get all the messaggioList + restMessaggioMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(messaggio.getId().intValue()))) + .andExpect(jsonPath("$.[*].spedito").value(hasItem(DEFAULT_SPEDITO.toString()))) + .andExpect(jsonPath("$.[*].testo").value(hasItem(DEFAULT_TESTO))) + .andExpect(jsonPath("$.[*].letto").value(hasItem(DEFAULT_LETTO.toString()))); + } + + @SuppressWarnings({ "unchecked" }) + void getAllMessaggiosWithEagerRelationshipsIsEnabled() throws Exception { + when(messaggioServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restMessaggioMockMvc.perform(get(ENTITY_API_URL + "?eagerload=true")).andExpect(status().isOk()); + + verify(messaggioServiceMock, times(1)).findAllWithEagerRelationships(any()); + } + + @SuppressWarnings({ "unchecked" }) + void getAllMessaggiosWithEagerRelationshipsIsNotEnabled() throws Exception { + when(messaggioServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restMessaggioMockMvc.perform(get(ENTITY_API_URL + "?eagerload=false")).andExpect(status().isOk()); + verify(messaggioRepositoryMock, times(1)).findAll(any(Pageable.class)); + } + + @Test + @Transactional + void getMessaggio() throws Exception { + // Initialize the database + insertedMessaggio = messaggioRepository.saveAndFlush(messaggio); + + // Get the messaggio + restMessaggioMockMvc + .perform(get(ENTITY_API_URL_ID, messaggio.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(messaggio.getId().intValue())) + .andExpect(jsonPath("$.spedito").value(DEFAULT_SPEDITO.toString())) + .andExpect(jsonPath("$.testo").value(DEFAULT_TESTO)) + .andExpect(jsonPath("$.letto").value(DEFAULT_LETTO.toString())); + } + + @Test + @Transactional + void getNonExistingMessaggio() throws Exception { + // Get the messaggio + restMessaggioMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound()); + } + + @Test + @Transactional + void putExistingMessaggio() throws Exception { + // Initialize the database + insertedMessaggio = messaggioRepository.saveAndFlush(messaggio); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the messaggio + Messaggio updatedMessaggio = messaggioRepository.findById(messaggio.getId()).orElseThrow(); + // Disconnect from session so that the updates on updatedMessaggio are not directly saved in db + em.detach(updatedMessaggio); + updatedMessaggio.spedito(UPDATED_SPEDITO).testo(UPDATED_TESTO).letto(UPDATED_LETTO); + MessaggioDTO messaggioDTO = messaggioMapper.toDto(updatedMessaggio); + + restMessaggioMockMvc + .perform( + put(ENTITY_API_URL_ID, messaggioDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(messaggioDTO)) + ) + .andExpect(status().isOk()); + + // Validate the Messaggio in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertPersistedMessaggioToMatchAllProperties(updatedMessaggio); + } + + @Test + @Transactional + void putNonExistingMessaggio() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + messaggio.setId(longCount.incrementAndGet()); + + // Create the Messaggio + MessaggioDTO messaggioDTO = messaggioMapper.toDto(messaggio); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restMessaggioMockMvc + .perform( + put(ENTITY_API_URL_ID, messaggioDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(messaggioDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Messaggio in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithIdMismatchMessaggio() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + messaggio.setId(longCount.incrementAndGet()); + + // Create the Messaggio + MessaggioDTO messaggioDTO = messaggioMapper.toDto(messaggio); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restMessaggioMockMvc + .perform( + put(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(messaggioDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Messaggio in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithMissingIdPathParamMessaggio() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + messaggio.setId(longCount.incrementAndGet()); + + // Create the Messaggio + MessaggioDTO messaggioDTO = messaggioMapper.toDto(messaggio); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restMessaggioMockMvc + .perform(put(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(messaggioDTO))) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Messaggio in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void partialUpdateMessaggioWithPatch() throws Exception { + // Initialize the database + insertedMessaggio = messaggioRepository.saveAndFlush(messaggio); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the messaggio using partial update + Messaggio partialUpdatedMessaggio = new Messaggio(); + partialUpdatedMessaggio.setId(messaggio.getId()); + + partialUpdatedMessaggio.spedito(UPDATED_SPEDITO).letto(UPDATED_LETTO); + + restMessaggioMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedMessaggio.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedMessaggio)) + ) + .andExpect(status().isOk()); + + // Validate the Messaggio in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertMessaggioUpdatableFieldsEquals( + createUpdateProxyForBean(partialUpdatedMessaggio, messaggio), + getPersistedMessaggio(messaggio) + ); + } + + @Test + @Transactional + void fullUpdateMessaggioWithPatch() throws Exception { + // Initialize the database + insertedMessaggio = messaggioRepository.saveAndFlush(messaggio); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the messaggio using partial update + Messaggio partialUpdatedMessaggio = new Messaggio(); + partialUpdatedMessaggio.setId(messaggio.getId()); + + partialUpdatedMessaggio.spedito(UPDATED_SPEDITO).testo(UPDATED_TESTO).letto(UPDATED_LETTO); + + restMessaggioMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedMessaggio.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedMessaggio)) + ) + .andExpect(status().isOk()); + + // Validate the Messaggio in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertMessaggioUpdatableFieldsEquals(partialUpdatedMessaggio, getPersistedMessaggio(partialUpdatedMessaggio)); + } + + @Test + @Transactional + void patchNonExistingMessaggio() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + messaggio.setId(longCount.incrementAndGet()); + + // Create the Messaggio + MessaggioDTO messaggioDTO = messaggioMapper.toDto(messaggio); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restMessaggioMockMvc + .perform( + patch(ENTITY_API_URL_ID, messaggioDTO.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(messaggioDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Messaggio in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithIdMismatchMessaggio() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + messaggio.setId(longCount.incrementAndGet()); + + // Create the Messaggio + MessaggioDTO messaggioDTO = messaggioMapper.toDto(messaggio); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restMessaggioMockMvc + .perform( + patch(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(messaggioDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Messaggio in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithMissingIdPathParamMessaggio() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + messaggio.setId(longCount.incrementAndGet()); + + // Create the Messaggio + MessaggioDTO messaggioDTO = messaggioMapper.toDto(messaggio); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restMessaggioMockMvc + .perform( + patch(ENTITY_API_URL).with(csrf()).contentType("application/merge-patch+json").content(om.writeValueAsBytes(messaggioDTO)) + ) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Messaggio in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void deleteMessaggio() throws Exception { + // Initialize the database + insertedMessaggio = messaggioRepository.saveAndFlush(messaggio); + + long databaseSizeBeforeDelete = getRepositoryCount(); + + // Delete the messaggio + restMessaggioMockMvc + .perform(delete(ENTITY_API_URL_ID, messaggio.getId()).with(csrf()).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + assertDecrementedRepositoryCount(databaseSizeBeforeDelete); + } + + protected long getRepositoryCount() { + return messaggioRepository.count(); + } + + protected void assertIncrementedRepositoryCount(long countBefore) { + assertThat(countBefore + 1).isEqualTo(getRepositoryCount()); + } + + protected void assertDecrementedRepositoryCount(long countBefore) { + assertThat(countBefore - 1).isEqualTo(getRepositoryCount()); + } + + protected void assertSameRepositoryCount(long countBefore) { + assertThat(countBefore).isEqualTo(getRepositoryCount()); + } + + protected Messaggio getPersistedMessaggio(Messaggio messaggio) { + return messaggioRepository.findById(messaggio.getId()).orElseThrow(); + } + + protected void assertPersistedMessaggioToMatchAllProperties(Messaggio expectedMessaggio) { + assertMessaggioAllPropertiesEquals(expectedMessaggio, getPersistedMessaggio(expectedMessaggio)); + } + + protected void assertPersistedMessaggioToMatchUpdatableProperties(Messaggio expectedMessaggio) { + assertMessaggioAllUpdatablePropertiesEquals(expectedMessaggio, getPersistedMessaggio(expectedMessaggio)); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/web/rest/ModelloLiberatoriaResourceIT.java b/src/test/java/it/sw/pa/comune/artegna/web/rest/ModelloLiberatoriaResourceIT.java new file mode 100644 index 0000000..c4c6108 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/web/rest/ModelloLiberatoriaResourceIT.java @@ -0,0 +1,520 @@ +package it.sw.pa.comune.artegna.web.rest; + +import static it.sw.pa.comune.artegna.domain.ModelloLiberatoriaAsserts.*; +import static it.sw.pa.comune.artegna.web.rest.TestUtil.createUpdateProxyForBean; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import it.sw.pa.comune.artegna.IntegrationTest; +import it.sw.pa.comune.artegna.domain.ModelloLiberatoria; +import it.sw.pa.comune.artegna.repository.ModelloLiberatoriaRepository; +import it.sw.pa.comune.artegna.service.dto.ModelloLiberatoriaDTO; +import it.sw.pa.comune.artegna.service.mapper.ModelloLiberatoriaMapper; +import jakarta.persistence.EntityManager; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.Base64; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +/** + * Integration tests for the {@link ModelloLiberatoriaResource} REST controller. + */ +@IntegrationTest +@AutoConfigureMockMvc +@WithMockUser +class ModelloLiberatoriaResourceIT { + + private static final String DEFAULT_NOME = "AAAAAAAAAA"; + private static final String UPDATED_NOME = "BBBBBBBBBB"; + + private static final String DEFAULT_TESTO = "AAAAAAAAAA"; + private static final String UPDATED_TESTO = "BBBBBBBBBB"; + + private static final byte[] DEFAULT_DOCUMENTO = TestUtil.createByteArray(1, "0"); + private static final byte[] UPDATED_DOCUMENTO = TestUtil.createByteArray(1, "1"); + private static final String DEFAULT_DOCUMENTO_CONTENT_TYPE = "image/jpg"; + private static final String UPDATED_DOCUMENTO_CONTENT_TYPE = "image/png"; + + private static final Instant DEFAULT_VALIDO_DAL = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_VALIDO_DAL = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final Instant DEFAULT_VALIDO_AL = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_VALIDO_AL = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final String ENTITY_API_URL = "/api/modello-liberatorias"; + private static final String ENTITY_API_URL_ID = ENTITY_API_URL + "/{id}"; + + private static Random random = new Random(); + private static AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + @Autowired + private ObjectMapper om; + + @Autowired + private ModelloLiberatoriaRepository modelloLiberatoriaRepository; + + @Autowired + private ModelloLiberatoriaMapper modelloLiberatoriaMapper; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restModelloLiberatoriaMockMvc; + + private ModelloLiberatoria modelloLiberatoria; + + private ModelloLiberatoria insertedModelloLiberatoria; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static ModelloLiberatoria createEntity() { + return new ModelloLiberatoria() + .nome(DEFAULT_NOME) + .testo(DEFAULT_TESTO) + .documento(DEFAULT_DOCUMENTO) + .documentoContentType(DEFAULT_DOCUMENTO_CONTENT_TYPE) + .validoDal(DEFAULT_VALIDO_DAL) + .validoAl(DEFAULT_VALIDO_AL); + } + + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static ModelloLiberatoria createUpdatedEntity() { + return new ModelloLiberatoria() + .nome(UPDATED_NOME) + .testo(UPDATED_TESTO) + .documento(UPDATED_DOCUMENTO) + .documentoContentType(UPDATED_DOCUMENTO_CONTENT_TYPE) + .validoDal(UPDATED_VALIDO_DAL) + .validoAl(UPDATED_VALIDO_AL); + } + + @BeforeEach + void initTest() { + modelloLiberatoria = createEntity(); + } + + @AfterEach + void cleanup() { + if (insertedModelloLiberatoria != null) { + modelloLiberatoriaRepository.delete(insertedModelloLiberatoria); + insertedModelloLiberatoria = null; + } + } + + @Test + @Transactional + void createModelloLiberatoria() throws Exception { + long databaseSizeBeforeCreate = getRepositoryCount(); + // Create the ModelloLiberatoria + ModelloLiberatoriaDTO modelloLiberatoriaDTO = modelloLiberatoriaMapper.toDto(modelloLiberatoria); + var returnedModelloLiberatoriaDTO = om.readValue( + restModelloLiberatoriaMockMvc + .perform( + post(ENTITY_API_URL) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(modelloLiberatoriaDTO)) + ) + .andExpect(status().isCreated()) + .andReturn() + .getResponse() + .getContentAsString(), + ModelloLiberatoriaDTO.class + ); + + // Validate the ModelloLiberatoria in the database + assertIncrementedRepositoryCount(databaseSizeBeforeCreate); + var returnedModelloLiberatoria = modelloLiberatoriaMapper.toEntity(returnedModelloLiberatoriaDTO); + assertModelloLiberatoriaUpdatableFieldsEquals( + returnedModelloLiberatoria, + getPersistedModelloLiberatoria(returnedModelloLiberatoria) + ); + + insertedModelloLiberatoria = returnedModelloLiberatoria; + } + + @Test + @Transactional + void createModelloLiberatoriaWithExistingId() throws Exception { + // Create the ModelloLiberatoria with an existing ID + modelloLiberatoria.setId(1L); + ModelloLiberatoriaDTO modelloLiberatoriaDTO = modelloLiberatoriaMapper.toDto(modelloLiberatoria); + + long databaseSizeBeforeCreate = getRepositoryCount(); + + // An entity with an existing ID cannot be created, so this API call must fail + restModelloLiberatoriaMockMvc + .perform( + post(ENTITY_API_URL) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(modelloLiberatoriaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the ModelloLiberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeCreate); + } + + @Test + @Transactional + void getAllModelloLiberatorias() throws Exception { + // Initialize the database + insertedModelloLiberatoria = modelloLiberatoriaRepository.saveAndFlush(modelloLiberatoria); + + // Get all the modelloLiberatoriaList + restModelloLiberatoriaMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(modelloLiberatoria.getId().intValue()))) + .andExpect(jsonPath("$.[*].nome").value(hasItem(DEFAULT_NOME))) + .andExpect(jsonPath("$.[*].testo").value(hasItem(DEFAULT_TESTO))) + .andExpect(jsonPath("$.[*].documentoContentType").value(hasItem(DEFAULT_DOCUMENTO_CONTENT_TYPE))) + .andExpect(jsonPath("$.[*].documento").value(hasItem(Base64.getEncoder().encodeToString(DEFAULT_DOCUMENTO)))) + .andExpect(jsonPath("$.[*].validoDal").value(hasItem(DEFAULT_VALIDO_DAL.toString()))) + .andExpect(jsonPath("$.[*].validoAl").value(hasItem(DEFAULT_VALIDO_AL.toString()))); + } + + @Test + @Transactional + void getModelloLiberatoria() throws Exception { + // Initialize the database + insertedModelloLiberatoria = modelloLiberatoriaRepository.saveAndFlush(modelloLiberatoria); + + // Get the modelloLiberatoria + restModelloLiberatoriaMockMvc + .perform(get(ENTITY_API_URL_ID, modelloLiberatoria.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(modelloLiberatoria.getId().intValue())) + .andExpect(jsonPath("$.nome").value(DEFAULT_NOME)) + .andExpect(jsonPath("$.testo").value(DEFAULT_TESTO)) + .andExpect(jsonPath("$.documentoContentType").value(DEFAULT_DOCUMENTO_CONTENT_TYPE)) + .andExpect(jsonPath("$.documento").value(Base64.getEncoder().encodeToString(DEFAULT_DOCUMENTO))) + .andExpect(jsonPath("$.validoDal").value(DEFAULT_VALIDO_DAL.toString())) + .andExpect(jsonPath("$.validoAl").value(DEFAULT_VALIDO_AL.toString())); + } + + @Test + @Transactional + void getNonExistingModelloLiberatoria() throws Exception { + // Get the modelloLiberatoria + restModelloLiberatoriaMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound()); + } + + @Test + @Transactional + void putExistingModelloLiberatoria() throws Exception { + // Initialize the database + insertedModelloLiberatoria = modelloLiberatoriaRepository.saveAndFlush(modelloLiberatoria); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the modelloLiberatoria + ModelloLiberatoria updatedModelloLiberatoria = modelloLiberatoriaRepository.findById(modelloLiberatoria.getId()).orElseThrow(); + // Disconnect from session so that the updates on updatedModelloLiberatoria are not directly saved in db + em.detach(updatedModelloLiberatoria); + updatedModelloLiberatoria + .nome(UPDATED_NOME) + .testo(UPDATED_TESTO) + .documento(UPDATED_DOCUMENTO) + .documentoContentType(UPDATED_DOCUMENTO_CONTENT_TYPE) + .validoDal(UPDATED_VALIDO_DAL) + .validoAl(UPDATED_VALIDO_AL); + ModelloLiberatoriaDTO modelloLiberatoriaDTO = modelloLiberatoriaMapper.toDto(updatedModelloLiberatoria); + + restModelloLiberatoriaMockMvc + .perform( + put(ENTITY_API_URL_ID, modelloLiberatoriaDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(modelloLiberatoriaDTO)) + ) + .andExpect(status().isOk()); + + // Validate the ModelloLiberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertPersistedModelloLiberatoriaToMatchAllProperties(updatedModelloLiberatoria); + } + + @Test + @Transactional + void putNonExistingModelloLiberatoria() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + modelloLiberatoria.setId(longCount.incrementAndGet()); + + // Create the ModelloLiberatoria + ModelloLiberatoriaDTO modelloLiberatoriaDTO = modelloLiberatoriaMapper.toDto(modelloLiberatoria); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restModelloLiberatoriaMockMvc + .perform( + put(ENTITY_API_URL_ID, modelloLiberatoriaDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(modelloLiberatoriaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the ModelloLiberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithIdMismatchModelloLiberatoria() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + modelloLiberatoria.setId(longCount.incrementAndGet()); + + // Create the ModelloLiberatoria + ModelloLiberatoriaDTO modelloLiberatoriaDTO = modelloLiberatoriaMapper.toDto(modelloLiberatoria); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restModelloLiberatoriaMockMvc + .perform( + put(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(modelloLiberatoriaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the ModelloLiberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithMissingIdPathParamModelloLiberatoria() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + modelloLiberatoria.setId(longCount.incrementAndGet()); + + // Create the ModelloLiberatoria + ModelloLiberatoriaDTO modelloLiberatoriaDTO = modelloLiberatoriaMapper.toDto(modelloLiberatoria); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restModelloLiberatoriaMockMvc + .perform( + put(ENTITY_API_URL) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(modelloLiberatoriaDTO)) + ) + .andExpect(status().isMethodNotAllowed()); + + // Validate the ModelloLiberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void partialUpdateModelloLiberatoriaWithPatch() throws Exception { + // Initialize the database + insertedModelloLiberatoria = modelloLiberatoriaRepository.saveAndFlush(modelloLiberatoria); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the modelloLiberatoria using partial update + ModelloLiberatoria partialUpdatedModelloLiberatoria = new ModelloLiberatoria(); + partialUpdatedModelloLiberatoria.setId(modelloLiberatoria.getId()); + + partialUpdatedModelloLiberatoria.testo(UPDATED_TESTO).validoDal(UPDATED_VALIDO_DAL); + + restModelloLiberatoriaMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedModelloLiberatoria.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedModelloLiberatoria)) + ) + .andExpect(status().isOk()); + + // Validate the ModelloLiberatoria in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertModelloLiberatoriaUpdatableFieldsEquals( + createUpdateProxyForBean(partialUpdatedModelloLiberatoria, modelloLiberatoria), + getPersistedModelloLiberatoria(modelloLiberatoria) + ); + } + + @Test + @Transactional + void fullUpdateModelloLiberatoriaWithPatch() throws Exception { + // Initialize the database + insertedModelloLiberatoria = modelloLiberatoriaRepository.saveAndFlush(modelloLiberatoria); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the modelloLiberatoria using partial update + ModelloLiberatoria partialUpdatedModelloLiberatoria = new ModelloLiberatoria(); + partialUpdatedModelloLiberatoria.setId(modelloLiberatoria.getId()); + + partialUpdatedModelloLiberatoria + .nome(UPDATED_NOME) + .testo(UPDATED_TESTO) + .documento(UPDATED_DOCUMENTO) + .documentoContentType(UPDATED_DOCUMENTO_CONTENT_TYPE) + .validoDal(UPDATED_VALIDO_DAL) + .validoAl(UPDATED_VALIDO_AL); + + restModelloLiberatoriaMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedModelloLiberatoria.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedModelloLiberatoria)) + ) + .andExpect(status().isOk()); + + // Validate the ModelloLiberatoria in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertModelloLiberatoriaUpdatableFieldsEquals( + partialUpdatedModelloLiberatoria, + getPersistedModelloLiberatoria(partialUpdatedModelloLiberatoria) + ); + } + + @Test + @Transactional + void patchNonExistingModelloLiberatoria() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + modelloLiberatoria.setId(longCount.incrementAndGet()); + + // Create the ModelloLiberatoria + ModelloLiberatoriaDTO modelloLiberatoriaDTO = modelloLiberatoriaMapper.toDto(modelloLiberatoria); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restModelloLiberatoriaMockMvc + .perform( + patch(ENTITY_API_URL_ID, modelloLiberatoriaDTO.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(modelloLiberatoriaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the ModelloLiberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithIdMismatchModelloLiberatoria() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + modelloLiberatoria.setId(longCount.incrementAndGet()); + + // Create the ModelloLiberatoria + ModelloLiberatoriaDTO modelloLiberatoriaDTO = modelloLiberatoriaMapper.toDto(modelloLiberatoria); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restModelloLiberatoriaMockMvc + .perform( + patch(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(modelloLiberatoriaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the ModelloLiberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithMissingIdPathParamModelloLiberatoria() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + modelloLiberatoria.setId(longCount.incrementAndGet()); + + // Create the ModelloLiberatoria + ModelloLiberatoriaDTO modelloLiberatoriaDTO = modelloLiberatoriaMapper.toDto(modelloLiberatoria); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restModelloLiberatoriaMockMvc + .perform( + patch(ENTITY_API_URL) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(modelloLiberatoriaDTO)) + ) + .andExpect(status().isMethodNotAllowed()); + + // Validate the ModelloLiberatoria in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void deleteModelloLiberatoria() throws Exception { + // Initialize the database + insertedModelloLiberatoria = modelloLiberatoriaRepository.saveAndFlush(modelloLiberatoria); + + long databaseSizeBeforeDelete = getRepositoryCount(); + + // Delete the modelloLiberatoria + restModelloLiberatoriaMockMvc + .perform(delete(ENTITY_API_URL_ID, modelloLiberatoria.getId()).with(csrf()).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + assertDecrementedRepositoryCount(databaseSizeBeforeDelete); + } + + protected long getRepositoryCount() { + return modelloLiberatoriaRepository.count(); + } + + protected void assertIncrementedRepositoryCount(long countBefore) { + assertThat(countBefore + 1).isEqualTo(getRepositoryCount()); + } + + protected void assertDecrementedRepositoryCount(long countBefore) { + assertThat(countBefore - 1).isEqualTo(getRepositoryCount()); + } + + protected void assertSameRepositoryCount(long countBefore) { + assertThat(countBefore).isEqualTo(getRepositoryCount()); + } + + protected ModelloLiberatoria getPersistedModelloLiberatoria(ModelloLiberatoria modelloLiberatoria) { + return modelloLiberatoriaRepository.findById(modelloLiberatoria.getId()).orElseThrow(); + } + + protected void assertPersistedModelloLiberatoriaToMatchAllProperties(ModelloLiberatoria expectedModelloLiberatoria) { + assertModelloLiberatoriaAllPropertiesEquals(expectedModelloLiberatoria, getPersistedModelloLiberatoria(expectedModelloLiberatoria)); + } + + protected void assertPersistedModelloLiberatoriaToMatchUpdatableProperties(ModelloLiberatoria expectedModelloLiberatoria) { + assertModelloLiberatoriaAllUpdatablePropertiesEquals( + expectedModelloLiberatoria, + getPersistedModelloLiberatoria(expectedModelloLiberatoria) + ); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/web/rest/NotificaResourceIT.java b/src/test/java/it/sw/pa/comune/artegna/web/rest/NotificaResourceIT.java new file mode 100644 index 0000000..d6d74f1 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/web/rest/NotificaResourceIT.java @@ -0,0 +1,846 @@ +package it.sw.pa.comune.artegna.web.rest; + +import static it.sw.pa.comune.artegna.domain.NotificaAsserts.*; +import static it.sw.pa.comune.artegna.web.rest.TestUtil.createUpdateProxyForBean; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import it.sw.pa.comune.artegna.IntegrationTest; +import it.sw.pa.comune.artegna.domain.Conferma; +import it.sw.pa.comune.artegna.domain.Notifica; +import it.sw.pa.comune.artegna.domain.enumeration.TipoCanaleNotifica; +import it.sw.pa.comune.artegna.domain.enumeration.TipoEventoNotifica; +import it.sw.pa.comune.artegna.repository.NotificaRepository; +import it.sw.pa.comune.artegna.service.dto.NotificaDTO; +import it.sw.pa.comune.artegna.service.mapper.NotificaMapper; +import jakarta.persistence.EntityManager; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +/** + * Integration tests for the {@link NotificaResource} REST controller. + */ +@IntegrationTest +@AutoConfigureMockMvc +@WithMockUser +class NotificaResourceIT { + + private static final TipoCanaleNotifica DEFAULT_TIPO_CANALE = TipoCanaleNotifica.EMAIL; + private static final TipoCanaleNotifica UPDATED_TIPO_CANALE = TipoCanaleNotifica.WHATSAPP; + + private static final TipoEventoNotifica DEFAULT_TIPO_EVENTO = TipoEventoNotifica.RICHIESTA_CREATA; + private static final TipoEventoNotifica UPDATED_TIPO_EVENTO = TipoEventoNotifica.PRENOTAZIONE_CONFERMATA; + + private static final String DEFAULT_MESSAGGIO = "AAAAAAAAAA"; + private static final String UPDATED_MESSAGGIO = "BBBBBBBBBB"; + + private static final Boolean DEFAULT_INVIATA = false; + private static final Boolean UPDATED_INVIATA = true; + + private static final Instant DEFAULT_INVIATA_AT = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_INVIATA_AT = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final String DEFAULT_ERRORE = "AAAAAAAAAA"; + private static final String UPDATED_ERRORE = "BBBBBBBBBB"; + + private static final Instant DEFAULT_CREATED_AT = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_CREATED_AT = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final String ENTITY_API_URL = "/api/notificas"; + private static final String ENTITY_API_URL_ID = ENTITY_API_URL + "/{id}"; + + private static Random random = new Random(); + private static AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + @Autowired + private ObjectMapper om; + + @Autowired + private NotificaRepository notificaRepository; + + @Autowired + private NotificaMapper notificaMapper; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restNotificaMockMvc; + + private Notifica notifica; + + private Notifica insertedNotifica; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Notifica createEntity() { + return new Notifica() + .tipoCanale(DEFAULT_TIPO_CANALE) + .tipoEvento(DEFAULT_TIPO_EVENTO) + .messaggio(DEFAULT_MESSAGGIO) + .inviata(DEFAULT_INVIATA) + .inviataAt(DEFAULT_INVIATA_AT) + .errore(DEFAULT_ERRORE) + .createdAt(DEFAULT_CREATED_AT); + } + + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Notifica createUpdatedEntity() { + return new Notifica() + .tipoCanale(UPDATED_TIPO_CANALE) + .tipoEvento(UPDATED_TIPO_EVENTO) + .messaggio(UPDATED_MESSAGGIO) + .inviata(UPDATED_INVIATA) + .inviataAt(UPDATED_INVIATA_AT) + .errore(UPDATED_ERRORE) + .createdAt(UPDATED_CREATED_AT); + } + + @BeforeEach + void initTest() { + notifica = createEntity(); + } + + @AfterEach + void cleanup() { + if (insertedNotifica != null) { + notificaRepository.delete(insertedNotifica); + insertedNotifica = null; + } + } + + @Test + @Transactional + void createNotifica() throws Exception { + long databaseSizeBeforeCreate = getRepositoryCount(); + // Create the Notifica + NotificaDTO notificaDTO = notificaMapper.toDto(notifica); + var returnedNotificaDTO = om.readValue( + restNotificaMockMvc + .perform( + post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(notificaDTO)) + ) + .andExpect(status().isCreated()) + .andReturn() + .getResponse() + .getContentAsString(), + NotificaDTO.class + ); + + // Validate the Notifica in the database + assertIncrementedRepositoryCount(databaseSizeBeforeCreate); + var returnedNotifica = notificaMapper.toEntity(returnedNotificaDTO); + assertNotificaUpdatableFieldsEquals(returnedNotifica, getPersistedNotifica(returnedNotifica)); + + insertedNotifica = returnedNotifica; + } + + @Test + @Transactional + void createNotificaWithExistingId() throws Exception { + // Create the Notifica with an existing ID + notifica.setId(1L); + NotificaDTO notificaDTO = notificaMapper.toDto(notifica); + + long databaseSizeBeforeCreate = getRepositoryCount(); + + // An entity with an existing ID cannot be created, so this API call must fail + restNotificaMockMvc + .perform(post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(notificaDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Notifica in the database + assertSameRepositoryCount(databaseSizeBeforeCreate); + } + + @Test + @Transactional + void getAllNotificas() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList + restNotificaMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(notifica.getId().intValue()))) + .andExpect(jsonPath("$.[*].tipoCanale").value(hasItem(DEFAULT_TIPO_CANALE.toString()))) + .andExpect(jsonPath("$.[*].tipoEvento").value(hasItem(DEFAULT_TIPO_EVENTO.toString()))) + .andExpect(jsonPath("$.[*].messaggio").value(hasItem(DEFAULT_MESSAGGIO))) + .andExpect(jsonPath("$.[*].inviata").value(hasItem(DEFAULT_INVIATA))) + .andExpect(jsonPath("$.[*].inviataAt").value(hasItem(DEFAULT_INVIATA_AT.toString()))) + .andExpect(jsonPath("$.[*].errore").value(hasItem(DEFAULT_ERRORE))) + .andExpect(jsonPath("$.[*].createdAt").value(hasItem(DEFAULT_CREATED_AT.toString()))); + } + + @Test + @Transactional + void getNotifica() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get the notifica + restNotificaMockMvc + .perform(get(ENTITY_API_URL_ID, notifica.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(notifica.getId().intValue())) + .andExpect(jsonPath("$.tipoCanale").value(DEFAULT_TIPO_CANALE.toString())) + .andExpect(jsonPath("$.tipoEvento").value(DEFAULT_TIPO_EVENTO.toString())) + .andExpect(jsonPath("$.messaggio").value(DEFAULT_MESSAGGIO)) + .andExpect(jsonPath("$.inviata").value(DEFAULT_INVIATA)) + .andExpect(jsonPath("$.inviataAt").value(DEFAULT_INVIATA_AT.toString())) + .andExpect(jsonPath("$.errore").value(DEFAULT_ERRORE)) + .andExpect(jsonPath("$.createdAt").value(DEFAULT_CREATED_AT.toString())); + } + + @Test + @Transactional + void getNotificasByIdFiltering() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + Long id = notifica.getId(); + + defaultNotificaFiltering("id.equals=" + id, "id.notEquals=" + id); + + defaultNotificaFiltering("id.greaterThanOrEqual=" + id, "id.greaterThan=" + id); + + defaultNotificaFiltering("id.lessThanOrEqual=" + id, "id.lessThan=" + id); + } + + @Test + @Transactional + void getAllNotificasByTipoCanaleIsEqualToSomething() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where tipoCanale equals to + defaultNotificaFiltering("tipoCanale.equals=" + DEFAULT_TIPO_CANALE, "tipoCanale.equals=" + UPDATED_TIPO_CANALE); + } + + @Test + @Transactional + void getAllNotificasByTipoCanaleIsInShouldWork() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where tipoCanale in + defaultNotificaFiltering( + "tipoCanale.in=" + DEFAULT_TIPO_CANALE + "," + UPDATED_TIPO_CANALE, + "tipoCanale.in=" + UPDATED_TIPO_CANALE + ); + } + + @Test + @Transactional + void getAllNotificasByTipoCanaleIsNullOrNotNull() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where tipoCanale is not null + defaultNotificaFiltering("tipoCanale.specified=true", "tipoCanale.specified=false"); + } + + @Test + @Transactional + void getAllNotificasByTipoEventoIsEqualToSomething() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where tipoEvento equals to + defaultNotificaFiltering("tipoEvento.equals=" + DEFAULT_TIPO_EVENTO, "tipoEvento.equals=" + UPDATED_TIPO_EVENTO); + } + + @Test + @Transactional + void getAllNotificasByTipoEventoIsInShouldWork() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where tipoEvento in + defaultNotificaFiltering( + "tipoEvento.in=" + DEFAULT_TIPO_EVENTO + "," + UPDATED_TIPO_EVENTO, + "tipoEvento.in=" + UPDATED_TIPO_EVENTO + ); + } + + @Test + @Transactional + void getAllNotificasByTipoEventoIsNullOrNotNull() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where tipoEvento is not null + defaultNotificaFiltering("tipoEvento.specified=true", "tipoEvento.specified=false"); + } + + @Test + @Transactional + void getAllNotificasByMessaggioIsEqualToSomething() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where messaggio equals to + defaultNotificaFiltering("messaggio.equals=" + DEFAULT_MESSAGGIO, "messaggio.equals=" + UPDATED_MESSAGGIO); + } + + @Test + @Transactional + void getAllNotificasByMessaggioIsInShouldWork() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where messaggio in + defaultNotificaFiltering("messaggio.in=" + DEFAULT_MESSAGGIO + "," + UPDATED_MESSAGGIO, "messaggio.in=" + UPDATED_MESSAGGIO); + } + + @Test + @Transactional + void getAllNotificasByMessaggioIsNullOrNotNull() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where messaggio is not null + defaultNotificaFiltering("messaggio.specified=true", "messaggio.specified=false"); + } + + @Test + @Transactional + void getAllNotificasByMessaggioContainsSomething() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where messaggio contains + defaultNotificaFiltering("messaggio.contains=" + DEFAULT_MESSAGGIO, "messaggio.contains=" + UPDATED_MESSAGGIO); + } + + @Test + @Transactional + void getAllNotificasByMessaggioNotContainsSomething() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where messaggio does not contain + defaultNotificaFiltering("messaggio.doesNotContain=" + UPDATED_MESSAGGIO, "messaggio.doesNotContain=" + DEFAULT_MESSAGGIO); + } + + @Test + @Transactional + void getAllNotificasByInviataIsEqualToSomething() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where inviata equals to + defaultNotificaFiltering("inviata.equals=" + DEFAULT_INVIATA, "inviata.equals=" + UPDATED_INVIATA); + } + + @Test + @Transactional + void getAllNotificasByInviataIsInShouldWork() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where inviata in + defaultNotificaFiltering("inviata.in=" + DEFAULT_INVIATA + "," + UPDATED_INVIATA, "inviata.in=" + UPDATED_INVIATA); + } + + @Test + @Transactional + void getAllNotificasByInviataIsNullOrNotNull() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where inviata is not null + defaultNotificaFiltering("inviata.specified=true", "inviata.specified=false"); + } + + @Test + @Transactional + void getAllNotificasByInviataAtIsEqualToSomething() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where inviataAt equals to + defaultNotificaFiltering("inviataAt.equals=" + DEFAULT_INVIATA_AT, "inviataAt.equals=" + UPDATED_INVIATA_AT); + } + + @Test + @Transactional + void getAllNotificasByInviataAtIsInShouldWork() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where inviataAt in + defaultNotificaFiltering("inviataAt.in=" + DEFAULT_INVIATA_AT + "," + UPDATED_INVIATA_AT, "inviataAt.in=" + UPDATED_INVIATA_AT); + } + + @Test + @Transactional + void getAllNotificasByInviataAtIsNullOrNotNull() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where inviataAt is not null + defaultNotificaFiltering("inviataAt.specified=true", "inviataAt.specified=false"); + } + + @Test + @Transactional + void getAllNotificasByErroreIsEqualToSomething() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where errore equals to + defaultNotificaFiltering("errore.equals=" + DEFAULT_ERRORE, "errore.equals=" + UPDATED_ERRORE); + } + + @Test + @Transactional + void getAllNotificasByErroreIsInShouldWork() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where errore in + defaultNotificaFiltering("errore.in=" + DEFAULT_ERRORE + "," + UPDATED_ERRORE, "errore.in=" + UPDATED_ERRORE); + } + + @Test + @Transactional + void getAllNotificasByErroreIsNullOrNotNull() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where errore is not null + defaultNotificaFiltering("errore.specified=true", "errore.specified=false"); + } + + @Test + @Transactional + void getAllNotificasByErroreContainsSomething() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where errore contains + defaultNotificaFiltering("errore.contains=" + DEFAULT_ERRORE, "errore.contains=" + UPDATED_ERRORE); + } + + @Test + @Transactional + void getAllNotificasByErroreNotContainsSomething() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where errore does not contain + defaultNotificaFiltering("errore.doesNotContain=" + UPDATED_ERRORE, "errore.doesNotContain=" + DEFAULT_ERRORE); + } + + @Test + @Transactional + void getAllNotificasByCreatedAtIsEqualToSomething() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where createdAt equals to + defaultNotificaFiltering("createdAt.equals=" + DEFAULT_CREATED_AT, "createdAt.equals=" + UPDATED_CREATED_AT); + } + + @Test + @Transactional + void getAllNotificasByCreatedAtIsInShouldWork() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where createdAt in + defaultNotificaFiltering("createdAt.in=" + DEFAULT_CREATED_AT + "," + UPDATED_CREATED_AT, "createdAt.in=" + UPDATED_CREATED_AT); + } + + @Test + @Transactional + void getAllNotificasByCreatedAtIsNullOrNotNull() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + // Get all the notificaList where createdAt is not null + defaultNotificaFiltering("createdAt.specified=true", "createdAt.specified=false"); + } + + @Test + @Transactional + void getAllNotificasByConfermaIsEqualToSomething() throws Exception { + Conferma conferma; + if (TestUtil.findAll(em, Conferma.class).isEmpty()) { + notificaRepository.saveAndFlush(notifica); + conferma = ConfermaResourceIT.createEntity(); + } else { + conferma = TestUtil.findAll(em, Conferma.class).get(0); + } + em.persist(conferma); + em.flush(); + notifica.setConferma(conferma); + notificaRepository.saveAndFlush(notifica); + Long confermaId = conferma.getId(); + // Get all the notificaList where conferma equals to confermaId + defaultNotificaShouldBeFound("confermaId.equals=" + confermaId); + + // Get all the notificaList where conferma equals to (confermaId + 1) + defaultNotificaShouldNotBeFound("confermaId.equals=" + (confermaId + 1)); + } + + private void defaultNotificaFiltering(String shouldBeFound, String shouldNotBeFound) throws Exception { + defaultNotificaShouldBeFound(shouldBeFound); + defaultNotificaShouldNotBeFound(shouldNotBeFound); + } + + /** + * Executes the search, and checks that the default entity is returned. + */ + private void defaultNotificaShouldBeFound(String filter) throws Exception { + restNotificaMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(notifica.getId().intValue()))) + .andExpect(jsonPath("$.[*].tipoCanale").value(hasItem(DEFAULT_TIPO_CANALE.toString()))) + .andExpect(jsonPath("$.[*].tipoEvento").value(hasItem(DEFAULT_TIPO_EVENTO.toString()))) + .andExpect(jsonPath("$.[*].messaggio").value(hasItem(DEFAULT_MESSAGGIO))) + .andExpect(jsonPath("$.[*].inviata").value(hasItem(DEFAULT_INVIATA))) + .andExpect(jsonPath("$.[*].inviataAt").value(hasItem(DEFAULT_INVIATA_AT.toString()))) + .andExpect(jsonPath("$.[*].errore").value(hasItem(DEFAULT_ERRORE))) + .andExpect(jsonPath("$.[*].createdAt").value(hasItem(DEFAULT_CREATED_AT.toString()))); + + // Check, that the count call also returns 1 + restNotificaMockMvc + .perform(get(ENTITY_API_URL + "/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(content().string("1")); + } + + /** + * Executes the search, and checks that the default entity is not returned. + */ + private void defaultNotificaShouldNotBeFound(String filter) throws Exception { + restNotificaMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$").isArray()) + .andExpect(jsonPath("$").isEmpty()); + + // Check, that the count call also returns 0 + restNotificaMockMvc + .perform(get(ENTITY_API_URL + "/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(content().string("0")); + } + + @Test + @Transactional + void getNonExistingNotifica() throws Exception { + // Get the notifica + restNotificaMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound()); + } + + @Test + @Transactional + void putExistingNotifica() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the notifica + Notifica updatedNotifica = notificaRepository.findById(notifica.getId()).orElseThrow(); + // Disconnect from session so that the updates on updatedNotifica are not directly saved in db + em.detach(updatedNotifica); + updatedNotifica + .tipoCanale(UPDATED_TIPO_CANALE) + .tipoEvento(UPDATED_TIPO_EVENTO) + .messaggio(UPDATED_MESSAGGIO) + .inviata(UPDATED_INVIATA) + .inviataAt(UPDATED_INVIATA_AT) + .errore(UPDATED_ERRORE) + .createdAt(UPDATED_CREATED_AT); + NotificaDTO notificaDTO = notificaMapper.toDto(updatedNotifica); + + restNotificaMockMvc + .perform( + put(ENTITY_API_URL_ID, notificaDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(notificaDTO)) + ) + .andExpect(status().isOk()); + + // Validate the Notifica in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertPersistedNotificaToMatchAllProperties(updatedNotifica); + } + + @Test + @Transactional + void putNonExistingNotifica() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + notifica.setId(longCount.incrementAndGet()); + + // Create the Notifica + NotificaDTO notificaDTO = notificaMapper.toDto(notifica); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restNotificaMockMvc + .perform( + put(ENTITY_API_URL_ID, notificaDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(notificaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Notifica in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithIdMismatchNotifica() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + notifica.setId(longCount.incrementAndGet()); + + // Create the Notifica + NotificaDTO notificaDTO = notificaMapper.toDto(notifica); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restNotificaMockMvc + .perform( + put(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(notificaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Notifica in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithMissingIdPathParamNotifica() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + notifica.setId(longCount.incrementAndGet()); + + // Create the Notifica + NotificaDTO notificaDTO = notificaMapper.toDto(notifica); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restNotificaMockMvc + .perform(put(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(notificaDTO))) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Notifica in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void partialUpdateNotificaWithPatch() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the notifica using partial update + Notifica partialUpdatedNotifica = new Notifica(); + partialUpdatedNotifica.setId(notifica.getId()); + + partialUpdatedNotifica.tipoCanale(UPDATED_TIPO_CANALE).messaggio(UPDATED_MESSAGGIO); + + restNotificaMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedNotifica.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedNotifica)) + ) + .andExpect(status().isOk()); + + // Validate the Notifica in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertNotificaUpdatableFieldsEquals(createUpdateProxyForBean(partialUpdatedNotifica, notifica), getPersistedNotifica(notifica)); + } + + @Test + @Transactional + void fullUpdateNotificaWithPatch() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the notifica using partial update + Notifica partialUpdatedNotifica = new Notifica(); + partialUpdatedNotifica.setId(notifica.getId()); + + partialUpdatedNotifica + .tipoCanale(UPDATED_TIPO_CANALE) + .tipoEvento(UPDATED_TIPO_EVENTO) + .messaggio(UPDATED_MESSAGGIO) + .inviata(UPDATED_INVIATA) + .inviataAt(UPDATED_INVIATA_AT) + .errore(UPDATED_ERRORE) + .createdAt(UPDATED_CREATED_AT); + + restNotificaMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedNotifica.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedNotifica)) + ) + .andExpect(status().isOk()); + + // Validate the Notifica in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertNotificaUpdatableFieldsEquals(partialUpdatedNotifica, getPersistedNotifica(partialUpdatedNotifica)); + } + + @Test + @Transactional + void patchNonExistingNotifica() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + notifica.setId(longCount.incrementAndGet()); + + // Create the Notifica + NotificaDTO notificaDTO = notificaMapper.toDto(notifica); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restNotificaMockMvc + .perform( + patch(ENTITY_API_URL_ID, notificaDTO.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(notificaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Notifica in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithIdMismatchNotifica() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + notifica.setId(longCount.incrementAndGet()); + + // Create the Notifica + NotificaDTO notificaDTO = notificaMapper.toDto(notifica); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restNotificaMockMvc + .perform( + patch(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(notificaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Notifica in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithMissingIdPathParamNotifica() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + notifica.setId(longCount.incrementAndGet()); + + // Create the Notifica + NotificaDTO notificaDTO = notificaMapper.toDto(notifica); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restNotificaMockMvc + .perform( + patch(ENTITY_API_URL).with(csrf()).contentType("application/merge-patch+json").content(om.writeValueAsBytes(notificaDTO)) + ) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Notifica in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void deleteNotifica() throws Exception { + // Initialize the database + insertedNotifica = notificaRepository.saveAndFlush(notifica); + + long databaseSizeBeforeDelete = getRepositoryCount(); + + // Delete the notifica + restNotificaMockMvc + .perform(delete(ENTITY_API_URL_ID, notifica.getId()).with(csrf()).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + assertDecrementedRepositoryCount(databaseSizeBeforeDelete); + } + + protected long getRepositoryCount() { + return notificaRepository.count(); + } + + protected void assertIncrementedRepositoryCount(long countBefore) { + assertThat(countBefore + 1).isEqualTo(getRepositoryCount()); + } + + protected void assertDecrementedRepositoryCount(long countBefore) { + assertThat(countBefore - 1).isEqualTo(getRepositoryCount()); + } + + protected void assertSameRepositoryCount(long countBefore) { + assertThat(countBefore).isEqualTo(getRepositoryCount()); + } + + protected Notifica getPersistedNotifica(Notifica notifica) { + return notificaRepository.findById(notifica.getId()).orElseThrow(); + } + + protected void assertPersistedNotificaToMatchAllProperties(Notifica expectedNotifica) { + assertNotificaAllPropertiesEquals(expectedNotifica, getPersistedNotifica(expectedNotifica)); + } + + protected void assertPersistedNotificaToMatchUpdatableProperties(Notifica expectedNotifica) { + assertNotificaAllUpdatablePropertiesEquals(expectedNotifica, getPersistedNotifica(expectedNotifica)); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/web/rest/PrenotazioneResourceIT.java b/src/test/java/it/sw/pa/comune/artegna/web/rest/PrenotazioneResourceIT.java new file mode 100644 index 0000000..3aace34 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/web/rest/PrenotazioneResourceIT.java @@ -0,0 +1,962 @@ +package it.sw.pa.comune.artegna.web.rest; + +import static it.sw.pa.comune.artegna.domain.PrenotazioneAsserts.*; +import static it.sw.pa.comune.artegna.web.rest.TestUtil.createUpdateProxyForBean; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.mockito.Mockito.*; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import it.sw.pa.comune.artegna.IntegrationTest; +import it.sw.pa.comune.artegna.domain.Conferma; +import it.sw.pa.comune.artegna.domain.Prenotazione; +import it.sw.pa.comune.artegna.domain.Struttura; +import it.sw.pa.comune.artegna.domain.UtenteApp; +import it.sw.pa.comune.artegna.domain.enumeration.StatoPrenotazione; +import it.sw.pa.comune.artegna.repository.PrenotazioneRepository; +import it.sw.pa.comune.artegna.service.PrenotazioneService; +import it.sw.pa.comune.artegna.service.dto.PrenotazioneDTO; +import it.sw.pa.comune.artegna.service.mapper.PrenotazioneMapper; +import jakarta.persistence.EntityManager; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +/** + * Integration tests for the {@link PrenotazioneResource} REST controller. + */ +@IntegrationTest +@ExtendWith(MockitoExtension.class) +@AutoConfigureMockMvc +@WithMockUser +class PrenotazioneResourceIT { + + private static final Instant DEFAULT_ORA_INIZIO = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_ORA_INIZIO = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final Instant DEFAULT_ORA_FINE = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_ORA_FINE = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final StatoPrenotazione DEFAULT_STATO = StatoPrenotazione.RICHIESTA; + private static final StatoPrenotazione UPDATED_STATO = StatoPrenotazione.CONFERMATA; + + private static final String DEFAULT_MOTIVO_EVENTO = "AAAAAAAAAA"; + private static final String UPDATED_MOTIVO_EVENTO = "BBBBBBBBBB"; + + private static final Integer DEFAULT_NUMERO_PARTECIPANTI = 1; + private static final Integer UPDATED_NUMERO_PARTECIPANTI = 2; + private static final Integer SMALLER_NUMERO_PARTECIPANTI = 1 - 1; + + private static final String DEFAULT_NOTE_UTENTE = "AAAAAAAAAA"; + private static final String UPDATED_NOTE_UTENTE = "BBBBBBBBBB"; + + private static final String ENTITY_API_URL = "/api/prenotaziones"; + private static final String ENTITY_API_URL_ID = ENTITY_API_URL + "/{id}"; + + private static Random random = new Random(); + private static AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + @Autowired + private ObjectMapper om; + + @Autowired + private PrenotazioneRepository prenotazioneRepository; + + @Mock + private PrenotazioneRepository prenotazioneRepositoryMock; + + @Autowired + private PrenotazioneMapper prenotazioneMapper; + + @Mock + private PrenotazioneService prenotazioneServiceMock; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restPrenotazioneMockMvc; + + private Prenotazione prenotazione; + + private Prenotazione insertedPrenotazione; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Prenotazione createEntity() { + return new Prenotazione() + .oraInizio(DEFAULT_ORA_INIZIO) + .oraFine(DEFAULT_ORA_FINE) + .stato(DEFAULT_STATO) + .motivoEvento(DEFAULT_MOTIVO_EVENTO) + .numeroPartecipanti(DEFAULT_NUMERO_PARTECIPANTI) + .noteUtente(DEFAULT_NOTE_UTENTE); + } + + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Prenotazione createUpdatedEntity() { + return new Prenotazione() + .oraInizio(UPDATED_ORA_INIZIO) + .oraFine(UPDATED_ORA_FINE) + .stato(UPDATED_STATO) + .motivoEvento(UPDATED_MOTIVO_EVENTO) + .numeroPartecipanti(UPDATED_NUMERO_PARTECIPANTI) + .noteUtente(UPDATED_NOTE_UTENTE); + } + + @BeforeEach + void initTest() { + prenotazione = createEntity(); + } + + @AfterEach + void cleanup() { + if (insertedPrenotazione != null) { + prenotazioneRepository.delete(insertedPrenotazione); + insertedPrenotazione = null; + } + } + + @Test + @Transactional + void createPrenotazione() throws Exception { + long databaseSizeBeforeCreate = getRepositoryCount(); + // Create the Prenotazione + PrenotazioneDTO prenotazioneDTO = prenotazioneMapper.toDto(prenotazione); + var returnedPrenotazioneDTO = om.readValue( + restPrenotazioneMockMvc + .perform( + post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(prenotazioneDTO)) + ) + .andExpect(status().isCreated()) + .andReturn() + .getResponse() + .getContentAsString(), + PrenotazioneDTO.class + ); + + // Validate the Prenotazione in the database + assertIncrementedRepositoryCount(databaseSizeBeforeCreate); + var returnedPrenotazione = prenotazioneMapper.toEntity(returnedPrenotazioneDTO); + assertPrenotazioneUpdatableFieldsEquals(returnedPrenotazione, getPersistedPrenotazione(returnedPrenotazione)); + + insertedPrenotazione = returnedPrenotazione; + } + + @Test + @Transactional + void createPrenotazioneWithExistingId() throws Exception { + // Create the Prenotazione with an existing ID + prenotazione.setId(1L); + PrenotazioneDTO prenotazioneDTO = prenotazioneMapper.toDto(prenotazione); + + long databaseSizeBeforeCreate = getRepositoryCount(); + + // An entity with an existing ID cannot be created, so this API call must fail + restPrenotazioneMockMvc + .perform( + post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(prenotazioneDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Prenotazione in the database + assertSameRepositoryCount(databaseSizeBeforeCreate); + } + + @Test + @Transactional + void getAllPrenotaziones() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList + restPrenotazioneMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(prenotazione.getId().intValue()))) + .andExpect(jsonPath("$.[*].oraInizio").value(hasItem(DEFAULT_ORA_INIZIO.toString()))) + .andExpect(jsonPath("$.[*].oraFine").value(hasItem(DEFAULT_ORA_FINE.toString()))) + .andExpect(jsonPath("$.[*].stato").value(hasItem(DEFAULT_STATO.toString()))) + .andExpect(jsonPath("$.[*].motivoEvento").value(hasItem(DEFAULT_MOTIVO_EVENTO))) + .andExpect(jsonPath("$.[*].numeroPartecipanti").value(hasItem(DEFAULT_NUMERO_PARTECIPANTI))) + .andExpect(jsonPath("$.[*].noteUtente").value(hasItem(DEFAULT_NOTE_UTENTE))); + } + + @SuppressWarnings({ "unchecked" }) + void getAllPrenotazionesWithEagerRelationshipsIsEnabled() throws Exception { + when(prenotazioneServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restPrenotazioneMockMvc.perform(get(ENTITY_API_URL + "?eagerload=true")).andExpect(status().isOk()); + + verify(prenotazioneServiceMock, times(1)).findAllWithEagerRelationships(any()); + } + + @SuppressWarnings({ "unchecked" }) + void getAllPrenotazionesWithEagerRelationshipsIsNotEnabled() throws Exception { + when(prenotazioneServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restPrenotazioneMockMvc.perform(get(ENTITY_API_URL + "?eagerload=false")).andExpect(status().isOk()); + verify(prenotazioneRepositoryMock, times(1)).findAll(any(Pageable.class)); + } + + @Test + @Transactional + void getPrenotazione() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get the prenotazione + restPrenotazioneMockMvc + .perform(get(ENTITY_API_URL_ID, prenotazione.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(prenotazione.getId().intValue())) + .andExpect(jsonPath("$.oraInizio").value(DEFAULT_ORA_INIZIO.toString())) + .andExpect(jsonPath("$.oraFine").value(DEFAULT_ORA_FINE.toString())) + .andExpect(jsonPath("$.stato").value(DEFAULT_STATO.toString())) + .andExpect(jsonPath("$.motivoEvento").value(DEFAULT_MOTIVO_EVENTO)) + .andExpect(jsonPath("$.numeroPartecipanti").value(DEFAULT_NUMERO_PARTECIPANTI)) + .andExpect(jsonPath("$.noteUtente").value(DEFAULT_NOTE_UTENTE)); + } + + @Test + @Transactional + void getPrenotazionesByIdFiltering() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + Long id = prenotazione.getId(); + + defaultPrenotazioneFiltering("id.equals=" + id, "id.notEquals=" + id); + + defaultPrenotazioneFiltering("id.greaterThanOrEqual=" + id, "id.greaterThan=" + id); + + defaultPrenotazioneFiltering("id.lessThanOrEqual=" + id, "id.lessThan=" + id); + } + + @Test + @Transactional + void getAllPrenotazionesByOraInizioIsEqualToSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where oraInizio equals to + defaultPrenotazioneFiltering("oraInizio.equals=" + DEFAULT_ORA_INIZIO, "oraInizio.equals=" + UPDATED_ORA_INIZIO); + } + + @Test + @Transactional + void getAllPrenotazionesByOraInizioIsInShouldWork() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where oraInizio in + defaultPrenotazioneFiltering("oraInizio.in=" + DEFAULT_ORA_INIZIO + "," + UPDATED_ORA_INIZIO, "oraInizio.in=" + UPDATED_ORA_INIZIO); + } + + @Test + @Transactional + void getAllPrenotazionesByOraInizioIsNullOrNotNull() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where oraInizio is not null + defaultPrenotazioneFiltering("oraInizio.specified=true", "oraInizio.specified=false"); + } + + @Test + @Transactional + void getAllPrenotazionesByOraFineIsEqualToSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where oraFine equals to + defaultPrenotazioneFiltering("oraFine.equals=" + DEFAULT_ORA_FINE, "oraFine.equals=" + UPDATED_ORA_FINE); + } + + @Test + @Transactional + void getAllPrenotazionesByOraFineIsInShouldWork() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where oraFine in + defaultPrenotazioneFiltering("oraFine.in=" + DEFAULT_ORA_FINE + "," + UPDATED_ORA_FINE, "oraFine.in=" + UPDATED_ORA_FINE); + } + + @Test + @Transactional + void getAllPrenotazionesByOraFineIsNullOrNotNull() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where oraFine is not null + defaultPrenotazioneFiltering("oraFine.specified=true", "oraFine.specified=false"); + } + + @Test + @Transactional + void getAllPrenotazionesByStatoIsEqualToSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where stato equals to + defaultPrenotazioneFiltering("stato.equals=" + DEFAULT_STATO, "stato.equals=" + UPDATED_STATO); + } + + @Test + @Transactional + void getAllPrenotazionesByStatoIsInShouldWork() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where stato in + defaultPrenotazioneFiltering("stato.in=" + DEFAULT_STATO + "," + UPDATED_STATO, "stato.in=" + UPDATED_STATO); + } + + @Test + @Transactional + void getAllPrenotazionesByStatoIsNullOrNotNull() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where stato is not null + defaultPrenotazioneFiltering("stato.specified=true", "stato.specified=false"); + } + + @Test + @Transactional + void getAllPrenotazionesByMotivoEventoIsEqualToSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where motivoEvento equals to + defaultPrenotazioneFiltering("motivoEvento.equals=" + DEFAULT_MOTIVO_EVENTO, "motivoEvento.equals=" + UPDATED_MOTIVO_EVENTO); + } + + @Test + @Transactional + void getAllPrenotazionesByMotivoEventoIsInShouldWork() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where motivoEvento in + defaultPrenotazioneFiltering( + "motivoEvento.in=" + DEFAULT_MOTIVO_EVENTO + "," + UPDATED_MOTIVO_EVENTO, + "motivoEvento.in=" + UPDATED_MOTIVO_EVENTO + ); + } + + @Test + @Transactional + void getAllPrenotazionesByMotivoEventoIsNullOrNotNull() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where motivoEvento is not null + defaultPrenotazioneFiltering("motivoEvento.specified=true", "motivoEvento.specified=false"); + } + + @Test + @Transactional + void getAllPrenotazionesByMotivoEventoContainsSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where motivoEvento contains + defaultPrenotazioneFiltering("motivoEvento.contains=" + DEFAULT_MOTIVO_EVENTO, "motivoEvento.contains=" + UPDATED_MOTIVO_EVENTO); + } + + @Test + @Transactional + void getAllPrenotazionesByMotivoEventoNotContainsSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where motivoEvento does not contain + defaultPrenotazioneFiltering( + "motivoEvento.doesNotContain=" + UPDATED_MOTIVO_EVENTO, + "motivoEvento.doesNotContain=" + DEFAULT_MOTIVO_EVENTO + ); + } + + @Test + @Transactional + void getAllPrenotazionesByNumeroPartecipantiIsEqualToSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where numeroPartecipanti equals to + defaultPrenotazioneFiltering( + "numeroPartecipanti.equals=" + DEFAULT_NUMERO_PARTECIPANTI, + "numeroPartecipanti.equals=" + UPDATED_NUMERO_PARTECIPANTI + ); + } + + @Test + @Transactional + void getAllPrenotazionesByNumeroPartecipantiIsInShouldWork() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where numeroPartecipanti in + defaultPrenotazioneFiltering( + "numeroPartecipanti.in=" + DEFAULT_NUMERO_PARTECIPANTI + "," + UPDATED_NUMERO_PARTECIPANTI, + "numeroPartecipanti.in=" + UPDATED_NUMERO_PARTECIPANTI + ); + } + + @Test + @Transactional + void getAllPrenotazionesByNumeroPartecipantiIsNullOrNotNull() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where numeroPartecipanti is not null + defaultPrenotazioneFiltering("numeroPartecipanti.specified=true", "numeroPartecipanti.specified=false"); + } + + @Test + @Transactional + void getAllPrenotazionesByNumeroPartecipantiIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where numeroPartecipanti is greater than or equal to + defaultPrenotazioneFiltering( + "numeroPartecipanti.greaterThanOrEqual=" + DEFAULT_NUMERO_PARTECIPANTI, + "numeroPartecipanti.greaterThanOrEqual=" + UPDATED_NUMERO_PARTECIPANTI + ); + } + + @Test + @Transactional + void getAllPrenotazionesByNumeroPartecipantiIsLessThanOrEqualToSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where numeroPartecipanti is less than or equal to + defaultPrenotazioneFiltering( + "numeroPartecipanti.lessThanOrEqual=" + DEFAULT_NUMERO_PARTECIPANTI, + "numeroPartecipanti.lessThanOrEqual=" + SMALLER_NUMERO_PARTECIPANTI + ); + } + + @Test + @Transactional + void getAllPrenotazionesByNumeroPartecipantiIsLessThanSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where numeroPartecipanti is less than + defaultPrenotazioneFiltering( + "numeroPartecipanti.lessThan=" + UPDATED_NUMERO_PARTECIPANTI, + "numeroPartecipanti.lessThan=" + DEFAULT_NUMERO_PARTECIPANTI + ); + } + + @Test + @Transactional + void getAllPrenotazionesByNumeroPartecipantiIsGreaterThanSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where numeroPartecipanti is greater than + defaultPrenotazioneFiltering( + "numeroPartecipanti.greaterThan=" + SMALLER_NUMERO_PARTECIPANTI, + "numeroPartecipanti.greaterThan=" + DEFAULT_NUMERO_PARTECIPANTI + ); + } + + @Test + @Transactional + void getAllPrenotazionesByNoteUtenteIsEqualToSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where noteUtente equals to + defaultPrenotazioneFiltering("noteUtente.equals=" + DEFAULT_NOTE_UTENTE, "noteUtente.equals=" + UPDATED_NOTE_UTENTE); + } + + @Test + @Transactional + void getAllPrenotazionesByNoteUtenteIsInShouldWork() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where noteUtente in + defaultPrenotazioneFiltering( + "noteUtente.in=" + DEFAULT_NOTE_UTENTE + "," + UPDATED_NOTE_UTENTE, + "noteUtente.in=" + UPDATED_NOTE_UTENTE + ); + } + + @Test + @Transactional + void getAllPrenotazionesByNoteUtenteIsNullOrNotNull() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where noteUtente is not null + defaultPrenotazioneFiltering("noteUtente.specified=true", "noteUtente.specified=false"); + } + + @Test + @Transactional + void getAllPrenotazionesByNoteUtenteContainsSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where noteUtente contains + defaultPrenotazioneFiltering("noteUtente.contains=" + DEFAULT_NOTE_UTENTE, "noteUtente.contains=" + UPDATED_NOTE_UTENTE); + } + + @Test + @Transactional + void getAllPrenotazionesByNoteUtenteNotContainsSomething() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + // Get all the prenotazioneList where noteUtente does not contain + defaultPrenotazioneFiltering( + "noteUtente.doesNotContain=" + UPDATED_NOTE_UTENTE, + "noteUtente.doesNotContain=" + DEFAULT_NOTE_UTENTE + ); + } + + @Test + @Transactional + void getAllPrenotazionesByConfermaIsEqualToSomething() throws Exception { + Conferma conferma; + if (TestUtil.findAll(em, Conferma.class).isEmpty()) { + prenotazioneRepository.saveAndFlush(prenotazione); + conferma = ConfermaResourceIT.createEntity(); + } else { + conferma = TestUtil.findAll(em, Conferma.class).get(0); + } + em.persist(conferma); + em.flush(); + prenotazione.setConferma(conferma); + prenotazioneRepository.saveAndFlush(prenotazione); + Long confermaId = conferma.getId(); + // Get all the prenotazioneList where conferma equals to confermaId + defaultPrenotazioneShouldBeFound("confermaId.equals=" + confermaId); + + // Get all the prenotazioneList where conferma equals to (confermaId + 1) + defaultPrenotazioneShouldNotBeFound("confermaId.equals=" + (confermaId + 1)); + } + + @Test + @Transactional + void getAllPrenotazionesByUtenteIsEqualToSomething() throws Exception { + UtenteApp utente; + if (TestUtil.findAll(em, UtenteApp.class).isEmpty()) { + prenotazioneRepository.saveAndFlush(prenotazione); + utente = UtenteAppResourceIT.createEntity(); + } else { + utente = TestUtil.findAll(em, UtenteApp.class).get(0); + } + em.persist(utente); + em.flush(); + prenotazione.setUtente(utente); + prenotazioneRepository.saveAndFlush(prenotazione); + Long utenteId = utente.getId(); + // Get all the prenotazioneList where utente equals to utenteId + defaultPrenotazioneShouldBeFound("utenteId.equals=" + utenteId); + + // Get all the prenotazioneList where utente equals to (utenteId + 1) + defaultPrenotazioneShouldNotBeFound("utenteId.equals=" + (utenteId + 1)); + } + + @Test + @Transactional + void getAllPrenotazionesByStrutturaIsEqualToSomething() throws Exception { + Struttura struttura; + if (TestUtil.findAll(em, Struttura.class).isEmpty()) { + prenotazioneRepository.saveAndFlush(prenotazione); + struttura = StrutturaResourceIT.createEntity(); + } else { + struttura = TestUtil.findAll(em, Struttura.class).get(0); + } + em.persist(struttura); + em.flush(); + prenotazione.setStruttura(struttura); + prenotazioneRepository.saveAndFlush(prenotazione); + Long strutturaId = struttura.getId(); + // Get all the prenotazioneList where struttura equals to strutturaId + defaultPrenotazioneShouldBeFound("strutturaId.equals=" + strutturaId); + + // Get all the prenotazioneList where struttura equals to (strutturaId + 1) + defaultPrenotazioneShouldNotBeFound("strutturaId.equals=" + (strutturaId + 1)); + } + + private void defaultPrenotazioneFiltering(String shouldBeFound, String shouldNotBeFound) throws Exception { + defaultPrenotazioneShouldBeFound(shouldBeFound); + defaultPrenotazioneShouldNotBeFound(shouldNotBeFound); + } + + /** + * Executes the search, and checks that the default entity is returned. + */ + private void defaultPrenotazioneShouldBeFound(String filter) throws Exception { + restPrenotazioneMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(prenotazione.getId().intValue()))) + .andExpect(jsonPath("$.[*].oraInizio").value(hasItem(DEFAULT_ORA_INIZIO.toString()))) + .andExpect(jsonPath("$.[*].oraFine").value(hasItem(DEFAULT_ORA_FINE.toString()))) + .andExpect(jsonPath("$.[*].stato").value(hasItem(DEFAULT_STATO.toString()))) + .andExpect(jsonPath("$.[*].motivoEvento").value(hasItem(DEFAULT_MOTIVO_EVENTO))) + .andExpect(jsonPath("$.[*].numeroPartecipanti").value(hasItem(DEFAULT_NUMERO_PARTECIPANTI))) + .andExpect(jsonPath("$.[*].noteUtente").value(hasItem(DEFAULT_NOTE_UTENTE))); + + // Check, that the count call also returns 1 + restPrenotazioneMockMvc + .perform(get(ENTITY_API_URL + "/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(content().string("1")); + } + + /** + * Executes the search, and checks that the default entity is not returned. + */ + private void defaultPrenotazioneShouldNotBeFound(String filter) throws Exception { + restPrenotazioneMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$").isArray()) + .andExpect(jsonPath("$").isEmpty()); + + // Check, that the count call also returns 0 + restPrenotazioneMockMvc + .perform(get(ENTITY_API_URL + "/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(content().string("0")); + } + + @Test + @Transactional + void getNonExistingPrenotazione() throws Exception { + // Get the prenotazione + restPrenotazioneMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound()); + } + + @Test + @Transactional + void putExistingPrenotazione() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the prenotazione + Prenotazione updatedPrenotazione = prenotazioneRepository.findById(prenotazione.getId()).orElseThrow(); + // Disconnect from session so that the updates on updatedPrenotazione are not directly saved in db + em.detach(updatedPrenotazione); + updatedPrenotazione + .oraInizio(UPDATED_ORA_INIZIO) + .oraFine(UPDATED_ORA_FINE) + .stato(UPDATED_STATO) + .motivoEvento(UPDATED_MOTIVO_EVENTO) + .numeroPartecipanti(UPDATED_NUMERO_PARTECIPANTI) + .noteUtente(UPDATED_NOTE_UTENTE); + PrenotazioneDTO prenotazioneDTO = prenotazioneMapper.toDto(updatedPrenotazione); + + restPrenotazioneMockMvc + .perform( + put(ENTITY_API_URL_ID, prenotazioneDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(prenotazioneDTO)) + ) + .andExpect(status().isOk()); + + // Validate the Prenotazione in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertPersistedPrenotazioneToMatchAllProperties(updatedPrenotazione); + } + + @Test + @Transactional + void putNonExistingPrenotazione() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + prenotazione.setId(longCount.incrementAndGet()); + + // Create the Prenotazione + PrenotazioneDTO prenotazioneDTO = prenotazioneMapper.toDto(prenotazione); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restPrenotazioneMockMvc + .perform( + put(ENTITY_API_URL_ID, prenotazioneDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(prenotazioneDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Prenotazione in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithIdMismatchPrenotazione() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + prenotazione.setId(longCount.incrementAndGet()); + + // Create the Prenotazione + PrenotazioneDTO prenotazioneDTO = prenotazioneMapper.toDto(prenotazione); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restPrenotazioneMockMvc + .perform( + put(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(prenotazioneDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Prenotazione in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithMissingIdPathParamPrenotazione() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + prenotazione.setId(longCount.incrementAndGet()); + + // Create the Prenotazione + PrenotazioneDTO prenotazioneDTO = prenotazioneMapper.toDto(prenotazione); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restPrenotazioneMockMvc + .perform( + put(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(prenotazioneDTO)) + ) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Prenotazione in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void partialUpdatePrenotazioneWithPatch() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the prenotazione using partial update + Prenotazione partialUpdatedPrenotazione = new Prenotazione(); + partialUpdatedPrenotazione.setId(prenotazione.getId()); + + partialUpdatedPrenotazione + .oraFine(UPDATED_ORA_FINE) + .stato(UPDATED_STATO) + .motivoEvento(UPDATED_MOTIVO_EVENTO) + .numeroPartecipanti(UPDATED_NUMERO_PARTECIPANTI); + + restPrenotazioneMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedPrenotazione.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedPrenotazione)) + ) + .andExpect(status().isOk()); + + // Validate the Prenotazione in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertPrenotazioneUpdatableFieldsEquals( + createUpdateProxyForBean(partialUpdatedPrenotazione, prenotazione), + getPersistedPrenotazione(prenotazione) + ); + } + + @Test + @Transactional + void fullUpdatePrenotazioneWithPatch() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the prenotazione using partial update + Prenotazione partialUpdatedPrenotazione = new Prenotazione(); + partialUpdatedPrenotazione.setId(prenotazione.getId()); + + partialUpdatedPrenotazione + .oraInizio(UPDATED_ORA_INIZIO) + .oraFine(UPDATED_ORA_FINE) + .stato(UPDATED_STATO) + .motivoEvento(UPDATED_MOTIVO_EVENTO) + .numeroPartecipanti(UPDATED_NUMERO_PARTECIPANTI) + .noteUtente(UPDATED_NOTE_UTENTE); + + restPrenotazioneMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedPrenotazione.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedPrenotazione)) + ) + .andExpect(status().isOk()); + + // Validate the Prenotazione in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertPrenotazioneUpdatableFieldsEquals(partialUpdatedPrenotazione, getPersistedPrenotazione(partialUpdatedPrenotazione)); + } + + @Test + @Transactional + void patchNonExistingPrenotazione() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + prenotazione.setId(longCount.incrementAndGet()); + + // Create the Prenotazione + PrenotazioneDTO prenotazioneDTO = prenotazioneMapper.toDto(prenotazione); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restPrenotazioneMockMvc + .perform( + patch(ENTITY_API_URL_ID, prenotazioneDTO.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(prenotazioneDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Prenotazione in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithIdMismatchPrenotazione() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + prenotazione.setId(longCount.incrementAndGet()); + + // Create the Prenotazione + PrenotazioneDTO prenotazioneDTO = prenotazioneMapper.toDto(prenotazione); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restPrenotazioneMockMvc + .perform( + patch(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(prenotazioneDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Prenotazione in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithMissingIdPathParamPrenotazione() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + prenotazione.setId(longCount.incrementAndGet()); + + // Create the Prenotazione + PrenotazioneDTO prenotazioneDTO = prenotazioneMapper.toDto(prenotazione); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restPrenotazioneMockMvc + .perform( + patch(ENTITY_API_URL) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(prenotazioneDTO)) + ) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Prenotazione in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void deletePrenotazione() throws Exception { + // Initialize the database + insertedPrenotazione = prenotazioneRepository.saveAndFlush(prenotazione); + + long databaseSizeBeforeDelete = getRepositoryCount(); + + // Delete the prenotazione + restPrenotazioneMockMvc + .perform(delete(ENTITY_API_URL_ID, prenotazione.getId()).with(csrf()).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + assertDecrementedRepositoryCount(databaseSizeBeforeDelete); + } + + protected long getRepositoryCount() { + return prenotazioneRepository.count(); + } + + protected void assertIncrementedRepositoryCount(long countBefore) { + assertThat(countBefore + 1).isEqualTo(getRepositoryCount()); + } + + protected void assertDecrementedRepositoryCount(long countBefore) { + assertThat(countBefore - 1).isEqualTo(getRepositoryCount()); + } + + protected void assertSameRepositoryCount(long countBefore) { + assertThat(countBefore).isEqualTo(getRepositoryCount()); + } + + protected Prenotazione getPersistedPrenotazione(Prenotazione prenotazione) { + return prenotazioneRepository.findById(prenotazione.getId()).orElseThrow(); + } + + protected void assertPersistedPrenotazioneToMatchAllProperties(Prenotazione expectedPrenotazione) { + assertPrenotazioneAllPropertiesEquals(expectedPrenotazione, getPersistedPrenotazione(expectedPrenotazione)); + } + + protected void assertPersistedPrenotazioneToMatchUpdatableProperties(Prenotazione expectedPrenotazione) { + assertPrenotazioneAllUpdatablePropertiesEquals(expectedPrenotazione, getPersistedPrenotazione(expectedPrenotazione)); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/web/rest/StrutturaResourceIT.java b/src/test/java/it/sw/pa/comune/artegna/web/rest/StrutturaResourceIT.java new file mode 100644 index 0000000..2c9290e --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/web/rest/StrutturaResourceIT.java @@ -0,0 +1,951 @@ +package it.sw.pa.comune.artegna.web.rest; + +import static it.sw.pa.comune.artegna.domain.StrutturaAsserts.*; +import static it.sw.pa.comune.artegna.web.rest.TestUtil.createUpdateProxyForBean; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import it.sw.pa.comune.artegna.IntegrationTest; +import it.sw.pa.comune.artegna.domain.Struttura; +import it.sw.pa.comune.artegna.repository.StrutturaRepository; +import it.sw.pa.comune.artegna.service.dto.StrutturaDTO; +import it.sw.pa.comune.artegna.service.mapper.StrutturaMapper; +import jakarta.persistence.EntityManager; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +/** + * Integration tests for the {@link StrutturaResource} REST controller. + */ +@IntegrationTest +@AutoConfigureMockMvc +@WithMockUser +class StrutturaResourceIT { + + private static final String DEFAULT_NOME = "AAAAAAAAAA"; + private static final String UPDATED_NOME = "BBBBBBBBBB"; + + private static final String DEFAULT_DESCRIZIONE = "AAAAAAAAAA"; + private static final String UPDATED_DESCRIZIONE = "BBBBBBBBBB"; + + private static final String DEFAULT_INDIRIZZO = "AAAAAAAAAA"; + private static final String UPDATED_INDIRIZZO = "BBBBBBBBBB"; + + private static final Integer DEFAULT_CAPIENZA_MAX = 1; + private static final Integer UPDATED_CAPIENZA_MAX = 2; + private static final Integer SMALLER_CAPIENZA_MAX = 1 - 1; + + private static final Boolean DEFAULT_ATTIVA = false; + private static final Boolean UPDATED_ATTIVA = true; + + private static final String DEFAULT_FOTO_URL = "AAAAAAAAAA"; + private static final String UPDATED_FOTO_URL = "BBBBBBBBBB"; + + private static final Instant DEFAULT_CREATED_AT = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_CREATED_AT = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final Instant DEFAULT_UPDATED_AT = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_UPDATED_AT = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final String ENTITY_API_URL = "/api/strutturas"; + private static final String ENTITY_API_URL_ID = ENTITY_API_URL + "/{id}"; + + private static Random random = new Random(); + private static AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + @Autowired + private ObjectMapper om; + + @Autowired + private StrutturaRepository strutturaRepository; + + @Autowired + private StrutturaMapper strutturaMapper; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restStrutturaMockMvc; + + private Struttura struttura; + + private Struttura insertedStruttura; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Struttura createEntity() { + return new Struttura() + .nome(DEFAULT_NOME) + .descrizione(DEFAULT_DESCRIZIONE) + .indirizzo(DEFAULT_INDIRIZZO) + .capienzaMax(DEFAULT_CAPIENZA_MAX) + .attiva(DEFAULT_ATTIVA) + .fotoUrl(DEFAULT_FOTO_URL) + .createdAt(DEFAULT_CREATED_AT) + .updatedAt(DEFAULT_UPDATED_AT); + } + + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Struttura createUpdatedEntity() { + return new Struttura() + .nome(UPDATED_NOME) + .descrizione(UPDATED_DESCRIZIONE) + .indirizzo(UPDATED_INDIRIZZO) + .capienzaMax(UPDATED_CAPIENZA_MAX) + .attiva(UPDATED_ATTIVA) + .fotoUrl(UPDATED_FOTO_URL) + .createdAt(UPDATED_CREATED_AT) + .updatedAt(UPDATED_UPDATED_AT); + } + + @BeforeEach + void initTest() { + struttura = createEntity(); + } + + @AfterEach + void cleanup() { + if (insertedStruttura != null) { + strutturaRepository.delete(insertedStruttura); + insertedStruttura = null; + } + } + + @Test + @Transactional + void createStruttura() throws Exception { + long databaseSizeBeforeCreate = getRepositoryCount(); + // Create the Struttura + StrutturaDTO strutturaDTO = strutturaMapper.toDto(struttura); + var returnedStrutturaDTO = om.readValue( + restStrutturaMockMvc + .perform( + post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(strutturaDTO)) + ) + .andExpect(status().isCreated()) + .andReturn() + .getResponse() + .getContentAsString(), + StrutturaDTO.class + ); + + // Validate the Struttura in the database + assertIncrementedRepositoryCount(databaseSizeBeforeCreate); + var returnedStruttura = strutturaMapper.toEntity(returnedStrutturaDTO); + assertStrutturaUpdatableFieldsEquals(returnedStruttura, getPersistedStruttura(returnedStruttura)); + + insertedStruttura = returnedStruttura; + } + + @Test + @Transactional + void createStrutturaWithExistingId() throws Exception { + // Create the Struttura with an existing ID + struttura.setId(1L); + StrutturaDTO strutturaDTO = strutturaMapper.toDto(struttura); + + long databaseSizeBeforeCreate = getRepositoryCount(); + + // An entity with an existing ID cannot be created, so this API call must fail + restStrutturaMockMvc + .perform(post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(strutturaDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Struttura in the database + assertSameRepositoryCount(databaseSizeBeforeCreate); + } + + @Test + @Transactional + void getAllStrutturas() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList + restStrutturaMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(struttura.getId().intValue()))) + .andExpect(jsonPath("$.[*].nome").value(hasItem(DEFAULT_NOME))) + .andExpect(jsonPath("$.[*].descrizione").value(hasItem(DEFAULT_DESCRIZIONE))) + .andExpect(jsonPath("$.[*].indirizzo").value(hasItem(DEFAULT_INDIRIZZO))) + .andExpect(jsonPath("$.[*].capienzaMax").value(hasItem(DEFAULT_CAPIENZA_MAX))) + .andExpect(jsonPath("$.[*].attiva").value(hasItem(DEFAULT_ATTIVA))) + .andExpect(jsonPath("$.[*].fotoUrl").value(hasItem(DEFAULT_FOTO_URL))) + .andExpect(jsonPath("$.[*].createdAt").value(hasItem(DEFAULT_CREATED_AT.toString()))) + .andExpect(jsonPath("$.[*].updatedAt").value(hasItem(DEFAULT_UPDATED_AT.toString()))); + } + + @Test + @Transactional + void getStruttura() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get the struttura + restStrutturaMockMvc + .perform(get(ENTITY_API_URL_ID, struttura.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(struttura.getId().intValue())) + .andExpect(jsonPath("$.nome").value(DEFAULT_NOME)) + .andExpect(jsonPath("$.descrizione").value(DEFAULT_DESCRIZIONE)) + .andExpect(jsonPath("$.indirizzo").value(DEFAULT_INDIRIZZO)) + .andExpect(jsonPath("$.capienzaMax").value(DEFAULT_CAPIENZA_MAX)) + .andExpect(jsonPath("$.attiva").value(DEFAULT_ATTIVA)) + .andExpect(jsonPath("$.fotoUrl").value(DEFAULT_FOTO_URL)) + .andExpect(jsonPath("$.createdAt").value(DEFAULT_CREATED_AT.toString())) + .andExpect(jsonPath("$.updatedAt").value(DEFAULT_UPDATED_AT.toString())); + } + + @Test + @Transactional + void getStrutturasByIdFiltering() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + Long id = struttura.getId(); + + defaultStrutturaFiltering("id.equals=" + id, "id.notEquals=" + id); + + defaultStrutturaFiltering("id.greaterThanOrEqual=" + id, "id.greaterThan=" + id); + + defaultStrutturaFiltering("id.lessThanOrEqual=" + id, "id.lessThan=" + id); + } + + @Test + @Transactional + void getAllStrutturasByNomeIsEqualToSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where nome equals to + defaultStrutturaFiltering("nome.equals=" + DEFAULT_NOME, "nome.equals=" + UPDATED_NOME); + } + + @Test + @Transactional + void getAllStrutturasByNomeIsInShouldWork() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where nome in + defaultStrutturaFiltering("nome.in=" + DEFAULT_NOME + "," + UPDATED_NOME, "nome.in=" + UPDATED_NOME); + } + + @Test + @Transactional + void getAllStrutturasByNomeIsNullOrNotNull() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where nome is not null + defaultStrutturaFiltering("nome.specified=true", "nome.specified=false"); + } + + @Test + @Transactional + void getAllStrutturasByNomeContainsSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where nome contains + defaultStrutturaFiltering("nome.contains=" + DEFAULT_NOME, "nome.contains=" + UPDATED_NOME); + } + + @Test + @Transactional + void getAllStrutturasByNomeNotContainsSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where nome does not contain + defaultStrutturaFiltering("nome.doesNotContain=" + UPDATED_NOME, "nome.doesNotContain=" + DEFAULT_NOME); + } + + @Test + @Transactional + void getAllStrutturasByDescrizioneIsEqualToSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where descrizione equals to + defaultStrutturaFiltering("descrizione.equals=" + DEFAULT_DESCRIZIONE, "descrizione.equals=" + UPDATED_DESCRIZIONE); + } + + @Test + @Transactional + void getAllStrutturasByDescrizioneIsInShouldWork() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where descrizione in + defaultStrutturaFiltering( + "descrizione.in=" + DEFAULT_DESCRIZIONE + "," + UPDATED_DESCRIZIONE, + "descrizione.in=" + UPDATED_DESCRIZIONE + ); + } + + @Test + @Transactional + void getAllStrutturasByDescrizioneIsNullOrNotNull() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where descrizione is not null + defaultStrutturaFiltering("descrizione.specified=true", "descrizione.specified=false"); + } + + @Test + @Transactional + void getAllStrutturasByDescrizioneContainsSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where descrizione contains + defaultStrutturaFiltering("descrizione.contains=" + DEFAULT_DESCRIZIONE, "descrizione.contains=" + UPDATED_DESCRIZIONE); + } + + @Test + @Transactional + void getAllStrutturasByDescrizioneNotContainsSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where descrizione does not contain + defaultStrutturaFiltering("descrizione.doesNotContain=" + UPDATED_DESCRIZIONE, "descrizione.doesNotContain=" + DEFAULT_DESCRIZIONE); + } + + @Test + @Transactional + void getAllStrutturasByIndirizzoIsEqualToSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where indirizzo equals to + defaultStrutturaFiltering("indirizzo.equals=" + DEFAULT_INDIRIZZO, "indirizzo.equals=" + UPDATED_INDIRIZZO); + } + + @Test + @Transactional + void getAllStrutturasByIndirizzoIsInShouldWork() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where indirizzo in + defaultStrutturaFiltering("indirizzo.in=" + DEFAULT_INDIRIZZO + "," + UPDATED_INDIRIZZO, "indirizzo.in=" + UPDATED_INDIRIZZO); + } + + @Test + @Transactional + void getAllStrutturasByIndirizzoIsNullOrNotNull() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where indirizzo is not null + defaultStrutturaFiltering("indirizzo.specified=true", "indirizzo.specified=false"); + } + + @Test + @Transactional + void getAllStrutturasByIndirizzoContainsSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where indirizzo contains + defaultStrutturaFiltering("indirizzo.contains=" + DEFAULT_INDIRIZZO, "indirizzo.contains=" + UPDATED_INDIRIZZO); + } + + @Test + @Transactional + void getAllStrutturasByIndirizzoNotContainsSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where indirizzo does not contain + defaultStrutturaFiltering("indirizzo.doesNotContain=" + UPDATED_INDIRIZZO, "indirizzo.doesNotContain=" + DEFAULT_INDIRIZZO); + } + + @Test + @Transactional + void getAllStrutturasByCapienzaMaxIsEqualToSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where capienzaMax equals to + defaultStrutturaFiltering("capienzaMax.equals=" + DEFAULT_CAPIENZA_MAX, "capienzaMax.equals=" + UPDATED_CAPIENZA_MAX); + } + + @Test + @Transactional + void getAllStrutturasByCapienzaMaxIsInShouldWork() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where capienzaMax in + defaultStrutturaFiltering( + "capienzaMax.in=" + DEFAULT_CAPIENZA_MAX + "," + UPDATED_CAPIENZA_MAX, + "capienzaMax.in=" + UPDATED_CAPIENZA_MAX + ); + } + + @Test + @Transactional + void getAllStrutturasByCapienzaMaxIsNullOrNotNull() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where capienzaMax is not null + defaultStrutturaFiltering("capienzaMax.specified=true", "capienzaMax.specified=false"); + } + + @Test + @Transactional + void getAllStrutturasByCapienzaMaxIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where capienzaMax is greater than or equal to + defaultStrutturaFiltering( + "capienzaMax.greaterThanOrEqual=" + DEFAULT_CAPIENZA_MAX, + "capienzaMax.greaterThanOrEqual=" + UPDATED_CAPIENZA_MAX + ); + } + + @Test + @Transactional + void getAllStrutturasByCapienzaMaxIsLessThanOrEqualToSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where capienzaMax is less than or equal to + defaultStrutturaFiltering( + "capienzaMax.lessThanOrEqual=" + DEFAULT_CAPIENZA_MAX, + "capienzaMax.lessThanOrEqual=" + SMALLER_CAPIENZA_MAX + ); + } + + @Test + @Transactional + void getAllStrutturasByCapienzaMaxIsLessThanSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where capienzaMax is less than + defaultStrutturaFiltering("capienzaMax.lessThan=" + UPDATED_CAPIENZA_MAX, "capienzaMax.lessThan=" + DEFAULT_CAPIENZA_MAX); + } + + @Test + @Transactional + void getAllStrutturasByCapienzaMaxIsGreaterThanSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where capienzaMax is greater than + defaultStrutturaFiltering("capienzaMax.greaterThan=" + SMALLER_CAPIENZA_MAX, "capienzaMax.greaterThan=" + DEFAULT_CAPIENZA_MAX); + } + + @Test + @Transactional + void getAllStrutturasByAttivaIsEqualToSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where attiva equals to + defaultStrutturaFiltering("attiva.equals=" + DEFAULT_ATTIVA, "attiva.equals=" + UPDATED_ATTIVA); + } + + @Test + @Transactional + void getAllStrutturasByAttivaIsInShouldWork() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where attiva in + defaultStrutturaFiltering("attiva.in=" + DEFAULT_ATTIVA + "," + UPDATED_ATTIVA, "attiva.in=" + UPDATED_ATTIVA); + } + + @Test + @Transactional + void getAllStrutturasByAttivaIsNullOrNotNull() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where attiva is not null + defaultStrutturaFiltering("attiva.specified=true", "attiva.specified=false"); + } + + @Test + @Transactional + void getAllStrutturasByFotoUrlIsEqualToSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where fotoUrl equals to + defaultStrutturaFiltering("fotoUrl.equals=" + DEFAULT_FOTO_URL, "fotoUrl.equals=" + UPDATED_FOTO_URL); + } + + @Test + @Transactional + void getAllStrutturasByFotoUrlIsInShouldWork() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where fotoUrl in + defaultStrutturaFiltering("fotoUrl.in=" + DEFAULT_FOTO_URL + "," + UPDATED_FOTO_URL, "fotoUrl.in=" + UPDATED_FOTO_URL); + } + + @Test + @Transactional + void getAllStrutturasByFotoUrlIsNullOrNotNull() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where fotoUrl is not null + defaultStrutturaFiltering("fotoUrl.specified=true", "fotoUrl.specified=false"); + } + + @Test + @Transactional + void getAllStrutturasByFotoUrlContainsSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where fotoUrl contains + defaultStrutturaFiltering("fotoUrl.contains=" + DEFAULT_FOTO_URL, "fotoUrl.contains=" + UPDATED_FOTO_URL); + } + + @Test + @Transactional + void getAllStrutturasByFotoUrlNotContainsSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where fotoUrl does not contain + defaultStrutturaFiltering("fotoUrl.doesNotContain=" + UPDATED_FOTO_URL, "fotoUrl.doesNotContain=" + DEFAULT_FOTO_URL); + } + + @Test + @Transactional + void getAllStrutturasByCreatedAtIsEqualToSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where createdAt equals to + defaultStrutturaFiltering("createdAt.equals=" + DEFAULT_CREATED_AT, "createdAt.equals=" + UPDATED_CREATED_AT); + } + + @Test + @Transactional + void getAllStrutturasByCreatedAtIsInShouldWork() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where createdAt in + defaultStrutturaFiltering("createdAt.in=" + DEFAULT_CREATED_AT + "," + UPDATED_CREATED_AT, "createdAt.in=" + UPDATED_CREATED_AT); + } + + @Test + @Transactional + void getAllStrutturasByCreatedAtIsNullOrNotNull() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where createdAt is not null + defaultStrutturaFiltering("createdAt.specified=true", "createdAt.specified=false"); + } + + @Test + @Transactional + void getAllStrutturasByUpdatedAtIsEqualToSomething() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where updatedAt equals to + defaultStrutturaFiltering("updatedAt.equals=" + DEFAULT_UPDATED_AT, "updatedAt.equals=" + UPDATED_UPDATED_AT); + } + + @Test + @Transactional + void getAllStrutturasByUpdatedAtIsInShouldWork() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where updatedAt in + defaultStrutturaFiltering("updatedAt.in=" + DEFAULT_UPDATED_AT + "," + UPDATED_UPDATED_AT, "updatedAt.in=" + UPDATED_UPDATED_AT); + } + + @Test + @Transactional + void getAllStrutturasByUpdatedAtIsNullOrNotNull() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + // Get all the strutturaList where updatedAt is not null + defaultStrutturaFiltering("updatedAt.specified=true", "updatedAt.specified=false"); + } + + private void defaultStrutturaFiltering(String shouldBeFound, String shouldNotBeFound) throws Exception { + defaultStrutturaShouldBeFound(shouldBeFound); + defaultStrutturaShouldNotBeFound(shouldNotBeFound); + } + + /** + * Executes the search, and checks that the default entity is returned. + */ + private void defaultStrutturaShouldBeFound(String filter) throws Exception { + restStrutturaMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(struttura.getId().intValue()))) + .andExpect(jsonPath("$.[*].nome").value(hasItem(DEFAULT_NOME))) + .andExpect(jsonPath("$.[*].descrizione").value(hasItem(DEFAULT_DESCRIZIONE))) + .andExpect(jsonPath("$.[*].indirizzo").value(hasItem(DEFAULT_INDIRIZZO))) + .andExpect(jsonPath("$.[*].capienzaMax").value(hasItem(DEFAULT_CAPIENZA_MAX))) + .andExpect(jsonPath("$.[*].attiva").value(hasItem(DEFAULT_ATTIVA))) + .andExpect(jsonPath("$.[*].fotoUrl").value(hasItem(DEFAULT_FOTO_URL))) + .andExpect(jsonPath("$.[*].createdAt").value(hasItem(DEFAULT_CREATED_AT.toString()))) + .andExpect(jsonPath("$.[*].updatedAt").value(hasItem(DEFAULT_UPDATED_AT.toString()))); + + // Check, that the count call also returns 1 + restStrutturaMockMvc + .perform(get(ENTITY_API_URL + "/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(content().string("1")); + } + + /** + * Executes the search, and checks that the default entity is not returned. + */ + private void defaultStrutturaShouldNotBeFound(String filter) throws Exception { + restStrutturaMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$").isArray()) + .andExpect(jsonPath("$").isEmpty()); + + // Check, that the count call also returns 0 + restStrutturaMockMvc + .perform(get(ENTITY_API_URL + "/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(content().string("0")); + } + + @Test + @Transactional + void getNonExistingStruttura() throws Exception { + // Get the struttura + restStrutturaMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound()); + } + + @Test + @Transactional + void putExistingStruttura() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the struttura + Struttura updatedStruttura = strutturaRepository.findById(struttura.getId()).orElseThrow(); + // Disconnect from session so that the updates on updatedStruttura are not directly saved in db + em.detach(updatedStruttura); + updatedStruttura + .nome(UPDATED_NOME) + .descrizione(UPDATED_DESCRIZIONE) + .indirizzo(UPDATED_INDIRIZZO) + .capienzaMax(UPDATED_CAPIENZA_MAX) + .attiva(UPDATED_ATTIVA) + .fotoUrl(UPDATED_FOTO_URL) + .createdAt(UPDATED_CREATED_AT) + .updatedAt(UPDATED_UPDATED_AT); + StrutturaDTO strutturaDTO = strutturaMapper.toDto(updatedStruttura); + + restStrutturaMockMvc + .perform( + put(ENTITY_API_URL_ID, strutturaDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(strutturaDTO)) + ) + .andExpect(status().isOk()); + + // Validate the Struttura in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertPersistedStrutturaToMatchAllProperties(updatedStruttura); + } + + @Test + @Transactional + void putNonExistingStruttura() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + struttura.setId(longCount.incrementAndGet()); + + // Create the Struttura + StrutturaDTO strutturaDTO = strutturaMapper.toDto(struttura); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restStrutturaMockMvc + .perform( + put(ENTITY_API_URL_ID, strutturaDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(strutturaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Struttura in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithIdMismatchStruttura() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + struttura.setId(longCount.incrementAndGet()); + + // Create the Struttura + StrutturaDTO strutturaDTO = strutturaMapper.toDto(struttura); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restStrutturaMockMvc + .perform( + put(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(strutturaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Struttura in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithMissingIdPathParamStruttura() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + struttura.setId(longCount.incrementAndGet()); + + // Create the Struttura + StrutturaDTO strutturaDTO = strutturaMapper.toDto(struttura); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restStrutturaMockMvc + .perform(put(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(strutturaDTO))) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Struttura in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void partialUpdateStrutturaWithPatch() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the struttura using partial update + Struttura partialUpdatedStruttura = new Struttura(); + partialUpdatedStruttura.setId(struttura.getId()); + + partialUpdatedStruttura.nome(UPDATED_NOME).descrizione(UPDATED_DESCRIZIONE).updatedAt(UPDATED_UPDATED_AT); + + restStrutturaMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedStruttura.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedStruttura)) + ) + .andExpect(status().isOk()); + + // Validate the Struttura in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertStrutturaUpdatableFieldsEquals( + createUpdateProxyForBean(partialUpdatedStruttura, struttura), + getPersistedStruttura(struttura) + ); + } + + @Test + @Transactional + void fullUpdateStrutturaWithPatch() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the struttura using partial update + Struttura partialUpdatedStruttura = new Struttura(); + partialUpdatedStruttura.setId(struttura.getId()); + + partialUpdatedStruttura + .nome(UPDATED_NOME) + .descrizione(UPDATED_DESCRIZIONE) + .indirizzo(UPDATED_INDIRIZZO) + .capienzaMax(UPDATED_CAPIENZA_MAX) + .attiva(UPDATED_ATTIVA) + .fotoUrl(UPDATED_FOTO_URL) + .createdAt(UPDATED_CREATED_AT) + .updatedAt(UPDATED_UPDATED_AT); + + restStrutturaMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedStruttura.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedStruttura)) + ) + .andExpect(status().isOk()); + + // Validate the Struttura in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertStrutturaUpdatableFieldsEquals(partialUpdatedStruttura, getPersistedStruttura(partialUpdatedStruttura)); + } + + @Test + @Transactional + void patchNonExistingStruttura() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + struttura.setId(longCount.incrementAndGet()); + + // Create the Struttura + StrutturaDTO strutturaDTO = strutturaMapper.toDto(struttura); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restStrutturaMockMvc + .perform( + patch(ENTITY_API_URL_ID, strutturaDTO.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(strutturaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Struttura in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithIdMismatchStruttura() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + struttura.setId(longCount.incrementAndGet()); + + // Create the Struttura + StrutturaDTO strutturaDTO = strutturaMapper.toDto(struttura); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restStrutturaMockMvc + .perform( + patch(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(strutturaDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the Struttura in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithMissingIdPathParamStruttura() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + struttura.setId(longCount.incrementAndGet()); + + // Create the Struttura + StrutturaDTO strutturaDTO = strutturaMapper.toDto(struttura); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restStrutturaMockMvc + .perform( + patch(ENTITY_API_URL).with(csrf()).contentType("application/merge-patch+json").content(om.writeValueAsBytes(strutturaDTO)) + ) + .andExpect(status().isMethodNotAllowed()); + + // Validate the Struttura in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void deleteStruttura() throws Exception { + // Initialize the database + insertedStruttura = strutturaRepository.saveAndFlush(struttura); + + long databaseSizeBeforeDelete = getRepositoryCount(); + + // Delete the struttura + restStrutturaMockMvc + .perform(delete(ENTITY_API_URL_ID, struttura.getId()).with(csrf()).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + assertDecrementedRepositoryCount(databaseSizeBeforeDelete); + } + + protected long getRepositoryCount() { + return strutturaRepository.count(); + } + + protected void assertIncrementedRepositoryCount(long countBefore) { + assertThat(countBefore + 1).isEqualTo(getRepositoryCount()); + } + + protected void assertDecrementedRepositoryCount(long countBefore) { + assertThat(countBefore - 1).isEqualTo(getRepositoryCount()); + } + + protected void assertSameRepositoryCount(long countBefore) { + assertThat(countBefore).isEqualTo(getRepositoryCount()); + } + + protected Struttura getPersistedStruttura(Struttura struttura) { + return strutturaRepository.findById(struttura.getId()).orElseThrow(); + } + + protected void assertPersistedStrutturaToMatchAllProperties(Struttura expectedStruttura) { + assertStrutturaAllPropertiesEquals(expectedStruttura, getPersistedStruttura(expectedStruttura)); + } + + protected void assertPersistedStrutturaToMatchUpdatableProperties(Struttura expectedStruttura) { + assertStrutturaAllUpdatablePropertiesEquals(expectedStruttura, getPersistedStruttura(expectedStruttura)); + } +} diff --git a/src/test/java/it/sw/pa/comune/artegna/web/rest/UtenteAppResourceIT.java b/src/test/java/it/sw/pa/comune/artegna/web/rest/UtenteAppResourceIT.java new file mode 100644 index 0000000..c452127 --- /dev/null +++ b/src/test/java/it/sw/pa/comune/artegna/web/rest/UtenteAppResourceIT.java @@ -0,0 +1,652 @@ +package it.sw.pa.comune.artegna.web.rest; + +import static it.sw.pa.comune.artegna.domain.UtenteAppAsserts.*; +import static it.sw.pa.comune.artegna.web.rest.TestUtil.createUpdateProxyForBean; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import it.sw.pa.comune.artegna.IntegrationTest; +import it.sw.pa.comune.artegna.domain.UtenteApp; +import it.sw.pa.comune.artegna.domain.enumeration.Ruolo; +import it.sw.pa.comune.artegna.repository.UtenteAppRepository; +import it.sw.pa.comune.artegna.service.dto.UtenteAppDTO; +import it.sw.pa.comune.artegna.service.mapper.UtenteAppMapper; +import jakarta.persistence.EntityManager; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +/** + * Integration tests for the {@link UtenteAppResource} REST controller. + */ +@IntegrationTest +@AutoConfigureMockMvc +@WithMockUser +class UtenteAppResourceIT { + + private static final String DEFAULT_USERNAME = "AAAAAAAAAA"; + private static final String UPDATED_USERNAME = "BBBBBBBBBB"; + + private static final String DEFAULT_EMAIL = "AAAAAAAAAA"; + private static final String UPDATED_EMAIL = "BBBBBBBBBB"; + + private static final String DEFAULT_TELEFONO = "AAAAAAAAAA"; + private static final String UPDATED_TELEFONO = "BBBBBBBBBB"; + + private static final Ruolo DEFAULT_RUOLO = Ruolo.USER; + private static final Ruolo UPDATED_RUOLO = Ruolo.INCARICATO; + + private static final Boolean DEFAULT_ATTIVO = false; + private static final Boolean UPDATED_ATTIVO = true; + + private static final String DEFAULT_NOME = "AAAAAAAAAA"; + private static final String UPDATED_NOME = "BBBBBBBBBB"; + + private static final String DEFAULT_COGNOME = "AAAAAAAAAA"; + private static final String UPDATED_COGNOME = "BBBBBBBBBB"; + + private static final String DEFAULT_LUOGO_NASCITA = "AAAAAAAAAA"; + private static final String UPDATED_LUOGO_NASCITA = "BBBBBBBBBB"; + + private static final String DEFAULT_DATA_NASCITA = "AAAAAAAAAA"; + private static final String UPDATED_DATA_NASCITA = "BBBBBBBBBB"; + + private static final String DEFAULT_RESIDENTE = "AAAAAAAAAA"; + private static final String UPDATED_RESIDENTE = "BBBBBBBBBB"; + + private static final String DEFAULT_SOCIETA = "AAAAAAAAAA"; + private static final String UPDATED_SOCIETA = "BBBBBBBBBB"; + + private static final String DEFAULT_SEDE = "AAAAAAAAAA"; + private static final String UPDATED_SEDE = "BBBBBBBBBB"; + + private static final String DEFAULT_CODFISCALE = "AAAAAAAAAA"; + private static final String UPDATED_CODFISCALE = "BBBBBBBBBB"; + + private static final String DEFAULT_TELEFONO_SOC = "AAAAAAAAAA"; + private static final String UPDATED_TELEFONO_SOC = "BBBBBBBBBB"; + + private static final String DEFAULT_EMAIL_SOC = "AAAAAAAAAA"; + private static final String UPDATED_EMAIL_SOC = "BBBBBBBBBB"; + + private static final String ENTITY_API_URL = "/api/utente-apps"; + private static final String ENTITY_API_URL_ID = ENTITY_API_URL + "/{id}"; + + private static Random random = new Random(); + private static AtomicLong longCount = new AtomicLong(random.nextInt() + (2L * Integer.MAX_VALUE)); + + @Autowired + private ObjectMapper om; + + @Autowired + private UtenteAppRepository utenteAppRepository; + + @Autowired + private UtenteAppMapper utenteAppMapper; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restUtenteAppMockMvc; + + private UtenteApp utenteApp; + + private UtenteApp insertedUtenteApp; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static UtenteApp createEntity() { + return new UtenteApp() + .username(DEFAULT_USERNAME) + .email(DEFAULT_EMAIL) + .telefono(DEFAULT_TELEFONO) + .ruolo(DEFAULT_RUOLO) + .attivo(DEFAULT_ATTIVO) + .nome(DEFAULT_NOME) + .cognome(DEFAULT_COGNOME) + .luogoNascita(DEFAULT_LUOGO_NASCITA) + .dataNascita(DEFAULT_DATA_NASCITA) + .residente(DEFAULT_RESIDENTE) + .societa(DEFAULT_SOCIETA) + .sede(DEFAULT_SEDE) + .codfiscale(DEFAULT_CODFISCALE) + .telefonoSoc(DEFAULT_TELEFONO_SOC) + .emailSoc(DEFAULT_EMAIL_SOC); + } + + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static UtenteApp createUpdatedEntity() { + return new UtenteApp() + .username(UPDATED_USERNAME) + .email(UPDATED_EMAIL) + .telefono(UPDATED_TELEFONO) + .ruolo(UPDATED_RUOLO) + .attivo(UPDATED_ATTIVO) + .nome(UPDATED_NOME) + .cognome(UPDATED_COGNOME) + .luogoNascita(UPDATED_LUOGO_NASCITA) + .dataNascita(UPDATED_DATA_NASCITA) + .residente(UPDATED_RESIDENTE) + .societa(UPDATED_SOCIETA) + .sede(UPDATED_SEDE) + .codfiscale(UPDATED_CODFISCALE) + .telefonoSoc(UPDATED_TELEFONO_SOC) + .emailSoc(UPDATED_EMAIL_SOC); + } + + @BeforeEach + void initTest() { + utenteApp = createEntity(); + } + + @AfterEach + void cleanup() { + if (insertedUtenteApp != null) { + utenteAppRepository.delete(insertedUtenteApp); + insertedUtenteApp = null; + } + } + + @Test + @Transactional + void createUtenteApp() throws Exception { + long databaseSizeBeforeCreate = getRepositoryCount(); + // Create the UtenteApp + UtenteAppDTO utenteAppDTO = utenteAppMapper.toDto(utenteApp); + var returnedUtenteAppDTO = om.readValue( + restUtenteAppMockMvc + .perform( + post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(utenteAppDTO)) + ) + .andExpect(status().isCreated()) + .andReturn() + .getResponse() + .getContentAsString(), + UtenteAppDTO.class + ); + + // Validate the UtenteApp in the database + assertIncrementedRepositoryCount(databaseSizeBeforeCreate); + var returnedUtenteApp = utenteAppMapper.toEntity(returnedUtenteAppDTO); + assertUtenteAppUpdatableFieldsEquals(returnedUtenteApp, getPersistedUtenteApp(returnedUtenteApp)); + + insertedUtenteApp = returnedUtenteApp; + } + + @Test + @Transactional + void createUtenteAppWithExistingId() throws Exception { + // Create the UtenteApp with an existing ID + utenteApp.setId(1L); + UtenteAppDTO utenteAppDTO = utenteAppMapper.toDto(utenteApp); + + long databaseSizeBeforeCreate = getRepositoryCount(); + + // An entity with an existing ID cannot be created, so this API call must fail + restUtenteAppMockMvc + .perform(post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(utenteAppDTO))) + .andExpect(status().isBadRequest()); + + // Validate the UtenteApp in the database + assertSameRepositoryCount(databaseSizeBeforeCreate); + } + + @Test + @Transactional + void checkUsernameIsRequired() throws Exception { + long databaseSizeBeforeTest = getRepositoryCount(); + // set the field null + utenteApp.setUsername(null); + + // Create the UtenteApp, which fails. + UtenteAppDTO utenteAppDTO = utenteAppMapper.toDto(utenteApp); + + restUtenteAppMockMvc + .perform(post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(utenteAppDTO))) + .andExpect(status().isBadRequest()); + + assertSameRepositoryCount(databaseSizeBeforeTest); + } + + @Test + @Transactional + void checkEmailIsRequired() throws Exception { + long databaseSizeBeforeTest = getRepositoryCount(); + // set the field null + utenteApp.setEmail(null); + + // Create the UtenteApp, which fails. + UtenteAppDTO utenteAppDTO = utenteAppMapper.toDto(utenteApp); + + restUtenteAppMockMvc + .perform(post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(utenteAppDTO))) + .andExpect(status().isBadRequest()); + + assertSameRepositoryCount(databaseSizeBeforeTest); + } + + @Test + @Transactional + void checkRuoloIsRequired() throws Exception { + long databaseSizeBeforeTest = getRepositoryCount(); + // set the field null + utenteApp.setRuolo(null); + + // Create the UtenteApp, which fails. + UtenteAppDTO utenteAppDTO = utenteAppMapper.toDto(utenteApp); + + restUtenteAppMockMvc + .perform(post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(utenteAppDTO))) + .andExpect(status().isBadRequest()); + + assertSameRepositoryCount(databaseSizeBeforeTest); + } + + @Test + @Transactional + void checkAttivoIsRequired() throws Exception { + long databaseSizeBeforeTest = getRepositoryCount(); + // set the field null + utenteApp.setAttivo(null); + + // Create the UtenteApp, which fails. + UtenteAppDTO utenteAppDTO = utenteAppMapper.toDto(utenteApp); + + restUtenteAppMockMvc + .perform(post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(utenteAppDTO))) + .andExpect(status().isBadRequest()); + + assertSameRepositoryCount(databaseSizeBeforeTest); + } + + @Test + @Transactional + void getAllUtenteApps() throws Exception { + // Initialize the database + insertedUtenteApp = utenteAppRepository.saveAndFlush(utenteApp); + + // Get all the utenteAppList + restUtenteAppMockMvc + .perform(get(ENTITY_API_URL + "?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(utenteApp.getId().intValue()))) + .andExpect(jsonPath("$.[*].username").value(hasItem(DEFAULT_USERNAME))) + .andExpect(jsonPath("$.[*].email").value(hasItem(DEFAULT_EMAIL))) + .andExpect(jsonPath("$.[*].telefono").value(hasItem(DEFAULT_TELEFONO))) + .andExpect(jsonPath("$.[*].ruolo").value(hasItem(DEFAULT_RUOLO.toString()))) + .andExpect(jsonPath("$.[*].attivo").value(hasItem(DEFAULT_ATTIVO))) + .andExpect(jsonPath("$.[*].nome").value(hasItem(DEFAULT_NOME))) + .andExpect(jsonPath("$.[*].cognome").value(hasItem(DEFAULT_COGNOME))) + .andExpect(jsonPath("$.[*].luogoNascita").value(hasItem(DEFAULT_LUOGO_NASCITA))) + .andExpect(jsonPath("$.[*].dataNascita").value(hasItem(DEFAULT_DATA_NASCITA))) + .andExpect(jsonPath("$.[*].residente").value(hasItem(DEFAULT_RESIDENTE))) + .andExpect(jsonPath("$.[*].societa").value(hasItem(DEFAULT_SOCIETA))) + .andExpect(jsonPath("$.[*].sede").value(hasItem(DEFAULT_SEDE))) + .andExpect(jsonPath("$.[*].codfiscale").value(hasItem(DEFAULT_CODFISCALE))) + .andExpect(jsonPath("$.[*].telefonoSoc").value(hasItem(DEFAULT_TELEFONO_SOC))) + .andExpect(jsonPath("$.[*].emailSoc").value(hasItem(DEFAULT_EMAIL_SOC))); + } + + @Test + @Transactional + void getUtenteApp() throws Exception { + // Initialize the database + insertedUtenteApp = utenteAppRepository.saveAndFlush(utenteApp); + + // Get the utenteApp + restUtenteAppMockMvc + .perform(get(ENTITY_API_URL_ID, utenteApp.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(utenteApp.getId().intValue())) + .andExpect(jsonPath("$.username").value(DEFAULT_USERNAME)) + .andExpect(jsonPath("$.email").value(DEFAULT_EMAIL)) + .andExpect(jsonPath("$.telefono").value(DEFAULT_TELEFONO)) + .andExpect(jsonPath("$.ruolo").value(DEFAULT_RUOLO.toString())) + .andExpect(jsonPath("$.attivo").value(DEFAULT_ATTIVO)) + .andExpect(jsonPath("$.nome").value(DEFAULT_NOME)) + .andExpect(jsonPath("$.cognome").value(DEFAULT_COGNOME)) + .andExpect(jsonPath("$.luogoNascita").value(DEFAULT_LUOGO_NASCITA)) + .andExpect(jsonPath("$.dataNascita").value(DEFAULT_DATA_NASCITA)) + .andExpect(jsonPath("$.residente").value(DEFAULT_RESIDENTE)) + .andExpect(jsonPath("$.societa").value(DEFAULT_SOCIETA)) + .andExpect(jsonPath("$.sede").value(DEFAULT_SEDE)) + .andExpect(jsonPath("$.codfiscale").value(DEFAULT_CODFISCALE)) + .andExpect(jsonPath("$.telefonoSoc").value(DEFAULT_TELEFONO_SOC)) + .andExpect(jsonPath("$.emailSoc").value(DEFAULT_EMAIL_SOC)); + } + + @Test + @Transactional + void getNonExistingUtenteApp() throws Exception { + // Get the utenteApp + restUtenteAppMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound()); + } + + @Test + @Transactional + void putExistingUtenteApp() throws Exception { + // Initialize the database + insertedUtenteApp = utenteAppRepository.saveAndFlush(utenteApp); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the utenteApp + UtenteApp updatedUtenteApp = utenteAppRepository.findById(utenteApp.getId()).orElseThrow(); + // Disconnect from session so that the updates on updatedUtenteApp are not directly saved in db + em.detach(updatedUtenteApp); + updatedUtenteApp + .username(UPDATED_USERNAME) + .email(UPDATED_EMAIL) + .telefono(UPDATED_TELEFONO) + .ruolo(UPDATED_RUOLO) + .attivo(UPDATED_ATTIVO) + .nome(UPDATED_NOME) + .cognome(UPDATED_COGNOME) + .luogoNascita(UPDATED_LUOGO_NASCITA) + .dataNascita(UPDATED_DATA_NASCITA) + .residente(UPDATED_RESIDENTE) + .societa(UPDATED_SOCIETA) + .sede(UPDATED_SEDE) + .codfiscale(UPDATED_CODFISCALE) + .telefonoSoc(UPDATED_TELEFONO_SOC) + .emailSoc(UPDATED_EMAIL_SOC); + UtenteAppDTO utenteAppDTO = utenteAppMapper.toDto(updatedUtenteApp); + + restUtenteAppMockMvc + .perform( + put(ENTITY_API_URL_ID, utenteAppDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(utenteAppDTO)) + ) + .andExpect(status().isOk()); + + // Validate the UtenteApp in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertPersistedUtenteAppToMatchAllProperties(updatedUtenteApp); + } + + @Test + @Transactional + void putNonExistingUtenteApp() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + utenteApp.setId(longCount.incrementAndGet()); + + // Create the UtenteApp + UtenteAppDTO utenteAppDTO = utenteAppMapper.toDto(utenteApp); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restUtenteAppMockMvc + .perform( + put(ENTITY_API_URL_ID, utenteAppDTO.getId()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(utenteAppDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the UtenteApp in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithIdMismatchUtenteApp() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + utenteApp.setId(longCount.incrementAndGet()); + + // Create the UtenteApp + UtenteAppDTO utenteAppDTO = utenteAppMapper.toDto(utenteApp); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restUtenteAppMockMvc + .perform( + put(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(om.writeValueAsBytes(utenteAppDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the UtenteApp in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void putWithMissingIdPathParamUtenteApp() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + utenteApp.setId(longCount.incrementAndGet()); + + // Create the UtenteApp + UtenteAppDTO utenteAppDTO = utenteAppMapper.toDto(utenteApp); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restUtenteAppMockMvc + .perform(put(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(utenteAppDTO))) + .andExpect(status().isMethodNotAllowed()); + + // Validate the UtenteApp in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void partialUpdateUtenteAppWithPatch() throws Exception { + // Initialize the database + insertedUtenteApp = utenteAppRepository.saveAndFlush(utenteApp); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the utenteApp using partial update + UtenteApp partialUpdatedUtenteApp = new UtenteApp(); + partialUpdatedUtenteApp.setId(utenteApp.getId()); + + partialUpdatedUtenteApp + .email(UPDATED_EMAIL) + .ruolo(UPDATED_RUOLO) + .attivo(UPDATED_ATTIVO) + .nome(UPDATED_NOME) + .cognome(UPDATED_COGNOME) + .luogoNascita(UPDATED_LUOGO_NASCITA) + .residente(UPDATED_RESIDENTE) + .sede(UPDATED_SEDE) + .telefonoSoc(UPDATED_TELEFONO_SOC); + + restUtenteAppMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedUtenteApp.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedUtenteApp)) + ) + .andExpect(status().isOk()); + + // Validate the UtenteApp in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertUtenteAppUpdatableFieldsEquals( + createUpdateProxyForBean(partialUpdatedUtenteApp, utenteApp), + getPersistedUtenteApp(utenteApp) + ); + } + + @Test + @Transactional + void fullUpdateUtenteAppWithPatch() throws Exception { + // Initialize the database + insertedUtenteApp = utenteAppRepository.saveAndFlush(utenteApp); + + long databaseSizeBeforeUpdate = getRepositoryCount(); + + // Update the utenteApp using partial update + UtenteApp partialUpdatedUtenteApp = new UtenteApp(); + partialUpdatedUtenteApp.setId(utenteApp.getId()); + + partialUpdatedUtenteApp + .username(UPDATED_USERNAME) + .email(UPDATED_EMAIL) + .telefono(UPDATED_TELEFONO) + .ruolo(UPDATED_RUOLO) + .attivo(UPDATED_ATTIVO) + .nome(UPDATED_NOME) + .cognome(UPDATED_COGNOME) + .luogoNascita(UPDATED_LUOGO_NASCITA) + .dataNascita(UPDATED_DATA_NASCITA) + .residente(UPDATED_RESIDENTE) + .societa(UPDATED_SOCIETA) + .sede(UPDATED_SEDE) + .codfiscale(UPDATED_CODFISCALE) + .telefonoSoc(UPDATED_TELEFONO_SOC) + .emailSoc(UPDATED_EMAIL_SOC); + + restUtenteAppMockMvc + .perform( + patch(ENTITY_API_URL_ID, partialUpdatedUtenteApp.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(partialUpdatedUtenteApp)) + ) + .andExpect(status().isOk()); + + // Validate the UtenteApp in the database + + assertSameRepositoryCount(databaseSizeBeforeUpdate); + assertUtenteAppUpdatableFieldsEquals(partialUpdatedUtenteApp, getPersistedUtenteApp(partialUpdatedUtenteApp)); + } + + @Test + @Transactional + void patchNonExistingUtenteApp() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + utenteApp.setId(longCount.incrementAndGet()); + + // Create the UtenteApp + UtenteAppDTO utenteAppDTO = utenteAppMapper.toDto(utenteApp); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restUtenteAppMockMvc + .perform( + patch(ENTITY_API_URL_ID, utenteAppDTO.getId()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(utenteAppDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the UtenteApp in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithIdMismatchUtenteApp() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + utenteApp.setId(longCount.incrementAndGet()); + + // Create the UtenteApp + UtenteAppDTO utenteAppDTO = utenteAppMapper.toDto(utenteApp); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restUtenteAppMockMvc + .perform( + patch(ENTITY_API_URL_ID, longCount.incrementAndGet()) + .with(csrf()) + .contentType("application/merge-patch+json") + .content(om.writeValueAsBytes(utenteAppDTO)) + ) + .andExpect(status().isBadRequest()); + + // Validate the UtenteApp in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void patchWithMissingIdPathParamUtenteApp() throws Exception { + long databaseSizeBeforeUpdate = getRepositoryCount(); + utenteApp.setId(longCount.incrementAndGet()); + + // Create the UtenteApp + UtenteAppDTO utenteAppDTO = utenteAppMapper.toDto(utenteApp); + + // If url ID doesn't match entity ID, it will throw BadRequestAlertException + restUtenteAppMockMvc + .perform( + patch(ENTITY_API_URL).with(csrf()).contentType("application/merge-patch+json").content(om.writeValueAsBytes(utenteAppDTO)) + ) + .andExpect(status().isMethodNotAllowed()); + + // Validate the UtenteApp in the database + assertSameRepositoryCount(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + void deleteUtenteApp() throws Exception { + // Initialize the database + insertedUtenteApp = utenteAppRepository.saveAndFlush(utenteApp); + + long databaseSizeBeforeDelete = getRepositoryCount(); + + // Delete the utenteApp + restUtenteAppMockMvc + .perform(delete(ENTITY_API_URL_ID, utenteApp.getId()).with(csrf()).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + assertDecrementedRepositoryCount(databaseSizeBeforeDelete); + } + + protected long getRepositoryCount() { + return utenteAppRepository.count(); + } + + protected void assertIncrementedRepositoryCount(long countBefore) { + assertThat(countBefore + 1).isEqualTo(getRepositoryCount()); + } + + protected void assertDecrementedRepositoryCount(long countBefore) { + assertThat(countBefore - 1).isEqualTo(getRepositoryCount()); + } + + protected void assertSameRepositoryCount(long countBefore) { + assertThat(countBefore).isEqualTo(getRepositoryCount()); + } + + protected UtenteApp getPersistedUtenteApp(UtenteApp utenteApp) { + return utenteAppRepository.findById(utenteApp.getId()).orElseThrow(); + } + + protected void assertPersistedUtenteAppToMatchAllProperties(UtenteApp expectedUtenteApp) { + assertUtenteAppAllPropertiesEquals(expectedUtenteApp, getPersistedUtenteApp(expectedUtenteApp)); + } + + protected void assertPersistedUtenteAppToMatchUpdatableProperties(UtenteApp expectedUtenteApp) { + assertUtenteAppAllUpdatablePropertiesEquals(expectedUtenteApp, getPersistedUtenteApp(expectedUtenteApp)); + } +} diff --git a/src/test/javascript/cypress/e2e/entity/audit-log.cy.ts b/src/test/javascript/cypress/e2e/entity/audit-log.cy.ts new file mode 100644 index 0000000..50ddde2 --- /dev/null +++ b/src/test/javascript/cypress/e2e/entity/audit-log.cy.ts @@ -0,0 +1,192 @@ +import { + entityConfirmDeleteButtonSelector, + entityCreateButtonSelector, + entityCreateCancelButtonSelector, + entityCreateSaveButtonSelector, + entityDeleteButtonSelector, + entityDetailsBackButtonSelector, + entityDetailsButtonSelector, + entityEditButtonSelector, + entityTableSelector, +} from '../../support/entity'; + +describe('AuditLog e2e test', () => { + const auditLogPageUrl = '/audit-log'; + const auditLogPageUrlPattern = new RegExp('/audit-log(\\?.*)?$'); + const username = Cypress.env('E2E_USERNAME') ?? 'user'; + const password = Cypress.env('E2E_PASSWORD') ?? 'user'; + const auditLogSample = {}; + + let auditLog; + + beforeEach(() => { + cy.login(username, password); + }); + + beforeEach(() => { + cy.intercept('GET', '/api/audit-logs+(?*|)').as('entitiesRequest'); + cy.intercept('POST', '/api/audit-logs').as('postEntityRequest'); + cy.intercept('DELETE', '/api/audit-logs/*').as('deleteEntityRequest'); + }); + + afterEach(() => { + if (auditLog) { + cy.authenticatedRequest({ + method: 'DELETE', + url: `/api/audit-logs/${auditLog.id}`, + }).then(() => { + auditLog = undefined; + }); + } + }); + + it('AuditLogs menu should load AuditLogs page', () => { + cy.visit('/'); + cy.clickOnEntityMenuItem('audit-log'); + cy.wait('@entitiesRequest').then(({ response }) => { + if (response?.body.length === 0) { + cy.get(entityTableSelector).should('not.exist'); + } else { + cy.get(entityTableSelector).should('exist'); + } + }); + cy.getEntityHeading('AuditLog').should('exist'); + cy.url().should('match', auditLogPageUrlPattern); + }); + + describe('AuditLog page', () => { + describe('create button click', () => { + beforeEach(() => { + cy.visit(auditLogPageUrl); + cy.wait('@entitiesRequest'); + }); + + it('should load create AuditLog page', () => { + cy.get(entityCreateButtonSelector).click(); + cy.url().should('match', new RegExp('/audit-log/new$')); + cy.getEntityCreateUpdateHeading('AuditLog'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', auditLogPageUrlPattern); + }); + }); + + describe('with existing value', () => { + beforeEach(() => { + cy.authenticatedRequest({ + method: 'POST', + url: '/api/audit-logs', + body: auditLogSample, + }).then(({ body }) => { + auditLog = body; + + cy.intercept( + { + method: 'GET', + url: '/api/audit-logs+(?*|)', + times: 1, + }, + { + statusCode: 200, + headers: { + link: '; rel="last",; rel="first"', + }, + body: [auditLog], + }, + ).as('entitiesRequestInternal'); + }); + + cy.visit(auditLogPageUrl); + + cy.wait('@entitiesRequestInternal'); + }); + + it('detail button click should load details AuditLog page', () => { + cy.get(entityDetailsButtonSelector).first().click(); + cy.getEntityDetailsHeading('auditLog'); + cy.get(entityDetailsBackButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', auditLogPageUrlPattern); + }); + + it('edit button click should load edit AuditLog page and go back', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('AuditLog'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', auditLogPageUrlPattern); + }); + + it('edit button click should load edit AuditLog page and save', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('AuditLog'); + cy.get(entityCreateSaveButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', auditLogPageUrlPattern); + }); + + it('last delete button click should delete instance of AuditLog', () => { + cy.get(entityDeleteButtonSelector).last().click(); + cy.getEntityDeleteDialogHeading('auditLog').should('exist'); + cy.get(entityConfirmDeleteButtonSelector).click(); + cy.wait('@deleteEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(204); + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', auditLogPageUrlPattern); + + auditLog = undefined; + }); + }); + }); + + describe('new AuditLog page', () => { + beforeEach(() => { + cy.visit(auditLogPageUrl); + cy.get(entityCreateButtonSelector).click(); + cy.getEntityCreateUpdateHeading('AuditLog'); + }); + + it('should create an instance of AuditLog', () => { + cy.get(`[data-cy="entitaTipo"]`).select('CONFERMA'); + + cy.get(`[data-cy="entitaId"]`).type('4178'); + cy.get(`[data-cy="entitaId"]`).should('have.value', '4178'); + + cy.get(`[data-cy="azione"]`).select('DELETE'); + + cy.get(`[data-cy="dettagli"]`).type('avalanche'); + cy.get(`[data-cy="dettagli"]`).should('have.value', 'avalanche'); + + cy.get(`[data-cy="ipAddress"]`).type('phooey royal concerning'); + cy.get(`[data-cy="ipAddress"]`).should('have.value', 'phooey royal concerning'); + + cy.get(`[data-cy="createdAt"]`).type('2025-12-10T02:16'); + cy.get(`[data-cy="createdAt"]`).blur(); + cy.get(`[data-cy="createdAt"]`).should('have.value', '2025-12-10T02:16'); + + cy.get(entityCreateSaveButtonSelector).click(); + + cy.wait('@postEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(201); + auditLog = response.body; + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', auditLogPageUrlPattern); + }); + }); +}); diff --git a/src/test/javascript/cypress/e2e/entity/conferma.cy.ts b/src/test/javascript/cypress/e2e/entity/conferma.cy.ts new file mode 100644 index 0000000..58de546 --- /dev/null +++ b/src/test/javascript/cypress/e2e/entity/conferma.cy.ts @@ -0,0 +1,180 @@ +import { + entityConfirmDeleteButtonSelector, + entityCreateButtonSelector, + entityCreateCancelButtonSelector, + entityCreateSaveButtonSelector, + entityDeleteButtonSelector, + entityDetailsBackButtonSelector, + entityDetailsButtonSelector, + entityEditButtonSelector, + entityTableSelector, +} from '../../support/entity'; + +describe('Conferma e2e test', () => { + const confermaPageUrl = '/conferma'; + const confermaPageUrlPattern = new RegExp('/conferma(\\?.*)?$'); + const username = Cypress.env('E2E_USERNAME') ?? 'user'; + const password = Cypress.env('E2E_PASSWORD') ?? 'user'; + const confermaSample = {}; + + let conferma; + + beforeEach(() => { + cy.login(username, password); + }); + + beforeEach(() => { + cy.intercept('GET', '/api/confermas+(?*|)').as('entitiesRequest'); + cy.intercept('POST', '/api/confermas').as('postEntityRequest'); + cy.intercept('DELETE', '/api/confermas/*').as('deleteEntityRequest'); + }); + + afterEach(() => { + if (conferma) { + cy.authenticatedRequest({ + method: 'DELETE', + url: `/api/confermas/${conferma.id}`, + }).then(() => { + conferma = undefined; + }); + } + }); + + it('Confermas menu should load Confermas page', () => { + cy.visit('/'); + cy.clickOnEntityMenuItem('conferma'); + cy.wait('@entitiesRequest').then(({ response }) => { + if (response?.body.length === 0) { + cy.get(entityTableSelector).should('not.exist'); + } else { + cy.get(entityTableSelector).should('exist'); + } + }); + cy.getEntityHeading('Conferma').should('exist'); + cy.url().should('match', confermaPageUrlPattern); + }); + + describe('Conferma page', () => { + describe('create button click', () => { + beforeEach(() => { + cy.visit(confermaPageUrl); + cy.wait('@entitiesRequest'); + }); + + it('should load create Conferma page', () => { + cy.get(entityCreateButtonSelector).click(); + cy.url().should('match', new RegExp('/conferma/new$')); + cy.getEntityCreateUpdateHeading('Conferma'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', confermaPageUrlPattern); + }); + }); + + describe('with existing value', () => { + beforeEach(() => { + cy.authenticatedRequest({ + method: 'POST', + url: '/api/confermas', + body: confermaSample, + }).then(({ body }) => { + conferma = body; + + cy.intercept( + { + method: 'GET', + url: '/api/confermas+(?*|)', + times: 1, + }, + { + statusCode: 200, + headers: { + link: '; rel="last",; rel="first"', + }, + body: [conferma], + }, + ).as('entitiesRequestInternal'); + }); + + cy.visit(confermaPageUrl); + + cy.wait('@entitiesRequestInternal'); + }); + + it('detail button click should load details Conferma page', () => { + cy.get(entityDetailsButtonSelector).first().click(); + cy.getEntityDetailsHeading('conferma'); + cy.get(entityDetailsBackButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', confermaPageUrlPattern); + }); + + it('edit button click should load edit Conferma page and go back', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Conferma'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', confermaPageUrlPattern); + }); + + it('edit button click should load edit Conferma page and save', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Conferma'); + cy.get(entityCreateSaveButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', confermaPageUrlPattern); + }); + + it('last delete button click should delete instance of Conferma', () => { + cy.get(entityDeleteButtonSelector).last().click(); + cy.getEntityDeleteDialogHeading('conferma').should('exist'); + cy.get(entityConfirmDeleteButtonSelector).click(); + cy.wait('@deleteEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(204); + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', confermaPageUrlPattern); + + conferma = undefined; + }); + }); + }); + + describe('new Conferma page', () => { + beforeEach(() => { + cy.visit(confermaPageUrl); + cy.get(entityCreateButtonSelector).click(); + cy.getEntityCreateUpdateHeading('Conferma'); + }); + + it('should create an instance of Conferma', () => { + cy.get(`[data-cy="motivoConferma"]`).type('decent'); + cy.get(`[data-cy="motivoConferma"]`).should('have.value', 'decent'); + + cy.get(`[data-cy="tipoConferma"]`).select('RIFIUTATA'); + + cy.get(entityCreateSaveButtonSelector).click(); + + cy.wait('@postEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(201); + conferma = response.body; + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', confermaPageUrlPattern); + }); + }); +}); diff --git a/src/test/javascript/cypress/e2e/entity/disponibilita.cy.ts b/src/test/javascript/cypress/e2e/entity/disponibilita.cy.ts new file mode 100644 index 0000000..ab8df73 --- /dev/null +++ b/src/test/javascript/cypress/e2e/entity/disponibilita.cy.ts @@ -0,0 +1,200 @@ +import { + entityConfirmDeleteButtonSelector, + entityCreateButtonSelector, + entityCreateCancelButtonSelector, + entityCreateSaveButtonSelector, + entityDeleteButtonSelector, + entityDetailsBackButtonSelector, + entityDetailsButtonSelector, + entityEditButtonSelector, + entityTableSelector, +} from '../../support/entity'; + +describe('Disponibilita e2e test', () => { + const disponibilitaPageUrl = '/disponibilita'; + const disponibilitaPageUrlPattern = new RegExp('/disponibilita(\\?.*)?$'); + const username = Cypress.env('E2E_USERNAME') ?? 'user'; + const password = Cypress.env('E2E_PASSWORD') ?? 'user'; + const disponibilitaSample = {}; + + let disponibilita; + + beforeEach(() => { + cy.login(username, password); + }); + + beforeEach(() => { + cy.intercept('GET', '/api/disponibilitas+(?*|)').as('entitiesRequest'); + cy.intercept('POST', '/api/disponibilitas').as('postEntityRequest'); + cy.intercept('DELETE', '/api/disponibilitas/*').as('deleteEntityRequest'); + }); + + afterEach(() => { + if (disponibilita) { + cy.authenticatedRequest({ + method: 'DELETE', + url: `/api/disponibilitas/${disponibilita.id}`, + }).then(() => { + disponibilita = undefined; + }); + } + }); + + it('Disponibilitas menu should load Disponibilitas page', () => { + cy.visit('/'); + cy.clickOnEntityMenuItem('disponibilita'); + cy.wait('@entitiesRequest').then(({ response }) => { + if (response?.body.length === 0) { + cy.get(entityTableSelector).should('not.exist'); + } else { + cy.get(entityTableSelector).should('exist'); + } + }); + cy.getEntityHeading('Disponibilita').should('exist'); + cy.url().should('match', disponibilitaPageUrlPattern); + }); + + describe('Disponibilita page', () => { + describe('create button click', () => { + beforeEach(() => { + cy.visit(disponibilitaPageUrl); + cy.wait('@entitiesRequest'); + }); + + it('should load create Disponibilita page', () => { + cy.get(entityCreateButtonSelector).click(); + cy.url().should('match', new RegExp('/disponibilita/new$')); + cy.getEntityCreateUpdateHeading('Disponibilita'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', disponibilitaPageUrlPattern); + }); + }); + + describe('with existing value', () => { + beforeEach(() => { + cy.authenticatedRequest({ + method: 'POST', + url: '/api/disponibilitas', + body: disponibilitaSample, + }).then(({ body }) => { + disponibilita = body; + + cy.intercept( + { + method: 'GET', + url: '/api/disponibilitas+(?*|)', + times: 1, + }, + { + statusCode: 200, + headers: { + link: '; rel="last",; rel="first"', + }, + body: [disponibilita], + }, + ).as('entitiesRequestInternal'); + }); + + cy.visit(disponibilitaPageUrl); + + cy.wait('@entitiesRequestInternal'); + }); + + it('detail button click should load details Disponibilita page', () => { + cy.get(entityDetailsButtonSelector).first().click(); + cy.getEntityDetailsHeading('disponibilita'); + cy.get(entityDetailsBackButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', disponibilitaPageUrlPattern); + }); + + it('edit button click should load edit Disponibilita page and go back', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Disponibilita'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', disponibilitaPageUrlPattern); + }); + + it('edit button click should load edit Disponibilita page and save', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Disponibilita'); + cy.get(entityCreateSaveButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', disponibilitaPageUrlPattern); + }); + + it('last delete button click should delete instance of Disponibilita', () => { + cy.get(entityDeleteButtonSelector).last().click(); + cy.getEntityDeleteDialogHeading('disponibilita').should('exist'); + cy.get(entityConfirmDeleteButtonSelector).click(); + cy.wait('@deleteEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(204); + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', disponibilitaPageUrlPattern); + + disponibilita = undefined; + }); + }); + }); + + describe('new Disponibilita page', () => { + beforeEach(() => { + cy.visit(disponibilitaPageUrl); + cy.get(entityCreateButtonSelector).click(); + cy.getEntityCreateUpdateHeading('Disponibilita'); + }); + + it('should create an instance of Disponibilita', () => { + cy.get(`[data-cy="giornoSettimana"]`).select('MARTEDI'); + + cy.get(`[data-cy="dataSpecifica"]`).type('2025-12-10'); + cy.get(`[data-cy="dataSpecifica"]`).blur(); + cy.get(`[data-cy="dataSpecifica"]`).should('have.value', '2025-12-10'); + + cy.get(`[data-cy="oraInizio"]`).type('2025-12-10T14:03'); + cy.get(`[data-cy="oraInizio"]`).blur(); + cy.get(`[data-cy="oraInizio"]`).should('have.value', '2025-12-10T14:03'); + + cy.get(`[data-cy="oraFine"]`).type('2025-12-10T06:53'); + cy.get(`[data-cy="oraFine"]`).blur(); + cy.get(`[data-cy="oraFine"]`).should('have.value', '2025-12-10T06:53'); + + cy.get(`[data-cy="orarioInizio"]`).type('wide-eyed in'); + cy.get(`[data-cy="orarioInizio"]`).should('have.value', 'wide-eyed in'); + + cy.get(`[data-cy="orarioFine"]`).type('tank'); + cy.get(`[data-cy="orarioFine"]`).should('have.value', 'tank'); + + cy.get(`[data-cy="tipo"]`).select('DISPONIBILE'); + + cy.get(`[data-cy="note"]`).type('doodle vaguely vacantly'); + cy.get(`[data-cy="note"]`).should('have.value', 'doodle vaguely vacantly'); + + cy.get(entityCreateSaveButtonSelector).click(); + + cy.wait('@postEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(201); + disponibilita = response.body; + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', disponibilitaPageUrlPattern); + }); + }); +}); diff --git a/src/test/javascript/cypress/e2e/entity/liberatoria.cy.ts b/src/test/javascript/cypress/e2e/entity/liberatoria.cy.ts new file mode 100644 index 0000000..a79f041 --- /dev/null +++ b/src/test/javascript/cypress/e2e/entity/liberatoria.cy.ts @@ -0,0 +1,176 @@ +import { + entityConfirmDeleteButtonSelector, + entityCreateButtonSelector, + entityCreateCancelButtonSelector, + entityCreateSaveButtonSelector, + entityDeleteButtonSelector, + entityDetailsBackButtonSelector, + entityDetailsButtonSelector, + entityEditButtonSelector, + entityTableSelector, +} from '../../support/entity'; + +describe('Liberatoria e2e test', () => { + const liberatoriaPageUrl = '/liberatoria'; + const liberatoriaPageUrlPattern = new RegExp('/liberatoria(\\?.*)?$'); + const username = Cypress.env('E2E_USERNAME') ?? 'user'; + const password = Cypress.env('E2E_PASSWORD') ?? 'user'; + const liberatoriaSample = {}; + + let liberatoria; + + beforeEach(() => { + cy.login(username, password); + }); + + beforeEach(() => { + cy.intercept('GET', '/api/liberatorias+(?*|)').as('entitiesRequest'); + cy.intercept('POST', '/api/liberatorias').as('postEntityRequest'); + cy.intercept('DELETE', '/api/liberatorias/*').as('deleteEntityRequest'); + }); + + afterEach(() => { + if (liberatoria) { + cy.authenticatedRequest({ + method: 'DELETE', + url: `/api/liberatorias/${liberatoria.id}`, + }).then(() => { + liberatoria = undefined; + }); + } + }); + + it('Liberatorias menu should load Liberatorias page', () => { + cy.visit('/'); + cy.clickOnEntityMenuItem('liberatoria'); + cy.wait('@entitiesRequest').then(({ response }) => { + if (response?.body.length === 0) { + cy.get(entityTableSelector).should('not.exist'); + } else { + cy.get(entityTableSelector).should('exist'); + } + }); + cy.getEntityHeading('Liberatoria').should('exist'); + cy.url().should('match', liberatoriaPageUrlPattern); + }); + + describe('Liberatoria page', () => { + describe('create button click', () => { + beforeEach(() => { + cy.visit(liberatoriaPageUrl); + cy.wait('@entitiesRequest'); + }); + + it('should load create Liberatoria page', () => { + cy.get(entityCreateButtonSelector).click(); + cy.url().should('match', new RegExp('/liberatoria/new$')); + cy.getEntityCreateUpdateHeading('Liberatoria'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', liberatoriaPageUrlPattern); + }); + }); + + describe('with existing value', () => { + beforeEach(() => { + cy.authenticatedRequest({ + method: 'POST', + url: '/api/liberatorias', + body: liberatoriaSample, + }).then(({ body }) => { + liberatoria = body; + + cy.intercept( + { + method: 'GET', + url: '/api/liberatorias+(?*|)', + times: 1, + }, + { + statusCode: 200, + body: [liberatoria], + }, + ).as('entitiesRequestInternal'); + }); + + cy.visit(liberatoriaPageUrl); + + cy.wait('@entitiesRequestInternal'); + }); + + it('detail button click should load details Liberatoria page', () => { + cy.get(entityDetailsButtonSelector).first().click(); + cy.getEntityDetailsHeading('liberatoria'); + cy.get(entityDetailsBackButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', liberatoriaPageUrlPattern); + }); + + it('edit button click should load edit Liberatoria page and go back', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Liberatoria'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', liberatoriaPageUrlPattern); + }); + + it('edit button click should load edit Liberatoria page and save', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Liberatoria'); + cy.get(entityCreateSaveButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', liberatoriaPageUrlPattern); + }); + + it('last delete button click should delete instance of Liberatoria', () => { + cy.get(entityDeleteButtonSelector).last().click(); + cy.getEntityDeleteDialogHeading('liberatoria').should('exist'); + cy.get(entityConfirmDeleteButtonSelector).click(); + cy.wait('@deleteEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(204); + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', liberatoriaPageUrlPattern); + + liberatoria = undefined; + }); + }); + }); + + describe('new Liberatoria page', () => { + beforeEach(() => { + cy.visit(liberatoriaPageUrl); + cy.get(entityCreateButtonSelector).click(); + cy.getEntityCreateUpdateHeading('Liberatoria'); + }); + + it('should create an instance of Liberatoria', () => { + cy.get(`[data-cy="accettata"]`).type('2025-12-10T05:52'); + cy.get(`[data-cy="accettata"]`).blur(); + cy.get(`[data-cy="accettata"]`).should('have.value', '2025-12-10T05:52'); + + cy.get(entityCreateSaveButtonSelector).click(); + + cy.wait('@postEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(201); + liberatoria = response.body; + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', liberatoriaPageUrlPattern); + }); + }); +}); diff --git a/src/test/javascript/cypress/e2e/entity/messaggio.cy.ts b/src/test/javascript/cypress/e2e/entity/messaggio.cy.ts new file mode 100644 index 0000000..8bf367e --- /dev/null +++ b/src/test/javascript/cypress/e2e/entity/messaggio.cy.ts @@ -0,0 +1,183 @@ +import { + entityConfirmDeleteButtonSelector, + entityCreateButtonSelector, + entityCreateCancelButtonSelector, + entityCreateSaveButtonSelector, + entityDeleteButtonSelector, + entityDetailsBackButtonSelector, + entityDetailsButtonSelector, + entityEditButtonSelector, + entityTableSelector, +} from '../../support/entity'; + +describe('Messaggio e2e test', () => { + const messaggioPageUrl = '/messaggio'; + const messaggioPageUrlPattern = new RegExp('/messaggio(\\?.*)?$'); + const username = Cypress.env('E2E_USERNAME') ?? 'user'; + const password = Cypress.env('E2E_PASSWORD') ?? 'user'; + const messaggioSample = {}; + + let messaggio; + + beforeEach(() => { + cy.login(username, password); + }); + + beforeEach(() => { + cy.intercept('GET', '/api/messaggios+(?*|)').as('entitiesRequest'); + cy.intercept('POST', '/api/messaggios').as('postEntityRequest'); + cy.intercept('DELETE', '/api/messaggios/*').as('deleteEntityRequest'); + }); + + afterEach(() => { + if (messaggio) { + cy.authenticatedRequest({ + method: 'DELETE', + url: `/api/messaggios/${messaggio.id}`, + }).then(() => { + messaggio = undefined; + }); + } + }); + + it('Messaggios menu should load Messaggios page', () => { + cy.visit('/'); + cy.clickOnEntityMenuItem('messaggio'); + cy.wait('@entitiesRequest').then(({ response }) => { + if (response?.body.length === 0) { + cy.get(entityTableSelector).should('not.exist'); + } else { + cy.get(entityTableSelector).should('exist'); + } + }); + cy.getEntityHeading('Messaggio').should('exist'); + cy.url().should('match', messaggioPageUrlPattern); + }); + + describe('Messaggio page', () => { + describe('create button click', () => { + beforeEach(() => { + cy.visit(messaggioPageUrl); + cy.wait('@entitiesRequest'); + }); + + it('should load create Messaggio page', () => { + cy.get(entityCreateButtonSelector).click(); + cy.url().should('match', new RegExp('/messaggio/new$')); + cy.getEntityCreateUpdateHeading('Messaggio'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', messaggioPageUrlPattern); + }); + }); + + describe('with existing value', () => { + beforeEach(() => { + cy.authenticatedRequest({ + method: 'POST', + url: '/api/messaggios', + body: messaggioSample, + }).then(({ body }) => { + messaggio = body; + + cy.intercept( + { + method: 'GET', + url: '/api/messaggios+(?*|)', + times: 1, + }, + { + statusCode: 200, + body: [messaggio], + }, + ).as('entitiesRequestInternal'); + }); + + cy.visit(messaggioPageUrl); + + cy.wait('@entitiesRequestInternal'); + }); + + it('detail button click should load details Messaggio page', () => { + cy.get(entityDetailsButtonSelector).first().click(); + cy.getEntityDetailsHeading('messaggio'); + cy.get(entityDetailsBackButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', messaggioPageUrlPattern); + }); + + it('edit button click should load edit Messaggio page and go back', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Messaggio'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', messaggioPageUrlPattern); + }); + + it('edit button click should load edit Messaggio page and save', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Messaggio'); + cy.get(entityCreateSaveButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', messaggioPageUrlPattern); + }); + + it('last delete button click should delete instance of Messaggio', () => { + cy.get(entityDeleteButtonSelector).last().click(); + cy.getEntityDeleteDialogHeading('messaggio').should('exist'); + cy.get(entityConfirmDeleteButtonSelector).click(); + cy.wait('@deleteEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(204); + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', messaggioPageUrlPattern); + + messaggio = undefined; + }); + }); + }); + + describe('new Messaggio page', () => { + beforeEach(() => { + cy.visit(messaggioPageUrl); + cy.get(entityCreateButtonSelector).click(); + cy.getEntityCreateUpdateHeading('Messaggio'); + }); + + it('should create an instance of Messaggio', () => { + cy.get(`[data-cy="spedito"]`).type('2025-12-10T09:25'); + cy.get(`[data-cy="spedito"]`).blur(); + cy.get(`[data-cy="spedito"]`).should('have.value', '2025-12-10T09:25'); + + cy.get(`[data-cy="testo"]`).type('for'); + cy.get(`[data-cy="testo"]`).should('have.value', 'for'); + + cy.get(`[data-cy="letto"]`).type('2025-12-10T02:14'); + cy.get(`[data-cy="letto"]`).blur(); + cy.get(`[data-cy="letto"]`).should('have.value', '2025-12-10T02:14'); + + cy.get(entityCreateSaveButtonSelector).click(); + + cy.wait('@postEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(201); + messaggio = response.body; + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', messaggioPageUrlPattern); + }); + }); +}); diff --git a/src/test/javascript/cypress/e2e/entity/modello-liberatoria.cy.ts b/src/test/javascript/cypress/e2e/entity/modello-liberatoria.cy.ts new file mode 100644 index 0000000..2024bc7 --- /dev/null +++ b/src/test/javascript/cypress/e2e/entity/modello-liberatoria.cy.ts @@ -0,0 +1,190 @@ +import { + entityConfirmDeleteButtonSelector, + entityCreateButtonSelector, + entityCreateCancelButtonSelector, + entityCreateSaveButtonSelector, + entityDeleteButtonSelector, + entityDetailsBackButtonSelector, + entityDetailsButtonSelector, + entityEditButtonSelector, + entityTableSelector, +} from '../../support/entity'; + +describe('ModelloLiberatoria e2e test', () => { + const modelloLiberatoriaPageUrl = '/modello-liberatoria'; + const modelloLiberatoriaPageUrlPattern = new RegExp('/modello-liberatoria(\\?.*)?$'); + const username = Cypress.env('E2E_USERNAME') ?? 'user'; + const password = Cypress.env('E2E_PASSWORD') ?? 'user'; + const modelloLiberatoriaSample = {}; + + let modelloLiberatoria; + + beforeEach(() => { + cy.login(username, password); + }); + + beforeEach(() => { + cy.intercept('GET', '/api/modello-liberatorias+(?*|)').as('entitiesRequest'); + cy.intercept('POST', '/api/modello-liberatorias').as('postEntityRequest'); + cy.intercept('DELETE', '/api/modello-liberatorias/*').as('deleteEntityRequest'); + }); + + afterEach(() => { + if (modelloLiberatoria) { + cy.authenticatedRequest({ + method: 'DELETE', + url: `/api/modello-liberatorias/${modelloLiberatoria.id}`, + }).then(() => { + modelloLiberatoria = undefined; + }); + } + }); + + it('ModelloLiberatorias menu should load ModelloLiberatorias page', () => { + cy.visit('/'); + cy.clickOnEntityMenuItem('modello-liberatoria'); + cy.wait('@entitiesRequest').then(({ response }) => { + if (response?.body.length === 0) { + cy.get(entityTableSelector).should('not.exist'); + } else { + cy.get(entityTableSelector).should('exist'); + } + }); + cy.getEntityHeading('ModelloLiberatoria').should('exist'); + cy.url().should('match', modelloLiberatoriaPageUrlPattern); + }); + + describe('ModelloLiberatoria page', () => { + describe('create button click', () => { + beforeEach(() => { + cy.visit(modelloLiberatoriaPageUrl); + cy.wait('@entitiesRequest'); + }); + + it('should load create ModelloLiberatoria page', () => { + cy.get(entityCreateButtonSelector).click(); + cy.url().should('match', new RegExp('/modello-liberatoria/new$')); + cy.getEntityCreateUpdateHeading('ModelloLiberatoria'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', modelloLiberatoriaPageUrlPattern); + }); + }); + + describe('with existing value', () => { + beforeEach(() => { + cy.authenticatedRequest({ + method: 'POST', + url: '/api/modello-liberatorias', + body: modelloLiberatoriaSample, + }).then(({ body }) => { + modelloLiberatoria = body; + + cy.intercept( + { + method: 'GET', + url: '/api/modello-liberatorias+(?*|)', + times: 1, + }, + { + statusCode: 200, + body: [modelloLiberatoria], + }, + ).as('entitiesRequestInternal'); + }); + + cy.visit(modelloLiberatoriaPageUrl); + + cy.wait('@entitiesRequestInternal'); + }); + + it('detail button click should load details ModelloLiberatoria page', () => { + cy.get(entityDetailsButtonSelector).first().click(); + cy.getEntityDetailsHeading('modelloLiberatoria'); + cy.get(entityDetailsBackButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', modelloLiberatoriaPageUrlPattern); + }); + + it('edit button click should load edit ModelloLiberatoria page and go back', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('ModelloLiberatoria'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', modelloLiberatoriaPageUrlPattern); + }); + + it('edit button click should load edit ModelloLiberatoria page and save', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('ModelloLiberatoria'); + cy.get(entityCreateSaveButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', modelloLiberatoriaPageUrlPattern); + }); + + it('last delete button click should delete instance of ModelloLiberatoria', () => { + cy.get(entityDeleteButtonSelector).last().click(); + cy.getEntityDeleteDialogHeading('modelloLiberatoria').should('exist'); + cy.get(entityConfirmDeleteButtonSelector).click(); + cy.wait('@deleteEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(204); + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', modelloLiberatoriaPageUrlPattern); + + modelloLiberatoria = undefined; + }); + }); + }); + + describe('new ModelloLiberatoria page', () => { + beforeEach(() => { + cy.visit(modelloLiberatoriaPageUrl); + cy.get(entityCreateButtonSelector).click(); + cy.getEntityCreateUpdateHeading('ModelloLiberatoria'); + }); + + it('should create an instance of ModelloLiberatoria', () => { + cy.get(`[data-cy="nome"]`).type('sedately in'); + cy.get(`[data-cy="nome"]`).should('have.value', 'sedately in'); + + cy.get(`[data-cy="testo"]`).type('before'); + cy.get(`[data-cy="testo"]`).should('have.value', 'before'); + + cy.setFieldImageAsBytesOfEntity('documento', 'integration-test.png', 'image/png'); + + cy.get(`[data-cy="validoDal"]`).type('2025-12-09T16:22'); + cy.get(`[data-cy="validoDal"]`).blur(); + cy.get(`[data-cy="validoDal"]`).should('have.value', '2025-12-09T16:22'); + + cy.get(`[data-cy="validoAl"]`).type('2025-12-09T22:55'); + cy.get(`[data-cy="validoAl"]`).blur(); + cy.get(`[data-cy="validoAl"]`).should('have.value', '2025-12-09T22:55'); + + // since cypress clicks submit too fast before the blob fields are validated + cy.wait(200); // eslint-disable-line cypress/no-unnecessary-waiting + cy.get(entityCreateSaveButtonSelector).click(); + + cy.wait('@postEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(201); + modelloLiberatoria = response.body; + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', modelloLiberatoriaPageUrlPattern); + }); + }); +}); diff --git a/src/test/javascript/cypress/e2e/entity/notifica.cy.ts b/src/test/javascript/cypress/e2e/entity/notifica.cy.ts new file mode 100644 index 0000000..66a86f9 --- /dev/null +++ b/src/test/javascript/cypress/e2e/entity/notifica.cy.ts @@ -0,0 +1,197 @@ +import { + entityConfirmDeleteButtonSelector, + entityCreateButtonSelector, + entityCreateCancelButtonSelector, + entityCreateSaveButtonSelector, + entityDeleteButtonSelector, + entityDetailsBackButtonSelector, + entityDetailsButtonSelector, + entityEditButtonSelector, + entityTableSelector, +} from '../../support/entity'; + +describe('Notifica e2e test', () => { + const notificaPageUrl = '/notifica'; + const notificaPageUrlPattern = new RegExp('/notifica(\\?.*)?$'); + const username = Cypress.env('E2E_USERNAME') ?? 'user'; + const password = Cypress.env('E2E_PASSWORD') ?? 'user'; + const notificaSample = {}; + + let notifica; + + beforeEach(() => { + cy.login(username, password); + }); + + beforeEach(() => { + cy.intercept('GET', '/api/notificas+(?*|)').as('entitiesRequest'); + cy.intercept('POST', '/api/notificas').as('postEntityRequest'); + cy.intercept('DELETE', '/api/notificas/*').as('deleteEntityRequest'); + }); + + afterEach(() => { + if (notifica) { + cy.authenticatedRequest({ + method: 'DELETE', + url: `/api/notificas/${notifica.id}`, + }).then(() => { + notifica = undefined; + }); + } + }); + + it('Notificas menu should load Notificas page', () => { + cy.visit('/'); + cy.clickOnEntityMenuItem('notifica'); + cy.wait('@entitiesRequest').then(({ response }) => { + if (response?.body.length === 0) { + cy.get(entityTableSelector).should('not.exist'); + } else { + cy.get(entityTableSelector).should('exist'); + } + }); + cy.getEntityHeading('Notifica').should('exist'); + cy.url().should('match', notificaPageUrlPattern); + }); + + describe('Notifica page', () => { + describe('create button click', () => { + beforeEach(() => { + cy.visit(notificaPageUrl); + cy.wait('@entitiesRequest'); + }); + + it('should load create Notifica page', () => { + cy.get(entityCreateButtonSelector).click(); + cy.url().should('match', new RegExp('/notifica/new$')); + cy.getEntityCreateUpdateHeading('Notifica'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', notificaPageUrlPattern); + }); + }); + + describe('with existing value', () => { + beforeEach(() => { + cy.authenticatedRequest({ + method: 'POST', + url: '/api/notificas', + body: notificaSample, + }).then(({ body }) => { + notifica = body; + + cy.intercept( + { + method: 'GET', + url: '/api/notificas+(?*|)', + times: 1, + }, + { + statusCode: 200, + headers: { + link: '; rel="last",; rel="first"', + }, + body: [notifica], + }, + ).as('entitiesRequestInternal'); + }); + + cy.visit(notificaPageUrl); + + cy.wait('@entitiesRequestInternal'); + }); + + it('detail button click should load details Notifica page', () => { + cy.get(entityDetailsButtonSelector).first().click(); + cy.getEntityDetailsHeading('notifica'); + cy.get(entityDetailsBackButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', notificaPageUrlPattern); + }); + + it('edit button click should load edit Notifica page and go back', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Notifica'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', notificaPageUrlPattern); + }); + + it('edit button click should load edit Notifica page and save', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Notifica'); + cy.get(entityCreateSaveButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', notificaPageUrlPattern); + }); + + it('last delete button click should delete instance of Notifica', () => { + cy.get(entityDeleteButtonSelector).last().click(); + cy.getEntityDeleteDialogHeading('notifica').should('exist'); + cy.get(entityConfirmDeleteButtonSelector).click(); + cy.wait('@deleteEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(204); + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', notificaPageUrlPattern); + + notifica = undefined; + }); + }); + }); + + describe('new Notifica page', () => { + beforeEach(() => { + cy.visit(notificaPageUrl); + cy.get(entityCreateButtonSelector).click(); + cy.getEntityCreateUpdateHeading('Notifica'); + }); + + it('should create an instance of Notifica', () => { + cy.get(`[data-cy="tipoCanale"]`).select('EMAIL'); + + cy.get(`[data-cy="tipoEvento"]`).select('PRENOTAZIONE_RIFIUTATA'); + + cy.get(`[data-cy="messaggio"]`).type('brr ha'); + cy.get(`[data-cy="messaggio"]`).should('have.value', 'brr ha'); + + cy.get(`[data-cy="inviata"]`).should('not.be.checked'); + cy.get(`[data-cy="inviata"]`).click(); + cy.get(`[data-cy="inviata"]`).should('be.checked'); + + cy.get(`[data-cy="inviataAt"]`).type('2025-12-10T15:18'); + cy.get(`[data-cy="inviataAt"]`).blur(); + cy.get(`[data-cy="inviataAt"]`).should('have.value', '2025-12-10T15:18'); + + cy.get(`[data-cy="errore"]`).type('upwardly'); + cy.get(`[data-cy="errore"]`).should('have.value', 'upwardly'); + + cy.get(`[data-cy="createdAt"]`).type('2025-12-09T16:35'); + cy.get(`[data-cy="createdAt"]`).blur(); + cy.get(`[data-cy="createdAt"]`).should('have.value', '2025-12-09T16:35'); + + cy.get(entityCreateSaveButtonSelector).click(); + + cy.wait('@postEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(201); + notifica = response.body; + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', notificaPageUrlPattern); + }); + }); +}); diff --git a/src/test/javascript/cypress/e2e/entity/prenotazione.cy.ts b/src/test/javascript/cypress/e2e/entity/prenotazione.cy.ts new file mode 100644 index 0000000..cb8d928 --- /dev/null +++ b/src/test/javascript/cypress/e2e/entity/prenotazione.cy.ts @@ -0,0 +1,194 @@ +import { + entityConfirmDeleteButtonSelector, + entityCreateButtonSelector, + entityCreateCancelButtonSelector, + entityCreateSaveButtonSelector, + entityDeleteButtonSelector, + entityDetailsBackButtonSelector, + entityDetailsButtonSelector, + entityEditButtonSelector, + entityTableSelector, +} from '../../support/entity'; + +describe('Prenotazione e2e test', () => { + const prenotazionePageUrl = '/prenotazione'; + const prenotazionePageUrlPattern = new RegExp('/prenotazione(\\?.*)?$'); + const username = Cypress.env('E2E_USERNAME') ?? 'user'; + const password = Cypress.env('E2E_PASSWORD') ?? 'user'; + const prenotazioneSample = {}; + + let prenotazione; + + beforeEach(() => { + cy.login(username, password); + }); + + beforeEach(() => { + cy.intercept('GET', '/api/prenotaziones+(?*|)').as('entitiesRequest'); + cy.intercept('POST', '/api/prenotaziones').as('postEntityRequest'); + cy.intercept('DELETE', '/api/prenotaziones/*').as('deleteEntityRequest'); + }); + + afterEach(() => { + if (prenotazione) { + cy.authenticatedRequest({ + method: 'DELETE', + url: `/api/prenotaziones/${prenotazione.id}`, + }).then(() => { + prenotazione = undefined; + }); + } + }); + + it('Prenotaziones menu should load Prenotaziones page', () => { + cy.visit('/'); + cy.clickOnEntityMenuItem('prenotazione'); + cy.wait('@entitiesRequest').then(({ response }) => { + if (response?.body.length === 0) { + cy.get(entityTableSelector).should('not.exist'); + } else { + cy.get(entityTableSelector).should('exist'); + } + }); + cy.getEntityHeading('Prenotazione').should('exist'); + cy.url().should('match', prenotazionePageUrlPattern); + }); + + describe('Prenotazione page', () => { + describe('create button click', () => { + beforeEach(() => { + cy.visit(prenotazionePageUrl); + cy.wait('@entitiesRequest'); + }); + + it('should load create Prenotazione page', () => { + cy.get(entityCreateButtonSelector).click(); + cy.url().should('match', new RegExp('/prenotazione/new$')); + cy.getEntityCreateUpdateHeading('Prenotazione'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', prenotazionePageUrlPattern); + }); + }); + + describe('with existing value', () => { + beforeEach(() => { + cy.authenticatedRequest({ + method: 'POST', + url: '/api/prenotaziones', + body: prenotazioneSample, + }).then(({ body }) => { + prenotazione = body; + + cy.intercept( + { + method: 'GET', + url: '/api/prenotaziones+(?*|)', + times: 1, + }, + { + statusCode: 200, + headers: { + link: '; rel="last",; rel="first"', + }, + body: [prenotazione], + }, + ).as('entitiesRequestInternal'); + }); + + cy.visit(prenotazionePageUrl); + + cy.wait('@entitiesRequestInternal'); + }); + + it('detail button click should load details Prenotazione page', () => { + cy.get(entityDetailsButtonSelector).first().click(); + cy.getEntityDetailsHeading('prenotazione'); + cy.get(entityDetailsBackButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', prenotazionePageUrlPattern); + }); + + it('edit button click should load edit Prenotazione page and go back', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Prenotazione'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', prenotazionePageUrlPattern); + }); + + it('edit button click should load edit Prenotazione page and save', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Prenotazione'); + cy.get(entityCreateSaveButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', prenotazionePageUrlPattern); + }); + + it('last delete button click should delete instance of Prenotazione', () => { + cy.get(entityDeleteButtonSelector).last().click(); + cy.getEntityDeleteDialogHeading('prenotazione').should('exist'); + cy.get(entityConfirmDeleteButtonSelector).click(); + cy.wait('@deleteEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(204); + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', prenotazionePageUrlPattern); + + prenotazione = undefined; + }); + }); + }); + + describe('new Prenotazione page', () => { + beforeEach(() => { + cy.visit(prenotazionePageUrl); + cy.get(entityCreateButtonSelector).click(); + cy.getEntityCreateUpdateHeading('Prenotazione'); + }); + + it('should create an instance of Prenotazione', () => { + cy.get(`[data-cy="oraInizio"]`).type('2025-12-10T05:00'); + cy.get(`[data-cy="oraInizio"]`).blur(); + cy.get(`[data-cy="oraInizio"]`).should('have.value', '2025-12-10T05:00'); + + cy.get(`[data-cy="oraFine"]`).type('2025-12-10T14:09'); + cy.get(`[data-cy="oraFine"]`).blur(); + cy.get(`[data-cy="oraFine"]`).should('have.value', '2025-12-10T14:09'); + + cy.get(`[data-cy="stato"]`).select('ANNULLATA'); + + cy.get(`[data-cy="motivoEvento"]`).type('via'); + cy.get(`[data-cy="motivoEvento"]`).should('have.value', 'via'); + + cy.get(`[data-cy="numeroPartecipanti"]`).type('30937'); + cy.get(`[data-cy="numeroPartecipanti"]`).should('have.value', '30937'); + + cy.get(`[data-cy="noteUtente"]`).type('gah while ick'); + cy.get(`[data-cy="noteUtente"]`).should('have.value', 'gah while ick'); + + cy.get(entityCreateSaveButtonSelector).click(); + + cy.wait('@postEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(201); + prenotazione = response.body; + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', prenotazionePageUrlPattern); + }); + }); +}); diff --git a/src/test/javascript/cypress/e2e/entity/struttura.cy.ts b/src/test/javascript/cypress/e2e/entity/struttura.cy.ts new file mode 100644 index 0000000..29c49ee --- /dev/null +++ b/src/test/javascript/cypress/e2e/entity/struttura.cy.ts @@ -0,0 +1,202 @@ +import { + entityConfirmDeleteButtonSelector, + entityCreateButtonSelector, + entityCreateCancelButtonSelector, + entityCreateSaveButtonSelector, + entityDeleteButtonSelector, + entityDetailsBackButtonSelector, + entityDetailsButtonSelector, + entityEditButtonSelector, + entityTableSelector, +} from '../../support/entity'; + +describe('Struttura e2e test', () => { + const strutturaPageUrl = '/struttura'; + const strutturaPageUrlPattern = new RegExp('/struttura(\\?.*)?$'); + const username = Cypress.env('E2E_USERNAME') ?? 'user'; + const password = Cypress.env('E2E_PASSWORD') ?? 'user'; + const strutturaSample = {}; + + let struttura; + + beforeEach(() => { + cy.login(username, password); + }); + + beforeEach(() => { + cy.intercept('GET', '/api/strutturas+(?*|)').as('entitiesRequest'); + cy.intercept('POST', '/api/strutturas').as('postEntityRequest'); + cy.intercept('DELETE', '/api/strutturas/*').as('deleteEntityRequest'); + }); + + afterEach(() => { + if (struttura) { + cy.authenticatedRequest({ + method: 'DELETE', + url: `/api/strutturas/${struttura.id}`, + }).then(() => { + struttura = undefined; + }); + } + }); + + it('Strutturas menu should load Strutturas page', () => { + cy.visit('/'); + cy.clickOnEntityMenuItem('struttura'); + cy.wait('@entitiesRequest').then(({ response }) => { + if (response?.body.length === 0) { + cy.get(entityTableSelector).should('not.exist'); + } else { + cy.get(entityTableSelector).should('exist'); + } + }); + cy.getEntityHeading('Struttura').should('exist'); + cy.url().should('match', strutturaPageUrlPattern); + }); + + describe('Struttura page', () => { + describe('create button click', () => { + beforeEach(() => { + cy.visit(strutturaPageUrl); + cy.wait('@entitiesRequest'); + }); + + it('should load create Struttura page', () => { + cy.get(entityCreateButtonSelector).click(); + cy.url().should('match', new RegExp('/struttura/new$')); + cy.getEntityCreateUpdateHeading('Struttura'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', strutturaPageUrlPattern); + }); + }); + + describe('with existing value', () => { + beforeEach(() => { + cy.authenticatedRequest({ + method: 'POST', + url: '/api/strutturas', + body: strutturaSample, + }).then(({ body }) => { + struttura = body; + + cy.intercept( + { + method: 'GET', + url: '/api/strutturas+(?*|)', + times: 1, + }, + { + statusCode: 200, + headers: { + link: '; rel="last",; rel="first"', + }, + body: [struttura], + }, + ).as('entitiesRequestInternal'); + }); + + cy.visit(strutturaPageUrl); + + cy.wait('@entitiesRequestInternal'); + }); + + it('detail button click should load details Struttura page', () => { + cy.get(entityDetailsButtonSelector).first().click(); + cy.getEntityDetailsHeading('struttura'); + cy.get(entityDetailsBackButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', strutturaPageUrlPattern); + }); + + it('edit button click should load edit Struttura page and go back', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Struttura'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', strutturaPageUrlPattern); + }); + + it('edit button click should load edit Struttura page and save', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('Struttura'); + cy.get(entityCreateSaveButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', strutturaPageUrlPattern); + }); + + it('last delete button click should delete instance of Struttura', () => { + cy.get(entityDeleteButtonSelector).last().click(); + cy.getEntityDeleteDialogHeading('struttura').should('exist'); + cy.get(entityConfirmDeleteButtonSelector).click(); + cy.wait('@deleteEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(204); + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', strutturaPageUrlPattern); + + struttura = undefined; + }); + }); + }); + + describe('new Struttura page', () => { + beforeEach(() => { + cy.visit(strutturaPageUrl); + cy.get(entityCreateButtonSelector).click(); + cy.getEntityCreateUpdateHeading('Struttura'); + }); + + it('should create an instance of Struttura', () => { + cy.get(`[data-cy="nome"]`).type('finally how'); + cy.get(`[data-cy="nome"]`).should('have.value', 'finally how'); + + cy.get(`[data-cy="descrizione"]`).type('immediately supposing'); + cy.get(`[data-cy="descrizione"]`).should('have.value', 'immediately supposing'); + + cy.get(`[data-cy="indirizzo"]`).type('elevation brush yieldingly'); + cy.get(`[data-cy="indirizzo"]`).should('have.value', 'elevation brush yieldingly'); + + cy.get(`[data-cy="capienzaMax"]`).type('16547'); + cy.get(`[data-cy="capienzaMax"]`).should('have.value', '16547'); + + cy.get(`[data-cy="attiva"]`).should('not.be.checked'); + cy.get(`[data-cy="attiva"]`).click(); + cy.get(`[data-cy="attiva"]`).should('be.checked'); + + cy.get(`[data-cy="fotoUrl"]`).type('where mmm'); + cy.get(`[data-cy="fotoUrl"]`).should('have.value', 'where mmm'); + + cy.get(`[data-cy="createdAt"]`).type('2025-12-09T23:39'); + cy.get(`[data-cy="createdAt"]`).blur(); + cy.get(`[data-cy="createdAt"]`).should('have.value', '2025-12-09T23:39'); + + cy.get(`[data-cy="updatedAt"]`).type('2025-12-10T07:08'); + cy.get(`[data-cy="updatedAt"]`).blur(); + cy.get(`[data-cy="updatedAt"]`).should('have.value', '2025-12-10T07:08'); + + cy.get(entityCreateSaveButtonSelector).click(); + + cy.wait('@postEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(201); + struttura = response.body; + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', strutturaPageUrlPattern); + }); + }); +}); diff --git a/src/test/javascript/cypress/e2e/entity/utente-app.cy.ts b/src/test/javascript/cypress/e2e/entity/utente-app.cy.ts new file mode 100644 index 0000000..c150f51 --- /dev/null +++ b/src/test/javascript/cypress/e2e/entity/utente-app.cy.ts @@ -0,0 +1,217 @@ +import { + entityConfirmDeleteButtonSelector, + entityCreateButtonSelector, + entityCreateCancelButtonSelector, + entityCreateSaveButtonSelector, + entityDeleteButtonSelector, + entityDetailsBackButtonSelector, + entityDetailsButtonSelector, + entityEditButtonSelector, + entityTableSelector, +} from '../../support/entity'; + +describe('UtenteApp e2e test', () => { + const utenteAppPageUrl = '/utente-app'; + const utenteAppPageUrlPattern = new RegExp('/utente-app(\\?.*)?$'); + const username = Cypress.env('E2E_USERNAME') ?? 'user'; + const password = Cypress.env('E2E_PASSWORD') ?? 'user'; + const utenteAppSample = { username: 'bell for windy', email: 'Oronzo88@libero.it', ruolo: 'ADMIN', attivo: false }; + + let utenteApp; + + beforeEach(() => { + cy.login(username, password); + }); + + beforeEach(() => { + cy.intercept('GET', '/api/utente-apps+(?*|)').as('entitiesRequest'); + cy.intercept('POST', '/api/utente-apps').as('postEntityRequest'); + cy.intercept('DELETE', '/api/utente-apps/*').as('deleteEntityRequest'); + }); + + afterEach(() => { + if (utenteApp) { + cy.authenticatedRequest({ + method: 'DELETE', + url: `/api/utente-apps/${utenteApp.id}`, + }).then(() => { + utenteApp = undefined; + }); + } + }); + + it('UtenteApps menu should load UtenteApps page', () => { + cy.visit('/'); + cy.clickOnEntityMenuItem('utente-app'); + cy.wait('@entitiesRequest').then(({ response }) => { + if (response?.body.length === 0) { + cy.get(entityTableSelector).should('not.exist'); + } else { + cy.get(entityTableSelector).should('exist'); + } + }); + cy.getEntityHeading('UtenteApp').should('exist'); + cy.url().should('match', utenteAppPageUrlPattern); + }); + + describe('UtenteApp page', () => { + describe('create button click', () => { + beforeEach(() => { + cy.visit(utenteAppPageUrl); + cy.wait('@entitiesRequest'); + }); + + it('should load create UtenteApp page', () => { + cy.get(entityCreateButtonSelector).click(); + cy.url().should('match', new RegExp('/utente-app/new$')); + cy.getEntityCreateUpdateHeading('UtenteApp'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', utenteAppPageUrlPattern); + }); + }); + + describe('with existing value', () => { + beforeEach(() => { + cy.authenticatedRequest({ + method: 'POST', + url: '/api/utente-apps', + body: utenteAppSample, + }).then(({ body }) => { + utenteApp = body; + + cy.intercept( + { + method: 'GET', + url: '/api/utente-apps+(?*|)', + times: 1, + }, + { + statusCode: 200, + body: [utenteApp], + }, + ).as('entitiesRequestInternal'); + }); + + cy.visit(utenteAppPageUrl); + + cy.wait('@entitiesRequestInternal'); + }); + + it('detail button click should load details UtenteApp page', () => { + cy.get(entityDetailsButtonSelector).first().click(); + cy.getEntityDetailsHeading('utenteApp'); + cy.get(entityDetailsBackButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', utenteAppPageUrlPattern); + }); + + it('edit button click should load edit UtenteApp page and go back', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('UtenteApp'); + cy.get(entityCreateSaveButtonSelector).should('exist'); + cy.get(entityCreateCancelButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', utenteAppPageUrlPattern); + }); + + it('edit button click should load edit UtenteApp page and save', () => { + cy.get(entityEditButtonSelector).first().click(); + cy.getEntityCreateUpdateHeading('UtenteApp'); + cy.get(entityCreateSaveButtonSelector).click(); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', utenteAppPageUrlPattern); + }); + + it('last delete button click should delete instance of UtenteApp', () => { + cy.get(entityDeleteButtonSelector).last().click(); + cy.getEntityDeleteDialogHeading('utenteApp').should('exist'); + cy.get(entityConfirmDeleteButtonSelector).click(); + cy.wait('@deleteEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(204); + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', utenteAppPageUrlPattern); + + utenteApp = undefined; + }); + }); + }); + + describe('new UtenteApp page', () => { + beforeEach(() => { + cy.visit(utenteAppPageUrl); + cy.get(entityCreateButtonSelector).click(); + cy.getEntityCreateUpdateHeading('UtenteApp'); + }); + + it('should create an instance of UtenteApp', () => { + cy.get(`[data-cy="username"]`).type('since woeful'); + cy.get(`[data-cy="username"]`).should('have.value', 'since woeful'); + + cy.get(`[data-cy="email"]`).type('Richelmo81@hotmail.com'); + cy.get(`[data-cy="email"]`).should('have.value', 'Richelmo81@hotmail.com'); + + cy.get(`[data-cy="telefono"]`).type('bathrobe westernise'); + cy.get(`[data-cy="telefono"]`).should('have.value', 'bathrobe westernise'); + + cy.get(`[data-cy="ruolo"]`).select('INCARICATO'); + + cy.get(`[data-cy="attivo"]`).should('not.be.checked'); + cy.get(`[data-cy="attivo"]`).click(); + cy.get(`[data-cy="attivo"]`).should('be.checked'); + + cy.get(`[data-cy="nome"]`).type('apud hydrant thankfully'); + cy.get(`[data-cy="nome"]`).should('have.value', 'apud hydrant thankfully'); + + cy.get(`[data-cy="cognome"]`).type('uproot who spirited'); + cy.get(`[data-cy="cognome"]`).should('have.value', 'uproot who spirited'); + + cy.get(`[data-cy="luogoNascita"]`).type('a gadzooks until'); + cy.get(`[data-cy="luogoNascita"]`).should('have.value', 'a gadzooks until'); + + cy.get(`[data-cy="dataNascita"]`).type('gad past'); + cy.get(`[data-cy="dataNascita"]`).should('have.value', 'gad past'); + + cy.get(`[data-cy="residente"]`).type('object'); + cy.get(`[data-cy="residente"]`).should('have.value', 'object'); + + cy.get(`[data-cy="societa"]`).type('polyester forage'); + cy.get(`[data-cy="societa"]`).should('have.value', 'polyester forage'); + + cy.get(`[data-cy="sede"]`).type('once'); + cy.get(`[data-cy="sede"]`).should('have.value', 'once'); + + cy.get(`[data-cy="codfiscale"]`).type('ha'); + cy.get(`[data-cy="codfiscale"]`).should('have.value', 'ha'); + + cy.get(`[data-cy="telefonoSoc"]`).type('serenade rationale meh'); + cy.get(`[data-cy="telefonoSoc"]`).should('have.value', 'serenade rationale meh'); + + cy.get(`[data-cy="emailSoc"]`).type('oh hungrily wonderfully'); + cy.get(`[data-cy="emailSoc"]`).should('have.value', 'oh hungrily wonderfully'); + + cy.get(entityCreateSaveButtonSelector).click(); + + cy.wait('@postEntityRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(201); + utenteApp = response.body; + }); + cy.wait('@entitiesRequest').then(({ response }) => { + expect(response?.statusCode).to.equal(200); + }); + cy.url().should('match', utenteAppPageUrlPattern); + }); + }); +});