RetourPrefectureService { public void receiveAnomalieActe(EnveloppeMISILLCL enveloppeMISILLCL, AnomalieActe anomalieActe, Attachment attachment) { LocalAuthority localAuthority = localAuthorityRepository.findBySiren(enveloppeMISILLCL.getDestinataire().getSIREN()) .orElseThrow(ActeNotFoundException::new); Acte acte = acteRepository.findFirstByNumberAndDecisionAndNatureAndLocalAuthority_UuidAndDraftNull( anomalieActe.getActeRecu().getNumeroInterne(), anomalieActe.getActeRecu().getDate(), ActeNature.code(anomalieActe.getActeRecu().getCodeNatureActe()), localAuthority.getUuid()) .orElseThrow(ActeNotFoundException::new); publishActeHistory(acte.getUuid(), StatusType.NACK_RECEIVED, attachment, Optional.of(anomalieActe.getDetail()), Optional.empty()); } RetourPrefectureService(ActeRepository acteRepository, ActeHistoryRepository acteHistoryRepository,
                                   LocalAuthorityRepository localAuthorityRepository, ApplicationEventPublisher applicationEventPublisher, ZipGeneratorUtil zipGeneratorUtil); void receiveARActe(ARActe arActe, Attachment attachment); void receiveARAnnulation(ARAnnulation arAnnulation, Attachment attachment); void receiveAnomalieActe(EnveloppeMISILLCL enveloppeMISILLCL, AnomalieActe anomalieActe, Attachment attachment); void receiveAnomalieEnveloppe(AnomalieEnveloppe anomalieEnveloppe, Attachment attachment); void receiveCourrierSimple(CourrierSimple courrierSimple, Attachment attachment); void receiveDemandePieceComplementaire(DemandePieceComplementaire demandePieceComplementaire, Attachment attachment); void receiveLettreObservations(LettreObservations lettreObservations, Attachment attachment); void receiveDefere(DefereTA defereTA, List<Attachment> attachments); void receiveARPieceComplementaire(ARReponseCL arReponseCL, Attachment attachment); void receiveARReponseRejetLettreObservations(ARReponseCL arReponseCL, Attachment attachment);  }
@Test public void testReceiveAnomalieActe() throws IOException, JAXBException { given(localAuthorityRepository.findBySiren(any())) .willReturn(Optional.of(new LocalAuthority("uuid", "name", "siren", "name"))); given(acteRepository.findFirstByNumberAndDecisionAndNatureAndLocalAuthority_UuidAndDraftNull(any(), any(), any(), any())) .willReturn(Optional.of(acte())); Pair<AnomalieActe, Attachment> parsedData = parseClassPathResource("data/044-214400152----1-3_1.xml", AnomalieActe.class); EnveloppeMISILLCL enveloppeMISILLCL = parseSingleClassPathResource("data/EACT--SPREF0441-214400152-20181012-9.xml", EnveloppeMISILLCL.class); retourPrefectureService.receiveAnomalieActe(enveloppeMISILLCL, parsedData.getLeft(), parsedData.getRight()); verify(localAuthorityRepository).findBySiren("214400152"); verify(acteRepository).findFirstByNumberAndDecisionAndNatureAndLocalAuthority_UuidAndDraftNull( eq("123456"), eq(LocalDate.of(2018, 10, 1)), eq(ActeNature.DELIBERATIONS), eq("uuid")); verify(retourPrefectureService).publishActeHistory(eq("uuid"), eq(StatusType.NACK_RECEIVED), eq(parsedData.getRight()), eq(Optional.of("ODT-VERIF-01 : Votre acte a été transmis avec une date de classification qui n'est pas à jour")), eq(Optional.empty())); }