diff --git a/app/back/src/main/fr/gouv/monprojetsup/authentification/domain/entity/ProfilEleve.kt b/app/back/src/main/fr/gouv/monprojetsup/authentification/domain/entity/ProfilEleve.kt index e9ecb8da3..150d60869 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/authentification/domain/entity/ProfilEleve.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/authentification/domain/entity/ProfilEleve.kt @@ -1,6 +1,6 @@ package fr.gouv.monprojetsup.authentification.domain.entity -import fr.gouv.monprojetsup.eleve.domain.entity.Commune +import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixAlternance import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixDureeEtudesPrevue @@ -19,7 +19,7 @@ sealed class ProfilEleve(open val id: String) : ProfilUtilisateur() { val metiersFavoris: List?, val dureeEtudesPrevue: ChoixDureeEtudesPrevue?, val alternance: ChoixAlternance?, - val communesFavorites: List?, + val communesFavorites: List?, val formationsFavorites: List?, val moyenneGenerale: Float?, val corbeilleFormations: List, diff --git a/app/back/src/main/fr/gouv/monprojetsup/eleve/application/dto/ModificationProfilDTO.kt b/app/back/src/main/fr/gouv/monprojetsup/eleve/application/dto/ModificationProfilDTO.kt index 410281bf8..d545feb1d 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/eleve/application/dto/ModificationProfilDTO.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/eleve/application/dto/ModificationProfilDTO.kt @@ -2,7 +2,7 @@ package fr.gouv.monprojetsup.eleve.application.dto import com.fasterxml.jackson.annotation.JsonProperty import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve -import fr.gouv.monprojetsup.eleve.domain.entity.Commune +import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite import fr.gouv.monprojetsup.eleve.domain.entity.ModificationProfilEleve import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixAlternance @@ -143,7 +143,7 @@ data class ModificationProfilDTO( dureeEtudesPrevue = dureeEtudesPrevue, alternance = alternance, formationsFavorites = formationsFavorites?.map { it.toVoeuFormation() }, - communesFavorites = communesFavorites?.map { it.toCommune() }, + communesFavorites = communesFavorites?.map { it.toCommuneFavoris() }, specialites = specialites, moyenneGenerale = moyenneGenerale, centresInterets = centresInterets, @@ -166,15 +166,15 @@ data class ModificationProfilDTO( @JsonProperty("longitude") val longitude: Double, ) { - constructor(commune: Commune) : this( - codeInsee = commune.codeInsee, - nom = commune.nom, - latitude = commune.latitude, - longitude = commune.longitude, + constructor(communeFavorite: CommuneFavorite) : this( + codeInsee = communeFavorite.codeInsee, + nom = communeFavorite.nom, + latitude = communeFavorite.latitude, + longitude = communeFavorite.longitude, ) - fun toCommune() = - Commune( + fun toCommuneFavoris() = + CommuneFavorite( codeInsee = codeInsee, nom = nom, latitude = latitude, diff --git a/app/back/src/main/fr/gouv/monprojetsup/eleve/application/dto/ProfilDTO.kt b/app/back/src/main/fr/gouv/monprojetsup/eleve/application/dto/ProfilDTO.kt index a76521c8f..839ff6d07 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/eleve/application/dto/ProfilDTO.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/eleve/application/dto/ProfilDTO.kt @@ -2,7 +2,7 @@ package fr.gouv.monprojetsup.eleve.application.dto import com.fasterxml.jackson.annotation.JsonProperty import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve -import fr.gouv.monprojetsup.eleve.domain.entity.Commune +import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixAlternance import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixDureeEtudesPrevue @@ -133,11 +133,11 @@ data class ProfilDTO( @JsonProperty("longitude") val longitude: Double, ) { - constructor(commune: Commune) : this( - codeInsee = commune.codeInsee, - nom = commune.nom, - latitude = commune.latitude, - longitude = commune.longitude, + constructor(communeFavorite: CommuneFavorite) : this( + codeInsee = communeFavorite.codeInsee, + nom = communeFavorite.nom, + latitude = communeFavorite.latitude, + longitude = communeFavorite.longitude, ) } diff --git a/app/back/src/main/fr/gouv/monprojetsup/eleve/domain/entity/Commune.kt b/app/back/src/main/fr/gouv/monprojetsup/eleve/domain/entity/CommuneFavorite.kt similarity index 84% rename from app/back/src/main/fr/gouv/monprojetsup/eleve/domain/entity/Commune.kt rename to app/back/src/main/fr/gouv/monprojetsup/eleve/domain/entity/CommuneFavorite.kt index 386264089..d0f5e7b22 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/eleve/domain/entity/Commune.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/eleve/domain/entity/CommuneFavorite.kt @@ -1,6 +1,6 @@ package fr.gouv.monprojetsup.eleve.domain.entity -data class Commune( +data class CommuneFavorite( val codeInsee: String, val nom: String, val latitude: Double, diff --git a/app/back/src/main/fr/gouv/monprojetsup/eleve/domain/entity/ModificationProfilEleve.kt b/app/back/src/main/fr/gouv/monprojetsup/eleve/domain/entity/ModificationProfilEleve.kt index 22f578b36..6a94ca829 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/eleve/domain/entity/ModificationProfilEleve.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/eleve/domain/entity/ModificationProfilEleve.kt @@ -15,7 +15,7 @@ data class ModificationProfilEleve( val metiersFavoris: List? = null, val dureeEtudesPrevue: ChoixDureeEtudesPrevue? = null, val alternance: ChoixAlternance? = null, - val communesFavorites: List? = null, + val communesFavorites: List? = null, val formationsFavorites: List? = null, val moyenneGenerale: Float? = null, val corbeilleFormations: List? = null, diff --git a/app/back/src/main/fr/gouv/monprojetsup/eleve/infrastructure/entity/CommuneEntity.kt b/app/back/src/main/fr/gouv/monprojetsup/eleve/infrastructure/entity/CommuneEntity.kt index f0cf3a361..94c53d693 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/eleve/infrastructure/entity/CommuneEntity.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/eleve/infrastructure/entity/CommuneEntity.kt @@ -1,6 +1,6 @@ package fr.gouv.monprojetsup.eleve.infrastructure.entity -import fr.gouv.monprojetsup.eleve.domain.entity.Commune +import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite import java.io.Serializable data class CommuneEntity( @@ -9,15 +9,15 @@ data class CommuneEntity( val latitude: Double, val longitude: Double, ) : Serializable { - constructor(commune: Commune) : this( - codeInsee = commune.codeInsee, - nom = commune.nom, - latitude = commune.latitude, - longitude = commune.longitude, + constructor(communeFavorite: CommuneFavorite) : this( + codeInsee = communeFavorite.codeInsee, + nom = communeFavorite.nom, + latitude = communeFavorite.latitude, + longitude = communeFavorite.longitude, ) fun toCommune() = - Commune( + CommuneFavorite( codeInsee = codeInsee, nom = nom, latitude = latitude, diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/application/dto/FormationAvecExplicationsDTO.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/application/dto/FormationAvecExplicationsDTO.kt index 1cc88c91d..3a8818bb1 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/application/dto/FormationAvecExplicationsDTO.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/application/dto/FormationAvecExplicationsDTO.kt @@ -3,6 +3,7 @@ package fr.gouv.monprojetsup.formation.application.dto import fr.gouv.monprojetsup.commun.lien.application.dto.LienDTO import fr.gouv.monprojetsup.eleve.application.dto.ModificationProfilDTO import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecVoeuxAuxAlentours +import fr.gouv.monprojetsup.formation.domain.entity.CommuneCourte import fr.gouv.monprojetsup.formation.domain.entity.CritereAnalyseCandidature import fr.gouv.monprojetsup.formation.domain.entity.ExplicationGeographique import fr.gouv.monprojetsup.formation.domain.entity.ExplicationsSuggestionDetaillees @@ -48,6 +49,7 @@ data class FormationAvecExplicationsDTO( val criteresAnalyseCandidature: List, val repartitionAdmisAnneePrecedente: RepartitionAdmisAnneePrecedenteDTO?, val liens: List, + val communes: List, val voeux: List, val communesFavoritesAvecLeursVoeux: List, val metiers: List, @@ -76,12 +78,20 @@ data class FormationAvecExplicationsDTO( communesFavoritesAvecLeursVoeux = when (ficheFormation) { is FicheFormation.FicheFormationPourProfil -> - ficheFormation.voeuxParCommunesFavorites.map { + ficheFormation.informationsSurLesVoeuxEtLeursCommunes.voeuxParCommunesFavorites.map { CommuneAvecSesVoeuxDTO(it) } is FicheFormation.FicheFormationSansProfil -> emptyList() }, + communes = + when (ficheFormation) { + is FicheFormation.FicheFormationPourProfil -> + ficheFormation.informationsSurLesVoeuxEtLeursCommunes.communesTriees.map { + CommuneCourteDTO(it) + } + is FicheFormation.FicheFormationSansProfil -> emptyList() + }, metiers = ficheFormation.metiers.map { metier -> MetierDTO(metier) @@ -276,7 +286,7 @@ data class FormationAvecExplicationsDTO( constructor( communeAvecVoeuxAuxAlentours: CommuneAvecVoeuxAuxAlentours, ) : this( - commune = ModificationProfilDTO.CommuneDTO(communeAvecVoeuxAuxAlentours.commune), + commune = ModificationProfilDTO.CommuneDTO(communeAvecVoeuxAuxAlentours.communeFavorite), voeuxAvecDistance = communeAvecVoeuxAuxAlentours.distances.map { VoeuAvecDistanceDTO(it) }, ) @@ -299,11 +309,7 @@ data class FormationAvecExplicationsDTO( constructor(voeu: Voeu) : this( id = voeu.id, nom = voeu.nom, - commune = - CommuneCourteDTO( - nom = voeu.commune.nom, - codeInsee = voeu.commune.codeInsee, - ), + commune = CommuneCourteDTO(voeu.commune), ) } @@ -314,5 +320,10 @@ data class FormationAvecExplicationsDTO( data class CommuneCourteDTO( val nom: String, val codeInsee: String, - ) + ) { + constructor(commune: CommuneCourte) : this( + nom = commune.nom, + codeInsee = commune.codeInsee, + ) + } } diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/CommuneAvecVoeuxAuxAlentours.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/CommuneAvecVoeuxAuxAlentours.kt index 83eec8e09..453bdfa67 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/CommuneAvecVoeuxAuxAlentours.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/CommuneAvecVoeuxAuxAlentours.kt @@ -1,9 +1,9 @@ package fr.gouv.monprojetsup.formation.domain.entity -import fr.gouv.monprojetsup.eleve.domain.entity.Commune +import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite data class CommuneAvecVoeuxAuxAlentours( - val commune: Commune, + val communeFavorite: CommuneFavorite, val distances: List, ) { data class VoeuAvecDistance( @@ -13,7 +13,7 @@ data class CommuneAvecVoeuxAuxAlentours( } data class CommuneAvecIdsVoeuxAuxAlentours( - val commune: Commune, + val communeFavorite: CommuneFavorite, val distances: List, ) { data class VoeuAvecDistance( diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/CommuneCourte.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/CommuneCourte.kt new file mode 100644 index 000000000..5c80d6b33 --- /dev/null +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/CommuneCourte.kt @@ -0,0 +1,6 @@ +package fr.gouv.monprojetsup.formation.domain.entity + +data class CommuneCourte( + val nom: String, + val codeInsee: String, +) diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/FicheFormation.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/FicheFormation.kt index 2642881e1..1adf398b6 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/FicheFormation.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/FicheFormation.kt @@ -60,9 +60,8 @@ sealed class FicheFormation( override val liens: List, override val criteresAnalyseCandidature: List, override val statistiquesDesAdmis: StatistiquesDesAdmis?, - override val voeux: List, override val apprentissage: Boolean, - val voeuxParCommunesFavorites: List, + val informationsSurLesVoeuxEtLeursCommunes: InformationsSurLesVoeuxEtLeursCommunes, val tauxAffinite: Int, val metiersTriesParAffinites: List, val explications: ExplicationsSuggestionDetaillees?, @@ -76,7 +75,7 @@ sealed class FicheFormation( formationsAssociees = formationsAssociees, liens = liens, metiers = metiersTriesParAffinites, - voeux = voeux, + voeux = informationsSurLesVoeuxEtLeursCommunes.voeux, criteresAnalyseCandidature = criteresAnalyseCandidature, statistiquesDesAdmis = statistiquesDesAdmis, apprentissage = apprentissage, @@ -92,5 +91,11 @@ sealed class FicheFormation( val baccalaureat: Baccalaureat, val pourcentage: Int, ) + + data class InformationsSurLesVoeuxEtLeursCommunes( + val voeux: List, + val communesTriees: List, + val voeuxParCommunesFavorites: List, + ) } } diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/Voeu.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/Voeu.kt index 2b7e88ef4..3cac42c26 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/Voeu.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/domain/entity/Voeu.kt @@ -1,9 +1,9 @@ package fr.gouv.monprojetsup.formation.domain.entity -import fr.gouv.monprojetsup.eleve.domain.entity.Commune - data class Voeu( val id: String, val nom: String, - val commune: Commune, + val commune: CommuneCourte, + val latitude: Double, + val longitude: Double, ) diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/domain/port/CommunesAvecVoeuxAuxAlentoursRepository.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/domain/port/CommunesAvecVoeuxAuxAlentoursRepository.kt index 47d6c7274..e51b265d3 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/domain/port/CommunesAvecVoeuxAuxAlentoursRepository.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/domain/port/CommunesAvecVoeuxAuxAlentoursRepository.kt @@ -1,8 +1,8 @@ package fr.gouv.monprojetsup.formation.domain.port -import fr.gouv.monprojetsup.eleve.domain.entity.Commune +import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecIdsVoeuxAuxAlentours interface CommunesAvecVoeuxAuxAlentoursRepository { - fun recupererVoeuxAutoursDeCommmune(communes: List): List + fun recupererVoeuxAutoursDeCommmune(communeFavorites: List): List } diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/domain/port/VoeuRepository.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/domain/port/VoeuRepository.kt index 96720d9af..ef826dfab 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/domain/port/VoeuRepository.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/domain/port/VoeuRepository.kt @@ -10,7 +10,10 @@ interface VoeuRepository { obsoletesInclus: Boolean, ): Map> - fun recupererLesVoeuxDUneFormation(idFormation: String): List + fun recupererLesVoeuxDUneFormation( + idFormation: String, + obsoletesInclus: Boolean, + ): List fun recupererIdsVoeuxInexistants(idsVoeux: List): List } diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/entity/JoinFormationVoeuQuery.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/entity/JoinFormationVoeuQuery.kt index 55725a665..dd0443b42 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/entity/JoinFormationVoeuQuery.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/entity/JoinFormationVoeuQuery.kt @@ -1,6 +1,6 @@ package fr.gouv.monprojetsup.formation.infrastructure.entity -import fr.gouv.monprojetsup.eleve.domain.entity.Commune +import fr.gouv.monprojetsup.formation.domain.entity.CommuneCourte import fr.gouv.monprojetsup.formation.domain.entity.Voeu data class JoinFormationVoeuQuery( @@ -29,11 +29,11 @@ data class JoinFormationVoeuQuery( id = idVoeu, nom = nomVoeu, commune = - Commune( + CommuneCourte( nom = nomCommune, codeInsee = codeCommune, - latitude = latitude, - longitude = longitude, ), + latitude = latitude, + longitude = longitude, ) } diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/entity/VoeuEntity.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/entity/VoeuEntity.kt index fc45675cc..cf10d28de 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/entity/VoeuEntity.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/entity/VoeuEntity.kt @@ -1,7 +1,5 @@ package fr.gouv.monprojetsup.formation.infrastructure.entity -import fr.gouv.monprojetsup.eleve.domain.entity.Commune -import fr.gouv.monprojetsup.formation.domain.entity.Voeu import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.Id @@ -30,17 +28,4 @@ class VoeuEntity { @Column(name = "obsolete", nullable = false) var obsolete: Boolean = false - - fun toVoeu() = - Voeu( - id = id, - nom = nom, - commune = - Commune( - codeInsee = codeCommune, - nom = commune, - latitude = latitude, - longitude = longitude, - ), - ) } diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/repository/CommunesAvecVoeuxAuxAlentoursBDDRepository.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/repository/CommunesAvecVoeuxAuxAlentoursBDDRepository.kt index 53c3aecad..b664aae08 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/repository/CommunesAvecVoeuxAuxAlentoursBDDRepository.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/repository/CommunesAvecVoeuxAuxAlentoursBDDRepository.kt @@ -1,6 +1,6 @@ package fr.gouv.monprojetsup.formation.infrastructure.repository -import fr.gouv.monprojetsup.eleve.domain.entity.Commune +import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecIdsVoeuxAuxAlentours import fr.gouv.monprojetsup.formation.domain.port.CommunesAvecVoeuxAuxAlentoursRepository import fr.gouv.monprojetsup.logging.MonProjetSupLogger @@ -13,9 +13,9 @@ class CommunesAvecVoeuxAuxAlentoursBDDRepository( private val logger: MonProjetSupLogger, ) : CommunesAvecVoeuxAuxAlentoursRepository { @Transactional(readOnly = true) - override fun recupererVoeuxAutoursDeCommmune(communes: List): List { - val entites = communesAvecVoeuxAuxAlentoursJPARepository.findAllByCodeInseeIn(communes.map { it.codeInsee }) - return communes.map { commune -> + override fun recupererVoeuxAutoursDeCommmune(communeFavorites: List): List { + val entites = communesAvecVoeuxAuxAlentoursJPARepository.findAllByCodeInseeIn(communeFavorites.map { it.codeInsee }) + return communeFavorites.map { commune -> val distances = entites.firstOrNull { communeAvecVoeuxAuxAlentours -> commune.codeInsee == communeAvecVoeuxAuxAlentours.codeInsee @@ -28,7 +28,7 @@ class CommunesAvecVoeuxAuxAlentoursBDDRepository( ) } CommuneAvecIdsVoeuxAuxAlentours( - commune = commune, + communeFavorite = commune, distances = distances?.map { distance -> CommuneAvecIdsVoeuxAuxAlentours.VoeuAvecDistance( diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/repository/VoeuBDDRepository.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/repository/VoeuBDDRepository.kt index 9e1d41c99..730b3c678 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/repository/VoeuBDDRepository.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/infrastructure/repository/VoeuBDDRepository.kt @@ -36,8 +36,18 @@ class VoeuBDDRepository( } @Transactional(readOnly = true) - override fun recupererLesVoeuxDUneFormation(idFormation: String): List { - return findAllByIdFormationIn(listOf(idFormation)).map { it.toVoeu() } + override fun recupererLesVoeuxDUneFormation( + idFormation: String, + obsoletesInclus: Boolean, + ): List { + val formations = listOf(idFormation) + return ( + if (obsoletesInclus) { + findAllByIdFormationIn(formations) + } else { + findAllByIdFormationInNotObsolete(formations) + } + ).map { it.toVoeu() } } @Transactional(readOnly = true) diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererFormationService.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererFormationService.kt index e2965d832..68ba3485e 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererFormationService.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererFormationService.kt @@ -12,10 +12,9 @@ import org.springframework.stereotype.Service class RecupererFormationService( val suggestionHttpClient: SuggestionHttpClient, val formationRepository: FormationRepository, - val recupererVoeuxDUneFormationService: RecupererVoeuxDUneFormationService, + val recupererInformationsSurLesVoeuxEtLeursCommunesService: RecupererInformationsSurLesVoeuxEtLeursCommunesService, val critereAnalyseCandidatureService: CritereAnalyseCandidatureService, val recupererExplicationsEtExemplesMetiersPourFormationService: RecupererExplicationsEtExemplesMetiersPourFormationService, - val recupererVoeuxDesCommunesFavoritesService: RecupererVoeuxDesCommunesFavoritesService, val statistiquesDesAdmisPourFormationsService: StatistiquesDesAdmisPourFormationsService, val metiersTriesParProfilBuilder: MetiersTriesParProfilBuilder, val calculDuTauxDAffiniteBuilder: CalculDuTauxDAffiniteBuilder, @@ -41,15 +40,11 @@ class RecupererFormationService( formation.id, ) val voeuxDeLaFormation = - recupererVoeuxDUneFormationService.recupererVoeuxTriesParAffinites( + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererInformationsSurLesVoeuxEtLeursCommunes( idFormation = formation.id, profilEleve = profilEleve, obsoletesInclus = true, ) - val voeuxParCommunesFavorites = - profilEleve.communesFavorites?.let { - recupererVoeuxDesCommunesFavoritesService.recupererVoeuxAutoursDeCommmunes(it, voeuxDeLaFormation) - } ?: emptyList() FicheFormation.FicheFormationPourProfil( id = formation.id, nom = formation.nom, @@ -69,15 +64,18 @@ class RecupererFormationService( metiers = exemplesDeMetiers, idsMetierTriesParAffinite = affinitesFormationEtMetier.metiersTriesParAffinites, ), - voeux = voeuxDeLaFormation, - voeuxParCommunesFavorites = voeuxParCommunesFavorites, + informationsSurLesVoeuxEtLeursCommunes = voeuxDeLaFormation, criteresAnalyseCandidature = criteresAnalyseCandidature, explications = explications, statistiquesDesAdmis = statistiquesDesAdmis, apprentissage = formation.apprentissage, ) } else { - val voeux = recupererVoeuxDUneFormationService.recupererVoeux(formation.id, obsoletesInclus = true) + val voeux = + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererVoeux( + formation.id, + obsoletesInclus = true, + ) FicheFormation.FicheFormationSansProfil( id = formation.id, nom = formation.nom, diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererFormationsService.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererFormationsService.kt index c19c54bc0..0a3d10823 100644 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererFormationsService.kt +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererFormationsService.kt @@ -2,8 +2,11 @@ package fr.gouv.monprojetsup.formation.usecase import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve import fr.gouv.monprojetsup.formation.domain.entity.FicheFormation +import fr.gouv.monprojetsup.formation.domain.entity.FicheFormation.FicheFormationPourProfil.InformationsSurLesVoeuxEtLeursCommunes +import fr.gouv.monprojetsup.formation.domain.entity.Formation import fr.gouv.monprojetsup.formation.domain.entity.SuggestionsPourUnProfil import fr.gouv.monprojetsup.formation.domain.port.FormationRepository +import fr.gouv.monprojetsup.logging.MonProjetSupLogger import fr.gouv.monprojetsup.metier.domain.port.MetierRepository import org.springframework.stereotype.Service @@ -11,13 +14,13 @@ import org.springframework.stereotype.Service class RecupererFormationsService( private val formationRepository: FormationRepository, private val metierRepository: MetierRepository, - private val recupererVoeuxDUneFormationService: RecupererVoeuxDUneFormationService, - private val recupererVoeuxDesCommunesFavoritesService: RecupererVoeuxDesCommunesFavoritesService, + private val recupererInformationsSurLesVoeuxEtLeursCommunesService: RecupererInformationsSurLesVoeuxEtLeursCommunesService, private val critereAnalyseCandidatureService: CritereAnalyseCandidatureService, private val recupererExplicationsEtExemplesMetiersPourFormationService: RecupererExplicationsEtExemplesMetiersPourFormationService, private val statistiquesDesAdmisPourFormationsService: StatistiquesDesAdmisPourFormationsService, private val metiersTriesParProfilBuilder: MetiersTriesParProfilBuilder, private val calculDuTauxDAffiniteBuilder: CalculDuTauxDAffiniteBuilder, + private val logger: MonProjetSupLogger, ) { fun recupererFichesFormationPourProfil( profilEleve: ProfilEleve.AvecProfilExistant, @@ -40,15 +43,12 @@ class RecupererFormationsService( idsDesFormationsRetournees, ) val voeux = - recupererVoeuxDUneFormationService.recupererVoeuxTriesParAffinites( + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererInformationsSurLesVoeuxEtLeursCommunes( idsDesFormationsRetournees, profilEleve, obsoletesInclus, ) - val voeuxAutoursDesCommunesFavorites = - profilEleve.communesFavorites?.let { - recupererVoeuxDesCommunesFavoritesService.recupererVoeuxAutoursDeCommmunes(it, voeux) - } ?: emptyMap() + return formations.map { formation -> val (explicationsDeLaFormation, exemplesDeMetiersDeLaFormation) = explications[formation.id] ?: Pair(null, emptyList()) FicheFormation.FicheFormationPourProfil( @@ -70,8 +70,7 @@ class RecupererFormationsService( metiers = exemplesDeMetiersDeLaFormation, idsMetierTriesParAffinite = suggestionsPourUnProfil.metiersTriesParAffinites, ), - voeux = voeux[formation.id] ?: emptyList(), - voeuxParCommunesFavorites = voeuxAutoursDesCommunesFavorites[formation.id] ?: emptyList(), + informationsSurLesVoeuxEtLeursCommunes = recupererInformationsSurLesVoeuxEtLeursCommunes(voeux, formation), criteresAnalyseCandidature = criteresAnalyseCandidature[formation.id] ?: emptyList(), explications = explicationsDeLaFormation, statistiquesDesAdmis = statistiquesDesAdmis[formation.id], @@ -80,6 +79,28 @@ class RecupererFormationsService( } } + private fun recupererInformationsSurLesVoeuxEtLeursCommunes( + voeux: Map, + formation: Formation, + ): InformationsSurLesVoeuxEtLeursCommunes { + val voeuxDeLaFormation = voeux[formation.id] + return if (voeuxDeLaFormation != null) { + return voeuxDeLaFormation + } else { + logger.error( + type = "FORMATION_SANS_VOEUX", + message = "La formation ${formation.id} n'est pas présente dans la map des formations", + exception = null, + parametres = mapOf("idFormation" to formation.id), + ) + InformationsSurLesVoeuxEtLeursCommunes( + voeux = emptyList(), + communesTriees = emptyList(), + voeuxParCommunesFavorites = emptyList(), + ) + } + } + fun recupererFichesFormation( idsFormations: List, obsoletesInclus: Boolean, @@ -94,7 +115,8 @@ class RecupererFormationsService( idsFormations = idsDesFormationsRetournees, classe = null, ) - val voeux = recupererVoeuxDUneFormationService.recupererVoeux(idsDesFormationsRetournees, obsoletesInclus) + val voeux = + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererVoeux(idsDesFormationsRetournees, obsoletesInclus) return formations.map { formation -> FicheFormation.FicheFormationSansProfil( id = formation.id, diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererInformationsSurLesVoeuxEtLeursCommunesService.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererInformationsSurLesVoeuxEtLeursCommunesService.kt new file mode 100644 index 000000000..1dce9654d --- /dev/null +++ b/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererInformationsSurLesVoeuxEtLeursCommunesService.kt @@ -0,0 +1,149 @@ +package fr.gouv.monprojetsup.formation.usecase + +import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve +import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecIdsVoeuxAuxAlentours +import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecVoeuxAuxAlentours +import fr.gouv.monprojetsup.formation.domain.entity.CommuneCourte +import fr.gouv.monprojetsup.formation.domain.entity.FicheFormation.FicheFormationPourProfil.InformationsSurLesVoeuxEtLeursCommunes +import fr.gouv.monprojetsup.formation.domain.entity.Voeu +import fr.gouv.monprojetsup.formation.domain.port.CommunesAvecVoeuxAuxAlentoursRepository +import fr.gouv.monprojetsup.formation.domain.port.VoeuRepository +import org.springframework.stereotype.Service + +@Service +class RecupererInformationsSurLesVoeuxEtLeursCommunesService( + private val voeuRepository: VoeuRepository, + private val communesAvecVoeuxAuxAlentoursRepository: CommunesAvecVoeuxAuxAlentoursRepository, +) { + fun recupererVoeux( + idFormation: String, + obsoletesInclus: Boolean, + ): List { + return voeuRepository.recupererLesVoeuxDUneFormation(idFormation, obsoletesInclus) + } + + fun recupererVoeux( + idsFormations: List, + obsoletesInclus: Boolean, + ): Map> { + return voeuRepository.recupererLesVoeuxDeFormations(idsFormations, obsoletesInclus) + } + + fun recupererInformationsSurLesVoeuxEtLeursCommunes( + idFormation: String, + profilEleve: ProfilEleve.AvecProfilExistant, + obsoletesInclus: Boolean, + ): InformationsSurLesVoeuxEtLeursCommunes { + val voeux = voeuRepository.recupererLesVoeuxDUneFormation(idFormation, obsoletesInclus) + if (!profilEleve.communesFavorites.isNullOrEmpty()) { + val voeuxAutoursDesCommunesFavorites = + communesAvecVoeuxAuxAlentoursRepository.recupererVoeuxAutoursDeCommmune( + profilEleve.communesFavorites, + ) + val idsVoeuxTriesParDistance = creerLesIdsDesVoeuxTriesParDistance(voeuxAutoursDesCommunesFavorites) + return informationsSurLesVoeuxEtLeursCommunesPourProfil(voeux, voeuxAutoursDesCommunesFavorites, idsVoeuxTriesParDistance) + } else { + return informationsSurLesVoeuxEtLeursCommunesSansProfil(voeux) + } + } + + fun recupererInformationsSurLesVoeuxEtLeursCommunes( + idsFormations: List, + profilEleve: ProfilEleve.AvecProfilExistant, + obsoletesInclus: Boolean, + ): Map { + val voeux = voeuRepository.recupererLesVoeuxDeFormations(idsFormations, obsoletesInclus) + if (!profilEleve.communesFavorites.isNullOrEmpty()) { + val voeuxAutoursDesCommunesFavorites = + communesAvecVoeuxAuxAlentoursRepository.recupererVoeuxAutoursDeCommmune( + profilEleve.communesFavorites, + ) + val idsVoeuxTriesParDistance = creerLesIdsDesVoeuxTriesParDistance(voeuxAutoursDesCommunesFavorites) + return voeux.map { + it.key to + informationsSurLesVoeuxEtLeursCommunesPourProfil( + it.value, + voeuxAutoursDesCommunesFavorites, + idsVoeuxTriesParDistance, + ) + }.toMap() + } else { + return voeux.map { + it.key to informationsSurLesVoeuxEtLeursCommunesSansProfil(it.value) + }.toMap() + } + } + + private fun creerLesIdsDesVoeuxTriesParDistance(voeuxAutoursDesCommunesFavorites: List) = + voeuxAutoursDesCommunesFavorites.flatMap { it.distances }.sortedBy { it.km }.map { it.idVoeu } + + private fun informationsSurLesVoeuxEtLeursCommunesSansProfil(voeux: List) = + InformationsSurLesVoeuxEtLeursCommunes( + voeux = voeux, + communesTriees = extraireCommunes(voeux), + voeuxParCommunesFavorites = emptyList(), + ) + + private fun informationsSurLesVoeuxEtLeursCommunesPourProfil( + voeux: List, + voeuxAutoursDesCommunesFavorites: List, + idsVoeuxTriesParDistance: List, + ): InformationsSurLesVoeuxEtLeursCommunes { + val voeuxTries = trierLesVoeux(voeux, idsVoeuxTriesParDistance) + return InformationsSurLesVoeuxEtLeursCommunes( + voeux = voeuxTries, + communesTriees = extraireCommunes(voeuxTries), + voeuxParCommunesFavorites = + creerVoeuxParCommunes( + voeuxAuxAlentoursDeCommunes = voeuxAutoursDesCommunesFavorites, + voeuxDeLaFormation = voeuxTries, + ), + ) + } + + private fun extraireCommunes(voeux: List): List { + return voeux.map { it.commune }.distinctBy { it.codeInsee } + } + + private fun trierLesVoeux( + voeux: List, + idsVoeuxTriesParDistance: List, + ): List { + return trierUneListeDObjetsParUneListeDIds(idsVoeuxTriesParDistance, voeux) { it.id } + } + + fun trierUneListeDObjetsParUneListeDIds( + idsTries: List, + objetsAtrier: List, + idSelector: (T) -> String, + ): List { + val indexMapDesIds = idsTries.withIndex().associate { it.value to it.index } + val indexMapDesObjets = objetsAtrier.withIndex().associate { idSelector(it.value) to it.index } + val nombreIds = idsTries.size + val comparateur = + compareBy( + { indexMapDesIds[idSelector(it)] ?: Int.MAX_VALUE }, + { (nombreIds + (indexMapDesObjets[idSelector(it)] ?: Int.MAX_VALUE)) }, + ) + return objetsAtrier.sortedWith(comparateur) + } + + private fun creerVoeuxParCommunes( + voeuxAuxAlentoursDeCommunes: List, + voeuxDeLaFormation: List, + ): List = + voeuxAuxAlentoursDeCommunes.map { voeuxAuxAlentoursDUneCommune -> + CommuneAvecVoeuxAuxAlentours( + communeFavorite = voeuxAuxAlentoursDUneCommune.communeFavorite, + distances = + voeuxAuxAlentoursDUneCommune.distances.mapNotNull { distance -> + voeuxDeLaFormation.firstOrNull { it.id == distance.idVoeu }?.let { voeu -> + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu, + distance.km, + ) + } + }.sortedBy { it.km }, + ) + } +} diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererVoeuxDUneFormationService.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererVoeuxDUneFormationService.kt deleted file mode 100644 index 3c9036065..000000000 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererVoeuxDUneFormationService.kt +++ /dev/null @@ -1,150 +0,0 @@ -package fr.gouv.monprojetsup.formation.usecase - -import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve -import fr.gouv.monprojetsup.eleve.domain.entity.Commune -import fr.gouv.monprojetsup.formation.domain.entity.Voeu -import fr.gouv.monprojetsup.formation.domain.port.VoeuRepository -import fr.gouv.monprojetsup.logging.MonProjetSupLogger -import fr.gouv.monprojetsup.logging.domain.WarningALogguer -import org.springframework.stereotype.Service - -@Service -class RecupererVoeuxDUneFormationService( - private val voeuRepository: VoeuRepository, - private val logger: MonProjetSupLogger, -) { - fun recupererVoeuxTriesParAffinites( - idsFormations: List, - profilEleve: ProfilEleve.AvecProfilExistant, - obsoletesInclus: Boolean, - ): Map> { - val voeux = voeuRepository.recupererLesVoeuxDeFormations(idsFormations, obsoletesInclus) - val messagesDeWarning = mutableListOf() - val voeuxTriesParAffinitesParFormation = - voeux.entries.associate { entry -> - entry.key to - triesParAffinitesVoeux( - voeux = entry.value, - profilEleve = profilEleve, - messagesDeWarning = messagesDeWarning, - ) - } - messagesDeWarning.distinct().forEach { - logger.warn(type = it.type, message = it.messageException, parametres = it.parametres) - } - return voeuxTriesParAffinitesParFormation - } - - fun recupererVoeuxTriesParAffinites( - idFormation: String, - profilEleve: ProfilEleve.AvecProfilExistant, - obsoletesInclus: Boolean, - ): List { - val voeux = voeuRepository.recupererLesVoeuxDUneFormation(idFormation) - val messagesDeWarning = mutableListOf() - val voeuxTriesParAffinites = - triesParAffinitesVoeux(voeux, profilEleve, messagesDeWarning) - messagesDeWarning.forEach { - logger.warn(type = it.type, message = it.messageException, parametres = it.parametres) - } - return voeuxTriesParAffinites - } - - fun recupererVoeux( - idFormation: String, - obsoletesInclus: Boolean, - ): List { - return voeuRepository.recupererLesVoeuxDUneFormation(idFormation) - } - - fun recupererVoeux( - idsFormations: List, - obsoletesInclus: Boolean, - ): Map> { - return voeuRepository.recupererLesVoeuxDeFormations(idsFormations, obsoletesInclus) - } - - private fun triesParAffinitesVoeux( - voeux: List, - profilEleve: ProfilEleve.AvecProfilExistant, - messagesDeWarning: MutableList, - ): List { - return profilEleve.communesFavorites?.takeUnless { it.isEmpty() }?.let { communesFavorites -> - val voeuxDansUneVilleFavorite = mutableListOf() - val voeuxDansUnDepartementFavoris = mutableListOf() - val autresVoeux = mutableListOf() - voeux.forEach { voeu -> - if (estUneCommuneFavorite(communesFavorites, voeu)) { - voeuxDansUneVilleFavorite.add(voeu) - } else if (estDansUnDepartementFavoris(profilEleve.id, communesFavorites, voeu, messagesDeWarning)) { - voeuxDansUnDepartementFavoris.add(voeu) - } else { - autresVoeux.add(voeu) - } - } - voeuxDansUneVilleFavorite + voeuxDansUnDepartementFavoris + autresVoeux - } ?: voeux - } - - private fun estDansUnDepartementFavoris( - idEleve: String, - communes: List, - voeu: Voeu, - messagesDeWarning: MutableList, - ): Boolean { - val departementDuVoeu = - recupererDepartement( - commune = voeu.commune, - messagesDeWarning = messagesDeWarning, - warning = - WarningALogguer( - messageException = - "La commune du voeu ${voeu.id} a un code commune " + - "non standard : ${voeu.commune.codeInsee}", - parametres = mapOf("idVoeu" to voeu.id, "codeInsee" to voeu.commune.codeInsee), - type = "CODE_INSEE_NON_RECONNU_SUR_VOEU", - ), - ) - return communes.any { commune: Commune -> - val departementDeLaCommune = - recupererDepartement( - commune = commune, - messagesDeWarning = messagesDeWarning, - warning = - WarningALogguer( - messageException = - "La commune ${commune.nom} présente dans le profil de l'élève $idEleve a un code commune " + - "non standard : ${commune.codeInsee}", - parametres = mapOf("nomCommune" to commune.nom, "codeInsee" to commune.codeInsee), - type = "CODE_INSEE_NON_RECONNU_DANS_PROFIL", - ), - ) - departementDuVoeu == departementDeLaCommune - } - } - - private fun recupererDepartement( - commune: Commune, - warning: WarningALogguer, - messagesDeWarning: MutableList, - ) = try { - val codeCommune = commune.codeInsee.substring(0, 2) - when { - codeCommune == "2A" || codeCommune == "2B" -> 20 - codeCommune.toInt() <= 96 -> commune.codeInsee.substring(0, 2).toInt() - codeCommune.toInt() > 96 -> commune.codeInsee.substring(0, 3).toInt() - else -> { - messagesDeWarning.add(warning) - 0 - } - } - } catch (e: Exception) { - messagesDeWarning.add(warning) - 0 - } - - private fun estUneCommuneFavorite( - communes: List, - voeu: Voeu, - ) = communes.any { voeu.commune.codeInsee == it.codeInsee } -} diff --git a/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererVoeuxDesCommunesFavoritesService.kt b/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererVoeuxDesCommunesFavoritesService.kt deleted file mode 100644 index ab75f2859..000000000 --- a/app/back/src/main/fr/gouv/monprojetsup/formation/usecase/RecupererVoeuxDesCommunesFavoritesService.kt +++ /dev/null @@ -1,49 +0,0 @@ -package fr.gouv.monprojetsup.formation.usecase - -import fr.gouv.monprojetsup.eleve.domain.entity.Commune -import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecIdsVoeuxAuxAlentours -import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecVoeuxAuxAlentours -import fr.gouv.monprojetsup.formation.domain.entity.Voeu -import fr.gouv.monprojetsup.formation.domain.port.CommunesAvecVoeuxAuxAlentoursRepository -import org.springframework.stereotype.Service - -@Service -class RecupererVoeuxDesCommunesFavoritesService( - private val voeuxParVilleRepository: CommunesAvecVoeuxAuxAlentoursRepository, -) { - fun recupererVoeuxAutoursDeCommmunes( - communes: List, - voeuxDeLaFormation: List, - ): List { - val voeuxAuxAlentoursDeCommunes = voeuxParVilleRepository.recupererVoeuxAutoursDeCommmune(communes) - return creerVoeuxAutoursCommunes(voeuxAuxAlentoursDeCommunes, voeuxDeLaFormation) - } - - fun recupererVoeuxAutoursDeCommmunes( - communes: List, - voeuxDeLaFormation: Map>, - ): Map> { - val voeuxAuxAlentoursDeCommunes = voeuxParVilleRepository.recupererVoeuxAutoursDeCommmune(communes) - return voeuxDeLaFormation.map { - it.key to creerVoeuxAutoursCommunes(voeuxAuxAlentoursDeCommunes, it.value) - }.toMap() - } - - private fun creerVoeuxAutoursCommunes( - voeuxAuxAlentoursDeCommunes: List, - voeuxDeLaFormation: List, - ) = voeuxAuxAlentoursDeCommunes.map { voeuxAuxAlentoursDUneCommune -> - CommuneAvecVoeuxAuxAlentours( - commune = voeuxAuxAlentoursDUneCommune.commune, - distances = - voeuxAuxAlentoursDUneCommune.distances.mapNotNull { distance -> - voeuxDeLaFormation.firstOrNull { it.id == distance.idVoeu }?.let { voeu -> - CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( - voeu, - distance.km, - ) - } - }, - ) - } -} diff --git a/app/back/src/test/fr/gouv/monprojetsup/authentification/usecase/RecupererEleveServiceTest.kt b/app/back/src/test/fr/gouv/monprojetsup/authentification/usecase/RecupererEleveServiceTest.kt index 3311db099..f48d3879d 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/authentification/usecase/RecupererEleveServiceTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/authentification/usecase/RecupererEleveServiceTest.kt @@ -3,9 +3,9 @@ package fr.gouv.monprojetsup.authentification.usecase import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation import fr.gouv.monprojetsup.eleve.domain.port.EleveRepository +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites import fr.gouv.monprojetsup.formation.domain.port.FormationRepository import fr.gouv.monprojetsup.formation.domain.port.VoeuRepository -import fr.gouv.monprojetsup.formation.entity.Communes import fr.gouv.monprojetsup.metier.domain.port.MetierRepository import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixAlternance import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixDureeEtudesPrevue @@ -76,7 +76,7 @@ class RecupererEleveServiceTest { metiersFavoris = listOf("MET.116", "MET.188"), dureeEtudesPrevue = ChoixDureeEtudesPrevue.COURTE, alternance = ChoixAlternance.INDIFFERENT, - communesFavorites = listOf(Communes.PARIS15EME, Communes.MARSEILLE), + communesFavorites = listOf(CommunesFavorites.PARIS15EME, CommunesFavorites.MARSEILLE), formationsFavorites = listOf( VoeuFormation( diff --git a/app/back/src/test/fr/gouv/monprojetsup/commun/application/controller/ControllerTest.kt b/app/back/src/test/fr/gouv/monprojetsup/commun/application/controller/ControllerTest.kt index 8214763b3..e65ba3ef4 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/commun/application/controller/ControllerTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/commun/application/controller/ControllerTest.kt @@ -5,7 +5,7 @@ import fr.gouv.monprojetsup.authentification.usecase.RecupererEleveService import fr.gouv.monprojetsup.commun.MonProjetSupTestConfiguration import fr.gouv.monprojetsup.configuration.SecuriteConfiguration import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation -import fr.gouv.monprojetsup.formation.entity.Communes +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites import fr.gouv.monprojetsup.logging.MonProjetSupLogger import fr.gouv.monprojetsup.parametre.domain.entity.Parametre import fr.gouv.monprojetsup.parametre.domain.port.ParametreRepository @@ -50,7 +50,7 @@ abstract class ControllerTest { baccalaureat = "Générale", dureeEtudesPrevue = ChoixDureeEtudesPrevue.INDIFFERENT, alternance = ChoixAlternance.PAS_INTERESSE, - communesFavorites = listOf(Communes.PARIS15EME), + communesFavorites = listOf(CommunesFavorites.PARIS15EME), specialites = listOf("1056", "1054"), centresInterets = listOf("T_ROME_2092381917", "T_IDEO2_4812"), moyenneGenerale = 14f, diff --git a/app/back/src/test/fr/gouv/monprojetsup/eleve/application/controller/ProfilEleveControllerTest.kt b/app/back/src/test/fr/gouv/monprojetsup/eleve/application/controller/ProfilEleveControllerTest.kt index 5acc3f7cb..0e0980957 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/eleve/application/controller/ProfilEleveControllerTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/eleve/application/controller/ProfilEleveControllerTest.kt @@ -10,10 +10,10 @@ import fr.gouv.monprojetsup.commun.erreur.domain.MonProjetSupNotFoundException import fr.gouv.monprojetsup.eleve.domain.entity.ModificationProfilEleve import fr.gouv.monprojetsup.eleve.domain.entity.ParametresPourRecupererToken import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites import fr.gouv.monprojetsup.eleve.usecase.MiseAJourEleveService import fr.gouv.monprojetsup.eleve.usecase.MiseAJourFavorisParcoursupService import fr.gouv.monprojetsup.eleve.usecase.MiseAJourIdParcoursupService -import fr.gouv.monprojetsup.formation.entity.Communes import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixAlternance import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixDureeEtudesPrevue import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixNiveau @@ -55,7 +55,7 @@ class ProfilEleveControllerTest( baccalaureat = "Générale", dureeEtudesPrevue = ChoixDureeEtudesPrevue.LONGUE, alternance = ChoixAlternance.INTERESSE, - communesFavorites = listOf(Communes.PARIS15EME), + communesFavorites = listOf(CommunesFavorites.PARIS15EME), specialites = listOf("1054"), centresInterets = listOf("T_IDEO2_4812"), moyenneGenerale = 14f, @@ -206,7 +206,7 @@ class ProfilEleveControllerTest( baccalaureat = "NC", dureeEtudesPrevue = ChoixDureeEtudesPrevue.INDIFFERENT, alternance = ChoixAlternance.PAS_INTERESSE, - communesFavorites = listOf(Communes.PARIS15EME, Communes.MARSEILLE), + communesFavorites = listOf(CommunesFavorites.PARIS15EME, CommunesFavorites.MARSEILLE), specialites = listOf("mat1001", "mat1049"), centresInterets = null, moyenneGenerale = 4.9f, @@ -526,7 +526,7 @@ class ProfilEleveControllerTest( baccalaureat = "NC", dureeEtudesPrevue = ChoixDureeEtudesPrevue.INDIFFERENT, alternance = ChoixAlternance.PAS_INTERESSE, - communesFavorites = listOf(Communes.PARIS15EME, Communes.MARSEILLE), + communesFavorites = listOf(CommunesFavorites.PARIS15EME, CommunesFavorites.MARSEILLE), specialites = listOf("mat1001", "mat1049"), centresInterets = null, moyenneGenerale = 4.9f, diff --git a/app/back/src/test/fr/gouv/monprojetsup/formation/entity/Communes.kt b/app/back/src/test/fr/gouv/monprojetsup/eleve/entity/CommunesFavorites.kt similarity index 82% rename from app/back/src/test/fr/gouv/monprojetsup/formation/entity/Communes.kt rename to app/back/src/test/fr/gouv/monprojetsup/eleve/entity/CommunesFavorites.kt index b000862e4..8ebae0a38 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/formation/entity/Communes.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/eleve/entity/CommunesFavorites.kt @@ -1,10 +1,10 @@ -package fr.gouv.monprojetsup.formation.entity +package fr.gouv.monprojetsup.eleve.entity -import fr.gouv.monprojetsup.eleve.domain.entity.Commune +import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite -object Communes { +object CommunesFavorites { val GRENOBLE = - Commune( + CommuneFavorite( codeInsee = "38185", nom = "Grenoble", longitude = 5.71667, @@ -12,7 +12,7 @@ object Communes { ) val STRASBOURG = - Commune( + CommuneFavorite( codeInsee = "67482", nom = "Strasbourg", longitude = 1.666667, @@ -20,7 +20,7 @@ object Communes { ) val PARIS15EME = - Commune( + CommuneFavorite( codeInsee = "75115", nom = "Paris", longitude = 2.2885659, @@ -28,7 +28,7 @@ object Communes { ) val PARIS19EME = - Commune( + CommuneFavorite( codeInsee = "75119", nom = "Paris", longitude = 2.393, @@ -36,7 +36,7 @@ object Communes { ) val PARIS5EME = - Commune( + CommuneFavorite( codeInsee = "75105", nom = "Paris", longitude = 2.344, @@ -44,7 +44,7 @@ object Communes { ) val MARSEILLE = - Commune( + CommuneFavorite( codeInsee = "13055", nom = "Marseille", latitude = 43.300000, @@ -52,7 +52,7 @@ object Communes { ) val LYON = - Commune( + CommuneFavorite( codeInsee = "69123", nom = "Lyon", latitude = 45.75, @@ -60,7 +60,7 @@ object Communes { ) val CAEN = - Commune( + CommuneFavorite( codeInsee = "14118", nom = "Caen", latitude = 49.183334, @@ -68,7 +68,7 @@ object Communes { ) val MONTREUIL = - Commune( + CommuneFavorite( codeInsee = "93048", nom = "Montreuil", latitude = 48.861, @@ -76,7 +76,7 @@ object Communes { ) val NANCY = - Commune( + CommuneFavorite( codeInsee = "54395", nom = "Nancy", latitude = 48.692, @@ -84,7 +84,7 @@ object Communes { ) val RENNES = - Commune( + CommuneFavorite( codeInsee = "35238", nom = "Rennes", latitude = 48.117, @@ -92,7 +92,7 @@ object Communes { ) val SAINT_MALO = - Commune( + CommuneFavorite( codeInsee = "35288", nom = "Saint-Malo", latitude = 48.6571, @@ -100,7 +100,7 @@ object Communes { ) val AJACCIO = - Commune( + CommuneFavorite( codeInsee = "2A004", nom = "Ajaccio", latitude = 41.9267, @@ -108,7 +108,7 @@ object Communes { ) val BASTIA = - Commune( + CommuneFavorite( codeInsee = "2B033", nom = "Bastia", latitude = 42.6985, @@ -116,7 +116,7 @@ object Communes { ) val SAINT_PIERRE = - Commune( + CommuneFavorite( codeInsee = "97416", nom = "Saint-Pierre", latitude = -21.29634, @@ -124,7 +124,7 @@ object Communes { ) val FORT_DE_FRANCE = - Commune( + CommuneFavorite( codeInsee = "97209", nom = "Fort-de-France", latitude = 14.61852, diff --git a/app/back/src/test/fr/gouv/monprojetsup/eleve/infrastructure/repository/EleveBDDRepositoryTest.kt b/app/back/src/test/fr/gouv/monprojetsup/eleve/infrastructure/repository/EleveBDDRepositoryTest.kt index 4e9f58ede..aa6432b9b 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/eleve/infrastructure/repository/EleveBDDRepositoryTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/eleve/infrastructure/repository/EleveBDDRepositoryTest.kt @@ -4,7 +4,7 @@ import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve import fr.gouv.monprojetsup.commun.erreur.domain.MonProjetSupNotFoundException import fr.gouv.monprojetsup.commun.infrastructure.repository.BDDRepositoryTest import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation -import fr.gouv.monprojetsup.formation.entity.Communes +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites import fr.gouv.monprojetsup.logging.MonProjetSupLogger import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixAlternance import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixDureeEtudesPrevue @@ -50,7 +50,7 @@ class EleveBDDRepositoryTest : BDDRepositoryTest() { metiersFavoris = listOf("MET001"), dureeEtudesPrevue = ChoixDureeEtudesPrevue.COURTE, alternance = ChoixAlternance.INDIFFERENT, - communesFavorites = listOf(Communes.PARIS15EME, Communes.MARSEILLE), + communesFavorites = listOf(CommunesFavorites.PARIS15EME, CommunesFavorites.MARSEILLE), formationsFavorites = listOf( VoeuFormation( @@ -83,7 +83,7 @@ class EleveBDDRepositoryTest : BDDRepositoryTest() { metiersFavoris = listOf("MET002"), dureeEtudesPrevue = ChoixDureeEtudesPrevue.LONGUE, alternance = ChoixAlternance.TRES_INTERESSE, - communesFavorites = listOf(Communes.PARIS15EME, Communes.MARSEILLE), + communesFavorites = listOf(CommunesFavorites.PARIS15EME, CommunesFavorites.MARSEILLE), formationsFavorites = listOf( VoeuFormation( @@ -214,7 +214,7 @@ class EleveBDDRepositoryTest : BDDRepositoryTest() { metiersFavoris = listOf("MET001"), dureeEtudesPrevue = ChoixDureeEtudesPrevue.COURTE, alternance = ChoixAlternance.INDIFFERENT, - communesFavorites = listOf(Communes.PARIS15EME, Communes.MARSEILLE), + communesFavorites = listOf(CommunesFavorites.PARIS15EME, CommunesFavorites.MARSEILLE), formationsFavorites = listOf( VoeuFormation( diff --git a/app/back/src/test/fr/gouv/monprojetsup/eleve/usecase/MiseAJourEleveServiceTest.kt b/app/back/src/test/fr/gouv/monprojetsup/eleve/usecase/MiseAJourEleveServiceTest.kt index fcca96918..dc2a48c63 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/eleve/usecase/MiseAJourEleveServiceTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/eleve/usecase/MiseAJourEleveServiceTest.kt @@ -5,10 +5,11 @@ import fr.gouv.monprojetsup.commun.erreur.domain.MonProjetSupBadRequestException import fr.gouv.monprojetsup.eleve.domain.entity.ModificationProfilEleve import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation import fr.gouv.monprojetsup.eleve.domain.port.EleveRepository +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites import fr.gouv.monprojetsup.formation.domain.entity.Voeu import fr.gouv.monprojetsup.formation.domain.port.FormationRepository import fr.gouv.monprojetsup.formation.domain.port.VoeuRepository -import fr.gouv.monprojetsup.formation.entity.Communes +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes import fr.gouv.monprojetsup.metier.domain.port.MetierRepository import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixAlternance import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixDureeEtudesPrevue @@ -74,7 +75,7 @@ class MiseAJourEleveServiceTest { metiersFavoris = listOf("MET001"), dureeEtudesPrevue = ChoixDureeEtudesPrevue.COURTE, alternance = ChoixAlternance.INDIFFERENT, - communesFavorites = listOf(Communes.PARIS15EME, Communes.MARSEILLE), + communesFavorites = listOf(CommunesFavorites.PARIS15EME, CommunesFavorites.MARSEILLE), formationsFavorites = listOf( VoeuFormation( @@ -654,12 +655,16 @@ class MiseAJourEleveServiceTest { Voeu( id = "ta1", nom = "Nom ta1", - commune = Communes.CAEN, + commune = CommunesCourtes.CAEN, + latitude = 49.183334, + longitude = -0.350000, ), Voeu( id = "ta129", nom = "Nom ta129", - commune = Communes.GRENOBLE, + commune = CommunesCourtes.GRENOBLE, + longitude = 5.71667, + latitude = 45.16667, ), ), "fl3" to emptyList(), @@ -708,12 +713,16 @@ class MiseAJourEleveServiceTest { Voeu( id = "ta1", nom = "Nom ta1", - commune = Communes.CAEN, + commune = CommunesCourtes.CAEN, + latitude = 49.183334, + longitude = -0.350000, ), Voeu( id = "ta2", nom = "Nom ta2", - commune = Communes.PARIS15EME, + commune = CommunesCourtes.PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, ), ), "fl3" to @@ -721,12 +730,16 @@ class MiseAJourEleveServiceTest { Voeu( id = "ta1", nom = "Nom ta1", - commune = Communes.CAEN, + commune = CommunesCourtes.CAEN, + latitude = 49.183334, + longitude = -0.350000, ), Voeu( id = "ta129", nom = "Nom ta129", - commune = Communes.GRENOBLE, + commune = CommunesCourtes.GRENOBLE, + longitude = 5.71667, + latitude = 45.16667, ), ), ) @@ -853,7 +866,7 @@ class MiseAJourEleveServiceTest { metiersFavoris = listOf("MET004"), dureeEtudesPrevue = ChoixDureeEtudesPrevue.LONGUE, alternance = ChoixAlternance.PAS_INTERESSE, - communesFavorites = listOf(Communes.PARIS15EME), + communesFavorites = listOf(CommunesFavorites.PARIS15EME), formationsFavorites = listOf( VoeuFormation( @@ -885,17 +898,23 @@ class MiseAJourEleveServiceTest { Voeu( id = "ta12", nom = "Nom ta12", - commune = Communes.MARSEILLE, + commune = CommunesCourtes.MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, ), Voeu( id = "ta13", nom = "Nom ta13", - commune = Communes.PARIS15EME, + commune = CommunesCourtes.PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, ), Voeu( id = "ta20", nom = "Nom ta20", - commune = Communes.CAEN, + commune = CommunesCourtes.CAEN, + latitude = 49.183334, + longitude = -0.350000, ), ), ), @@ -919,7 +938,7 @@ class MiseAJourEleveServiceTest { metiersFavoris = listOf("MET004"), dureeEtudesPrevue = ChoixDureeEtudesPrevue.LONGUE, alternance = ChoixAlternance.PAS_INTERESSE, - communesFavorites = listOf(Communes.PARIS15EME), + communesFavorites = listOf(CommunesFavorites.PARIS15EME), formationsFavorites = listOf( VoeuFormation( @@ -964,7 +983,7 @@ class MiseAJourEleveServiceTest { metiersFavoris = listOf("MET001"), dureeEtudesPrevue = ChoixDureeEtudesPrevue.COURTE, alternance = ChoixAlternance.INDIFFERENT, - communesFavorites = listOf(Communes.PARIS15EME, Communes.MARSEILLE), + communesFavorites = listOf(CommunesFavorites.PARIS15EME, CommunesFavorites.MARSEILLE), formationsFavorites = listOf( VoeuFormation( diff --git a/app/back/src/test/fr/gouv/monprojetsup/eleve/usecase/MiseAJourFavorisParcoursupServiceTest.kt b/app/back/src/test/fr/gouv/monprojetsup/eleve/usecase/MiseAJourFavorisParcoursupServiceTest.kt index 6fe958adb..d17191ec6 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/eleve/usecase/MiseAJourFavorisParcoursupServiceTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/eleve/usecase/MiseAJourFavorisParcoursupServiceTest.kt @@ -4,9 +4,10 @@ import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve import fr.gouv.monprojetsup.commun.erreur.domain.MonProjetSupInternalErrorException import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation import fr.gouv.monprojetsup.eleve.domain.port.CompteParcoursupRepository +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites import fr.gouv.monprojetsup.formation.domain.entity.Voeu import fr.gouv.monprojetsup.formation.domain.port.VoeuRepository -import fr.gouv.monprojetsup.formation.entity.Communes +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes import fr.gouv.monprojetsup.logging.MonProjetSupLogger import fr.gouv.monprojetsup.parcoursup.domain.entity.FavorisParcoursup import fr.gouv.monprojetsup.parcoursup.infrastructure.client.ParcoursupFavorisApiFavorisClient @@ -177,7 +178,9 @@ class MiseAJourFavorisParcoursupServiceTest { Voeu( id = "ta2", nom = "Mon voeu 2", - commune = Communes.PARIS15EME, + commune = CommunesCourtes.PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, ), ), ), @@ -227,12 +230,16 @@ class MiseAJourFavorisParcoursupServiceTest { Voeu( id = "ta1", nom = "Mon voeu 1", - commune = Communes.MARSEILLE, + commune = CommunesCourtes.MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, ), Voeu( id = "ta18", nom = "Mon voeu 18", - commune = Communes.SAINT_MALO, + commune = CommunesCourtes.SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, ), ), "fl0010" to @@ -240,7 +247,9 @@ class MiseAJourFavorisParcoursupServiceTest { Voeu( id = "ta7", nom = "Mon voeu 7", - commune = Communes.PARIS15EME, + commune = CommunesCourtes.PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, ), ), "fl0753" to @@ -248,7 +257,9 @@ class MiseAJourFavorisParcoursupServiceTest { Voeu( id = "ta19", nom = "Mon voeu 19", - commune = Communes.PARIS5EME, + commune = CommunesCourtes.PARIS5EME, + longitude = 2.344, + latitude = 48.846, ), ), ), @@ -297,7 +308,7 @@ class MiseAJourFavorisParcoursupServiceTest { metiersFavoris = listOf("MET001"), dureeEtudesPrevue = ChoixDureeEtudesPrevue.COURTE, alternance = ChoixAlternance.INDIFFERENT, - communesFavorites = listOf(Communes.PARIS15EME, Communes.MARSEILLE), + communesFavorites = listOf(CommunesFavorites.PARIS15EME, CommunesFavorites.MARSEILLE), formationsFavorites = formationsFavorites, moyenneGenerale = -1.0f, corbeilleFormations = listOf("fl1234", "fl5678"), diff --git a/app/back/src/test/fr/gouv/monprojetsup/formation/application/controller/FormationControllerTest.kt b/app/back/src/test/fr/gouv/monprojetsup/formation/application/controller/FormationControllerTest.kt index 2e42840d4..4ced9a3f5 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/formation/application/controller/FormationControllerTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/formation/application/controller/FormationControllerTest.kt @@ -11,6 +11,7 @@ import fr.gouv.monprojetsup.commun.erreur.domain.MonProjetSupNotFoundException import fr.gouv.monprojetsup.commun.hateoas.domain.entity.Hateoas import fr.gouv.monprojetsup.commun.hateoas.usecase.HateoasBuilder import fr.gouv.monprojetsup.commun.lien.domain.entity.Lien +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecVoeuxAuxAlentours import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance import fr.gouv.monprojetsup.formation.domain.entity.CritereAnalyseCandidature @@ -20,6 +21,7 @@ import fr.gouv.monprojetsup.formation.domain.entity.ExplicationsSuggestionDetail import fr.gouv.monprojetsup.formation.domain.entity.FicheFormation import fr.gouv.monprojetsup.formation.domain.entity.FicheFormation.FicheFormationPourProfil.ExplicationAutoEvaluationMoyenne import fr.gouv.monprojetsup.formation.domain.entity.FicheFormation.FicheFormationPourProfil.ExplicationTypeBaccalaureat +import fr.gouv.monprojetsup.formation.domain.entity.FicheFormation.FicheFormationPourProfil.InformationsSurLesVoeuxEtLeursCommunes import fr.gouv.monprojetsup.formation.domain.entity.FormationCourte import fr.gouv.monprojetsup.formation.domain.entity.StatistiquesDesAdmis import fr.gouv.monprojetsup.formation.domain.entity.StatistiquesDesAdmis.MoyenneGeneraleDesAdmis @@ -29,11 +31,12 @@ import fr.gouv.monprojetsup.formation.domain.entity.StatistiquesDesAdmis.Reparti import fr.gouv.monprojetsup.formation.domain.entity.SuggestionsPourUnProfil import fr.gouv.monprojetsup.formation.domain.entity.SuggestionsPourUnProfil.FormationAvecSonAffinite import fr.gouv.monprojetsup.formation.domain.entity.Voeu -import fr.gouv.monprojetsup.formation.entity.Communes.LYON -import fr.gouv.monprojetsup.formation.entity.Communes.MARSEILLE -import fr.gouv.monprojetsup.formation.entity.Communes.PARIS15EME -import fr.gouv.monprojetsup.formation.entity.Communes.PARIS5EME -import fr.gouv.monprojetsup.formation.entity.Communes.STRASBOURG +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.LYON +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.MARSEILLE +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.MONTREUIL +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.PARIS15EME +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.PARIS5EME +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.STRASBOURG import fr.gouv.monprojetsup.formation.usecase.OrdonnerRechercheFormationsBuilder import fr.gouv.monprojetsup.formation.usecase.RechercherFormationsService import fr.gouv.monprojetsup.formation.usecase.RecupererFormationService @@ -175,31 +178,83 @@ class FormationControllerTest( "cycle-pluridisciplinaire-d-etudes-superieures", ), ), - voeux = - listOf( - Voeu(id = "ta10", nom = "Nom du ta10", commune = LYON), - Voeu(id = "ta3", nom = "Nom du ta3", commune = PARIS5EME), - Voeu(id = "ta11", nom = "Nom du ta11", commune = LYON), - Voeu(id = "ta32", nom = "Nom du ta32", commune = PARIS15EME), - Voeu(id = "ta17", nom = "Nom du ta17", commune = STRASBOURG), - Voeu(id = "ta7", nom = "Nom du ta7", commune = MARSEILLE), - ), - voeuxParCommunesFavorites = - listOf( - CommuneAvecVoeuxAuxAlentours( - commune = PARIS15EME, - distances = - listOf( - VoeuAvecDistance( - Voeu(id = "ta3", nom = "Nom du ta3", commune = PARIS5EME), - km = 3, - ), - VoeuAvecDistance( - Voeu(id = "ta32", nom = "Nom du ta32", commune = PARIS15EME), - km = 1, - ), + informationsSurLesVoeuxEtLeursCommunes = + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, ), - ), + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta32", + nom = "Nom du ta32", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = STRASBOURG, + longitude = 1.666667, + latitude = 50.266666, + ), + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), + ), + communesTriees = listOf(PARIS15EME, PARIS5EME, MONTREUIL, LYON, STRASBOURG, MARSEILLE), + voeuxParCommunesFavorites = + listOf( + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.PARIS15EME, + distances = + listOf( + VoeuAvecDistance( + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + km = 3, + ), + VoeuAvecDistance( + Voeu( + id = "ta32", + nom = "Nom du ta32", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + km = 1, + ), + ), + ), + ), ), metiersTriesParAffinites = listOf( @@ -329,12 +384,48 @@ class FormationControllerTest( ), voeux = listOf( - Voeu(id = "ta10", nom = "Nom du ta10", commune = LYON), - Voeu(id = "ta3", nom = "Nom du ta3", commune = PARIS5EME), - Voeu(id = "ta11", nom = "Nom du ta11", commune = LYON), - Voeu(id = "ta32", nom = "Nom du ta32", commune = PARIS15EME), - Voeu(id = "ta17", nom = "Nom du ta17", commune = STRASBOURG), - Voeu(id = "ta7", nom = "Nom du ta7", commune = MARSEILLE), + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta32", + nom = "Nom du ta32", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = STRASBOURG, + longitude = 1.666667, + latitude = 50.266666, + ), + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), ), criteresAnalyseCandidature = listOf( @@ -467,7 +558,12 @@ class FormationControllerTest( statistiquesDesAdmis = null, tauxAffinite = 17, metiersTriesParAffinites = emptyList(), - voeux = emptyList(), + informationsSurLesVoeuxEtLeursCommunes = + InformationsSurLesVoeuxEtLeursCommunes( + voeux = emptyList(), + communesTriees = emptyList(), + voeuxParCommunesFavorites = emptyList(), + ), apprentissage = false, explications = null, ), @@ -572,6 +668,32 @@ class FormationControllerTest( "url": "https://www.onisep.fr/ressources/univers-formation/formations/post-bac/cycle-pluridisciplinaire-d-etudes-superieures" } ], + "communes": [ + { + "nom": "Paris", + "codeInsee": "75115" + }, + { + "nom": "Paris", + "codeInsee": "75105" + }, + { + "nom": "Montreuil", + "codeInsee": "93048" + }, + { + "nom": "Lyon", + "codeInsee": "69123" + }, + { + "nom": "Strasbourg", + "codeInsee": "67482" + }, + { + "nom": "Marseille", + "codeInsee": "13055" + } + ], "voeux": [ { "id": "ta10", @@ -712,6 +834,7 @@ class FormationControllerTest( { "id": "T_ITM_1356", "nom": "soin aux animaux", + "description": null, "emoji": "\uD83D\uDC2E" } ], @@ -776,41 +899,9 @@ class FormationControllerTest( "criteresAnalyseCandidature": [], "repartitionAdmisAnneePrecedente": null, "liens": [], + "communes": [], "voeux": [], - "communesFavoritesAvecLeursVoeux": [ - { - "commune": { - "codeInsee": "75115", - "nom": "Paris", - "latitude": 48.851227, - "longitude": 2.2885659 - }, - "voeuxAvecDistance": [ - { - "voeu": { - "id": "ta3", - "nom": "Nom du ta3", - "commune": { - "nom": "Paris", - "codeInsee": "75105" - } - }, - "distanceKm": 3 - }, - { - "voeu": { - "id": "ta32", - "nom": "Nom du ta32", - "commune": { - "nom": "Paris", - "codeInsee": "75115" - } - }, - "distanceKm": 1 - } - ] - } - ], + "communesFavoritesAvecLeursVoeux": [], "metiers": [], "tauxAffinite": 17, "apprentissage": false @@ -1243,7 +1334,12 @@ class FormationControllerTest( statistiquesDesAdmis = null, tauxAffinite = 17, metiersTriesParAffinites = emptyList(), - voeux = emptyList(), + informationsSurLesVoeuxEtLeursCommunes = + InformationsSurLesVoeuxEtLeursCommunes( + voeux = emptyList(), + communesTriees = emptyList(), + voeuxParCommunesFavorites = emptyList(), + ), apprentissage = false, explications = null, ), @@ -1348,6 +1444,32 @@ class FormationControllerTest( "url": "https://www.onisep.fr/ressources/univers-formation/formations/post-bac/cycle-pluridisciplinaire-d-etudes-superieures" } ], + "communes": [ + { + "nom": "Paris", + "codeInsee": "75115" + }, + { + "nom": "Paris", + "codeInsee": "75105" + }, + { + "nom": "Montreuil", + "codeInsee": "93048" + }, + { + "nom": "Lyon", + "codeInsee": "69123" + }, + { + "nom": "Strasbourg", + "codeInsee": "67482" + }, + { + "nom": "Marseille", + "codeInsee": "13055" + } + ], "voeux": [ { "id": "ta10", @@ -1488,6 +1610,7 @@ class FormationControllerTest( { "id": "T_ITM_1356", "nom": "soin aux animaux", + "description": null, "emoji": "\uD83D\uDC2E" } ], @@ -1552,41 +1675,9 @@ class FormationControllerTest( "criteresAnalyseCandidature": [], "repartitionAdmisAnneePrecedente": null, "liens": [], + "communes": [], "voeux": [], - "communesFavoritesAvecLeursVoeux": [ - { - "commune": { - "codeInsee": "75115", - "nom": "Paris", - "latitude": 48.851227, - "longitude": 2.2885659 - }, - "voeuxAvecDistance": [ - { - "voeu": { - "id": "ta3", - "nom": "Nom du ta3", - "commune": { - "nom": "Paris", - "codeInsee": "75105" - } - }, - "distanceKm": 3 - }, - { - "voeu": { - "id": "ta32", - "nom": "Nom du ta32", - "commune": { - "nom": "Paris", - "codeInsee": "75115" - } - }, - "distanceKm": 1 - } - ] - } - ], + "communesFavoritesAvecLeursVoeux": [], "metiers": [], "tauxAffinite": 17, "apprentissage": false @@ -4190,7 +4281,12 @@ class FormationControllerTest( statistiquesDesAdmis = null, tauxAffinite = 17, metiersTriesParAffinites = emptyList(), - voeux = emptyList(), + informationsSurLesVoeuxEtLeursCommunes = + InformationsSurLesVoeuxEtLeursCommunes( + voeux = emptyList(), + communesTriees = emptyList(), + voeuxParCommunesFavorites = emptyList(), + ), apprentissage = false, explications = null, ), @@ -4313,6 +4409,32 @@ class FormationControllerTest( "url": "https://www.onisep.fr/ressources/univers-formation/formations/post-bac/cycle-pluridisciplinaire-d-etudes-superieures" } ], + "communes": [ + { + "nom": "Paris", + "codeInsee": "75115" + }, + { + "nom": "Paris", + "codeInsee": "75105" + }, + { + "nom": "Montreuil", + "codeInsee": "93048" + }, + { + "nom": "Lyon", + "codeInsee": "69123" + }, + { + "nom": "Strasbourg", + "codeInsee": "67482" + }, + { + "nom": "Marseille", + "codeInsee": "13055" + } + ], "voeux": [ { "id": "ta10", @@ -4453,6 +4575,7 @@ class FormationControllerTest( { "id": "T_ITM_1356", "nom": "soin aux animaux", + "description": null, "emoji": "\uD83D\uDC2E" } ], @@ -4517,41 +4640,9 @@ class FormationControllerTest( "criteresAnalyseCandidature": [], "repartitionAdmisAnneePrecedente": null, "liens": [], + "communes": [], "voeux": [], - "communesFavoritesAvecLeursVoeux": [ - { - "commune": { - "codeInsee": "75115", - "nom": "Paris", - "latitude": 48.851227, - "longitude": 2.2885659 - }, - "voeuxAvecDistance": [ - { - "voeu": { - "id": "ta3", - "nom": "Nom du ta3", - "commune": { - "nom": "Paris", - "codeInsee": "75105" - } - }, - "distanceKm": 3 - }, - { - "voeu": { - "id": "ta32", - "nom": "Nom du ta32", - "commune": { - "nom": "Paris", - "codeInsee": "75115" - } - }, - "distanceKm": 1 - } - ] - } - ], + "communesFavoritesAvecLeursVoeux": [], "metiers": [], "tauxAffinite": 17, "apprentissage": false @@ -4601,7 +4692,12 @@ class FormationControllerTest( statistiquesDesAdmis = null, tauxAffinite = 17, metiersTriesParAffinites = emptyList(), - voeux = emptyList(), + informationsSurLesVoeuxEtLeursCommunes = + InformationsSurLesVoeuxEtLeursCommunes( + voeux = emptyList(), + communesTriees = emptyList(), + voeuxParCommunesFavorites = emptyList(), + ), apprentissage = false, explications = null, ), @@ -4724,6 +4820,32 @@ class FormationControllerTest( "url": "https://www.onisep.fr/ressources/univers-formation/formations/post-bac/cycle-pluridisciplinaire-d-etudes-superieures" } ], + "communes": [ + { + "nom": "Paris", + "codeInsee": "75115" + }, + { + "nom": "Paris", + "codeInsee": "75105" + }, + { + "nom": "Montreuil", + "codeInsee": "93048" + }, + { + "nom": "Lyon", + "codeInsee": "69123" + }, + { + "nom": "Strasbourg", + "codeInsee": "67482" + }, + { + "nom": "Marseille", + "codeInsee": "13055" + } + ], "voeux": [ { "id": "ta10", @@ -4864,6 +4986,7 @@ class FormationControllerTest( { "id": "T_ITM_1356", "nom": "soin aux animaux", + "description": null, "emoji": "\uD83D\uDC2E" } ], @@ -4928,41 +5051,9 @@ class FormationControllerTest( "criteresAnalyseCandidature": [], "repartitionAdmisAnneePrecedente": null, "liens": [], + "communes": [], "voeux": [], - "communesFavoritesAvecLeursVoeux": [ - { - "commune": { - "codeInsee": "75115", - "nom": "Paris", - "latitude": 48.851227, - "longitude": 2.2885659 - }, - "voeuxAvecDistance": [ - { - "voeu": { - "id": "ta3", - "nom": "Nom du ta3", - "commune": { - "nom": "Paris", - "codeInsee": "75105" - } - }, - "distanceKm": 3 - }, - { - "voeu": { - "id": "ta32", - "nom": "Nom du ta32", - "commune": { - "nom": "Paris", - "codeInsee": "75115" - } - }, - "distanceKm": 1 - } - ] - } - ], + "communesFavoritesAvecLeursVoeux": [], "metiers": [], "tauxAffinite": 17, "apprentissage": false diff --git a/app/back/src/test/fr/gouv/monprojetsup/formation/entity/CommunesCourtes.kt b/app/back/src/test/fr/gouv/monprojetsup/formation/entity/CommunesCourtes.kt new file mode 100644 index 000000000..b7b362ca7 --- /dev/null +++ b/app/back/src/test/fr/gouv/monprojetsup/formation/entity/CommunesCourtes.kt @@ -0,0 +1,101 @@ +package fr.gouv.monprojetsup.formation.entity + +import fr.gouv.monprojetsup.formation.domain.entity.CommuneCourte + +object CommunesCourtes { + val GRENOBLE = + CommuneCourte( + codeInsee = "38185", + nom = "Grenoble", + ) + + val STRASBOURG = + CommuneCourte( + codeInsee = "67482", + nom = "Strasbourg", + ) + + val PARIS15EME = + CommuneCourte( + codeInsee = "75115", + nom = "Paris", + ) + + val PARIS19EME = + CommuneCourte( + codeInsee = "75119", + nom = "Paris", + ) + + val PARIS5EME = + CommuneCourte( + codeInsee = "75105", + nom = "Paris", + ) + + val MARSEILLE = + CommuneCourte( + codeInsee = "13055", + nom = "Marseille", + ) + + val LYON = + CommuneCourte( + codeInsee = "69123", + nom = "Lyon", + ) + + val CAEN = + CommuneCourte( + codeInsee = "14118", + nom = "Caen", + ) + + val MONTREUIL = + CommuneCourte( + codeInsee = "93048", + nom = "Montreuil", + ) + + val NANCY = + CommuneCourte( + codeInsee = "54395", + nom = "Nancy", + ) + + val RENNES = + CommuneCourte( + codeInsee = "35238", + nom = "Rennes", + ) + + val SAINT_MALO = + CommuneCourte( + codeInsee = "35288", + nom = "Saint-Malo", + ) + + val AJACCIO = + CommuneCourte( + codeInsee = "2A004", + nom = "Ajaccio", + ) + + val BASTIA = + CommuneCourte( + codeInsee = "2B033", + nom = "Bastia", + ) + + val SAINT_PIERRE = + CommuneCourte( + codeInsee = "97416", + nom = "Saint-Pierre", + ) + + val FORT_DE_FRANCE = + CommuneCourte( + codeInsee = "97209", + nom = "Fort-de-France", + ) +} diff --git a/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/client/APISuggestionProfilDTOTest.kt b/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/client/APISuggestionProfilDTOTest.kt index 0b15faf18..d57eb9612 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/client/APISuggestionProfilDTOTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/client/APISuggestionProfilDTOTest.kt @@ -2,7 +2,7 @@ package fr.gouv.monprojetsup.formation.infrastructure.client import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation -import fr.gouv.monprojetsup.formation.entity.Communes +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites import fr.gouv.monprojetsup.formation.infrastructure.dto.APISuggestionProfilDTO import fr.gouv.monprojetsup.formation.infrastructure.dto.SuggestionDTO import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixAlternance @@ -38,7 +38,7 @@ class APISuggestionProfilDTOTest { baccalaureat = "Générale", dureeEtudesPrevue = ChoixDureeEtudesPrevue.INDIFFERENT, alternance = ChoixAlternance.PAS_INTERESSE, - communesFavorites = listOf(Communes.PARIS15EME), + communesFavorites = listOf(CommunesFavorites.PARIS15EME), specialites = listOf("mat1001", "mat1049"), centresInterets = listOf("chiffres_jongler", "aider_autres"), moyenneGenerale = 14f, @@ -102,7 +102,7 @@ class APISuggestionProfilDTOTest { baccalaureat = "Générale", dureeEtudesPrevue = ChoixDureeEtudesPrevue.INDIFFERENT, alternance = ChoixAlternance.PAS_INTERESSE, - communesFavorites = listOf(Communes.PARIS15EME, Communes.MARSEILLE), + communesFavorites = listOf(CommunesFavorites.PARIS15EME, CommunesFavorites.MARSEILLE), specialites = listOf("mat1001", "mat1049"), centresInterets = listOf("chiffres_jongler", "aider_autres"), moyenneGenerale = 10.5f, @@ -165,7 +165,7 @@ class APISuggestionProfilDTOTest { baccalaureat = "STHR", dureeEtudesPrevue = ChoixDureeEtudesPrevue.COURTE, alternance = ChoixAlternance.INDIFFERENT, - communesFavorites = listOf(Communes.LYON, Communes.CAEN), + communesFavorites = listOf(CommunesFavorites.LYON, CommunesFavorites.CAEN), specialites = listOf("1053", "1055"), centresInterets = emptyList(), moyenneGenerale = 19.5f, @@ -251,7 +251,7 @@ class APISuggestionProfilDTOTest { baccalaureat = "PA", dureeEtudesPrevue = ChoixDureeEtudesPrevue.AUCUNE_IDEE, alternance = ChoixAlternance.TRES_INTERESSE, - communesFavorites = listOf(Communes.LYON, Communes.PARIS15EME), + communesFavorites = listOf(CommunesFavorites.LYON, CommunesFavorites.PARIS15EME), specialites = listOf("1045"), centresInterets = emptyList(), moyenneGenerale = -1.0f, @@ -282,7 +282,7 @@ class APISuggestionProfilDTOTest { baccalaureat = "NC", dureeEtudesPrevue = ChoixDureeEtudesPrevue.INDIFFERENT, alternance = ChoixAlternance.PAS_INTERESSE, - communesFavorites = listOf(Communes.PARIS15EME, Communes.MARSEILLE), + communesFavorites = listOf(CommunesFavorites.PARIS15EME, CommunesFavorites.MARSEILLE), specialites = listOf("mat1001", "mat1049"), centresInterets = null, moyenneGenerale = 4.9f, diff --git a/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/client/SuggestionApiHttpClientTest.kt b/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/client/SuggestionApiHttpClientTest.kt index 19e004e99..433b518ce 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/client/SuggestionApiHttpClientTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/client/SuggestionApiHttpClientTest.kt @@ -6,6 +6,7 @@ import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve import fr.gouv.monprojetsup.commun.erreur.domain.MonProjetSupInternalErrorException import fr.gouv.monprojetsup.commun.helper.MockitoHelper import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites import fr.gouv.monprojetsup.formation.domain.entity.ExplicationGeographique import fr.gouv.monprojetsup.formation.domain.entity.ExplicationsSuggestionEtExemplesMetiers import fr.gouv.monprojetsup.formation.domain.entity.ExplicationsSuggestionEtExemplesMetiers.AffiniteSpecialite @@ -13,7 +14,6 @@ import fr.gouv.monprojetsup.formation.domain.entity.ExplicationsSuggestionEtExem import fr.gouv.monprojetsup.formation.domain.entity.ExplicationsSuggestionEtExemplesMetiers.TypeBaccalaureat import fr.gouv.monprojetsup.formation.domain.entity.SuggestionsPourUnProfil import fr.gouv.monprojetsup.formation.domain.entity.SuggestionsPourUnProfil.FormationAvecSonAffinite -import fr.gouv.monprojetsup.formation.entity.Communes import fr.gouv.monprojetsup.logging.MonProjetSupLogger import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixAlternance import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixDureeEtudesPrevue @@ -64,7 +64,7 @@ class SuggestionApiHttpClientTest { baccalaureat = "Générale", dureeEtudesPrevue = ChoixDureeEtudesPrevue.INDIFFERENT, alternance = ChoixAlternance.PAS_INTERESSE, - communesFavorites = listOf(Communes.PARIS15EME), + communesFavorites = listOf(CommunesFavorites.PARIS15EME), specialites = listOf("mat1001", "mat1049"), centresInterets = listOf("T_ROME_2092381917", "T_IDEO2_4812"), moyenneGenerale = 14f, diff --git a/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/repository/CommunesAvecVoeuxAuxAlentoursBDDRepositoryTest.kt b/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/repository/CommunesFavoritesAvecVoeuxAuxAlentoursBDDRepositoryTest.kt similarity index 81% rename from app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/repository/CommunesAvecVoeuxAuxAlentoursBDDRepositoryTest.kt rename to app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/repository/CommunesFavoritesAvecVoeuxAuxAlentoursBDDRepositoryTest.kt index cbfb3b031..41cec9d38 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/repository/CommunesAvecVoeuxAuxAlentoursBDDRepositoryTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/repository/CommunesFavoritesAvecVoeuxAuxAlentoursBDDRepositoryTest.kt @@ -1,9 +1,9 @@ package fr.gouv.monprojetsup.formation.infrastructure.repository import fr.gouv.monprojetsup.commun.infrastructure.repository.BDDRepositoryTest +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecIdsVoeuxAuxAlentours import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecIdsVoeuxAuxAlentours.VoeuAvecDistance -import fr.gouv.monprojetsup.formation.entity.Communes import fr.gouv.monprojetsup.logging.MonProjetSupLogger import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach @@ -13,7 +13,7 @@ import org.mockito.Mock import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.jdbc.Sql -class CommunesAvecVoeuxAuxAlentoursBDDRepositoryTest : BDDRepositoryTest() { +class CommunesFavoritesAvecVoeuxAuxAlentoursBDDRepositoryTest : BDDRepositoryTest() { @Autowired private lateinit var communesAvecVoeuxAuxAlentoursJPARepository: CommunesAvecVoeuxAuxAlentoursJPARepository @@ -35,7 +35,8 @@ class CommunesAvecVoeuxAuxAlentoursBDDRepositoryTest : BDDRepositoryTest() { @Sql("classpath:join_ville_voeu.sql") fun `doit retourner à vide pour les communes inconnues et logguer un warning`() { // Given - val communes = listOf(Communes.SAINT_MALO, Communes.MONTREUIL, Communes.CAEN, Communes.PARIS5EME) + val communes = + listOf(CommunesFavorites.SAINT_MALO, CommunesFavorites.MONTREUIL, CommunesFavorites.CAEN, CommunesFavorites.PARIS5EME) // When val result = communesAvecVoeuxAuxAlentoursBDDRepository.recupererVoeuxAutoursDeCommmune(communes) @@ -44,7 +45,7 @@ class CommunesAvecVoeuxAuxAlentoursBDDRepositoryTest : BDDRepositoryTest() { val attendu = listOf( CommuneAvecIdsVoeuxAuxAlentours( - Communes.SAINT_MALO, + CommunesFavorites.SAINT_MALO, distances = listOf( VoeuAvecDistance("ta60", 66), @@ -52,16 +53,16 @@ class CommunesAvecVoeuxAuxAlentoursBDDRepositoryTest : BDDRepositoryTest() { VoeuAvecDistance("ta480", 66), ), ), - CommuneAvecIdsVoeuxAuxAlentours(Communes.MONTREUIL, distances = emptyList()), + CommuneAvecIdsVoeuxAuxAlentours(CommunesFavorites.MONTREUIL, distances = emptyList()), CommuneAvecIdsVoeuxAuxAlentours( - Communes.CAEN, + CommunesFavorites.CAEN, distances = listOf( VoeuAvecDistance("ta33", 52), VoeuAvecDistance("ta256", 52), ), ), - CommuneAvecIdsVoeuxAuxAlentours(Communes.PARIS5EME, distances = emptyList()), + CommuneAvecIdsVoeuxAuxAlentours(CommunesFavorites.PARIS5EME, distances = emptyList()), ) assertThat(result).isEqualTo(attendu) then(logger).should().warn( diff --git a/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/repository/VoeuBDDRepositoryTest.kt b/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/repository/VoeuBDDRepositoryTest.kt index 1c6a1325b..c3d3dce8f 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/repository/VoeuBDDRepositoryTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/formation/infrastructure/repository/VoeuBDDRepositoryTest.kt @@ -2,11 +2,11 @@ package fr.gouv.monprojetsup.formation.infrastructure.repository import fr.gouv.monprojetsup.commun.infrastructure.repository.BDDRepositoryTest import fr.gouv.monprojetsup.formation.domain.entity.Voeu -import fr.gouv.monprojetsup.formation.entity.Communes.MONTREUIL -import fr.gouv.monprojetsup.formation.entity.Communes.NANCY -import fr.gouv.monprojetsup.formation.entity.Communes.PARIS19EME -import fr.gouv.monprojetsup.formation.entity.Communes.PARIS5EME -import fr.gouv.monprojetsup.formation.entity.Communes.RENNES +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.MONTREUIL +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.NANCY +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.PARIS19EME +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.PARIS5EME +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.RENNES import jakarta.persistence.EntityManager import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach @@ -45,11 +45,23 @@ class VoeuBDDRepositoryTest : BDDRepositoryTest() { mapOf( "fl0001" to listOf( - Voeu(id = "ta0001", nom = "Lycée professionnel horticole de Montreuil", commune = MONTREUIL), + Voeu( + id = "ta0001", + nom = "Lycée professionnel horticole de Montreuil", + commune = MONTREUIL, + latitude = 48.861, + longitude = 2.443, + ), ), "fl0003" to listOf( - Voeu(id = "ta0002", nom = "ENSAPLV", commune = PARIS19EME), + Voeu( + id = "ta0002", + nom = "ENSAPLV", + commune = PARIS19EME, + longitude = 2.393, + latitude = 48.889, + ), ), ), ) @@ -72,17 +84,47 @@ class VoeuBDDRepositoryTest : BDDRepositoryTest() { mapOf( "fl0001" to listOf( - Voeu(id = "ta0001", nom = "Lycée professionnel horticole de Montreuil", commune = MONTREUIL), + Voeu( + id = "ta0001", + nom = "Lycée professionnel horticole de Montreuil", + commune = MONTREUIL, + latitude = 48.861, + longitude = 2.443, + ), ), "fl0004" to listOf( - Voeu(id = "ta0005", nom = "Université Paris 1 Panthéon-Sorbonne", commune = PARIS5EME), + Voeu( + id = "ta0005", + nom = "Université Paris 1 Panthéon-Sorbonne", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), ), "fl0003" to listOf( - Voeu(id = "ta0002", nom = "ENSAPLV", commune = PARIS19EME), - Voeu(id = "ta0003", nom = "ENSA Nancy", commune = NANCY), - Voeu(id = "ta0004", nom = "ENSAB", commune = RENNES), + Voeu( + id = "ta0002", + nom = "ENSAPLV", + commune = PARIS19EME, + longitude = 2.393, + latitude = 48.889, + ), + Voeu( + id = "ta0003", + nom = "ENSA Nancy", + commune = NANCY, + latitude = 48.692, + longitude = 6.184, + ), + Voeu( + id = "ta0004", + nom = "ENSAB", + commune = RENNES, + latitude = 48.117, + longitude = 1.677, + ), ), ), ) @@ -102,15 +144,33 @@ class VoeuBDDRepositoryTest : BDDRepositoryTest() { mapOf( "fl0001" to listOf( - Voeu(id = "ta0001", nom = "Lycée professionnel horticole de Montreuil", commune = MONTREUIL), + Voeu( + id = "ta0001", + nom = "Lycée professionnel horticole de Montreuil", + commune = MONTREUIL, + latitude = 48.861, + longitude = 2.443, + ), ), "fl0004" to listOf( - Voeu(id = "ta0005", nom = "Université Paris 1 Panthéon-Sorbonne", commune = PARIS5EME), + Voeu( + id = "ta0005", + nom = "Université Paris 1 Panthéon-Sorbonne", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), ), "fl0003" to listOf( - Voeu(id = "ta0003", nom = "ENSA Nancy", commune = NANCY), + Voeu( + id = "ta0003", + nom = "ENSA Nancy", + commune = NANCY, + latitude = 48.692, + longitude = 6.184, + ), ), ), ) @@ -147,19 +207,60 @@ class VoeuBDDRepositoryTest : BDDRepositoryTest() { inner class RecupererLesVoeuxDUneFormation { @Test @Sql("classpath:formation_voeu.sql") - fun `Doit retourner les voeux d'une formation`() { + fun `Doit retourner les voeux d'une formation en incluant les obsolètes`() { // Given val idFormation = "fl0003" // When - val result = voeuBDDRepository.recupererLesVoeuxDUneFormation(idFormation) + val result = voeuBDDRepository.recupererLesVoeuxDUneFormation(idFormation, obsoletesInclus = true) // Then assertThat(result).usingRecursiveAssertion().isEqualTo( listOf( - Voeu(id = "ta0002", nom = "ENSAPLV", commune = PARIS19EME), - Voeu(id = "ta0003", nom = "ENSA Nancy", commune = NANCY), - Voeu(id = "ta0004", nom = "ENSAB", commune = RENNES), + Voeu( + id = "ta0002", + nom = "ENSAPLV", + commune = PARIS19EME, + longitude = 2.393, + latitude = 48.889, + ), + Voeu( + id = "ta0003", + nom = "ENSA Nancy", + commune = NANCY, + latitude = 48.692, + longitude = 6.184, + ), + Voeu( + id = "ta0004", + nom = "ENSAB", + commune = RENNES, + latitude = 48.117, + longitude = 1.677, + ), + ), + ) + } + + @Test + @Sql("classpath:formation_voeu.sql") + fun `Doit retourner les voeux d'une formation en retirant les obsolètes`() { + // Given + val idFormation = "fl0003" + + // When + val result = voeuBDDRepository.recupererLesVoeuxDUneFormation(idFormation, obsoletesInclus = false) + + // Then + assertThat(result).usingRecursiveAssertion().isEqualTo( + listOf( + Voeu( + id = "ta0003", + nom = "ENSA Nancy", + commune = NANCY, + latitude = 48.692, + longitude = 6.184, + ), ), ) } @@ -171,7 +272,7 @@ class VoeuBDDRepositoryTest : BDDRepositoryTest() { val idFormation = "fl0002" // When - val result = voeuBDDRepository.recupererLesVoeuxDUneFormation(idFormation) + val result = voeuBDDRepository.recupererLesVoeuxDUneFormation(idFormation, obsoletesInclus = true) // Then assertThat(result).usingRecursiveAssertion().isEqualTo(emptyList()) diff --git a/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererExplicationsEtExemplesMetiersPourFormationServiceTest.kt b/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererExplicationsEtExemplesMetiersPourFormationServiceTest.kt index e22a155bb..0af86dc9b 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererExplicationsEtExemplesMetiersPourFormationServiceTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererExplicationsEtExemplesMetiersPourFormationServiceTest.kt @@ -2,6 +2,7 @@ package fr.gouv.monprojetsup.formation.usecase import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites import fr.gouv.monprojetsup.formation.domain.entity.ExplicationGeographique import fr.gouv.monprojetsup.formation.domain.entity.ExplicationsSuggestionDetaillees import fr.gouv.monprojetsup.formation.domain.entity.ExplicationsSuggestionEtExemplesMetiers @@ -12,7 +13,6 @@ import fr.gouv.monprojetsup.formation.domain.entity.FicheFormation.FicheFormatio import fr.gouv.monprojetsup.formation.domain.entity.FormationCourte import fr.gouv.monprojetsup.formation.domain.port.FormationRepository import fr.gouv.monprojetsup.formation.domain.port.SuggestionHttpClient -import fr.gouv.monprojetsup.formation.entity.Communes import fr.gouv.monprojetsup.metier.domain.entity.Metier import fr.gouv.monprojetsup.metier.domain.entity.MetierCourt import fr.gouv.monprojetsup.metier.domain.port.MetierRepository @@ -75,7 +75,7 @@ class RecupererExplicationsEtExemplesMetiersPourFormationServiceTest { baccalaureat = "Générale", dureeEtudesPrevue = ChoixDureeEtudesPrevue.INDIFFERENT, alternance = ChoixAlternance.PAS_INTERESSE, - communesFavorites = listOf(Communes.CAEN), + communesFavorites = listOf(CommunesFavorites.CAEN), specialites = listOf("1001", "1049"), centresInterets = listOf("ci29", "ci17", "ci8"), moyenneGenerale = 14f, diff --git a/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererFormationServiceTest.kt b/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererFormationServiceTest.kt index 299805115..b8a88a467 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererFormationServiceTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererFormationServiceTest.kt @@ -3,6 +3,7 @@ package fr.gouv.monprojetsup.formation.usecase import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve import fr.gouv.monprojetsup.commun.lien.domain.entity.Lien import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecVoeuxAuxAlentours import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance import fr.gouv.monprojetsup.formation.domain.entity.CritereAnalyseCandidature @@ -15,14 +16,13 @@ import fr.gouv.monprojetsup.formation.domain.entity.SuggestionsPourUnProfil.Form import fr.gouv.monprojetsup.formation.domain.entity.Voeu import fr.gouv.monprojetsup.formation.domain.port.FormationRepository import fr.gouv.monprojetsup.formation.domain.port.SuggestionHttpClient -import fr.gouv.monprojetsup.formation.entity.Communes -import fr.gouv.monprojetsup.formation.entity.Communes.CAEN -import fr.gouv.monprojetsup.formation.entity.Communes.LYON -import fr.gouv.monprojetsup.formation.entity.Communes.MARSEILLE -import fr.gouv.monprojetsup.formation.entity.Communes.PARIS15EME -import fr.gouv.monprojetsup.formation.entity.Communes.PARIS5EME -import fr.gouv.monprojetsup.formation.entity.Communes.SAINT_MALO -import fr.gouv.monprojetsup.formation.entity.Communes.STRASBOURG +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.CAEN +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.LYON +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.MARSEILLE +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.PARIS15EME +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.PARIS5EME +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.SAINT_MALO +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.STRASBOURG import fr.gouv.monprojetsup.metier.domain.entity.Metier import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixAlternance import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixDureeEtudesPrevue @@ -47,10 +47,8 @@ class RecupererFormationServiceTest { lateinit var formationRepository: FormationRepository @Mock - lateinit var recupererVoeuxDUneFormationService: RecupererVoeuxDUneFormationService - - @Mock - lateinit var recupererVoeuxDesCommunesFavoritesService: RecupererVoeuxDesCommunesFavoritesService + lateinit var recupererInformationsSurLesVoeuxEtLeursCommunesService: + RecupererInformationsSurLesVoeuxEtLeursCommunesService @Mock lateinit var critereAnalyseCandidatureService: CritereAnalyseCandidatureService @@ -112,14 +110,52 @@ class RecupererFormationServiceTest { given(formationRepository.recupererUneFormation("fl0001")).willReturn(formation) val voeuxPossiblesPourLaFormationFL0001 = listOf( - Voeu(id = "ta10", nom = "Nom du ta10", commune = LYON), - Voeu(id = "ta3", nom = "Nom du ta3", commune = PARIS5EME), - Voeu(id = "ta11", nom = "Nom du ta11", commune = LYON), - Voeu(id = "ta32", nom = "Nom du ta32", commune = PARIS15EME), - Voeu(id = "ta17", nom = "Nom du ta17", commune = STRASBOURG), - Voeu(id = "ta7", nom = "Nom du ta7", commune = MARSEILLE), + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta32", + nom = "Nom du ta32", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = STRASBOURG, + longitude = 1.666667, + latitude = 50.266666, + ), + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), ) - given(recupererVoeuxDUneFormationService.recupererVoeux(idFormation = "fl0001", true)).willReturn( + given( + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererVoeux(idFormation = "fl0001", true), + ).willReturn( voeuxPossiblesPourLaFormationFL0001, ) val statistiquesDesAdmis = mock(StatistiquesDesAdmis::class.java) @@ -176,14 +212,55 @@ class RecupererFormationServiceTest { given(formationRepository.recupererUneFormation("fl0001")).willReturn(formation) val voeuxFormationFL0001 = listOf( - Voeu(id = "ta10", nom = "Nom du ta10", commune = LYON), - Voeu(id = "ta3", nom = "Nom du ta3", commune = PARIS5EME), - Voeu(id = "ta11", nom = "Nom du ta11", commune = LYON), - Voeu(id = "ta32", nom = "Nom du ta32", commune = PARIS15EME), - Voeu(id = "ta17", nom = "Nom du ta17", commune = STRASBOURG), - Voeu(id = "ta7", nom = "Nom du ta7", commune = MARSEILLE), + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta32", + nom = "Nom du ta32", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = STRASBOURG, + longitude = 1.666667, + latitude = 50.266666, + ), + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), ) - given(recupererVoeuxDUneFormationService.recupererVoeux(idFormation = "fl0001", obsoletesInclus = true)).willReturn( + given( + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererVoeux( + idFormation = "fl0001", + obsoletesInclus = true, + ), + ).willReturn( voeuxFormationFL0001, ) val statistiquesDesAdmis = mock(StatistiquesDesAdmis::class.java) @@ -213,7 +290,7 @@ class RecupererFormationServiceTest { baccalaureat = "Générale", dureeEtudesPrevue = ChoixDureeEtudesPrevue.INDIFFERENT, alternance = ChoixAlternance.PAS_INTERESSE, - communesFavorites = listOf(Communes.CAEN), + communesFavorites = listOf(CommunesFavorites.CAEN), specialites = listOf("1001", "1049"), centresInterets = listOf("T_ROME_2092381917", "T_IDEO2_4812"), moyenneGenerale = 14f, @@ -257,22 +334,96 @@ class RecupererFormationServiceTest { criteresAnalyseCandidature, ) given(formationRepository.recupererUneFormation("fl0001")).willReturn(formation) - val voeuxFormationFL0001 = + val voeuxTries = listOf( - Voeu(id = "ta10", nom = "Nom du ta10", commune = LYON), - Voeu(id = "ta3", nom = "Nom du ta3", commune = PARIS5EME), - Voeu(id = "ta11", nom = "Nom du ta11", commune = LYON), - Voeu(id = "ta32", nom = "Nom du ta32", commune = PARIS15EME), - Voeu(id = "ta17", nom = "Nom du ta17", commune = CAEN), - Voeu(id = "ta7", nom = "Nom du ta7", commune = SAINT_MALO), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = CAEN, + latitude = 49.183334, + longitude = -0.350000, + ), + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta32", + nom = "Nom du ta32", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + ) + val communesTriees = listOf(CAEN, LYON, PARIS5EME, PARIS15EME, SAINT_MALO) + val voeuxParCommunesFavorites = + listOf( + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.CAEN, + distances = + listOf( + VoeuAvecDistance( + voeu = + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = CAEN, + latitude = 49.183334, + longitude = -0.350000, + ), + km = 0, + ), + VoeuAvecDistance( + voeu = + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + km = 120, + ), + ), + ), + ) + val informationsSurLesVoeuxEtLeursCommunes = + FicheFormation.FicheFormationPourProfil.InformationsSurLesVoeuxEtLeursCommunes( + voeux = voeuxTries, + communesTriees = communesTriees, + voeuxParCommunesFavorites = voeuxParCommunesFavorites, ) given( - recupererVoeuxDUneFormationService.recupererVoeuxTriesParAffinites( + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererInformationsSurLesVoeuxEtLeursCommunes( idFormation = "fl0001", profilEleve = profil, obsoletesInclus = true, ), - ).willReturn(voeuxFormationFL0001) + ).willReturn(informationsSurLesVoeuxEtLeursCommunes) given( calculDuTauxDAffiniteBuilder.calculDuTauxDAffinite( formationAvecLeurAffinite = @@ -349,29 +500,6 @@ class RecupererFormationServiceTest { ), ), ) - val voeuxParCommunesFavorites = - listOf( - CommuneAvecVoeuxAuxAlentours( - commune = CAEN, - distances = - listOf( - VoeuAvecDistance( - voeu = Voeu(id = "ta17", nom = "Nom du ta17", commune = CAEN), - km = 0, - ), - VoeuAvecDistance( - voeu = Voeu(id = "ta7", nom = "Nom du ta7", commune = SAINT_MALO), - km = 120, - ), - ), - ), - ) - given( - recupererVoeuxDesCommunesFavoritesService.recupererVoeuxAutoursDeCommmunes( - communes = listOf(Communes.CAEN), - voeuxDeLaFormation = voeuxFormationFL0001, - ), - ).willReturn(voeuxParCommunesFavorites) // When val resultat = recupererFormationService.recupererFormation(profilEleve = profil, idFormation = "fl0001") @@ -415,8 +543,7 @@ class RecupererFormationServiceTest { liens = emptyList(), ), ), - voeux = voeuxFormationFL0001, - voeuxParCommunesFavorites = voeuxParCommunesFavorites, + informationsSurLesVoeuxEtLeursCommunes = informationsSurLesVoeuxEtLeursCommunes, tauxAffinite = 70, explications = explicationsEtExemplesMetiers.first, criteresAnalyseCandidature = diff --git a/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererFormationsServiceTest.kt b/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererFormationsServiceTest.kt index 601359747..3cac364f3 100644 --- a/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererFormationsServiceTest.kt +++ b/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererFormationsServiceTest.kt @@ -2,23 +2,26 @@ package fr.gouv.monprojetsup.formation.usecase import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve import fr.gouv.monprojetsup.commun.lien.domain.entity.Lien +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecVoeuxAuxAlentours import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance import fr.gouv.monprojetsup.formation.domain.entity.CritereAnalyseCandidature import fr.gouv.monprojetsup.formation.domain.entity.ExplicationsSuggestionDetaillees import fr.gouv.monprojetsup.formation.domain.entity.FicheFormation +import fr.gouv.monprojetsup.formation.domain.entity.FicheFormation.FicheFormationPourProfil.InformationsSurLesVoeuxEtLeursCommunes import fr.gouv.monprojetsup.formation.domain.entity.Formation import fr.gouv.monprojetsup.formation.domain.entity.StatistiquesDesAdmis import fr.gouv.monprojetsup.formation.domain.entity.SuggestionsPourUnProfil import fr.gouv.monprojetsup.formation.domain.entity.SuggestionsPourUnProfil.FormationAvecSonAffinite import fr.gouv.monprojetsup.formation.domain.entity.Voeu import fr.gouv.monprojetsup.formation.domain.port.FormationRepository -import fr.gouv.monprojetsup.formation.entity.Communes.CAEN -import fr.gouv.monprojetsup.formation.entity.Communes.LYON -import fr.gouv.monprojetsup.formation.entity.Communes.MARSEILLE -import fr.gouv.monprojetsup.formation.entity.Communes.PARIS15EME -import fr.gouv.monprojetsup.formation.entity.Communes.PARIS5EME -import fr.gouv.monprojetsup.formation.entity.Communes.SAINT_MALO +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.CAEN +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.LYON +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.MARSEILLE +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.PARIS15EME +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.PARIS5EME +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.SAINT_MALO +import fr.gouv.monprojetsup.logging.MonProjetSupLogger import fr.gouv.monprojetsup.metier.domain.entity.Metier import fr.gouv.monprojetsup.metier.domain.port.MetierRepository import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixNiveau @@ -27,6 +30,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.mockito.BDDMockito.given +import org.mockito.BDDMockito.then import org.mockito.InjectMocks import org.mockito.Mock import org.mockito.Mockito.mock @@ -40,10 +44,7 @@ class RecupererFormationsServiceTest { lateinit var metierRepository: MetierRepository @Mock - lateinit var recupererVoeuxDUneFormationService: RecupererVoeuxDUneFormationService - - @Mock - lateinit var recupererVoeuxDesCommunesFavoritesService: RecupererVoeuxDesCommunesFavoritesService + lateinit var recupererInformationsSurLesVoeuxEtLeursCommunesService: RecupererInformationsSurLesVoeuxEtLeursCommunesService @Mock lateinit var critereAnalyseCandidatureService: CritereAnalyseCandidatureService @@ -60,6 +61,9 @@ class RecupererFormationsServiceTest { @Mock lateinit var calculDuTauxDAffiniteBuilder: CalculDuTauxDAffiniteBuilder + @Mock + lateinit var logger: MonProjetSupLogger + @InjectMocks lateinit var recupererFormationsService: RecupererFormationsService @@ -76,7 +80,7 @@ class RecupererFormationsServiceTest { val profilEleve = mock(ProfilEleve.AvecProfilExistant::class.java) given(profilEleve.baccalaureat).willReturn("Général") given(profilEleve.classe).willReturn(ChoixNiveau.TERMINALE) - given(profilEleve.communesFavorites).willReturn(listOf(SAINT_MALO)) + given(profilEleve.communesFavorites).willReturn(listOf(CommunesFavorites.SAINT_MALO)) val formationAvecSonAffinite1 = mock(FormationAvecSonAffinite::class.java) val formationAvecSonAffinite2 = mock(FormationAvecSonAffinite::class.java) val formationAvecSonAffinite3 = mock(FormationAvecSonAffinite::class.java) @@ -160,64 +164,151 @@ class RecupererFormationsServiceTest { listOf("fl0001", "fl0003"), ), ).willReturn(explications) - val voeuxPossiblesPourLaFormationFL0001 = - listOf( - Voeu(id = "ta1", nom = "Nom du ta1", commune = PARIS15EME), - Voeu(id = "ta17", nom = "Nom du ta17", commune = SAINT_MALO), - Voeu(id = "ta6", nom = "Nom du ta6", commune = MARSEILLE), - ) - val voeuxPossiblesPourLaFormationFL0003 = - listOf( - Voeu(id = "ta10", nom = "Nom du ta10", commune = LYON), - Voeu(id = "ta3", nom = "Nom du ta3", commune = PARIS5EME), - Voeu(id = "ta11", nom = "Nom du ta11", commune = LYON), - Voeu(id = "ta32", nom = "Nom du ta32", commune = CAEN), - Voeu(id = "ta17", nom = "Nom du ta17", commune = SAINT_MALO), - Voeu(id = "ta7", nom = "Nom du ta7", commune = MARSEILLE), - ) - val voeuxDesFormations = mapOf("fl0001" to voeuxPossiblesPourLaFormationFL0001, "fl0003" to voeuxPossiblesPourLaFormationFL0003) - given( - recupererVoeuxDUneFormationService.recupererVoeuxTriesParAffinites( - idsFormations = listOf("fl0001", "fl0003"), - profilEleve = profilEleve, - obsoletesInclus = true, - ), - ).willReturn(voeuxDesFormations) - val voeuxParCommunesFavoritesFL0001 = listOf( CommuneAvecVoeuxAuxAlentours( - commune = SAINT_MALO, + communeFavorite = CommunesFavorites.SAINT_MALO, distances = listOf( - VoeuAvecDistance(voeu = Voeu(id = "ta17", nom = "Nom du ta17", commune = SAINT_MALO), km = 0), + VoeuAvecDistance( + voeu = + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + km = 0, + ), ), ), ) val voeuxParCommunesFavoritesFL0003 = listOf( CommuneAvecVoeuxAuxAlentours( - commune = SAINT_MALO, + communeFavorite = CommunesFavorites.SAINT_MALO, distances = listOf( - VoeuAvecDistance(voeu = Voeu(id = "ta17", nom = "Nom du ta17", commune = SAINT_MALO), km = 0), - VoeuAvecDistance(voeu = Voeu(id = "ta32", nom = "Nom du ta32", commune = CAEN), km = 120), + VoeuAvecDistance( + voeu = + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + km = 0, + ), + VoeuAvecDistance( + voeu = + Voeu( + id = "ta32", + nom = "Nom du ta32", + commune = CAEN, + latitude = 49.183334, + longitude = -0.350000, + ), + km = 120, + ), ), ), ) - val voeuxParCommunesFavorites = + val voeuxPossiblesPourLaFormationFL0001 = + listOf( + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + Voeu( + id = "ta1", + nom = "Nom du ta1", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta6", + nom = "Nom du ta6", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), + ) + val voeuxPossiblesPourLaFormationFL0003 = + listOf( + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta32", + nom = "Nom du ta32", + commune = CAEN, + latitude = 49.183334, + longitude = -0.350000, + ), + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), + ) + val informationsSurLesVoeuxEtLeursCommunesFL0001 = + InformationsSurLesVoeuxEtLeursCommunes( + voeux = voeuxPossiblesPourLaFormationFL0001, + communesTriees = listOf(SAINT_MALO, PARIS15EME, MARSEILLE), + voeuxParCommunesFavorites = voeuxParCommunesFavoritesFL0001, + ) + val informationsSurLesVoeuxEtLeursCommunesFL0003 = + InformationsSurLesVoeuxEtLeursCommunes( + voeux = voeuxPossiblesPourLaFormationFL0003, + communesTriees = listOf(SAINT_MALO, LYON, PARIS5EME, CAEN, MARSEILLE), + voeuxParCommunesFavorites = voeuxParCommunesFavoritesFL0003, + ) + val voeuxDesFormations = mapOf( - "fl0001" to voeuxParCommunesFavoritesFL0001, - "fl0003" to voeuxParCommunesFavoritesFL0003, + "fl0001" to informationsSurLesVoeuxEtLeursCommunesFL0001, + "fl0003" to informationsSurLesVoeuxEtLeursCommunesFL0003, ) + given( - recupererVoeuxDesCommunesFavoritesService.recupererVoeuxAutoursDeCommmunes( - listOf(SAINT_MALO), - voeuxDesFormations, + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererInformationsSurLesVoeuxEtLeursCommunes( + idsFormations = listOf("fl0001", "fl0003"), + profilEleve = profilEleve, + obsoletesInclus = true, ), - ).willReturn( - voeuxParCommunesFavorites, - ) + ).willReturn(voeuxDesFormations) given( calculDuTauxDAffiniteBuilder.calculDuTauxDAffinite( formationAvecLeurAffinite = formationsAvecAffinites, @@ -262,8 +353,7 @@ class RecupererFormationsServiceTest { statistiquesDesAdmis = statistiqueDesAdmisFL0001, tauxAffinite = 17, metiersTriesParAffinites = listOf(metier123, metier534), - voeux = voeuxPossiblesPourLaFormationFL0001, - voeuxParCommunesFavorites = voeuxParCommunesFavoritesFL0001, + informationsSurLesVoeuxEtLeursCommunes = informationsSurLesVoeuxEtLeursCommunesFL0001, explications = explicationsFL0001, apprentissage = true, ) @@ -281,8 +371,7 @@ class RecupererFormationsServiceTest { statistiquesDesAdmis = statistiqueDesAdmisFL0003, tauxAffinite = 87, metiersTriesParAffinites = listOf(metier234, metier534), - voeux = voeuxPossiblesPourLaFormationFL0003, - voeuxParCommunesFavorites = voeuxParCommunesFavoritesFL0003, + informationsSurLesVoeuxEtLeursCommunes = informationsSurLesVoeuxEtLeursCommunesFL0003, explications = explicationsFL0003, apprentissage = false, ) @@ -295,7 +384,7 @@ class RecupererFormationsServiceTest { val profilEleve = mock(ProfilEleve.AvecProfilExistant::class.java) given(profilEleve.baccalaureat).willReturn("Général") given(profilEleve.classe).willReturn(ChoixNiveau.TERMINALE) - given(profilEleve.communesFavorites).willReturn(listOf(CAEN)) + given(profilEleve.communesFavorites).willReturn(listOf(CommunesFavorites.CAEN)) val formationAvecSonAffinite1 = mock(FormationAvecSonAffinite::class.java) val formationAvecSonAffinite2 = mock(FormationAvecSonAffinite::class.java) val formationAvecSonAffinite3 = mock(FormationAvecSonAffinite::class.java) @@ -368,43 +457,73 @@ class RecupererFormationsServiceTest { ).willReturn(explications) val voeuxFL0001 = listOf( - Voeu(id = "ta1", nom = "Nom du ta1", commune = PARIS15EME), - Voeu(id = "ta17", nom = "Nom du ta17", commune = SAINT_MALO), - Voeu(id = "ta6", nom = "Nom du ta6", commune = MARSEILLE), + Voeu( + id = "ta1", + nom = "Nom du ta1", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + Voeu( + id = "ta6", + nom = "Nom du ta6", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), ) - val voeuxDesFormations = mapOf("fl0001" to voeuxFL0001) - given( - recupererVoeuxDUneFormationService.recupererVoeuxTriesParAffinites( - idsFormations = listOf("fl0001", "fl0003"), - profilEleve = profilEleve, - obsoletesInclus = true, - ), - ).willReturn(voeuxDesFormations) val voeuxParCommunesFavoritesFL0001 = listOf( CommuneAvecVoeuxAuxAlentours( - commune = CAEN, + communeFavorite = CommunesFavorites.CAEN, distances = listOf( VoeuAvecDistance( - voeu = Voeu(id = "ta17", nom = "Nom du ta17", commune = CAEN), + voeu = + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = CAEN, + latitude = 49.183334, + longitude = -0.350000, + ), km = 0, ), VoeuAvecDistance( - voeu = Voeu(id = "ta7", nom = "Nom du ta7", commune = SAINT_MALO), + voeu = + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), km = 120, ), ), ), ) + val informationsSurLesVoeuxEtLeursCommunesFL001 = + InformationsSurLesVoeuxEtLeursCommunes( + voeux = voeuxFL0001, + communesTriees = listOf(PARIS15EME, SAINT_MALO, MARSEILLE), + voeuxParCommunesFavorites = voeuxParCommunesFavoritesFL0001, + ) given( - recupererVoeuxDesCommunesFavoritesService.recupererVoeuxAutoursDeCommmunes( - listOf(CAEN), - voeuxDesFormations, + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererInformationsSurLesVoeuxEtLeursCommunes( + idsFormations = listOf("fl0001", "fl0003"), + profilEleve = profilEleve, + obsoletesInclus = true, ), - ).willReturn( - mapOf("fl0001" to voeuxParCommunesFavoritesFL0001), - ) + ).willReturn(mapOf("fl0001" to informationsSurLesVoeuxEtLeursCommunesFL001)) + given( calculDuTauxDAffiniteBuilder.calculDuTauxDAffinite( formationAvecLeurAffinite = formationsAvecAffinites, @@ -449,8 +568,7 @@ class RecupererFormationsServiceTest { statistiquesDesAdmis = statistiqueDesAdmisFL0001, tauxAffinite = 17, metiersTriesParAffinites = listOf(metier534), - voeux = voeuxFL0001, - voeuxParCommunesFavorites = voeuxParCommunesFavoritesFL0001, + informationsSurLesVoeuxEtLeursCommunes = informationsSurLesVoeuxEtLeursCommunesFL001, explications = explicationsFL0001, apprentissage = true, ) @@ -468,12 +586,22 @@ class RecupererFormationsServiceTest { statistiquesDesAdmis = null, tauxAffinite = 0, metiersTriesParAffinites = emptyList(), - voeux = emptyList(), - voeuxParCommunesFavorites = emptyList(), + informationsSurLesVoeuxEtLeursCommunes = + InformationsSurLesVoeuxEtLeursCommunes( + voeux = emptyList(), + communesTriees = emptyList(), + voeuxParCommunesFavorites = emptyList(), + ), explications = null, apprentissage = false, ) assertThat(resultat).usingRecursiveComparison().isEqualTo(listOf(ficheFormationFl0001, ficheFormationFl0003)) + then(logger).should().error( + type = "FORMATION_SANS_VOEUX", + message = "La formation fl0003 n'est pas présente dans la map des formations", + exception = null, + parametres = mapOf("idFormation" to "fl0003"), + ) } } @@ -552,21 +680,80 @@ class RecupererFormationsServiceTest { val voeuxPossiblesPourLaFormationFL0001 = listOf( - Voeu(id = "ta1", nom = "Nom du ta1", commune = PARIS15EME), - Voeu(id = "ta17", nom = "Nom du ta17", commune = SAINT_MALO), - Voeu(id = "ta6", nom = "Nom du ta6", commune = MARSEILLE), + Voeu( + id = "ta1", + nom = "Nom du ta1", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + Voeu( + id = "ta6", + nom = "Nom du ta6", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), ) val voeuxPossiblesPourLaFormationFL0003 = listOf( - Voeu(id = "ta10", nom = "Nom du ta10", commune = LYON), - Voeu(id = "ta3", nom = "Nom du ta3", commune = PARIS5EME), - Voeu(id = "ta11", nom = "Nom du ta11", commune = LYON), - Voeu(id = "ta32", nom = "Nom du ta32", commune = CAEN), - Voeu(id = "ta17", nom = "Nom du ta17", commune = SAINT_MALO), - Voeu(id = "ta7", nom = "Nom du ta7", commune = MARSEILLE), + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta32", + nom = "Nom du ta32", + commune = CAEN, + latitude = 49.183334, + longitude = -0.350000, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), ) val voeuxDesFormations = mapOf("fl0001" to voeuxPossiblesPourLaFormationFL0001, "fl0003" to voeuxPossiblesPourLaFormationFL0003) - given(recupererVoeuxDUneFormationService.recupererVoeux(idsFormations = listOf("fl0001", "fl0003"), true)).willReturn( + given( + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererVoeux( + idsFormations = listOf("fl0001", "fl0003"), + true, + ), + ).willReturn( voeuxDesFormations, ) @@ -676,12 +863,35 @@ class RecupererFormationsServiceTest { val voeuxPossiblesPourLaFormationFL0001 = listOf( - Voeu(id = "ta1", nom = "Nom du ta1", commune = PARIS15EME), - Voeu(id = "ta17", nom = "Nom du ta17", commune = SAINT_MALO), - Voeu(id = "ta6", nom = "Nom du ta6", commune = MARSEILLE), + Voeu( + id = "ta1", + nom = "Nom du ta1", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + Voeu( + id = "ta6", + nom = "Nom du ta6", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), ) val voeuxDesFormations = mapOf("fl0001" to voeuxPossiblesPourLaFormationFL0001) - given(recupererVoeuxDUneFormationService.recupererVoeux(idsFormations = listOf("fl0001", "fl0003"), true)).willReturn( + given( + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererVoeux( + idsFormations = listOf("fl0001", "fl0003"), + true, + ), + ).willReturn( voeuxDesFormations, ) diff --git a/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererInformationsSurLesVoeuxEtLeursCommunesFavoritesServiceTest.kt b/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererInformationsSurLesVoeuxEtLeursCommunesFavoritesServiceTest.kt new file mode 100644 index 000000000..a15ba405a --- /dev/null +++ b/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererInformationsSurLesVoeuxEtLeursCommunesFavoritesServiceTest.kt @@ -0,0 +1,1355 @@ +package fr.gouv.monprojetsup.formation.usecase + +import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve +import fr.gouv.monprojetsup.eleve.entity.CommunesFavorites +import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecIdsVoeuxAuxAlentours +import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecIdsVoeuxAuxAlentours.VoeuAvecDistance +import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecVoeuxAuxAlentours +import fr.gouv.monprojetsup.formation.domain.entity.FicheFormation.FicheFormationPourProfil.InformationsSurLesVoeuxEtLeursCommunes +import fr.gouv.monprojetsup.formation.domain.entity.Voeu +import fr.gouv.monprojetsup.formation.domain.port.CommunesAvecVoeuxAuxAlentoursRepository +import fr.gouv.monprojetsup.formation.domain.port.VoeuRepository +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.AJACCIO +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.BASTIA +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.FORT_DE_FRANCE +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.GRENOBLE +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.LYON +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.MARSEILLE +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.MONTREUIL +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.PARIS15EME +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.PARIS19EME +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.PARIS5EME +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.RENNES +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.SAINT_MALO +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.SAINT_PIERRE +import fr.gouv.monprojetsup.formation.entity.CommunesCourtes.STRASBOURG +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test +import org.mockito.BDDMockito.given +import org.mockito.BDDMockito.mock +import org.mockito.BDDMockito.then +import org.mockito.InjectMocks +import org.mockito.Mock +import org.mockito.MockitoAnnotations + +class RecupererInformationsSurLesVoeuxEtLeursCommunesFavoritesServiceTest { + @Mock + lateinit var voeuRepository: VoeuRepository + + @Mock + private lateinit var communesAvecVoeuxAuxAlentoursRepository: CommunesAvecVoeuxAuxAlentoursRepository + + @InjectMocks + lateinit var recupererInformationsSurLesVoeuxEtLeursCommunesService: RecupererInformationsSurLesVoeuxEtLeursCommunesService + + @Mock + private lateinit var profilEleve: ProfilEleve.AvecProfilExistant + + private val id = "f859056f-1f3b-49d4-96c8-2a93b925fbaa" + + @BeforeEach + fun setUp() { + MockitoAnnotations.openMocks(this) + given(profilEleve.id).willReturn(id) + } + + @Nested + inner class RecupererVoeuxPourUneFormation { + @Test + fun `les voeux doivent être retournés tels quels`() { + // Given + val ta1 = mock(Voeu::class.java) + val ta2 = mock(Voeu::class.java) + val ta3 = mock(Voeu::class.java) + given(voeuRepository.recupererLesVoeuxDUneFormation(idFormation = "fl2016", obsoletesInclus = true)).willReturn( + listOf(ta2, ta1, ta3), + ) + + // When + val result = + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererVoeux( + idFormation = "fl2016", + obsoletesInclus = true, + ) + + // Then + assertThat(result).isEqualTo(listOf(ta2, ta1, ta3)) + } + } + + @Nested + inner class RecupererVoeuxPourDesFormations { + @Test + fun `les voeux doivent être retournés tels quels`() { + // Given + val ta1 = mock(Voeu::class.java) + val ta2 = mock(Voeu::class.java) + val ta3 = mock(Voeu::class.java) + val voeux = + mapOf( + "fl2016" to listOf(ta2, ta1, ta3), + "fl2017" to emptyList(), + "fl2018" to listOf(ta1, ta2), + ) + given( + voeuRepository.recupererLesVoeuxDeFormations(idsFormations = listOf("fl2016", "fl2017", "fl2018"), true), + ).willReturn(voeux) + + // When + val result = + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererVoeux( + idsFormations = listOf("fl2016", "fl2017", "fl2018"), + obsoletesInclus = true, + ) + + // Then + assertThat(result).isEqualTo(voeux) + } + } + + @Nested + inner class RecupererInformationsSurLesVoeuxEtLeursCommunesFavoritesPourUneFormation { + private val voeux = + listOf( + Voeu( + id = "ta6", + nom = "Nom du ta6", + commune = FORT_DE_FRANCE, + latitude = 14.61852, + longitude = -61.04897, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = RENNES, + latitude = 48.117, + longitude = 1.677, + ), + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + Voeu( + id = "ta32", + nom = "Nom du ta32", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = PARIS19EME, + longitude = 2.393, + latitude = 48.889, + ), + Voeu( + id = "ta80", + nom = "Nom du ta80", + commune = BASTIA, + latitude = 42.6985, + longitude = 9.45098, + ), + ) + + @Test + fun `les communes doivent être ordonnées par affinités en plaçant en premier les communes favorites puis par distance`() { + // Given + val communes = + listOf(CommunesFavorites.LYON, CommunesFavorites.SAINT_MALO, CommunesFavorites.PARIS5EME, CommunesFavorites.GRENOBLE) + given(profilEleve.communesFavorites).willReturn(communes) + given(voeuRepository.recupererLesVoeuxDUneFormation(idFormation = "fl2016", obsoletesInclus = true)).willReturn(voeux) + val communesAvecIdsVoeuxAuxAlentours = + listOf( + CommuneAvecIdsVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.LYON, + distances = + listOf( + VoeuAvecDistance(idVoeu = "ta11", km = 0), + VoeuAvecDistance(idVoeu = "ta10", km = 0), + ), + ), + CommuneAvecIdsVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.SAINT_MALO, + distances = listOf(VoeuAvecDistance(idVoeu = "ta17", km = 77)), + ), + CommuneAvecIdsVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.PARIS5EME, + distances = + listOf( + VoeuAvecDistance(idVoeu = "ta3", km = 0), + VoeuAvecDistance(idVoeu = "ta32", km = 2), + VoeuAvecDistance(idVoeu = "ta7", km = 4), + ), + ), + CommuneAvecIdsVoeuxAuxAlentours(communeFavorite = CommunesFavorites.GRENOBLE, distances = emptyList()), + ) + given(communesAvecVoeuxAuxAlentoursRepository.recupererVoeuxAutoursDeCommmune(communes)).willReturn( + communesAvecIdsVoeuxAuxAlentours, + ) + + // When + val result = + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererInformationsSurLesVoeuxEtLeursCommunes( + idFormation = "fl2016", + profilEleve = profilEleve, + obsoletesInclus = true, + ) + + // Then + val voeuxTries = + listOf( + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + Voeu( + id = "ta32", + nom = "Nom du ta32", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = PARIS19EME, + longitude = 2.393, + latitude = 48.889, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = RENNES, + latitude = 48.117, + longitude = 1.677, + ), + Voeu( + id = "ta6", + nom = "Nom du ta6", + commune = FORT_DE_FRANCE, + latitude = 14.61852, + longitude = -61.04897, + ), + Voeu( + id = "ta80", + nom = "Nom du ta80", + commune = BASTIA, + latitude = 42.6985, + longitude = 9.45098, + ), + ) + val voeuxParCommunesFavorites = + listOf( + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.LYON, + distances = + listOf( + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + km = 0, + ), + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + km = 0, + ), + ), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.SAINT_MALO, + distances = + listOf( + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = RENNES, + latitude = 48.117, + longitude = 1.677, + ), + km = 77, + ), + ), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.PARIS5EME, + distances = + listOf( + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + km = 0, + ), + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta32", + nom = "Nom du ta32", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + km = 2, + ), + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = PARIS19EME, + longitude = 2.393, + latitude = 48.889, + ), + km = 4, + ), + ), + ), + CommuneAvecVoeuxAuxAlentours(communeFavorite = CommunesFavorites.GRENOBLE, distances = emptyList()), + ) + val attendu = + InformationsSurLesVoeuxEtLeursCommunes( + voeux = voeuxTries, + communesTriees = listOf(LYON, PARIS5EME, PARIS15EME, PARIS19EME, RENNES, FORT_DE_FRANCE, BASTIA), + voeuxParCommunesFavorites = voeuxParCommunesFavorites, + ) + assertThat(result).isEqualTo(attendu) + } + + @Test + fun `si la liste des communes favorites est vide, doit retourner la liste telle quelle`() { + // Given + given(profilEleve.communesFavorites).willReturn(emptyList()) + given(voeuRepository.recupererLesVoeuxDUneFormation(idFormation = "fl2016", obsoletesInclus = true)).willReturn(voeux) + + // When + val result = + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererInformationsSurLesVoeuxEtLeursCommunes( + idFormation = "fl2016", + profilEleve = profilEleve, + obsoletesInclus = true, + ) + + // Then + then(communesAvecVoeuxAuxAlentoursRepository).shouldHaveNoInteractions() + val attendu = + InformationsSurLesVoeuxEtLeursCommunes( + voeux = voeux, + communesTriees = listOf(FORT_DE_FRANCE, RENNES, LYON, PARIS5EME, PARIS15EME, PARIS19EME, BASTIA), + voeuxParCommunesFavorites = emptyList(), + ) + assertThat(result).isEqualTo(attendu) + } + + @Test + fun `si la liste des communes favorites est nulle, doit retourner la liste telle quelle`() { + // Given + given(profilEleve.communesFavorites).willReturn(null) + given(voeuRepository.recupererLesVoeuxDUneFormation(idFormation = "fl2016", obsoletesInclus = false)).willReturn(voeux) + + // When + val result = + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererInformationsSurLesVoeuxEtLeursCommunes( + idFormation = "fl2016", + profilEleve = profilEleve, + obsoletesInclus = false, + ) + + // Then + then(communesAvecVoeuxAuxAlentoursRepository).shouldHaveNoInteractions() + val attendu = + InformationsSurLesVoeuxEtLeursCommunes( + voeux = voeux, + communesTriees = listOf(FORT_DE_FRANCE, RENNES, LYON, PARIS5EME, PARIS15EME, PARIS19EME, BASTIA), + voeuxParCommunesFavorites = emptyList(), + ) + assertThat(result).isEqualTo(attendu) + } + } + + @Nested + inner class RecupererInformationsSurLesVoeuxEtLeursCommunesFavoritesPourDesFormations { + private val idsFormation = + listOf( + "fl680002", + "fr22", + "fl2009", + "fl2016", + "fl252", + ) + + private val voeux = + mapOf( + "fl680002" to + listOf( + Voeu( + id = "ta6", + nom = "Nom du ta6", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), + Voeu( + id = "ta1", + nom = "Nom du ta1", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + ), + "fr22" to + listOf( + Voeu( + id = "ta2", + nom = "Nom du ta2", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + ), + "fl2009" to + listOf( + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + Voeu( + id = "ta30", + nom = "Nom du ta30", + commune = AJACCIO, + latitude = 41.9267, + longitude = 8.73458, + ), + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = STRASBOURG, + longitude = 1.666667, + latitude = 50.266666, + ), + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + ), + "fl2016" to + listOf( + Voeu( + id = "ta4", + nom = "Nom du ta4", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), + Voeu( + id = "ta14", + nom = "Nom du ta14", + commune = FORT_DE_FRANCE, + latitude = 14.61852, + longitude = -61.04897, + ), + Voeu( + id = "ta15", + nom = "Nom du ta15", + commune = SAINT_PIERRE, + latitude = -21.29634, + longitude = 55.46069, + ), + ), + "fl252" to + listOf( + Voeu( + id = "ta8", + nom = "Nom du ta8", + commune = PARIS19EME, + longitude = 2.393, + latitude = 48.889, + ), + Voeu( + id = "ta5", + nom = "Nom du ta5", + commune = RENNES, + latitude = 48.117, + longitude = 1.677, + ), + Voeu( + id = "ta50", + nom = "Nom du ta50", + commune = BASTIA, + latitude = 42.6985, + longitude = 9.45098, + ), + Voeu( + id = "ta9", + nom = "Nom du ta9", + commune = MONTREUIL, + latitude = 48.861, + longitude = 2.443, + ), + ), + ) + + @BeforeEach + fun setUp() { + given(voeuRepository.recupererLesVoeuxDeFormations(idsFormation, true)).willReturn(voeux) + given(profilEleve.id).willReturn(id) + } + + @Test + fun `les communes doivent être ordonnées par affinités en plaçant en premier les communes favorites puis par distance`() { + // Given + val communesFavorites = + listOf( + CommunesFavorites.PARIS15EME, + CommunesFavorites.GRENOBLE, + CommunesFavorites.RENNES, + CommunesFavorites.FORT_DE_FRANCE, + CommunesFavorites.AJACCIO, + ) + given(profilEleve.communesFavorites).willReturn(communesFavorites) + val communesAvecIdsVoeuxAuxAlentours = + listOf( + CommuneAvecIdsVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.PARIS15EME, + distances = + listOf( + VoeuAvecDistance(idVoeu = "ta1", km = 0), + VoeuAvecDistance(idVoeu = "ta32", km = 0), + VoeuAvecDistance(idVoeu = "ta3", km = 1), + VoeuAvecDistance(idVoeu = "ta8", km = 3), + ), + ), + CommuneAvecIdsVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.GRENOBLE, + distances = emptyList(), + ), + CommuneAvecIdsVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.RENNES, + distances = + listOf( + VoeuAvecDistance(idVoeu = "ta17", km = 77), + VoeuAvecDistance(idVoeu = "ta5", km = 0), + ), + ), + CommuneAvecIdsVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.FORT_DE_FRANCE, + distances = + listOf( + VoeuAvecDistance(idVoeu = "ta14", km = 0), + ), + ), + CommuneAvecIdsVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.AJACCIO, + distances = + listOf( + VoeuAvecDistance(idVoeu = "ta30", km = 0), + VoeuAvecDistance(idVoeu = "ta50", km = 150), + ), + ), + ) + given( + communesAvecVoeuxAuxAlentoursRepository.recupererVoeuxAutoursDeCommmune(communesFavorites), + ).willReturn(communesAvecIdsVoeuxAuxAlentours) + + // When + val result = + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererInformationsSurLesVoeuxEtLeursCommunes( + idsFormations = idsFormation, + profilEleve = profilEleve, + obsoletesInclus = true, + ) + + // Then + val attendu = + mapOf( + "fl680002" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta1", + nom = "Nom du ta1", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + Voeu( + id = "ta6", + nom = "Nom du ta6", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), + ), + communesTriees = listOf(PARIS15EME, SAINT_MALO, MARSEILLE), + voeuxParCommunesFavorites = + listOf( + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.PARIS15EME, + distances = + listOf( + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta1", + nom = "Nom du ta1", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + km = 0, + ), + ), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.GRENOBLE, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.RENNES, + distances = + listOf( + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + km = 77, + ), + ), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.FORT_DE_FRANCE, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.AJACCIO, + distances = emptyList(), + ), + ), + ), + "fr22" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta2", + nom = "Nom du ta2", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + ), + communesTriees = listOf(LYON), + voeuxParCommunesFavorites = + listOf( + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.PARIS15EME, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.GRENOBLE, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.RENNES, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.FORT_DE_FRANCE, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.AJACCIO, + distances = emptyList(), + ), + ), + ), + "fl2009" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta30", + nom = "Nom du ta30", + commune = AJACCIO, + latitude = 41.9267, + longitude = 8.73458, + ), + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = STRASBOURG, + longitude = 1.666667, + latitude = 50.266666, + ), + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + ), + communesTriees = listOf(AJACCIO, PARIS5EME, LYON, STRASBOURG), + voeuxParCommunesFavorites = + listOf( + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.PARIS15EME, + distances = + listOf( + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + km = 1, + ), + ), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.GRENOBLE, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.RENNES, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.FORT_DE_FRANCE, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.AJACCIO, + distances = + listOf( + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta30", + nom = "Nom du ta30", + commune = AJACCIO, + latitude = 41.9267, + longitude = 8.73458, + ), + km = 0, + ), + ), + ), + ), + ), + "fl2016" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta14", + nom = "Nom du ta14", + commune = FORT_DE_FRANCE, + latitude = 14.61852, + longitude = -61.04897, + ), + Voeu( + id = "ta4", + nom = "Nom du ta4", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), + Voeu( + id = "ta15", + nom = "Nom du ta15", + commune = SAINT_PIERRE, + latitude = -21.29634, + longitude = 55.46069, + ), + ), + communesTriees = listOf(FORT_DE_FRANCE, MARSEILLE, SAINT_PIERRE), + voeuxParCommunesFavorites = + listOf( + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.PARIS15EME, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.GRENOBLE, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.RENNES, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.FORT_DE_FRANCE, + distances = + listOf( + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta14", + nom = "Nom du ta14", + commune = FORT_DE_FRANCE, + latitude = 14.61852, + longitude = -61.04897, + ), + km = 0, + ), + ), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.AJACCIO, + distances = emptyList(), + ), + ), + ), + "fl252" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta5", + nom = "Nom du ta5", + commune = RENNES, + latitude = 48.117, + longitude = 1.677, + ), + Voeu( + id = "ta8", + nom = "Nom du ta8", + commune = PARIS19EME, + longitude = 2.393, + latitude = 48.889, + ), + Voeu( + id = "ta50", + nom = "Nom du ta50", + commune = BASTIA, + latitude = 42.6985, + longitude = 9.45098, + ), + Voeu( + id = "ta9", + nom = "Nom du ta9", + commune = MONTREUIL, + latitude = 48.861, + longitude = 2.443, + ), + ), + communesTriees = listOf(RENNES, PARIS19EME, BASTIA, MONTREUIL), + voeuxParCommunesFavorites = + listOf( + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.PARIS15EME, + distances = + listOf( + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta8", + nom = "Nom du ta8", + commune = PARIS19EME, + longitude = 2.393, + latitude = 48.889, + ), + km = 3, + ), + ), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.GRENOBLE, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.RENNES, + distances = + listOf( + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta5", + nom = "Nom du ta5", + commune = RENNES, + latitude = 48.117, + longitude = 1.677, + ), + km = 0, + ), + ), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.FORT_DE_FRANCE, + distances = emptyList(), + ), + CommuneAvecVoeuxAuxAlentours( + communeFavorite = CommunesFavorites.AJACCIO, + distances = + listOf( + CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( + voeu = + Voeu( + id = "ta50", + nom = "Nom du ta50", + commune = BASTIA, + latitude = 42.6985, + longitude = 9.45098, + ), + km = 150, + ), + ), + ), + ), + ), + ) + assertThat(result).isEqualTo(attendu) + } + + @Test + fun `si la liste des communes favorites est vide, doit retourner la liste telle quelle`() { + // Given + given(profilEleve.communesFavorites).willReturn(emptyList()) + + // When + val result = + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererInformationsSurLesVoeuxEtLeursCommunes( + idsFormations = idsFormation, + profilEleve = profilEleve, + obsoletesInclus = true, + ) + + // Then + val attendu = + mapOf( + "fl680002" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta6", + nom = "Nom du ta6", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), + Voeu( + id = "ta1", + nom = "Nom du ta1", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + ), + communesTriees = listOf(MARSEILLE, PARIS15EME, SAINT_MALO), + voeuxParCommunesFavorites = emptyList(), + ), + "fr22" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta2", + nom = "Nom du ta2", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + ), + communesTriees = listOf(LYON), + voeuxParCommunesFavorites = emptyList(), + ), + "fl2009" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + Voeu( + id = "ta30", + nom = "Nom du ta30", + commune = AJACCIO, + latitude = 41.9267, + longitude = 8.73458, + ), + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = STRASBOURG, + longitude = 1.666667, + latitude = 50.266666, + ), + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + ), + communesTriees = listOf(LYON, PARIS5EME, AJACCIO, STRASBOURG), + voeuxParCommunesFavorites = emptyList(), + ), + "fl2016" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta4", + nom = "Nom du ta4", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), + Voeu( + id = "ta14", + nom = "Nom du ta14", + commune = FORT_DE_FRANCE, + latitude = 14.61852, + longitude = -61.04897, + ), + Voeu( + id = "ta15", + nom = "Nom du ta15", + commune = SAINT_PIERRE, + latitude = -21.29634, + longitude = 55.46069, + ), + ), + communesTriees = listOf(MARSEILLE, FORT_DE_FRANCE, SAINT_PIERRE), + voeuxParCommunesFavorites = emptyList(), + ), + "fl252" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta8", + nom = "Nom du ta8", + commune = PARIS19EME, + longitude = 2.393, + latitude = 48.889, + ), + Voeu( + id = "ta5", + nom = "Nom du ta5", + commune = RENNES, + latitude = 48.117, + longitude = 1.677, + ), + Voeu( + id = "ta50", + nom = "Nom du ta50", + commune = BASTIA, + latitude = 42.6985, + longitude = 9.45098, + ), + Voeu( + id = "ta9", + nom = "Nom du ta9", + commune = MONTREUIL, + latitude = 48.861, + longitude = 2.443, + ), + ), + communesTriees = listOf(PARIS19EME, RENNES, BASTIA, MONTREUIL), + voeuxParCommunesFavorites = emptyList(), + ), + ) + assertThat(result).isEqualTo(attendu) + } + + @Test + fun `si la liste des communes favorites est nulle, doit retourner la liste telle quelle`() { + // Given + given(profilEleve.communesFavorites).willReturn(null) + + // When + val result = + recupererInformationsSurLesVoeuxEtLeursCommunesService.recupererInformationsSurLesVoeuxEtLeursCommunes( + idsFormations = idsFormation, + profilEleve = profilEleve, + obsoletesInclus = true, + ) + + // Then + val attendu = + mapOf( + "fl680002" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta6", + nom = "Nom du ta6", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), + Voeu( + id = "ta1", + nom = "Nom du ta1", + commune = PARIS15EME, + longitude = 2.2885659, + latitude = 48.851227, + ), + Voeu( + id = "ta17", + nom = "Nom du ta17", + commune = SAINT_MALO, + latitude = 48.6571, + longitude = -1.96914, + ), + ), + communesTriees = listOf(MARSEILLE, PARIS15EME, SAINT_MALO), + voeuxParCommunesFavorites = emptyList(), + ), + "fr22" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta2", + nom = "Nom du ta2", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + ), + communesTriees = listOf(LYON), + voeuxParCommunesFavorites = emptyList(), + ), + "fl2009" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta10", + nom = "Nom du ta10", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + Voeu( + id = "ta3", + nom = "Nom du ta3", + commune = PARIS5EME, + longitude = 2.344, + latitude = 48.846, + ), + Voeu( + id = "ta30", + nom = "Nom du ta30", + commune = AJACCIO, + latitude = 41.9267, + longitude = 8.73458, + ), + Voeu( + id = "ta7", + nom = "Nom du ta7", + commune = STRASBOURG, + longitude = 1.666667, + latitude = 50.266666, + ), + Voeu( + id = "ta11", + nom = "Nom du ta11", + commune = LYON, + latitude = 45.75, + longitude = 4.85, + ), + ), + communesTriees = listOf(LYON, PARIS5EME, AJACCIO, STRASBOURG), + voeuxParCommunesFavorites = emptyList(), + ), + "fl2016" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta4", + nom = "Nom du ta4", + commune = MARSEILLE, + latitude = 43.300000, + longitude = 5.400000, + ), + Voeu( + id = "ta14", + nom = "Nom du ta14", + commune = FORT_DE_FRANCE, + latitude = 14.61852, + longitude = -61.04897, + ), + Voeu( + id = "ta15", + nom = "Nom du ta15", + commune = SAINT_PIERRE, + latitude = -21.29634, + longitude = 55.46069, + ), + ), + communesTriees = listOf(MARSEILLE, FORT_DE_FRANCE, SAINT_PIERRE), + voeuxParCommunesFavorites = emptyList(), + ), + "fl252" to + InformationsSurLesVoeuxEtLeursCommunes( + voeux = + listOf( + Voeu( + id = "ta8", + nom = "Nom du ta8", + commune = PARIS19EME, + longitude = 2.393, + latitude = 48.889, + ), + Voeu( + id = "ta5", + nom = "Nom du ta5", + commune = RENNES, + latitude = 48.117, + longitude = 1.677, + ), + Voeu( + id = "ta50", + nom = "Nom du ta50", + commune = BASTIA, + latitude = 42.6985, + longitude = 9.45098, + ), + Voeu( + id = "ta9", + nom = "Nom du ta9", + commune = MONTREUIL, + latitude = 48.861, + longitude = 2.443, + ), + ), + communesTriees = listOf(PARIS19EME, RENNES, BASTIA, MONTREUIL), + voeuxParCommunesFavorites = emptyList(), + ), + ) + assertThat(result).isEqualTo(attendu) + } + } +} diff --git a/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererVoeuxDUneFormationServiceTest.kt b/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererVoeuxDUneFormationServiceTest.kt deleted file mode 100644 index 4fc34adad..000000000 --- a/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererVoeuxDUneFormationServiceTest.kt +++ /dev/null @@ -1,384 +0,0 @@ -package fr.gouv.monprojetsup.formation.usecase - -import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve -import fr.gouv.monprojetsup.eleve.domain.entity.Commune -import fr.gouv.monprojetsup.formation.domain.entity.Voeu -import fr.gouv.monprojetsup.formation.domain.port.VoeuRepository -import fr.gouv.monprojetsup.formation.entity.Communes.AJACCIO -import fr.gouv.monprojetsup.formation.entity.Communes.BASTIA -import fr.gouv.monprojetsup.formation.entity.Communes.FORT_DE_FRANCE -import fr.gouv.monprojetsup.formation.entity.Communes.GRENOBLE -import fr.gouv.monprojetsup.formation.entity.Communes.LYON -import fr.gouv.monprojetsup.formation.entity.Communes.MARSEILLE -import fr.gouv.monprojetsup.formation.entity.Communes.MONTREUIL -import fr.gouv.monprojetsup.formation.entity.Communes.PARIS15EME -import fr.gouv.monprojetsup.formation.entity.Communes.PARIS19EME -import fr.gouv.monprojetsup.formation.entity.Communes.PARIS5EME -import fr.gouv.monprojetsup.formation.entity.Communes.RENNES -import fr.gouv.monprojetsup.formation.entity.Communes.SAINT_MALO -import fr.gouv.monprojetsup.formation.entity.Communes.SAINT_PIERRE -import fr.gouv.monprojetsup.formation.entity.Communes.STRASBOURG -import fr.gouv.monprojetsup.logging.MonProjetSupLogger -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -import org.mockito.BDDMockito.given -import org.mockito.BDDMockito.mock -import org.mockito.BDDMockito.then -import org.mockito.BDDMockito.times -import org.mockito.InjectMocks -import org.mockito.Mock -import org.mockito.MockitoAnnotations - -class RecupererVoeuxDUneFormationServiceTest { - @Mock - lateinit var voeuRepository: VoeuRepository - - @Mock - lateinit var logger: MonProjetSupLogger - - @InjectMocks - lateinit var recupererVoeuxDUneFormationService: RecupererVoeuxDUneFormationService - - @Mock - private lateinit var profilEleve: ProfilEleve.AvecProfilExistant - - private val id = "f859056f-1f3b-49d4-96c8-2a93b925fbaa" - - @BeforeEach - fun setUp() { - MockitoAnnotations.openMocks(this) - given(profilEleve.id).willReturn(id) - } - - @Nested - inner class RecupererVoeuxTriesParAffinitesPourDesFormations { - private val idsFormation = - listOf( - "fl680002", - "fr22", - "fl2009", - "fl2016", - "fl252", - ) - - private val voeux = - mapOf( - "fl680002" to - listOf( - Voeu(id = "ta6", nom = "Nom du ta6", commune = MARSEILLE), - Voeu(id = "ta1", nom = "Nom du ta1", commune = PARIS15EME), - Voeu(id = "ta17", nom = "Nom du ta17", commune = SAINT_MALO), - ), - "fr22" to - listOf( - Voeu(id = "ta2", nom = "Nom du ta2", commune = LYON), - ), - "fl2009" to - listOf( - Voeu(id = "ta10", nom = "Nom du ta10", commune = LYON), - Voeu(id = "ta3", nom = "Nom du ta3", commune = PARIS5EME), - Voeu(id = "ta3", nom = "Nom du ta30", commune = AJACCIO), - Voeu(id = "ta7", nom = "Nom du ta7", commune = STRASBOURG), - Voeu(id = "ta11", nom = "Nom du ta11", commune = LYON), - ), - "fl2016" to - listOf( - Voeu(id = "ta4", nom = "Nom du ta4", commune = MARSEILLE), - Voeu(id = "ta4", nom = "Nom du ta14", commune = FORT_DE_FRANCE), - Voeu(id = "ta4", nom = "Nom du ta15", commune = SAINT_PIERRE), - ), - "fl252" to - listOf( - Voeu(id = "ta8", nom = "Nom du ta8", commune = PARIS19EME), - Voeu(id = "ta5", nom = "Nom du ta5", commune = RENNES), - Voeu(id = "ta5", nom = "Nom du ta50", commune = BASTIA), - Voeu(id = "ta9", nom = "Nom du ta9", commune = MONTREUIL), - ), - ) - - @BeforeEach - fun setUp() { - given(voeuRepository.recupererLesVoeuxDeFormations(idsFormation, true)).willReturn(voeux) - given(profilEleve.id).willReturn(id) - } - - @Test - fun `les communes doivent être ordonnées par affinités en mettant en premiers les villes exactes, puis les départements`() { - // Given - given(profilEleve.communesFavorites).willReturn(listOf(PARIS15EME, RENNES, FORT_DE_FRANCE, AJACCIO)) - - // When - val result = - recupererVoeuxDUneFormationService.recupererVoeuxTriesParAffinites( - idsFormation, - profilEleve, - true, - ) - - // Then - assertThat(result).isEqualTo( - mapOf( - "fl680002" to - listOf( - Voeu(id = "ta1", nom = "Nom du ta1", commune = PARIS15EME), - Voeu(id = "ta17", nom = "Nom du ta17", commune = SAINT_MALO), - Voeu(id = "ta6", nom = "Nom du ta6", commune = MARSEILLE), - ), - "fr22" to - listOf( - Voeu(id = "ta2", nom = "Nom du ta2", commune = LYON), - ), - "fl2009" to - listOf( - Voeu(id = "ta3", nom = "Nom du ta30", commune = AJACCIO), - Voeu(id = "ta3", nom = "Nom du ta3", commune = PARIS5EME), - Voeu(id = "ta10", nom = "Nom du ta10", commune = LYON), - Voeu(id = "ta7", nom = "Nom du ta7", commune = STRASBOURG), - Voeu(id = "ta11", nom = "Nom du ta11", commune = LYON), - ), - "fl2016" to - listOf( - Voeu(id = "ta4", nom = "Nom du ta14", commune = FORT_DE_FRANCE), - Voeu(id = "ta4", nom = "Nom du ta4", commune = MARSEILLE), - Voeu(id = "ta4", nom = "Nom du ta15", commune = SAINT_PIERRE), - ), - "fl252" to - listOf( - Voeu(id = "ta5", nom = "Nom du ta5", commune = RENNES), - Voeu(id = "ta8", nom = "Nom du ta8", commune = PARIS19EME), - Voeu(id = "ta5", nom = "Nom du ta50", commune = BASTIA), - Voeu(id = "ta9", nom = "Nom du ta9", commune = MONTREUIL), - ), - ), - ) - } - - @Test - fun `si la liste des communes favorites est vide, doit retourner la liste telle quelle`() { - // Given - given(profilEleve.communesFavorites).willReturn(emptyList()) - val idsFormation = - listOf( - "fl680002", - "fr22", - "fl2009", - "fl2016", - "fl252", - ) - - // When - val result = - recupererVoeuxDUneFormationService.recupererVoeuxTriesParAffinites( - idsFormation, - profilEleve, - true, - ) - - // Then - assertThat(result).isEqualTo(voeux) - } - - @Test - fun `si la liste des communes favorites est nulle, doit retourner la liste telle quelle`() { - // Given - given(profilEleve.communesFavorites).willReturn(null) - - // When - val result = - recupererVoeuxDUneFormationService.recupererVoeuxTriesParAffinites( - idsFormation, - profilEleve, - true, - ) - - // Then - assertThat(result).isEqualTo(voeux) - } - - @Test - fun `si une des communes favorites a un code commune non valable, doit logguer un warning`() { - // Given - val communeInconnue = Commune(codeInsee = "Paris", nom = "Paris", latitude = 0.0, longitude = 0.0) - given(profilEleve.communesFavorites).willReturn(listOf(communeInconnue, RENNES)) - - // When - recupererVoeuxDUneFormationService.recupererVoeuxTriesParAffinites(idsFormation, profilEleve, true) - - // Then - then(logger).should(times(1)) - .warn( - type = "CODE_INSEE_NON_RECONNU_DANS_PROFIL", - message = - "La commune Paris présente dans le profil de l'élève f859056f-1f3b-49d4-96c8-2a93b925fbaa " + - "a un code commune non standard : Paris", - parametres = mapOf("nomCommune" to "Paris", "codeInsee" to "Paris"), - ) - } - - @Test - fun `si une des communes d'un voeu a un code commune non valable, doit logguer un warning`() { - // Given - val communeInconnue = Commune(codeInsee = "1", nom = "Paris", latitude = 0.0, longitude = 0.0) - given(voeuRepository.recupererLesVoeuxDeFormations(idsFormation, true)).willReturn( - mapOf( - "fl0001" to - listOf( - Voeu(id = "ta6", nom = "Nom du ta6", commune = MARSEILLE), - Voeu(id = "ta1", nom = "Nom du ta1", commune = communeInconnue), - Voeu(id = "ta17", nom = "Nom du ta17", commune = SAINT_MALO), - ), - ), - ) - given(profilEleve.communesFavorites).willReturn(listOf(PARIS15EME, RENNES)) - - // When - recupererVoeuxDUneFormationService.recupererVoeuxTriesParAffinites(idsFormation, profilEleve, true) - - // Then - then(logger).should(times(1)) - .warn( - type = "CODE_INSEE_NON_RECONNU_SUR_VOEU", - message = "La commune du voeu ta1 a un code commune non standard : 1", - parametres = mapOf("idVoeu" to "ta1", "codeInsee" to "1"), - ) - } - } - - @Nested - inner class RecupererVoeuxTriesParAffinitesPourUneFormation { - private val voeux = - listOf( - Voeu(id = "ta17", nom = "Nom du ta17", commune = STRASBOURG), - Voeu(id = "ta10", nom = "Nom du ta10", commune = LYON), - Voeu(id = "ta3", nom = "Nom du ta3", commune = PARIS5EME), - Voeu(id = "ta32", nom = "Nom du ta32", commune = PARIS15EME), - Voeu(id = "ta11", nom = "Nom du ta11", commune = LYON), - Voeu(id = "ta7", nom = "Nom du ta7", commune = MARSEILLE), - ) - - @Test - fun `les communes doivent être ordonnées par affinités en mettant en premiers les communes exactes, puis les départements`() { - // Given - given(profilEleve.communesFavorites).willReturn(listOf(LYON, GRENOBLE, PARIS5EME)) - given(voeuRepository.recupererLesVoeuxDUneFormation(idFormation = "fl2016")).willReturn( - voeux, - ) - - // When - val result = - recupererVoeuxDUneFormationService.recupererVoeuxTriesParAffinites( - idFormation = "fl2016", - profilEleve = profilEleve, - obsoletesInclus = true, - ) - - // Then - assertThat(result).isEqualTo( - listOf( - Voeu(id = "ta10", nom = "Nom du ta10", commune = LYON), - Voeu(id = "ta3", nom = "Nom du ta3", commune = PARIS5EME), - Voeu(id = "ta11", nom = "Nom du ta11", commune = LYON), - Voeu(id = "ta32", nom = "Nom du ta32", commune = PARIS15EME), - Voeu(id = "ta17", nom = "Nom du ta17", commune = STRASBOURG), - Voeu(id = "ta7", nom = "Nom du ta7", commune = MARSEILLE), - ), - ) - } - - @Test - fun `si la liste des communes favorites est vide, doit retourner la liste telle quelle`() { - // Given - given(profilEleve.communesFavorites).willReturn(emptyList()) - given(voeuRepository.recupererLesVoeuxDUneFormation(idFormation = "fl2016")).willReturn( - voeux, - ) - - // When - val result = - recupererVoeuxDUneFormationService.recupererVoeuxTriesParAffinites( - idFormation = "fl2016", - profilEleve = profilEleve, - obsoletesInclus = true, - ) - - // Then - assertThat(result).isEqualTo(voeux) - } - - @Test - fun `si la liste des communes favorites est nulle, doit retourner la liste telle quelle`() { - // Given - given(profilEleve.communesFavorites).willReturn(null) - given(voeuRepository.recupererLesVoeuxDUneFormation(idFormation = "fl2016")).willReturn( - voeux, - ) - - // When - val result = - recupererVoeuxDUneFormationService.recupererVoeuxTriesParAffinites( - idFormation = "fl2016", - profilEleve = profilEleve, - obsoletesInclus = true, - ) - - // Then - assertThat(result).isEqualTo(voeux) - } - } - - @Nested - inner class RecupererVoeuxPourUneFormation { - @Test - fun `les voeux doivent être retournés tels quels`() { - // Given - val ta1 = mock(Voeu::class.java) - val ta2 = mock(Voeu::class.java) - val ta3 = mock(Voeu::class.java) - given(voeuRepository.recupererLesVoeuxDUneFormation(idFormation = "fl2016")).willReturn( - listOf(ta2, ta1, ta3), - ) - - // When - val result = - recupererVoeuxDUneFormationService.recupererVoeux( - idFormation = "fl2016", - obsoletesInclus = true, - ) - - // Then - assertThat(result).isEqualTo(listOf(ta2, ta1, ta3)) - } - } - - @Nested - inner class RecupererVoeuxPourDesFormations { - @Test - fun `les voeux doivent être retournés tels quels`() { - // Given - val ta1 = mock(Voeu::class.java) - val ta2 = mock(Voeu::class.java) - val ta3 = mock(Voeu::class.java) - val voeux = - mapOf( - "fl2016" to listOf(ta2, ta1, ta3), - "fl2017" to emptyList(), - "fl2018" to listOf(ta1, ta2), - ) - given( - voeuRepository.recupererLesVoeuxDeFormations(idsFormations = listOf("fl2016", "fl2017", "fl2018"), true), - ).willReturn(voeux) - - // When - val result = - recupererVoeuxDUneFormationService.recupererVoeux( - idsFormations = listOf("fl2016", "fl2017", "fl2018"), - obsoletesInclus = true, - ) - - // Then - assertThat(result).isEqualTo(voeux) - } - } -} diff --git a/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererVoeuxDesCommunesFavoritesServiceTest.kt b/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererVoeuxDesCommunesFavoritesServiceTest.kt deleted file mode 100644 index 390de29df..000000000 --- a/app/back/src/test/fr/gouv/monprojetsup/formation/usecase/RecupererVoeuxDesCommunesFavoritesServiceTest.kt +++ /dev/null @@ -1,265 +0,0 @@ -package fr.gouv.monprojetsup.formation.usecase - -import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecIdsVoeuxAuxAlentours -import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecIdsVoeuxAuxAlentours.VoeuAvecDistance -import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecVoeuxAuxAlentours -import fr.gouv.monprojetsup.formation.domain.entity.Voeu -import fr.gouv.monprojetsup.formation.domain.port.CommunesAvecVoeuxAuxAlentoursRepository -import fr.gouv.monprojetsup.formation.entity.Communes.CAEN -import fr.gouv.monprojetsup.formation.entity.Communes.MONTREUIL -import fr.gouv.monprojetsup.formation.entity.Communes.PARIS5EME -import fr.gouv.monprojetsup.formation.entity.Communes.RENNES -import fr.gouv.monprojetsup.formation.entity.Communes.SAINT_MALO -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Nested -import org.junit.jupiter.api.Test -import org.mockito.BDDMockito.given -import org.mockito.InjectMocks -import org.mockito.Mock -import org.mockito.MockitoAnnotations - -class RecupererVoeuxDesCommunesFavoritesServiceTest { - @Mock - private lateinit var voeuxParVilleRepository: CommunesAvecVoeuxAuxAlentoursRepository - - @InjectMocks - private lateinit var recupererVoeuxDesCommunesFavoritesService: RecupererVoeuxDesCommunesFavoritesService - - @BeforeEach - fun setup() { - MockitoAnnotations.openMocks(this) - } - - @Nested - inner class RecupererVoeuxAutoursDeCommmunesDUneFormation { - @Test - fun `doit filtrer sur les voeux de la formation`() { - // Given - val communes = listOf(SAINT_MALO, MONTREUIL, CAEN, PARIS5EME) - val voeuxDeLaFormation = - listOf( - Voeu(id = "ta256", nom = "Nom du ta256", commune = RENNES), - Voeu(id = "ta33", nom = "Nom du ta33", commune = RENNES), - Voeu(id = "ta77", nom = "Nom du ta77", commune = RENNES), - ) - - val communeAvecIdsVoeuxAuxAlentours = - listOf( - CommuneAvecIdsVoeuxAuxAlentours( - commune = SAINT_MALO, - distances = - listOf( - VoeuAvecDistance(idVoeu = "ta60", km = 66), - VoeuAvecDistance(idVoeu = "ta77", km = 66), - VoeuAvecDistance(idVoeu = "ta480", km = 66), - ), - ), - CommuneAvecIdsVoeuxAuxAlentours(commune = MONTREUIL, distances = emptyList()), - CommuneAvecIdsVoeuxAuxAlentours( - commune = CAEN, - distances = - listOf( - VoeuAvecDistance(idVoeu = "ta33", km = 52), - VoeuAvecDistance(idVoeu = "ta256", km = 52), - ), - ), - CommuneAvecIdsVoeuxAuxAlentours(commune = PARIS5EME, distances = emptyList()), - ) - given(voeuxParVilleRepository.recupererVoeuxAutoursDeCommmune(communes)).willReturn(communeAvecIdsVoeuxAuxAlentours) - - // When - val resultat = - recupererVoeuxDesCommunesFavoritesService.recupererVoeuxAutoursDeCommmunes( - communes = communes, - voeuxDeLaFormation = voeuxDeLaFormation, - ) - - // Then - val attendu = - listOf( - CommuneAvecVoeuxAuxAlentours( - commune = SAINT_MALO, - distances = - listOf( - CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( - voeu = Voeu(id = "ta77", nom = "Nom du ta77", commune = RENNES), - km = 66, - ), - ), - ), - CommuneAvecVoeuxAuxAlentours(MONTREUIL, distances = emptyList()), - CommuneAvecVoeuxAuxAlentours( - commune = CAEN, - distances = - listOf( - CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( - voeu = Voeu(id = "ta33", nom = "Nom du ta33", commune = RENNES), - km = 52, - ), - CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( - voeu = Voeu(id = "ta256", nom = "Nom du ta256", commune = RENNES), - km = 52, - ), - ), - ), - CommuneAvecVoeuxAuxAlentours(PARIS5EME, distances = emptyList()), - ) - assertThat(resultat).isEqualTo(attendu) - } - } - - @Nested - inner class RecupererVoeuxAutoursDeCommmunesDeFormations { - @Test - fun `doit filtrer sur les voeux des formations`() { - // Given - val communes = listOf(SAINT_MALO, MONTREUIL, CAEN, PARIS5EME) - val voeuxDeLaFormation = - mapOf( - "fl0001" to - listOf( - Voeu(id = "ta256", nom = "Nom du ta256", commune = RENNES), - Voeu(id = "ta33", nom = "Nom du ta33", commune = RENNES), - Voeu(id = "ta77", nom = "Nom du ta77", commune = RENNES), - ), - "fl0003" to emptyList(), - "fl0004" to - listOf( - Voeu(id = "ta480", nom = "Nom du ta480", commune = PARIS5EME), - Voeu(id = "ta256", nom = "Nom du ta256", commune = RENNES), - ), - ) - - val communeAvecIdsVoeuxAuxAlentours = - listOf( - CommuneAvecIdsVoeuxAuxAlentours( - commune = SAINT_MALO, - distances = - listOf( - VoeuAvecDistance(idVoeu = "ta60", km = 66), - VoeuAvecDistance(idVoeu = "ta77", km = 66), - VoeuAvecDistance(idVoeu = "ta480", km = 66), - ), - ), - CommuneAvecIdsVoeuxAuxAlentours(commune = MONTREUIL, distances = emptyList()), - CommuneAvecIdsVoeuxAuxAlentours( - commune = CAEN, - distances = - listOf( - VoeuAvecDistance(idVoeu = "ta33", km = 52), - VoeuAvecDistance(idVoeu = "ta256", km = 52), - VoeuAvecDistance(idVoeu = "ta480", km = 12), - ), - ), - CommuneAvecIdsVoeuxAuxAlentours(commune = PARIS5EME, distances = emptyList()), - ) - given(voeuxParVilleRepository.recupererVoeuxAutoursDeCommmune(communes)).willReturn(communeAvecIdsVoeuxAuxAlentours) - - // When - val resultat = - recupererVoeuxDesCommunesFavoritesService.recupererVoeuxAutoursDeCommmunes( - communes = communes, - voeuxDeLaFormation = voeuxDeLaFormation, - ) - - // Then - val attendu = - mapOf( - "fl0001" to - listOf( - CommuneAvecVoeuxAuxAlentours( - commune = SAINT_MALO, - distances = - listOf( - CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( - voeu = Voeu(id = "ta77", nom = "Nom du ta77", commune = RENNES), - km = 66, - ), - ), - ), - CommuneAvecVoeuxAuxAlentours(MONTREUIL, distances = emptyList()), - CommuneAvecVoeuxAuxAlentours( - commune = CAEN, - distances = - listOf( - CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( - voeu = Voeu(id = "ta33", nom = "Nom du ta33", commune = RENNES), - km = 52, - ), - CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( - voeu = Voeu(id = "ta256", nom = "Nom du ta256", commune = RENNES), - km = 52, - ), - ), - ), - CommuneAvecVoeuxAuxAlentours(PARIS5EME, distances = emptyList()), - ), - "fl0003" to - listOf( - CommuneAvecVoeuxAuxAlentours( - commune = SAINT_MALO, - distances = emptyList(), - ), - CommuneAvecVoeuxAuxAlentours( - commune = MONTREUIL, - distances = emptyList(), - ), - CommuneAvecVoeuxAuxAlentours( - commune = CAEN, - distances = emptyList(), - ), - CommuneAvecVoeuxAuxAlentours( - commune = PARIS5EME, - distances = emptyList(), - ), - ), - "fl0004" to - listOf( - CommuneAvecVoeuxAuxAlentours( - commune = SAINT_MALO, - distances = - listOf( - CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( - voeu = - Voeu( - id = "ta480", - nom = "Nom du ta480", - commune = PARIS5EME, - ), - km = 66, - ), - ), - ), - CommuneAvecVoeuxAuxAlentours(commune = MONTREUIL, distances = listOf()), - CommuneAvecVoeuxAuxAlentours( - commune = CAEN, - distances = - listOf( - CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( - voeu = - Voeu( - id = "ta256", - nom = "Nom du ta256", - commune = RENNES, - ), - km = 52, - ), - CommuneAvecVoeuxAuxAlentours.VoeuAvecDistance( - voeu = - Voeu( - id = "ta480", - nom = "Nom du ta480", - commune = PARIS5EME, - ), - km = 12, - ), - ), - ), - CommuneAvecVoeuxAuxAlentours(commune = PARIS5EME, distances = listOf()), - ), - ) - assertThat(resultat).isEqualTo(attendu) - } - } -} diff --git a/app/etl/etl-common/src/main/java/fr/gouv/monprojetsup/data/Constants.java b/app/etl/etl-common/src/main/java/fr/gouv/monprojetsup/data/Constants.java index aa68bd6d1..4b60f93bd 100644 --- a/app/etl/etl-common/src/main/java/fr/gouv/monprojetsup/data/Constants.java +++ b/app/etl/etl-common/src/main/java/fr/gouv/monprojetsup/data/Constants.java @@ -12,6 +12,7 @@ public class Constants { public static final String LABEL_ARTICLE_PAS_LAS = "Les études de santé"; public static final String PAS_LAS_TEXT = "

Pour accéder aux études de santé (maïeutique, médecine, odontologie et pharmacie), les lycéens doivent suivre le PASS (parcours d'accès spécifique santé) ou une L.AS (licence avec option accès santé) à l'université et réussir aux sélections organisées à l'issue.

"; public static final String NEW_ONISEP_METIERS_SLUG_PREFIX = "https://explorer-avenirs.onisep.fr/http/redirection/metier/slug/"; + public static final String AVENIRS_FORMATION_SLUG_PREFIX = "https://explorer-avenirs.onisep.fr/http/redirection/formation/slug/"; public static final String EXPLORER_AVENIRS_URL = "https://explorer-avenirs.onisep.fr"; public static final String ONISEP_URL1 = "http://www.onisep.fr"; public static final String ONISEP_URL2 = "https://www.onisep.fr"; diff --git a/app/etl/etl-common/src/main/java/fr/gouv/monprojetsup/data/model/liens/UrlsUpdater.java b/app/etl/etl-common/src/main/java/fr/gouv/monprojetsup/data/model/liens/UrlsUpdater.java index 9f1ef86fa..4889756b7 100644 --- a/app/etl/etl-common/src/main/java/fr/gouv/monprojetsup/data/model/liens/UrlsUpdater.java +++ b/app/etl/etl-common/src/main/java/fr/gouv/monprojetsup/data/model/liens/UrlsUpdater.java @@ -13,6 +13,7 @@ import java.util.Map; import java.util.stream.Collectors; +import static fr.gouv.monprojetsup.data.Constants.AVENIRS_FORMATION_SLUG_PREFIX; import static fr.gouv.monprojetsup.data.Constants.LABEL_ARTICLE_PAS_LAS; public class UrlsUpdater { @@ -52,8 +53,9 @@ private static void addUrl(String key, String uri, String label, String source, } label = capitalizeFirstLetter(label).replace(".", " ") - //.replace(" - en apprentissage", "") .trim(); + val labelSansApprentissage = label.replace(" - en apprentissage", ""); + val url = DescriptifsFormationsMetiers.toAvenirs(uri, label, source); if(firstWithSameUri.isEmpty()) { @@ -93,11 +95,12 @@ public static String capitalizeFirstLetter(String sentence) { public static @NotNull Map> updateUrls( @NotNull List metiers, - @NotNull Map liensIdeoHotline, + @NotNull Map> mpsKeyToIdeo, @NotNull Map lasToGeneric, @NotNull Map psupKeytoMpsKey, @NotNull List mpsIds, @NotNull Map labels, + @NotNull Map labelsOriginauxPsup, @NotNull Map> liensAIgnorer, @NotNull Map> extraUrls ) { @@ -117,16 +120,14 @@ public static String capitalizeFirstLetter(String sentence) { metier.urls().forEach(url -> addUrl(metier.ideo(), url.valeur(), url.commentaire(), METIERS_IDEO_DU_SUP, urls)); }); - val aIgnorer = liensAIgnorer.entrySet().stream() - .filter(e -> e.getValue().stream().anyMatch(s -> !s.isBlank())) - .map(Map.Entry::getKey) - .collect(Collectors.toSet()); - - for (val entry : liensIdeoHotline.entrySet()) { - if(!aIgnorer.contains(entry.getKey())) { - addUrl(entry.getKey(), entry.getValue(), labels.getOrDefault(entry.getKey(), entry.getValue()), IDEO_HOTLINE, urls); - } - } + mpsKeyToIdeo.forEach((mpsKey, ideos) -> + ideos.forEach(ideo -> { + if(labels.containsKey(ideo)) { + val label = labels.get(ideo); + addUrl(mpsKey, AVENIRS_FORMATION_SLUG_PREFIX + ideo, label, "mpsKeyToIdeo", urls); + } + } + )); extraUrls.forEach((key, extraLinks) -> { val cleanupExtraLinks = extraLinks.stream().map(String::trim).filter(s -> !s.isBlank()).toList(); @@ -149,14 +150,14 @@ public static String capitalizeFirstLetter(String sentence) { mpsIdToPsupIds.forEach( (mpsKey, listpsupKey) -> { - if(labels.containsKey(mpsKey)) { - val label = labels.get(mpsKey); + if(labelsOriginauxPsup.containsKey(mpsKey)) { + val label = labelsOriginauxPsup.get(mpsKey); val l = new ArrayList<>(List.of(label)); - if(psupKeytoMpsKey.containsKey(mpsKey)) { + if(listpsupKey.size() == 1 && psupKeytoMpsKey.containsKey(mpsKey)) { l.add(mpsKey + "x"); } addUrl(mpsKey, DescriptifsFormationsMetiers.toParcoursupCarteUrl(l), - "L'offre de formation - " + label, + "Voir sur la carte Parcoursup - " + label, CARTE_PSUP, urls ); } @@ -169,7 +170,7 @@ public static String capitalizeFirstLetter(String sentence) { val label = labels.get(psupKey); val ll = psupKeytoMpsKey.containsKey(psupKey) ? List.of(label, psupKey + "x") : List.of(label); addUrl(mpsKey, DescriptifsFormationsMetiers.toParcoursupCarteUrl(ll), - "L'offre de formation - " + label, + "Les lieux de formation " + label, CARTE_PSUP, urls ); diff --git a/app/etl/etl-common/src/main/java/fr/gouv/monprojetsup/data/model/psup/PsupData.java b/app/etl/etl-common/src/main/java/fr/gouv/monprojetsup/data/model/psup/PsupData.java index 2fae991cc..2a0895bb4 100644 --- a/app/etl/etl-common/src/main/java/fr/gouv/monprojetsup/data/model/psup/PsupData.java +++ b/app/etl/etl-common/src/main/java/fr/gouv/monprojetsup/data/model/psup/PsupData.java @@ -67,9 +67,6 @@ public record PsupData( @NotNull TagsSources motsCles, - //liens onisep, par filière - @NotNull Map liensOnisep, - fr.gouv.monprojetsup.data.model.stats.PsupStatistiques stats, @NotNull List<@NotNull Bac> bacs @@ -93,7 +90,6 @@ public PsupData() { new HashMap<>(), new TreeMap<>(), new TagsSources(), - new TreeMap<>(), new fr.gouv.monprojetsup.data.model.stats.PsupStatistiques(), new ArrayList<>() ); @@ -153,13 +149,6 @@ public AdmissionStats buildStats() { ); } - - - - public void ajouterLienFiliereOnisep(Integer gFlCod, String lien) { - liensOnisep.put(gFlCodToMpsId(gFlCod), lien); - } - public @Nullable String getRecoPremGeneriques(Integer gFlCod) { return getRecoScoGeneriques(gFlCod, "PREM"); } diff --git a/app/etl/etl-psup/src/main/java/fr/gouv/monprojetsup/data/psup/ConnecteurBackendSQL.java b/app/etl/etl-psup/src/main/java/fr/gouv/monprojetsup/data/psup/ConnecteurBackendSQL.java index 1f74a0c94..e01acb1ea 100644 --- a/app/etl/etl-psup/src/main/java/fr/gouv/monprojetsup/data/psup/ConnecteurBackendSQL.java +++ b/app/etl/etl-psup/src/main/java/fr/gouv/monprojetsup/data/psup/ConnecteurBackendSQL.java @@ -139,7 +139,6 @@ public PsupData recupererData(@NotNull Set eds) throws Exception { recupererNomsfilieres(data, filActives); recupererNomsFilieresManquantsEtMostCles(data, filActives); - recupererLiensOnisep(data, filActives); recupererFilieresSimilaires(data); recupererDureesEtudes(data); recupererFormations(data); @@ -561,33 +560,6 @@ public static TagsSources recupererSources(AlgoCarteEntree carte, Set f return sources2; } - /** - * Recupère les liens onisep pour chaque filière - * - * @param data les données - * @param filActives les filières intéressantes - */ - private void recupererLiensOnisep(PsupData data, Set filActives) throws SQLException { - try (Statement stmt = conn.createStatement()) { - /* récupère la liste des candidats ayant des voeux confirmés à l'année n-1 */ - ConnecteurBackendSQL.LOGGER.info("Récupération des liens Onisep "); - stmt.setFetchSize(1_000_000); - String sql = "select g_fl_cod, g_fl_lie_inf from mps_liens_onisep"; - ConnecteurBackendSQL.LOGGER.info(sql); - try (ResultSet result = stmt.executeQuery(sql)) { - while (result.next()) { - int gFlCod = result.getInt(1); - if(filActives.contains(gFlCod)) { - String lien = result.getString(2); - data.ajouterLienFiliereOnisep(gFlCod, lien); - } - } - } - - } - - } - //group bac mat Map>> percCounters = new HashMap<>(); diff --git a/app/etl/etl-updatedb/src/main/java/fr/gouv/monprojetsup/data/etl/labels/Labels.java b/app/etl/etl-updatedb/src/main/java/fr/gouv/monprojetsup/data/etl/labels/Labels.java index 34f97c862..1f49ee64d 100644 --- a/app/etl/etl-updatedb/src/main/java/fr/gouv/monprojetsup/data/etl/labels/Labels.java +++ b/app/etl/etl-updatedb/src/main/java/fr/gouv/monprojetsup/data/etl/labels/Labels.java @@ -12,7 +12,11 @@ import java.util.Set; import java.util.stream.Collectors; -import static fr.gouv.monprojetsup.data.Constants.*; +import static fr.gouv.monprojetsup.data.Constants.LAS_MPS_ID; +import static fr.gouv.monprojetsup.data.Constants.PPPE_MPS_ID; +import static fr.gouv.monprojetsup.data.Constants.gFrCodToMpsId; +import static fr.gouv.monprojetsup.data.Constants.gTaCodToMpsId; +import static fr.gouv.monprojetsup.data.Constants.includeKey; public class Labels { @@ -98,6 +102,24 @@ public static Map getFormationsLabels(@NotNull PsupData psupData return result; } + @NotNull + public static Map getLabelsOriginauxPsup(@NotNull PsupData psupData) { + val result = new HashMap(); + + psupData.formations().formations.forEach((key, formation) -> { + result.put(gTaCodToMpsId(key), formation.libelle); + }); + psupData.filieres().forEach((key, filiere) -> { + result.put(Constants.gFlCodToMpsId(key), filiere.libelle); + }); + psupData.formations().typesMacros.forEach((key, libelle) -> { + result.put(gFrCodToMpsId(key), libelle); + }); + + return result; + + } + private static @NotNull Map getFormationsLabels(OnisepData oniData, boolean includeKeys) { return oniData.formationsIdeo().stream() @@ -123,6 +145,7 @@ public static Map getFormationsLabels(@NotNull PsupData psupData return result; } + @NotNull public static Map getDebugLabels(@NotNull PsupData psupData, @NotNull OnisepData oniData) { val result = new HashMap(); @@ -150,7 +173,7 @@ private static String getLibelleFront(String key, String libelle) { newLibelle = libelle.replace("EA-BAC3", "Ecole ") + " (Bac +3)"; } if(newLibelle.contains("EA-BAC5")) { - newLibelle = libelle.replace("EA-BAC3", "Ecole ") + " (Bac +5)"; + newLibelle = libelle.replace("EA-BAC5", "Ecole ") + " (Bac +5)"; } if(key.equals("fr90")) { newLibelle = "Sciences Po / Instituts d'études politiques (IEP)"; diff --git a/app/etl/etl-updatedb/src/main/kotlin/fr/gouv/monprojetsup/data/etl/MpsDataFromFiles.kt b/app/etl/etl-updatedb/src/main/kotlin/fr/gouv/monprojetsup/data/etl/MpsDataFromFiles.kt index 92d4a7f5e..1f795c004 100644 --- a/app/etl/etl-updatedb/src/main/kotlin/fr/gouv/monprojetsup/data/etl/MpsDataFromFiles.kt +++ b/app/etl/etl-updatedb/src/main/kotlin/fr/gouv/monprojetsup/data/etl/MpsDataFromFiles.kt @@ -215,6 +215,13 @@ class MpsDataFromFiles( ) } + private fun getLabelsOriginauxPsup(): MutableMap { + return Labels.getLabelsOriginauxPsup( + psupData + ) + } + + override fun getDebugLabels(): Map { return Labels.getDebugLabels( psupData, @@ -577,17 +584,19 @@ class MpsDataFromFiles( override fun getLiens(): Map> { val urls = UrlsUpdater.updateUrls( onisepData.metiersIdeo, - psupData.liensOnisep, + getMpsIdToIdeoIds(), psupData.lasToGeneric, psupData.psupKeyToMpsKey, getFormationsMpsIds(), getLabels(), + getLabelsOriginauxPsup(), getLiensMpsIgnorer(), getLiensMpsExtras(), ) return urls } + private fun getLiensMpsIgnorer(): Map> { val lines = CsvTools.readCSV( dataSources.getSourceDataFilePath(DataSources.LIENS_MPS_PATH), diff --git a/app/front/src/features/formation/infrastructure/gateway/formationHttpRepository/formationHttpRepository.ts b/app/front/src/features/formation/infrastructure/gateway/formationHttpRepository/formationHttpRepository.ts index 786833281..659debf4d 100644 --- a/app/front/src/features/formation/infrastructure/gateway/formationHttpRepository/formationHttpRepository.ts +++ b/app/front/src/features/formation/infrastructure/gateway/formationHttpRepository/formationHttpRepository.ts @@ -75,7 +75,7 @@ export class formationHttpRepository implements FormationRepository { } private _mapperVersLeDomaine(formationHttp: RécupérerFormationsRéponseHTTP["formations"][number]): Formation { - const regexLienParcoursSup = /\/\/dossier\.parcoursup\.fr/u; + const regexLienParcoursSup = /Parcoursup/u; return { id: formationHttp.formation.id, nom: formationHttp.formation.nom, @@ -86,7 +86,7 @@ export class formationHttpRepository implements FormationRepository { conseils: formationHttp.formation.descriptifConseils ?? null, }, estEnAlternance: formationHttp.formation.apprentissage, - lienParcoursSup: formationHttp.formation.liens.find((lien) => regexLienParcoursSup.exec(lien.url))?.url ?? null, + lienParcoursSup: formationHttp.formation.liens.find((lien) => regexLienParcoursSup.exec(lien.nom))?.url ?? null, liens: formationHttp.formation.liens.map((lien) => ({ intitulé: lien.nom, url: lien.url })), admis: { moyenneGénérale: {