diff --git a/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.facade.spec.ts b/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.facade.spec.ts index 49c3f00e0dec46f8de9e73fc639f637cc2cb73b2..329ddf97fb780671d82c886e829226a28260782d 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.facade.spec.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.facade.spec.ts @@ -4,7 +4,7 @@ import { CommandService, CreateCommand, } from '@alfa-client/command-shared'; -import { EMPTY_STRING, StateResource, createStateResource } from '@alfa-client/tech-shared'; +import { createStateResource, EMPTY_STRING, StateResource } from '@alfa-client/tech-shared'; import { Mock, mock, useFromMock } from '@alfa-client/test-utils'; import { VorgangWithEingangLinkRel, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { Store } from '@ngrx/store'; @@ -43,60 +43,22 @@ describe('BescheidFacade', () => { }); }); - describe('createBescheid', () => { + describe('createBescheidDraft', () => { const createCommand: CreateCommand = createCreateCommand(CommandOrder.CREATE_BESCHEID); - describe('with both Links', () => { - it('should call command service with CREATE_BESCHEID linkRel', () => { - const vorgang: VorgangWithEingangResource = createVorgangWithEingangResource([ - VorgangWithEingangLinkRel.CREATE_BESCHEID, - VorgangWithEingangLinkRel.CREATE_BESCHEID_DRAFT, - ]); - facade.createBescheid(vorgang, createCommand); + it('should create command', () => { + const vorgang: VorgangWithEingangResource = createVorgangWithEingangResource([ + VorgangWithEingangLinkRel.CREATE_BESCHEID_DRAFT, + ]); - expect(commandService.createCommandByProps).toHaveBeenCalledWith({ - resource: vorgang, - linkRel: VorgangWithEingangLinkRel.CREATE_BESCHEID, - command: createCommand, - }); - }); - }); - - describe('with CREATE_BESCHEID_DRAFT link', () => { - it('should call command service with CREATE_BESCHEID_DRAFT linkRel and empty snackBarMessage', () => { - const vorgang: VorgangWithEingangResource = createVorgangWithEingangResource([ - VorgangWithEingangLinkRel.CREATE_BESCHEID_DRAFT, - ]); - facade.createBescheid(vorgang, createCommand); - - expect(commandService.createCommandByProps).toHaveBeenCalledWith({ - resource: vorgang, - linkRel: VorgangWithEingangLinkRel.CREATE_BESCHEID_DRAFT, - command: createCommand, - snackBarMessage: EMPTY_STRING, - }); - }); - }); - - describe('with CREATE_BESCHEID link', () => { - it('should call command service with CREATE_BESCHEID_DRAFT linkRel', () => { - const vorgang: VorgangWithEingangResource = createVorgangWithEingangResource([ - VorgangWithEingangLinkRel.CREATE_BESCHEID, - ]); - - facade.createBescheid(vorgang, createCommand); + facade.createBescheidDraft(vorgang, createCommand); - expect(commandService.createCommandByProps).toHaveBeenCalledWith({ - resource: vorgang, - linkRel: VorgangWithEingangLinkRel.CREATE_BESCHEID, - command: createCommand, - }); + expect(commandService.createCommandByProps).toHaveBeenCalledWith({ + resource: vorgang, + linkRel: VorgangWithEingangLinkRel.CREATE_BESCHEID_DRAFT, + command: createCommand, + snackBarMessage: EMPTY_STRING, }); }); - it('should emit error if link is missing()', () => { - const vorgang: VorgangWithEingangResource = createVorgangWithEingangResource(); - - expect(() => facade.createBescheid(vorgang, createCommand)).toThrowError(); - }); }); }); diff --git a/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.facade.ts b/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.facade.ts index 35933803d5b40bdf4c79f94c3973fa1be790c471..d338a17a00b1bdfd2f6805f333036b90635a623d 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.facade.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.facade.ts @@ -8,7 +8,6 @@ import { EMPTY_STRING, StateResource } from '@alfa-client/tech-shared'; import { VorgangWithEingangLinkRel, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { Injectable } from '@angular/core'; import { Store } from '@ngrx/store'; -import { hasLink } from '@ngxp/rest'; import { Observable } from 'rxjs'; import * as BescheidSelectors from './bescheid.selectors'; @@ -24,31 +23,6 @@ export class BescheidFacade { return this.store.select(BescheidSelectors.bescheidCommand); } - public createBescheid( - vorgangWithEingang: VorgangWithEingangResource, - command: CreateCommand, - ): void { - if (hasLink(vorgangWithEingang, VorgangWithEingangLinkRel.CREATE_BESCHEID)) { - return this.createBescheidKiel(vorgangWithEingang, command); - } - if (hasLink(vorgangWithEingang, VorgangWithEingangLinkRel.CREATE_BESCHEID_DRAFT)) { - return this.createBescheidDraft(vorgangWithEingang, command); - } - throw new Error('Missing Link: CREATE_BESCHEID or CREATE_BESCHEID_DRAFT expected'); - } - - public createBescheidKiel( - vorgangWithEingang: VorgangWithEingangResource, - command: CreateCommand, - ): void { - const createCommandProps: CreateCommandProps = { - resource: vorgangWithEingang, - linkRel: VorgangWithEingangLinkRel.CREATE_BESCHEID, - command, - }; - this.commandService.createCommandByProps(createCommandProps); - } - public createBescheidDraft( vorgangWithEingang: VorgangWithEingangResource, command: CreateCommand, diff --git a/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.reducer.spec.ts b/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.reducer.spec.ts index 67058f2fbdf29b3c9d0fd5623dc297961760b677..e47c8f21156c5727a43406c6cc97551058db83f8 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.reducer.spec.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.reducer.spec.ts @@ -26,7 +26,7 @@ describe('Bescheid Reducer', () => { const resource: VorgangWithEingangResource = createVorgangWithEingangResource(); const action: Action = CommandActions.createCommand({ resource, - linkRel: VorgangWithEingangLinkRel.CREATE_BESCHEID, + linkRel: VorgangWithEingangLinkRel.CREATE_BESCHEID_DRAFT, command: { ...createCommandResource(), order: CommandOrder.CREATE_BESCHEID }, }); 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 228b24efb9cd33d7d236fbb0a5b4a4499cee4169..f0f740181ae37e11538d269dd8d64a10b36c2b3b 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 @@ -11,13 +11,13 @@ import { } from '@alfa-client/command-shared'; import { ApiError, + createEmptyStateResource, + createErrorStateResource, + createStateResource, EMPTY_ARRAY, EMPTY_STRING, HttpError, StateResource, - createEmptyStateResource, - createErrorStateResource, - createStateResource, } from '@alfa-client/tech-shared'; import { Mock, mock, useFromMock } from '@alfa-client/test-utils'; import { @@ -28,12 +28,12 @@ import { } from '@alfa-client/vorgang-shared'; import { fakeAsync, tick } from '@angular/core/testing'; import faker from '@faker-js/faker'; -import { ResourceUri, getUrl } from '@ngxp/rest'; +import { getUrl, ResourceUri } from '@ngxp/rest'; import { cold } from 'jest-marbles'; import { CommandLinkRel } from 'libs/command-shared/src/lib/command.linkrel'; import { createApiError } from 'libs/tech-shared/test/error'; import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang'; -import { Observable, first, of } from 'rxjs'; +import { first, Observable, of } from 'rxjs'; import { createBinaryFileListResource, createBinaryFileResource, @@ -155,7 +155,7 @@ describe('BescheidService', () => { it('should call facade', () => { service.createBescheid(vorgangWithEingang).pipe(first()).subscribe(); - expect(facade.createBescheid).toHaveBeenCalledWith(vorgangWithEingang, { + expect(facade.createBescheidDraft).toHaveBeenCalledWith(vorgangWithEingang, { order: CommandOrder.CREATE_BESCHEID, body: null, }); 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 76b74767032eac3979371d834d17c59217323600..277891fe474da829e8b3c8adacdcbf233fee73ee 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts @@ -13,19 +13,19 @@ import { tapOnCommandSuccessfullyDone, } from '@alfa-client/command-shared'; import { - EMPTY_ARRAY, - HttpError, - ResourceListService, - StateResource, createEmptyStateResource, createStateResource, + EMPTY_ARRAY, filterIsLoadedOrHasError, getEmbeddedResources, hasStateResourceError, + HttpError, isLoaded, isNotEmpty, isNotNil, + ResourceListService, sortByGermanDateStr, + StateResource, } from '@alfa-client/tech-shared'; import { VorgangCommandService, @@ -35,15 +35,15 @@ import { } from '@alfa-client/vorgang-shared'; import { getEmpfaenger } from '@alfa-client/vorgang-shared-ui'; import { Injectable } from '@angular/core'; -import { ResourceUri, getUrl, hasLink } from '@ngxp/rest'; +import { getUrl, hasLink, ResourceUri } from '@ngxp/rest'; import { BehaviorSubject, - Observable, - Subscription, filter, first, map, + Observable, startWith, + Subscription, switchMap, take, tap, @@ -172,7 +172,7 @@ export class BescheidService { vorgangWithEingang: VorgangWithEingangResource, bescheid?: Bescheid, ): Observable<StateResource<CommandResource>> { - this.facade.createBescheid(vorgangWithEingang, buildCreateBescheidCommand(bescheid)); + this.facade.createBescheidDraft(vorgangWithEingang, buildCreateBescheidCommand(bescheid)); return this.getBescheidCommand().pipe( tapOnCommandSuccessfullyDone((commandStateResource: StateResource<CommandResource>) => this.updateBescheidDraft(commandStateResource.resource), diff --git a/alfa-client/libs/bescheid/src/index.ts b/alfa-client/libs/bescheid/src/index.ts index 6e1524f86904bd889f89cbdfa55b147a978d67a5..9f2c0268f34d8c2099f74dbb30ffae0bed8a8a21 100644 --- a/alfa-client/libs/bescheid/src/index.ts +++ b/alfa-client/libs/bescheid/src/index.ts @@ -1,3 +1,2 @@ export * from './lib/bescheid.module'; export * from './lib/beschieden-date-in-vorgang-container/beschieden-date-in-vorgang-container.component'; -export * from './lib/create-bescheid-button-container/create-bescheid-button-container.component'; diff --git a/alfa-client/libs/bescheid/src/lib/bescheid.module.ts b/alfa-client/libs/bescheid/src/lib/bescheid.module.ts index e6faf4a67f1e937d0aab66ae583415d8a4030bd9..e80dff3c3e0610a0d46b4b5babfa41c1d713d01a 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid.module.ts +++ b/alfa-client/libs/bescheid/src/lib/bescheid.module.ts @@ -12,8 +12,6 @@ import { BescheidListInVorgangComponent } from './bescheid-list-in-vorgang-conta import { DocumentInBescheidContainerComponent } from './bescheid-list-in-vorgang-container/bescheid-list-in-vorgang/document-in-bescheid-container/document-in-bescheid-container.component'; import { BeschiedenDateContainerComponent } from './beschieden-date-in-vorgang-container/beschieden-date-container/beschieden-date-container.component'; import { BeschiedenDateInVorgangContainerComponent } from './beschieden-date-in-vorgang-container/beschieden-date-in-vorgang-container.component'; -import { CreateBescheidButtonContainerComponent } from './create-bescheid-button-container/create-bescheid-button-container.component'; -import { CreateBescheidButtonComponent } from './create-bescheid-button-container/create-bescheid-button/create-bescheid-button.component'; import { BescheidStatusTextComponent, @@ -36,8 +34,6 @@ import { CloseIconComponent, ], declarations: [ - CreateBescheidButtonContainerComponent, - CreateBescheidButtonComponent, BescheidInVorgangContainerComponent, BescheidInVorgangComponent, BescheidListInVorgangContainerComponent, @@ -48,7 +44,6 @@ import { ], exports: [ BescheidInVorgangContainerComponent, - CreateBescheidButtonContainerComponent, BescheidListInVorgangContainerComponent, BeschiedenDateInVorgangContainerComponent, ], diff --git a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button-container.component.html b/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button-container.component.html deleted file mode 100644 index 1cc547861a553e8955f7f4481a862c2d5daeb535..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button-container.component.html +++ /dev/null @@ -1,6 +0,0 @@ -<alfa-create-bescheid-button - data-test-id="create-bescheid-button-component" - [createBescheidCommand]="createBescheidInCommand$ | async" - (createBescheid)="create()" -> -</alfa-create-bescheid-button> diff --git a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button-container.component.scss b/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button-container.component.scss deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button-container.component.spec.ts b/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button-container.component.spec.ts deleted file mode 100644 index 55dc7e67d6a90ba7555860c8ead94e494bc39316..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button-container.component.spec.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { Mock, dispatchEventFromFixture, mock } from '@alfa-client/test-utils'; -import { VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; -import { BescheidService } from 'libs/bescheid-shared/src/lib/bescheid.service'; -import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; -import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang'; -import { MockComponent } from 'ng-mocks'; -import { CreateBescheidButtonContainerComponent } from './create-bescheid-button-container.component'; -import { CreateBescheidButtonComponent } from './create-bescheid-button/create-bescheid-button.component'; - -describe('CreateBescheidButtonContainerComponent', () => { - let component: CreateBescheidButtonContainerComponent; - let fixture: ComponentFixture<CreateBescheidButtonContainerComponent>; - - const createBescheidComponent: string = getDataTestIdOf('create-bescheid-button-component'); - const service: Mock<BescheidService> = mock(BescheidService); - const vorgangWithEingang: VorgangWithEingangResource = createVorgangWithEingangResource(); - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ - CreateBescheidButtonContainerComponent, - MockComponent(CreateBescheidButtonComponent), - ], - providers: [ - { - provide: BescheidService, - useValue: service, - }, - ], - }).compileComponents(); - - fixture = TestBed.createComponent(CreateBescheidButtonContainerComponent); - component = fixture.componentInstance; - component.vorgangWithEingang = vorgangWithEingang; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - describe('ngOnInit', () => { - it('should get bescheid command', () => { - component.ngOnInit(); - - expect(service.getBescheidCommand).toHaveBeenCalled(); - }); - }); - - describe('create', () => { - it('should call service', () => { - dispatchEventFromFixture(fixture, createBescheidComponent, 'createBescheid'); - - expect(service.createBescheid).toHaveBeenCalledWith(vorgangWithEingang); - }); - }); -}); diff --git a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button-container.component.ts b/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button-container.component.ts deleted file mode 100644 index a896daae64dd1c1e9470222356fe83b7c9f41b95..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button-container.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { CommandResource } from '@alfa-client/command-shared'; -import { StateResource, createEmptyStateResource } from '@alfa-client/tech-shared'; -import { VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; -import { Component, Input, OnInit } from '@angular/core'; -import { BescheidService } from 'libs/bescheid-shared/src/lib/bescheid.service'; -import { Observable, of } from 'rxjs'; - -@Component({ - selector: 'alfa-create-bescheid-button-container', - templateUrl: './create-bescheid-button-container.component.html', - styleUrls: ['./create-bescheid-button-container.component.scss'], -}) -export class CreateBescheidButtonContainerComponent implements OnInit { - @Input() vorgangWithEingang: VorgangWithEingangResource; - - public createBescheidInCommand$: Observable<StateResource<CommandResource>> = of( - createEmptyStateResource<CommandResource>(), - ); - - constructor(private bescheidService: BescheidService) {} - - ngOnInit(): void { - this.createBescheidInCommand$ = this.bescheidService.getBescheidCommand(); - } - - public create(): void { - this.bescheidService.createBescheid(this.vorgangWithEingang); - } -} diff --git a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button/create-bescheid-button.component.html b/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button/create-bescheid-button.component.html deleted file mode 100644 index ac1efb73c28ad0ed875c79f084ebf9a5ee55dec6..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button/create-bescheid-button.component.html +++ /dev/null @@ -1,8 +0,0 @@ -<ozgcloud-icon-button-with-spinner - data-test-id="create-bescheid-icon-button" - icon="description" - toolTip="Bescheid erstellen" - [stateResource]="createBescheidCommand" - (clickEmitter)="createBescheid.emit()" -> -</ozgcloud-icon-button-with-spinner> diff --git a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button/create-bescheid-button.component.scss b/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button/create-bescheid-button.component.scss deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button/create-bescheid-button.component.spec.ts b/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button/create-bescheid-button.component.spec.ts deleted file mode 100644 index d15b7638e4686c64dd015cae79be7e3cee5915f4..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button/create-bescheid-button.component.spec.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { dispatchEventFromFixture } from '@alfa-client/test-utils'; -import { IconButtonWithSpinnerComponent } from '@alfa-client/ui'; -import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; -import { MockComponent } from 'ng-mocks'; -import { CreateBescheidButtonComponent } from './create-bescheid-button.component'; - -describe('CreateBescheidButtonComponent', () => { - let component: CreateBescheidButtonComponent; - let fixture: ComponentFixture<CreateBescheidButtonComponent>; - - const createBescheidButton: string = getDataTestIdOf('create-bescheid-icon-button'); - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [CreateBescheidButtonComponent, MockComponent(IconButtonWithSpinnerComponent)], - }).compileComponents(); - - fixture = TestBed.createComponent(CreateBescheidButtonComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - describe('on button click', () => { - it('should emit createBescheid', () => { - jest.spyOn(component.createBescheid, 'emit'); - - dispatchEventFromFixture(fixture, createBescheidButton, 'clickEmitter'); - - expect(component.createBescheid.emit).toHaveBeenCalled(); - }); - }); -}); diff --git a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button/create-bescheid-button.component.ts b/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button/create-bescheid-button.component.ts deleted file mode 100644 index d01c5ecd049877b9fd5a63e4e2ee4cde9cd034b0..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/create-bescheid-button-container/create-bescheid-button/create-bescheid-button.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, EventEmitter, Input, Output } from '@angular/core'; -import { CommandResource } from '@alfa-client/command-shared'; -import { StateResource, createEmptyStateResource } from '@alfa-client/tech-shared'; - -@Component({ - selector: 'alfa-create-bescheid-button', - templateUrl: './create-bescheid-button.component.html', - styleUrls: ['./create-bescheid-button.component.scss'], -}) -export class CreateBescheidButtonComponent { - @Input() createBescheidCommand: StateResource<CommandResource> = - createEmptyStateResource<CommandResource>(); - - @Output() createBescheid: EventEmitter<void> = new EventEmitter(); -} diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-area/vorgang-detail-action-buttons/vorgang-detail-action-buttons.component.html b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-area/vorgang-detail-action-buttons/vorgang-detail-action-buttons.component.html index 85de971a72be9d72870985a6c9c32c35939b0079..2c9d56aca5b60504793eed40f24a3066de934e84 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-area/vorgang-detail-action-buttons/vorgang-detail-action-buttons.component.html +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-area/vorgang-detail-action-buttons/vorgang-detail-action-buttons.component.html @@ -82,9 +82,3 @@ [showAsIconButton]="showAsIconButton" [vorgang]="vorgangWithEingang" ></alfa-postfach-mail-button-container> - -<alfa-create-bescheid-button-container - *ngIf="vorgangWithEingang | hasLink: vorgangWithEingangLinkRel.CREATE_BESCHEID" - [vorgangWithEingang]="vorgangWithEingang" - data-test-id="create-bescheid-button-container" -></alfa-create-bescheid-button-container> diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-area/vorgang-detail-action-buttons/vorgang-detail-action-buttons.component.spec.ts b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-area/vorgang-detail-action-buttons/vorgang-detail-action-buttons.component.spec.ts index d62f61ebe56e9a706ee873724f56e4524b8c7d91..3d3eab79b4d777303aa0d2be366e76e21dcb3f23 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-area/vorgang-detail-action-buttons/vorgang-detail-action-buttons.component.spec.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-area/vorgang-detail-action-buttons/vorgang-detail-action-buttons.component.spec.ts @@ -21,13 +21,7 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { CreateBescheidButtonContainerComponent } from '@alfa-client/bescheid'; -import { - EndgueltigLoeschenButtonContainerComponent, - LoeschAnforderungZuruecknehmenButtonContainerComponent, - LoeschenAnfordernButtonContainerComponent, -} from '@alfa-client/loesch-anforderung'; +import { EndgueltigLoeschenButtonContainerComponent, LoeschAnforderungZuruecknehmenButtonContainerComponent, LoeschenAnfordernButtonContainerComponent } from '@alfa-client/loesch-anforderung'; import { PostfachMailButtonContainerComponent } from '@alfa-client/postfach'; import { HasLinkPipe } from '@alfa-client/tech-shared'; import { existsAsHtmlElement, notExistsAsHtmlElement } from '@alfa-client/test-utils'; @@ -35,6 +29,7 @@ import { IconButtonWithSpinnerComponent } from '@alfa-client/ui'; import { AssignUserProfileButtonContainerComponent } from '@alfa-client/user-profile'; import { VorgangWithEingangLinkRel } from '@alfa-client/vorgang-shared'; import { CreateWiedervorlageButtonContainerComponent } from '@alfa-client/wiedervorlage'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang'; import { MockComponent } from 'ng-mocks'; @@ -77,7 +72,6 @@ describe('VorgangDetailActionButtonsComponent', () => { MockComponent(LoeschenAnfordernButtonContainerComponent), MockComponent(EndgueltigLoeschenButtonContainerComponent), MockComponent(LoeschAnforderungZuruecknehmenButtonContainerComponent), - MockComponent(CreateBescheidButtonContainerComponent), ], }); }); diff --git a/alfa-client/libs/vorgang-shared/src/lib/vorgang.linkrel.ts b/alfa-client/libs/vorgang-shared/src/lib/vorgang.linkrel.ts index 57cfeeab38cb013afb230703102924d436b2acd0..8805fedd51dd0c1b6490f74e09df4346f6158900 100644 --- a/alfa-client/libs/vorgang-shared/src/lib/vorgang.linkrel.ts +++ b/alfa-client/libs/vorgang-shared/src/lib/vorgang.linkrel.ts @@ -56,7 +56,6 @@ export enum VorgangWithEingangLinkRel { HISTORIE = 'historie', SEARCH_USER_PROFILES = 'search-user-profiles', EXPORT = 'export', - CREATE_BESCHEID = 'createBescheid', CREATE_BESCHEID_DRAFT = 'createBescheidDraft', PROCESS_VORGANG = 'processVorgang', diff --git a/alfa-server/src/main/resources/application-e2e.yml b/alfa-server/src/main/resources/application-e2e.yml index 7aa16cc6e02921c1fa3157a05b185fcbf08c623d..585c3a5f701bd2f11ccc56211468786f077bfcd4 100644 --- a/alfa-server/src/main/resources/application-e2e.yml +++ b/alfa-server/src/main/resources/application-e2e.yml @@ -8,7 +8,6 @@ keycloak: ozgcloud: feature: - createBescheid: true reply-always-allowed: true forwarding: lninfo: diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/common/FeatureToggleProperties.java b/alfa-service/src/main/java/de/ozgcloud/alfa/common/FeatureToggleProperties.java index b06e637da196c9b9d5dfb11a5d51a72fb505da7d..80238fccb22376ea6e2ff8201f1d7b497a968dae 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/common/FeatureToggleProperties.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/common/FeatureToggleProperties.java @@ -12,11 +12,6 @@ import lombok.Setter; @ConfigurationProperties(prefix = "ozgcloud.feature") public class FeatureToggleProperties { - /** - * Enable/Disable bescheid creation feature. - */ - private boolean createBescheid = false; - /** * Enable mail reply option regardless of other configuration. */ diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/vorgang/VorgangWithEingangProcessor.java b/alfa-service/src/main/java/de/ozgcloud/alfa/vorgang/VorgangWithEingangProcessor.java index 94edbda19108796dfe1b0518e3cea960fa3aa1d5..6b111ac3c55ed436df4b141e6115ba419d599905 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/vorgang/VorgangWithEingangProcessor.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/vorgang/VorgangWithEingangProcessor.java @@ -23,7 +23,6 @@ */ package de.ozgcloud.alfa.vorgang; -import static java.util.Optional.*; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*; import java.util.List; @@ -39,7 +38,6 @@ import org.springframework.stereotype.Component; import de.ozgcloud.alfa.attachment.AttachmentController; import de.ozgcloud.alfa.attachment.AttachmentController.AttachmentsByVorgangController; -import de.ozgcloud.alfa.common.FeatureToggleProperties; import de.ozgcloud.alfa.common.ModelBuilder; import de.ozgcloud.alfa.common.command.CommandController.CommandByRelationController; import de.ozgcloud.alfa.common.user.CurrentUserService; @@ -64,7 +62,6 @@ class VorgangWithEingangProcessor implements RepresentationModelProcessor<Entity static final LinkRelation REL_POSTFACH_MAILS = LinkRelation.of("postfachMails"); static final LinkRelation REL_VORGANG_FORWARDING = LinkRelation.of("forwarding"); static final LinkRelation REL_HISTORIE = LinkRelation.of("historie"); - static final LinkRelation REL_BESCHEID = LinkRelation.of("createBescheid"); static final LinkRelation REL_PROCESS_VORGANG = LinkRelation.of("processVorgang"); static final String REL_SEARCH_USER = "search-user-profiles"; @@ -75,8 +72,6 @@ class VorgangWithEingangProcessor implements RepresentationModelProcessor<Entity private final CurrentUserService userService; private final UserManagerUrlProvider userManagerUrlProvider; - private final FeatureToggleProperties featureToggleProperties; - private final VorgangProperties vorgangProperties; private final VorgangProcessorProperties vorgangProcessorProperties; private static final Predicate<VorgangWithEingang> HAS_ATTACHMENTS = vorgangWithEingang -> vorgangWithEingang.getEingang() @@ -111,9 +106,6 @@ class VorgangWithEingangProcessor implements RepresentationModelProcessor<Entity .addLink(linkTo(methodOn(HistorieController.class).getAll(vorgang.getId())).withRel(REL_HISTORIE)) .ifMatch(() -> userManagerUrlProvider.isConfiguredForSearchUserProfile() && hasOrganisationsEinheitId(vorgang)) .addLink(this::buildSearchUserProfilesLink) - .ifMatch(this::isCreateBescheidEnabled) - .addLink(linkTo(methodOn(CommandByRelationController.class).createCommand(vorgang.getId(), vorgang.getId(), vorgang.getVersion(), - null)).withRel(REL_BESCHEID)) .ifMatch(this::isProcessable) .addLink( () -> linkTo(methodOn(CommandByRelationController.class).createCommand(vorgang.getId(), vorgang.getId(), vorgang.getVersion(), @@ -144,21 +136,6 @@ class VorgangWithEingangProcessor implements RepresentationModelProcessor<Entity return vorgang.getEingang().getZustaendigeStelle().getOrganisationseinheitenId(); } - boolean isCreateBescheidEnabled(VorgangWithEingang vorgang) { - return featureToggleProperties.isCreateBescheid() && hasVorgangCreateBescheidEnabled(vorgang); - } - - boolean hasVorgangCreateBescheidEnabled(VorgangWithEingang vorgang) { - return ofNullable(vorgang.getEingang()) - .map(Eingang::getHeader) - .map(this::isCreateBescheidEnabled) - .orElse(false); - } - - private boolean isCreateBescheidEnabled(EingangHeader eingangHeader) { - return vorgangProperties.getBescheid().stream().anyMatch(prop -> isFormIdAndFormEngineNameMatching(eingangHeader, prop)); - } - private boolean isProcessable(VorgangWithEingang vorgang) { return isAnyFormIdAndFormEngineNameMatching(vorgang.getEingang().getHeader(), vorgangProcessorProperties.getProcessor()); } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/vorgang/VorgangWithEingangProcessorTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/vorgang/VorgangWithEingangProcessorTest.java index 05306f1e29f313ec547dee7e7a8fc5ec1d652614..988b8cd04b8df6ae58cb6923785235828ebd5447 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/vorgang/VorgangWithEingangProcessorTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/vorgang/VorgangWithEingangProcessorTest.java @@ -27,7 +27,6 @@ import static de.ozgcloud.alfa.common.UserProfileUrlProviderTestFactory.*; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.BeforeEach; @@ -45,7 +44,6 @@ import org.springframework.hateoas.LinkRelation; import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriTemplate; -import de.ozgcloud.alfa.common.FeatureToggleProperties; import de.ozgcloud.alfa.common.UserProfileUrlProvider; import de.ozgcloud.alfa.common.command.CommandController.CommandByRelationController; import de.ozgcloud.alfa.common.user.CurrentUserService; @@ -66,12 +64,6 @@ class VorgangWithEingangProcessorTest { @Mock private UserManagerUrlProvider userManagerUrlProvider; - @Mock - private FeatureToggleProperties featureToggleProperties; - - @Mock - private VorgangProperties vorgangProperties; - @Mock private VorgangProcessorProperties vorgangProcessorProperties; @@ -332,218 +324,6 @@ class VorgangWithEingangProcessorTest { } } - @Nested - class TestHasVorgangCreateBescheidEnabled { - - @Nested - class TestOnEmptyBescheidProperties { - - @BeforeEach - void setUp() { - when(vorgangProperties.getBescheid()).thenReturn(Collections.emptyList()); - } - - @Test - void shouldReturnFalse() { - var hasEnabled = callProcessor(VorgangWithEingangTestFactory.create()); - - assertThat(hasEnabled).isFalse(); - } - - } - - @Nested - class TestOnBescheidPropertiesSet { - - @BeforeEach - void setUp() { - when(vorgangProperties.getBescheid()).thenReturn(List.of(VorgangPropertyTestFactory.create())); - } - - @Test - void shouldReturnFalseIfFormEngineNameNotEquals() { - var vorgang = createVorgang(EingangTestFactory.createBuilder() - .header(EingangHeaderTestFactory.createBuilder() - .formEngineName("different").build()) - .build()); - - var hasEnabled = callProcessor(vorgang); - - assertThat(hasEnabled).isFalse(); - } - - @Test - void shouldReturnTrue() { - var hasEnabled = callProcessor(VorgangWithEingangTestFactory.create()); - - assertThat(hasEnabled).isTrue(); - } - } - - @Test - void shouldReturnFalseOnEmptyEingang() { - var vorgangWithEmptyEingang = createVorgang(null); - - var hasEnabled = callProcessor(vorgangWithEmptyEingang); - - assertThat(hasEnabled).isFalse(); - } - - @Test - void shouldReturnFalseOnEmptyEingangHeader() { - var vorgangWithEmptyEingangHeader = EingangTestFactory.createBuilder().header(null).build(); - - var hasEnabled = callProcessor(createVorgang(vorgangWithEmptyEingangHeader)); - - assertThat(hasEnabled).isFalse(); - } - - @Test - void shouldReturnFalseOnEmptyFormEngineName() { - var vorgangWithEmptyFormEngineName = createVorgang( - EingangTestFactory.createBuilder().header(EingangHeaderTestFactory.createBuilder().formEngineName(null).build()).build()); - - var hasEnabled = callProcessor(vorgangWithEmptyFormEngineName); - - assertThat(hasEnabled).isFalse(); - } - - @Test - void shouldReturnFalseOnEmptyFormId() { - var vorgangWithEmptyFormId = createVorgang( - EingangTestFactory.createBuilder().header(EingangHeaderTestFactory.createBuilder().formId(null).build()).build()); - - var hasEnabled = callProcessor(vorgangWithEmptyFormId); - - assertThat(hasEnabled).isFalse(); - } - - private boolean callProcessor(VorgangWithEingang vorgang) { - return processor.hasVorgangCreateBescheidEnabled(vorgang); - } - - private VorgangWithEingang createVorgang(Eingang eingang) { - return VorgangWithEingangTestFactory.createBuilder().eingang(eingang).build(); - } - } - - @Nested - class TestIsCreateBescheidEnabled { - - @Nested - class TestFeatureToggleDisabled { - - @BeforeEach - void setUp() { - when(featureToggleProperties.isCreateBescheid()).thenReturn(false); - } - - @Test - void shouldCallFeatureToggleProperties() { - callProcessor(VorgangWithEingangTestFactory.create()); - - verify(featureToggleProperties).isCreateBescheid(); - } - - @Test - void shouldNotCallHasVorgangCreateBescheidEnabled() { - var vorgang = VorgangWithEingangTestFactory.create(); - - callProcessor(vorgang); - - verify(processor, never()).hasVorgangCreateBescheidEnabled(vorgang); - } - - @Test - void shouldReturnFalse() { - var isEnabled = callProcessor(VorgangWithEingangTestFactory.create()); - - assertThat(isEnabled).isFalse(); - } - } - - @Nested - class TestFeatureToggleEnabled { - - private final VorgangWithEingang vorgang = VorgangWithEingangTestFactory.create(); - - @BeforeEach - void setUp() { - when(featureToggleProperties.isCreateBescheid()).thenReturn(true); - } - - @Test - void shouldCallFeatureToggleProperties() { - callProcessor(vorgang); - - verify(featureToggleProperties).isCreateBescheid(); - } - - @Test - void shouldCallHasVorgangCreateBescheidEnabled() { - callProcessor(vorgang); - - verify(processor).hasVorgangCreateBescheidEnabled(vorgang); - } - - @Test - void shouldReturnTrue() { - doReturn(true).when(processor).hasVorgangCreateBescheidEnabled(vorgang); - - var isEnabled = callProcessor(vorgang); - - assertThat(isEnabled).isTrue(); - } - - @Test - void shouldReturnFalse() { - doReturn(false).when(processor).hasVorgangCreateBescheidEnabled(vorgang); - - var isEnabled = callProcessor(vorgang); - - assertThat(isEnabled).isFalse(); - } - } - - private boolean callProcessor(VorgangWithEingang vorgang) { - return processor.isCreateBescheidEnabled(vorgang); - } - - } - - @Nested - class TestCreateBescheidLink { - - private final VorgangWithEingang vorgang = VorgangWithEingangTestFactory.create(); - private final EntityModel<VorgangWithEingang> vorgangEntityModel = EntityModel.of(vorgang); - - @BeforeEach - void activateFeature() { - initUserProfileUrlProvider(urlProvider); - } - - @Test - void shouldHaveCreateBescheidLink() { - doReturn(true).when(processor).isCreateBescheidEnabled(vorgang); - - var model = processor.process(vorgangEntityModel); - - assertThat(model.getLink(VorgangWithEingangProcessor.REL_BESCHEID)).isPresent().get() - .extracting(Link::getHref) - .isEqualTo("/api/vorgangs/" + VorgangHeaderTestFactory.ID + "/relations/" + VorgangHeaderTestFactory.ID + "/" - + VorgangHeaderTestFactory.VERSION + "/commands"); - } - - @Test - void shouldHaveNoLinkIfDisabled() { - doReturn(false).when(processor).isCreateBescheidEnabled(vorgang); - - var model = processor.process(vorgangEntityModel); - - assertThat(model.getLink(VorgangWithEingangProcessor.REL_BESCHEID)).isEmpty(); - } - } - @DisplayName("Process vorgang") @Nested class TestProcessVorgang {