diff --git a/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.spec.ts b/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.spec.ts index 71dc21f419656314c564a01cf6f51cd6907b19d9..e60c95076e98ca10efd497ca91ec35114653f539 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.spec.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.spec.ts @@ -924,6 +924,22 @@ describe('BescheidService', () => { singleCold(createEmptyStateResource()), ); }); + + it('should emit empty upload in progress for upload bescheid document in progress', () => { + service.init(); + + expect(service.getUploadBescheidDocumentInProgress()).toBeObservable( + singleCold({ loading: false }), + ); + }); + + it('should emit empty upload in progress for upload attachmentdocument in progress', () => { + service.init(); + + expect(service.getUploadAttachmentInProgress()).toBeObservable( + singleCold({ loading: false }), + ); + }); }); describe('create bescheid document', () => { diff --git a/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts b/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts index 1319d619d0cd50d9aefbf616003409ca3a9ebf3e..90dbfa4346be7cf37beb1daf7bdbcd5c7db348be 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts @@ -152,7 +152,9 @@ export class BescheidService { ); this.bescheidDocumentFile$.next(createEmptyStateResource()); this.bescheidDocumentUri$.next(null); + this.uploadBescheidDocumentInProgress$.next({ loading: false }); this.uploadedAttachment$.next(createEmptyStateResource()); + this.uploadAttachmentInProgress$.next({ loading: false }); } public getBescheidDraft(): Observable<StateResource<BescheidResource>> { diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/bescheiden.formservice.ts b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/bescheiden.formservice.ts index dc987af324371fbc73cab82d955fa0cb935e9443..98394b5ed27371cb4171ca28ededf8fc04fb38de 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/bescheiden.formservice.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/bescheiden.formservice.ts @@ -10,13 +10,13 @@ import { BinaryFileResource } from '@alfa-client/binary-file-shared'; import { tapOnCommandSuccessfullyDone } from '@alfa-client/command-shared'; import { AbstractFormService, - EMPTY_STRING, - HttpError, - StateResource, convertToBoolean, + EMPTY_STRING, formatForDatabase, + HttpError, isNotEmpty, isNotNil, + StateResource, } from '@alfa-client/tech-shared'; import { VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { Injectable, OnDestroy } from '@angular/core'; @@ -27,16 +27,16 @@ import { UntypedFormControl, UntypedFormGroup, } from '@angular/forms'; -import { Resource, ResourceUri, getUrl, hasLink } from '@ngxp/rest'; +import { getUrl, hasLink, Resource, ResourceUri } from '@ngxp/rest'; import { isEmpty, isNil, isUndefined } from 'lodash-es'; import { BehaviorSubject, - Observable, - Subject, - Subscription, combineLatest, map, + Observable, startWith, + Subject, + Subscription, } from 'rxjs'; @Injectable() @@ -54,13 +54,13 @@ export class BescheidenFormService extends AbstractFormService implements OnDest static readonly BETREFF_DEFAULT: string = 'Ihr Bescheid zum Antrag'; static readonly NACHRICHTENTEXT_BEWILLIGT_DEFAULT: string = [ 'Sehr geehrte/r Antragsteller/in,', - 'ihr Antrag wurde bewilligt.', + 'Ihr Antrag wurde bewilligt.', 'Mit freundlichen Grüßen', 'Ihre Verwaltung', ].join('\n\n'); static readonly NACHRICHTENTEXT_ABGELEHNT_DEFAULT: string = [ 'Sehr geehrte/r Antragsteller/in,', - 'ihr Antrag wurde abgelehnt.', + 'Ihr Antrag wurde abgelehnt.', 'Mit freundlichen Grüßen', 'Ihre Verwaltung', ].join('\n\n'); @@ -269,6 +269,7 @@ export class BescheidenFormService extends AbstractFormService implements OnDest private setNachrichtSubject(value: string): void { this.form.controls[BescheidenFormService.FIELD_NACHRICHT_SUBJECT].patchValue(value); } + private setNachrichtText(value: string): void { this.form.controls[BescheidenFormService.FIELD_NACHRICHT_TEXT].patchValue(value); } diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result-attachments/vorgang-detail-bescheiden-result-attachments.component.spec.ts b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result-attachments/vorgang-detail-bescheiden-result-attachments.component.spec.ts index c9b80fe49d0d2389e5d647eac7bceb37dd55f7b3..38a32fe726c44d6f7c0152e0caec38bfb8c90791 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result-attachments/vorgang-detail-bescheiden-result-attachments.component.spec.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result-attachments/vorgang-detail-bescheiden-result-attachments.component.spec.ts @@ -315,6 +315,17 @@ describe('VorgangDetailBescheidenResultAttachmentsComponent', () => { expect(component.uploadedAttachments).toEqual([]); }); + it('should leave errors in uploaded', () => { + const error: StateResource<BinaryFileResource> = createStateResource( + createBinaryFileResource(), + ); + component.uploadedAttachments = [error]; + + component.deleteFile(uploadedAttachmentStateResource.resource); + + expect(component.uploadedAttachments).toEqual([error]); + }); + it('should not delete attachment from existing', () => { component.uploadedAttachments = [uploadedAttachmentStateResource]; component.existingAttachments = [existingAttachment]; diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result-attachments/vorgang-detail-bescheiden-result-attachments.component.ts b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result-attachments/vorgang-detail-bescheiden-result-attachments.component.ts index 084a5361b9ec8460e5cc0f518aeacb535cb47cf9..896a94a92a3a4ca65357269d66de5b83ce1d1730 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result-attachments/vorgang-detail-bescheiden-result-attachments.component.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result-attachments/vorgang-detail-bescheiden-result-attachments.component.ts @@ -1,16 +1,16 @@ import { BescheidService, UploadFileInProgress } from '@alfa-client/bescheid-shared'; import { BinaryFileResource } from '@alfa-client/binary-file-shared'; import { - StateResource, containsLoading, getSuccessfullyLoaded, hasStateResourceError, isLoaded, isNotNil, + StateResource, } from '@alfa-client/tech-shared'; import { Component, Input, OnDestroy, OnInit } from '@angular/core'; import { getUrl } from '@ngxp/rest'; -import { Observable, Subscription, first } from 'rxjs'; +import { first, Observable, Subscription } from 'rxjs'; import { BescheidenFormService } from '../../bescheiden.formservice'; @Component({ @@ -76,10 +76,11 @@ export class VorgangDetailBescheidenResultAttachmentsComponent implements OnDest deleteFile(file: BinaryFileResource): void { this.formService.deleteFile(file); this.uploadedAttachments = this.uploadedAttachments.filter( - (attachment) => getUrl(attachment.resource) !== getUrl(file), + (attachment: StateResource<BinaryFileResource>) => + !hasStateResourceError(attachment) && getUrl(attachment.resource) !== getUrl(file), ); this.existingAttachments = this.existingAttachments.filter( - (attachment) => getUrl(attachment) !== getUrl(file), + (attachment: BinaryFileResource) => getUrl(attachment) !== getUrl(file), ); } } diff --git a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-search-container/vorgang-search/vorgang-search.component.spec.ts b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-search-container/vorgang-search/vorgang-search.component.spec.ts index 4544ff07bbd8a19741c55ccd326b04b64f03fa0c..9fe1622edc1c551c7bff4d9ed5cb9ed910bceb40 100644 --- a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-search-container/vorgang-search/vorgang-search.component.spec.ts +++ b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-search-container/vorgang-search/vorgang-search.component.spec.ts @@ -51,11 +51,12 @@ import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIcon } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { NavigationEnd, Router, RouterEvent } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { getDataTestClassOf, getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { createVorgangListResource } from 'libs/vorgang-shared/test/vorgang'; import { MockComponent } from 'ng-mocks'; -import { BehaviorSubject, Subject, of } from 'rxjs'; +import { BehaviorSubject, ReplaySubject, Subject, of } from 'rxjs'; import { VorgangSearchAutocompleteOptionsContentComponent } from './vorgang-search-autocomplete-options-content/vorgang-search-autocomplete-options-content.component'; import { VorgangSearchClearButtonComponent } from './vorgang-search-clear-button/vorgang-search-clear-button.component'; import { VorgangSearchComponent } from './vorgang-search.component'; @@ -71,6 +72,13 @@ describe('VorgangSearchComponent', () => { const searchStringSubj: Subject<string> = new BehaviorSubject(EMPTY_STRING); + const routerEvents: ReplaySubject<RouterEvent> = new ReplaySubject<RouterEvent>(); + const routerMock = { + navigate: jest.fn(), + url: '/', + events: routerEvents.asObservable(), + }; + const searchPreviewOption: string = getDataTestClassOf('search-preview-option'); const searchClearButton: string = getDataTestIdOf('vorgang-search-clear-button'); @@ -116,6 +124,10 @@ describe('VorgangSearchComponent', () => { provide: NavigationService, useValue: navigationService, }, + { + provide: Router, + useValue: routerMock, + }, ], }).compileComponents(); }); @@ -154,6 +166,26 @@ describe('VorgangSearchComponent', () => { }); }); + describe('ngOnInit', () => { + it('should set focus if path ends with "/search"', () => { + component.focus = jest.fn(); + routerEvents.next(new NavigationEnd(1, '/alle/search', '')); + + component.ngOnInit(); + + expect(component.focus).toHaveBeenCalled(); + }); + + it('should not set focus if path does not end with "/search"', () => { + component.focus = jest.fn(); + routerEvents.next(new NavigationEnd(1, '/alle', '')); + + component.ngOnInit(); + + expect(component.focus).toHaveBeenCalled(); + }); + }); + describe('search clear button', () => { beforeEach(() => { searchStringSubj.next('test'); diff --git a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-search-container/vorgang-search/vorgang-search.component.ts b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-search-container/vorgang-search/vorgang-search.component.ts index cccfbaf8d41ff25b10b39d5643c5e1dfc29c057f..5375e849b6359a8ba54dd883b83ed8da5daae844 100644 --- a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-search-container/vorgang-search/vorgang-search.component.ts +++ b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-search-container/vorgang-search/vorgang-search.component.ts @@ -21,15 +21,27 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core'; -import { MatAutocomplete } from '@angular/material/autocomplete'; -import { MatButton } from '@angular/material/button'; import { StateResource, isNotNil } from '@alfa-client/tech-shared'; import { VorgangHeaderLinkRel, VorgangListLinkRel, VorgangListResource, } from '@alfa-client/vorgang-shared'; +import { + Component, + ElementRef, + EventEmitter, + Input, + OnDestroy, + OnInit, + Output, + ViewChild, +} from '@angular/core'; +import { MatAutocomplete } from '@angular/material/autocomplete'; +import { MatButton } from '@angular/material/button'; +import { Event, NavigationEnd, Router } from '@angular/router'; +import { Subscription, filter } from 'rxjs'; +import { isVorgangSearchRoute } from '../../vorgang-util'; import { VorgangSearchFormService } from './vorgang-search.formservice'; @Component({ @@ -38,7 +50,7 @@ import { VorgangSearchFormService } from './vorgang-search.formservice'; styleUrls: ['./vorgang-search.component.scss'], providers: [VorgangSearchFormService], }) -export class VorgangSearchComponent { +export class VorgangSearchComponent implements OnInit, OnDestroy { @Input() vorgangSearchPreviewList: StateResource<VorgangListResource>; @Input() searchString: string; @@ -49,11 +61,25 @@ export class VorgangSearchComponent { @ViewChild('searchAutoComplete') searchAutoComplete: MatAutocomplete; previouslyEnteredSearchValue: string; + private subscription: Subscription; readonly vorgangHeaderLinkRel = VorgangHeaderLinkRel; readonly vorgangListLinkRel = VorgangListLinkRel; - constructor(public formService: VorgangSearchFormService) {} + constructor( + public formService: VorgangSearchFormService, + public router: Router, + ) {} + + ngOnInit(): void { + this.subscription = this.router.events + .pipe(filter((event: Event) => event instanceof NavigationEnd)) + .subscribe((navigationEnd: Event) => { + if (isVorgangSearchRoute(navigationEnd as NavigationEnd)) { + this.focus(); + } + }); + } submit(): void { this.previouslyEnteredSearchValue = this.formService.getValue(); @@ -93,4 +119,8 @@ export class VorgangSearchComponent { focus(): void { this.searchInput.nativeElement.focus(); } + + ngOnDestroy(): void { + this.subscription.unsubscribe(); + } } diff --git a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-util.spec.ts b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-util.spec.ts index 41d1e94862b57a486bf7129415a25a1906781dc3..14ac51258c484adf8c4bfc7c77e02a1b78a2a2f3 100644 --- a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-util.spec.ts +++ b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-util.spec.ts @@ -23,17 +23,9 @@ */ import { EMPTY_STRING } from '@alfa-client/tech-shared'; import { Antragsteller, Vorgang, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; -import { - createAntragsteller, - createEingang, - createVorgangResource, - createVorgangWithEingangResource, -} from 'libs/vorgang-shared/test/vorgang'; -import { - VORGANG_KEIN_AKTENZEICHEN_ZUGEWIESEN, - getAktenzeichenText, - getEmpfaenger, -} from './vorgang-util'; +import { NavigationEnd } from '@angular/router'; +import { createAntragsteller, createEingang, createVorgangResource, createVorgangWithEingangResource, } from 'libs/vorgang-shared/test/vorgang'; +import { getAktenzeichenText, getEmpfaenger, isVorgangSearchRoute, VORGANG_KEIN_AKTENZEICHEN_ZUGEWIESEN, } from './vorgang-util'; describe('Vorgang Util', () => { describe('getAktenzeichenText', () => { @@ -54,6 +46,24 @@ describe('Vorgang Util', () => { }); }); + describe('isSearchRoute', () => { + it('should return true', () => { + const searchNavigationEnd: NavigationEnd = new NavigationEnd(1, '/alle/search', ''); + + const result: boolean = isVorgangSearchRoute(searchNavigationEnd); + + expect(result).toBeTruthy(); + }); + + it('should return false', () => { + const notSearchNavigationEnd: NavigationEnd = new NavigationEnd(1, '/alle', ''); + + const result: boolean = isVorgangSearchRoute(notSearchNavigationEnd); + + expect(result).toBeFalsy(); + }); + }); + describe('getEmpfaenger', () => { it('should return nachname only if exists', () => { const antragsteller: Antragsteller = { ...createAntragsteller(), vorname: undefined }; diff --git a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-util.ts b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-util.ts index 5d90f07fe9a46e9c19ab44294aab7ffb32f7138b..7ee464cc2b04095b19e3dc7fa6de9c6a4398c2bc 100644 --- a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-util.ts +++ b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-util.ts @@ -23,6 +23,7 @@ */ import { EMPTY_STRING } from '@alfa-client/tech-shared'; import { Vorgang, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; +import { NavigationEnd } from '@angular/router'; export const VORGANG_KEIN_AKTENZEICHEN_ZUGEWIESEN = 'kein Aktenzeichen'; @@ -34,6 +35,10 @@ export function getEmpfaenger(vorgangWithEingangResource: VorgangWithEingangReso return `${getVorname(vorgangWithEingangResource)} ${getNachname(vorgangWithEingangResource)}`.trim(); } +export function isVorgangSearchRoute(navigationEnd: NavigationEnd): boolean { + return navigationEnd.url.endsWith('/search'); +} + function getVorname(vorgangWithEingangResource: VorgangWithEingangResource): string { return vorgangWithEingangResource.eingang.antragsteller?.vorname ?? EMPTY_STRING; } diff --git a/alfa-xdomea/src/main/java/de/ozgcloud/alfa/bescheid/BescheidExportInput.java b/alfa-xdomea/src/main/java/de/ozgcloud/alfa/bescheid/BescheidExportInput.java index 2eaa029e52aa5080b6aabcc85a611af051072b00..aa25d85adf81618ded8e2c62097275c011c90313 100644 --- a/alfa-xdomea/src/main/java/de/ozgcloud/alfa/bescheid/BescheidExportInput.java +++ b/alfa-xdomea/src/main/java/de/ozgcloud/alfa/bescheid/BescheidExportInput.java @@ -3,6 +3,8 @@ package de.ozgcloud.alfa.bescheid; import java.util.List; import de.ozgcloud.alfa.common.file.OzgFile; +import lombok.Builder; +@Builder record BescheidExportInput(Bescheid bescheid, String organisationseinheitenId, List<OzgFile> files) { } diff --git a/alfa-xdomea/src/main/java/de/ozgcloud/alfa/bescheid/ExportBescheidService.java b/alfa-xdomea/src/main/java/de/ozgcloud/alfa/bescheid/ExportBescheidService.java index 1d66ad45f4a52597ed08fa0aa41aa6a93489e45c..8e29ef7f84f7b75f66b8df3ca5254cbf9c6eace3 100644 --- a/alfa-xdomea/src/main/java/de/ozgcloud/alfa/bescheid/ExportBescheidService.java +++ b/alfa-xdomea/src/main/java/de/ozgcloud/alfa/bescheid/ExportBescheidService.java @@ -1,6 +1,5 @@ package de.ozgcloud.alfa.bescheid; -import java.util.List; import java.util.stream.Stream; import org.springframework.stereotype.Service; @@ -32,16 +31,18 @@ public class ExportBescheidService { } BescheidExportInput createBescheidExportInput(Bescheid bescheid, VorgangWithEingang vorgang) { - return new BescheidExportInput(bescheid, vorgang.getOrganisationseinheitenID(), getAttachments(bescheid)); + return BescheidExportInput.builder() + .bescheid(bescheid) + .organisationseinheitenId(vorgang.getOrganisationseinheitenID()) + .files(Stream.concat(Stream.of(getDocument(bescheid)), getAttachments(bescheid)).toList()).build(); } - List<OzgFile> getAttachments(Bescheid bescheid) { - return binaryFileService.getFiles(bescheid.getAttachments()).toList(); + Stream<OzgFile> getAttachments(Bescheid bescheid) { + return binaryFileService.getFiles(bescheid.getAttachments()); } void addBescheidExportData(BescheidExportInput input, BescheidExportData.BescheidExportDataBuilder builder) { builder.dokumentType(buildDokumentType(input)) - .file(getDocument(input.bescheid())) .files(input.files()); } diff --git a/alfa-xdomea/src/main/java/de/ozgcloud/alfa/export/ExportService.java b/alfa-xdomea/src/main/java/de/ozgcloud/alfa/export/ExportService.java index dea71b8ecffd2e0a22f6d3f69107ffa6ce0e6b39..dfa730ff9003f54fcef6bc626d36c471dccec27e 100644 --- a/alfa-xdomea/src/main/java/de/ozgcloud/alfa/export/ExportService.java +++ b/alfa-xdomea/src/main/java/de/ozgcloud/alfa/export/ExportService.java @@ -75,7 +75,8 @@ class ExportService { var exportFiles = Stream .of(representations.stream(), attachments.stream(), kommentarsData.getAttachments().stream(), - postfachMailData.getAttachments().stream()) + postfachMailData.getAttachments().stream(), + bescheidData.getFiles().stream()) .flatMap(s -> s) .toList(); return ExportData.builder().abgabe(abgabe).exportFilename(buildXmlFilename(filenameId)).exportFiles(exportFiles).build(); diff --git a/alfa-xdomea/src/test/java/de/ozgcloud/alfa/bescheid/BescheidExportDataTestFactory.java b/alfa-xdomea/src/test/java/de/ozgcloud/alfa/bescheid/BescheidExportDataTestFactory.java index a8750928c920bc87ecdc49b5fe79aeae537cc26b..e731e4838f28f5056d77210640b33845c7f4ef1b 100644 --- a/alfa-xdomea/src/test/java/de/ozgcloud/alfa/bescheid/BescheidExportDataTestFactory.java +++ b/alfa-xdomea/src/test/java/de/ozgcloud/alfa/bescheid/BescheidExportDataTestFactory.java @@ -8,7 +8,8 @@ import de.xoev.xdomea.DokumentType; public class BescheidExportDataTestFactory { public static final DokumentType DOKUMENT_TYPE = DokumentTypeTestFactory.create(); - public static final OzgFile OZG_FILE = OzgFileTestFactory.createWithUniqueId(); + public static final OzgFile ATTACHMENT = OzgFileTestFactory.createWithUniqueId(); + public static final OzgFile DOCUMENT = OzgFileTestFactory.createWithUniqueId(); public static BescheidExportData create() { return createBuilder().build(); @@ -17,6 +18,7 @@ public class BescheidExportDataTestFactory { public static BescheidExportData.BescheidExportDataBuilder createBuilder() { return BescheidExportData.builder() .dokumentType(DOKUMENT_TYPE) - .file(OZG_FILE); + .file(DOCUMENT) + .file(ATTACHMENT); } } diff --git a/alfa-xdomea/src/test/java/de/ozgcloud/alfa/bescheid/BescheidExportInputTestFactory.java b/alfa-xdomea/src/test/java/de/ozgcloud/alfa/bescheid/BescheidExportInputTestFactory.java index 0051086930bbbe289f68949dc244733f7e5ab218..fbee5d69b45774fcfac881ab2f4550284704c447 100644 --- a/alfa-xdomea/src/test/java/de/ozgcloud/alfa/bescheid/BescheidExportInputTestFactory.java +++ b/alfa-xdomea/src/test/java/de/ozgcloud/alfa/bescheid/BescheidExportInputTestFactory.java @@ -10,10 +10,17 @@ public class BescheidExportInputTestFactory { public final static Bescheid BESCHEID = BescheidTestFactory.create(); public final static String ORGANISATIONSEINHEITEN_ID = ZustaendigeStelleTestFactory.ORGANISATIONSEINHEITEN_ID; - public final static List<OzgFile> ATTACHMENTS = List.of(OzgFileTestFactory.createWithUniqueId()); + public final static List<OzgFile> FILES = List.of(OzgFileTestFactory.createWithUniqueId()); public static BescheidExportInput create() { - return new BescheidExportInput(BESCHEID, ORGANISATIONSEINHEITEN_ID, ATTACHMENTS); + return createBuilder().build(); + } + + public static BescheidExportInput.BescheidExportInputBuilder createBuilder() { + return BescheidExportInput.builder() + .bescheid(BESCHEID) + .organisationseinheitenId(ORGANISATIONSEINHEITEN_ID) + .files(FILES); } } diff --git a/alfa-xdomea/src/test/java/de/ozgcloud/alfa/bescheid/ExportBescheidServiceTest.java b/alfa-xdomea/src/test/java/de/ozgcloud/alfa/bescheid/ExportBescheidServiceTest.java index 126aab998d2b46b39b5b8e5c2340f6200fe2adee..bd8d907e7cc79c9830cebdcb81e4061609657396 100644 --- a/alfa-xdomea/src/test/java/de/ozgcloud/alfa/bescheid/ExportBescheidServiceTest.java +++ b/alfa-xdomea/src/test/java/de/ozgcloud/alfa/bescheid/ExportBescheidServiceTest.java @@ -154,10 +154,13 @@ class ExportBescheidServiceTest { class TestCreateBescheidExportInput { private final VorgangWithEingang vorgang = VorgangWithEingangTestFactory.create(); private final Bescheid bescheid = BescheidTestFactory.create(); + private final OzgFile document = OzgFileTestFactory.create(); + private final OzgFile attachment = OzgFileTestFactory.create(); @BeforeEach void setUpMocks() { - doReturn(BescheidExportInputTestFactory.ATTACHMENTS).when(service).getAttachments(bescheid); + doReturn(Stream.of(attachment)).when(service).getAttachments(bescheid); + doReturn(document).when(service).getDocument(bescheid); } @Test @@ -167,11 +170,19 @@ class ExportBescheidServiceTest { verify(service).getAttachments(bescheid); } + @Test + void shouldCallGetDocument() { + callService(); + + verify(service).getDocument(bescheid); + } + @Test void shouldReturnInputData() { var resultInput = callService(); - assertThat(resultInput).usingRecursiveComparison().isEqualTo(BescheidExportInputTestFactory.create()); + assertThat(resultInput).usingRecursiveComparison() + .isEqualTo(BescheidExportInputTestFactory.createBuilder().files(List.of(document, attachment)).build()); } private BescheidExportInput callService() { @@ -243,7 +254,7 @@ class ExportBescheidServiceTest { @Nested class TestAddBescheidExportData { - private final List<OzgFile> attachments = BescheidExportInputTestFactory.ATTACHMENTS; + private final List<OzgFile> files = BescheidExportInputTestFactory.FILES; private final OzgFile document = OzgFileTestFactory.create(); private final DokumentType dokumentType = DokumentTypeTestFactory.create(); private final BescheidExportInput exportInput = BescheidExportInputTestFactory.create(); @@ -254,30 +265,14 @@ class ExportBescheidServiceTest { @BeforeEach void setUpMocks() { doReturn(dokumentType).when(service).buildDokumentType(exportInput); - doReturn(document).when(service).getDocument(exportInput.bescheid()); when(exportDataBuilder.dokumentType(dokumentType)).thenReturn(exportDataBuilder); - when(exportDataBuilder.file(document)).thenReturn(exportDataBuilder); - } - - @Test - void shouldGetDocument() { - callService(); - - verify(service).getDocument(exportInput.bescheid()); - } - - @Test - void shouldAddDocumentToBuilder() { - callService(); - - verify(exportDataBuilder).file(document); } @Test void shouldAddAttachmentsToBuilder() { callService(); - verify(exportDataBuilder).files(attachments); + verify(exportDataBuilder).files(files); } @Test @@ -303,7 +298,7 @@ class ExportBescheidServiceTest { class TestBuildDokumentType { private final BescheidExportInput exportInput = BescheidExportInputTestFactory.create(); private final Bescheid bescheid = BescheidExportInputTestFactory.BESCHEID; - private final List<OzgFile> attachments = BescheidExportInputTestFactory.ATTACHMENTS; + private final List<OzgFile> files = BescheidExportInputTestFactory.FILES; private final String fullName = UserProfileTestFactory.FULLNAME; private MockedStatic<DokumentTypeBuilder> dokumentTypeBuilderMockedStatic; @@ -316,7 +311,7 @@ class ExportBescheidServiceTest { dokumentTypeBuilderMockedStatic.when(DokumentTypeBuilder::builder).thenReturn(dokumentTypeBuilder); when(dokumentTypeBuilder.withBescheid(bescheid)).thenReturn(dokumentTypeBuilder); - when(dokumentTypeBuilder.withFiles(attachments)).thenReturn(dokumentTypeBuilder); + when(dokumentTypeBuilder.withFiles(files)).thenReturn(dokumentTypeBuilder); when(dokumentTypeBuilder.withFullName(fullName)).thenReturn(dokumentTypeBuilder); when(dokumentTypeBuilder.withOrganisationseinheitenId(BescheidExportInputTestFactory.ORGANISATIONSEINHEITEN_ID)) .thenReturn(dokumentTypeBuilder); @@ -347,7 +342,7 @@ class ExportBescheidServiceTest { void shouldBuildWithOzgFiles() { callService(); - verify(dokumentTypeBuilder).withFiles(attachments); + verify(dokumentTypeBuilder).withFiles(files); } @Test diff --git a/alfa-xdomea/src/test/java/de/ozgcloud/alfa/export/ExportServiceTest.java b/alfa-xdomea/src/test/java/de/ozgcloud/alfa/export/ExportServiceTest.java index 4cb6ebb420df44f1ea730e236351db5b1e781a13..6b7317d5dda8cd690a9ee490d22e9258bc4a2945 100644 --- a/alfa-xdomea/src/test/java/de/ozgcloud/alfa/export/ExportServiceTest.java +++ b/alfa-xdomea/src/test/java/de/ozgcloud/alfa/export/ExportServiceTest.java @@ -366,18 +366,18 @@ class ExportServiceTest { } @Test - void shouldContainExportExportFiles() { + void shouldContainExportFiles() { var exportData = callService(); assertThat(exportData.getExportFiles()) - .hasSize(4) + .hasSize(6) .containsAll(representations) .containsAll(attachments) .containsAll(kommentarsExportData.getAttachments()) - .containsAll(postfachMailExportData.getAttachments()); + .containsAll(postfachMailExportData.getAttachments()) + .containsAll(bescheidExportData.getFiles()); } - @Test void shouldExportKommentare() { callService();