diff --git a/alfa-client/apps/alfa-e2e/docker-compose.yml b/alfa-client/apps/alfa-e2e/docker-compose.yml index 0b889648c9c274ad0b7be4ccfb3490ff54c711c4..8471fbd5db736075a3443e0d9bf941e18078a73c 100644 --- a/alfa-client/apps/alfa-e2e/docker-compose.yml +++ b/alfa-client/apps/alfa-e2e/docker-compose.yml @@ -88,6 +88,10 @@ services: - GRPC_CLIENT_USER-MANAGER_NEGOTIATIONTYPE=PLAINTEXT - GRPC_CLIENT_VORGANG-MANAGER_ADDRESS=static://vorgang-manager:9090 - GRPC_CLIENT_VORGANG-MANAGER_NEGOTIATIONTYPE=PLAINTEXT + - GRPC_CLIENT_COLLABORATION-MANAGER_ADDRESS=static://vorgang-manager:9090 + - GRPC_CLIENT_COLLABORATION-MANAGER_NEGOTIATIONTYPE=PLAINTEXT + - GRPC_CLIENT_ZUFI-MANAGER_ADDRESS=static://zufi-manager-server:9190 + - GRPC_CLIENT_ZUFI-MANAGER_NEGOTIATIONTYPE=PLAINTEXT - KEYCLOAK_AUTH_SERVER_URL=https://sso.dev.by.ozg-cloud.de - KEYCLOAK_REALM=${KEYCLOAK_REALM:-by-e2e-tests-local-dev} - KEYCLOAK_RESOURCE=${KEYCLOAK_CLIENT:-alfa} @@ -106,8 +110,6 @@ services: - OZGCLOUD_VORGANG_BESCHEID_0_FORM_ENGINE_NAME=FormSolutions - OZGCLOUD_VORGANG_BESCHEID_0_FORM_ID=KFAS_STAGE_KI_10_Haltverbot_LANDESHACKATHON - OZGCLOUD_FEATURE_COLLABORATION_ENABLED=true - - GRPC_CLIENT_ZUFI-MANAGER_ADDRESS=static://zufi-manager-server:9190 - - GRPC_CLIENT_ZUFI-MANAGER_NEGOTIATIONTYPE=PLAINTEXT - OZGCLOUD_BARRIEREFREIHEIT_URL=http://bam.de ports: - 8080:8080 diff --git a/alfa-client/apps/alfa-e2e/src/e2e/main-tests/vorgang-zusammenarbeit/vorgang-zusammenarbeit-anfragen.cy.ts b/alfa-client/apps/alfa-e2e/src/e2e/main-tests/vorgang-zusammenarbeit/vorgang-zusammenarbeit-anfragen.cy.ts index 4805403d3a7231fc3eb5d3ed5364ebb7ecfa832b..93efa88639b3f666ebdc4d68d60cbc5d92792c1b 100644 --- a/alfa-client/apps/alfa-e2e/src/e2e/main-tests/vorgang-zusammenarbeit/vorgang-zusammenarbeit-anfragen.cy.ts +++ b/alfa-client/apps/alfa-e2e/src/e2e/main-tests/vorgang-zusammenarbeit/vorgang-zusammenarbeit-anfragen.cy.ts @@ -101,31 +101,31 @@ describe('Vorgang Zusammenarbeit anfragen', () => { zusammenarbeitContainer.hasSearchText(''); }); - it.skip('TODO: Setup Jenkins --- should find 2 results after entering kiel', () => { + it('TODO: Setup Jenkins --- should find 2 results after entering kiel', () => { zusammenarbeitContainer.enterSearchInput(stelleSearch2); zusammenarbeitContainer.expectNumberOfEntriesToBe(2); }); - it.skip('should close layer after click on search entry', () => { + it('should close layer after click on search entry', () => { zusammenarbeitContainer.clickSearchEntry(0); exist(zusammenarbeitContainer.getSendButton()); notExist(zusammenarbeitContainer.getSearchText()); }); - it.skip('should show part of address in Zufi header', () => { + it('should show part of address in Zufi header', () => { zusammenarbeitContainer.addressContains(stelleSearch2); }); - it.skip('should be able to enter title and message, and show scrollbar on long text', () => { + it('should be able to enter title and message, and show scrollbar on long text', () => { zusammenarbeitContainer.enterTitel(titleText); zusammenarbeitContainer.enterMessage(messageText); zusammenarbeitContainer.messageScrollbarIsPresent(); }); - it.skip('should show title and message, show snackbar, and remove buttons after sending', () => { + it('should show title and message, show snackbar, and remove buttons after sending', () => { zusammenarbeitContainer.sendAnfrage(); notExist(zusammenarbeitContainer.getSendButton()); diff --git a/alfa-client/libs/collaboration-shared/src/index.ts b/alfa-client/libs/collaboration-shared/src/index.ts index 58859f091df38c372a92ca17a76e2719ebf244d3..69d0e06165727bccba123a216f53f2c52606c9be 100644 --- a/alfa-client/libs/collaboration-shared/src/index.ts +++ b/alfa-client/libs/collaboration-shared/src/index.ts @@ -1,3 +1,4 @@ +export * from './lib/collaboration-list-resource.service'; export * from './lib/collaboration-shared.module'; export * from './lib/collaboration.linkrel'; export * from './lib/collaboration.model'; diff --git a/alfa-client/libs/collaboration-shared/src/lib/collaboration.model.ts b/alfa-client/libs/collaboration-shared/src/lib/collaboration.model.ts index 5cb0cb4409c1bf54e9447410b2e7bc02b54f1b30..ef9cfa6bd9d56e597e0ed9b2945319708b02688b 100644 --- a/alfa-client/libs/collaboration-shared/src/lib/collaboration.model.ts +++ b/alfa-client/libs/collaboration-shared/src/lib/collaboration.model.ts @@ -3,9 +3,14 @@ import { Resource, ResourceUri } from '@ngxp/rest'; export interface Collaboration { titel: string; - anfrage: string; + beschreibung: string; zustaendigeStelle: ResourceUri; - collaborationLevel?: number; + collaborationLevel?: (typeof CollaborationLevels)[keyof typeof CollaborationLevels]; +} + +export class CollaborationLevels { + public static readonly ORGANISATIONS_EINHEIT = 1; + public static readonly EXTERNE_FACHSTELLE = 4; } export interface CollaborationResource extends Collaboration, Resource, ListItemResource {} diff --git a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts index 3ad660af24dfd54fbe6a5b7368f2fe66e064aa4d..80d2dfbf9677d35d265488b3a1d38fa87679ae4b 100644 --- a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts +++ b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts @@ -46,6 +46,14 @@ describe('CollaborationService', () => { }); }); + describe('refresh list', () => { + it('should call service', () => { + service.refreshList(); + + expect(listService.refresh).toHaveBeenCalled(); + }); + }); + describe('organisationsEinheit', () => { describe('is form visible', () => { it('should return value', (done) => { diff --git a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts index 5e3a4bddae93de877988896523a9132e676c6575..d2e60c0515268430439e460b8916d80b53dab1dc 100644 --- a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts +++ b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts @@ -28,6 +28,10 @@ export class CollaborationService { return this.listService.getList(); } + public refreshList(): void { + this.listService.refresh(); + } + public isOrganisationsEinheitFormVisible(): Observable<boolean> { return this.showOrganisationsEinheitForm$.asObservable(); } diff --git a/alfa-client/libs/collaboration-shared/test/collaboration.ts b/alfa-client/libs/collaboration-shared/test/collaboration.ts index da923fb34b96e475b692c6212297e6f612f90be6..6eb8cfcd78c22cd95777be2eab44ddaf0b402ed0 100644 --- a/alfa-client/libs/collaboration-shared/test/collaboration.ts +++ b/alfa-client/libs/collaboration-shared/test/collaboration.ts @@ -9,7 +9,7 @@ import { Collaboration, CollaborationListResource, CollaborationResource } from export function createCollaboration(): Collaboration { return { titel: faker.word.sample(2), - anfrage: faker.word.sample(10), + beschreibung: faker.word.sample(10), zustaendigeStelle: faker.internet.url(), }; } diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.html b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.html index 3f896b077d98b171d49206be45d866764fc3923f..f4dd770f3b907164024207f747d053cd63e632fc 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.html +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.html @@ -1,3 +1,8 @@ +<alfa-collaboration-list-container + [collaborationStateListResource]="collaborationStateListResource$ | async" + class="mb-6 block" + data-test-id="collaboration-list" +></alfa-collaboration-list-container> <alfa-collaboration-in-vorgang [vorgang]="vorgang" [collaborationStateListResource]="collaborationStateListResource$ | async" diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts index 4543235a339d3c62076e82ead2f770e45f2af46b..0190fbc0f4b2d9dd9f4506c577af0c5fc1a62fa3 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts @@ -10,6 +10,7 @@ import { MockComponent } from 'ng-mocks'; import { of } from 'rxjs'; import { CollaborationInVorgangContainerComponent } from './collaboration-in-vorgang-container.component'; import { CollaborationInVorgangComponent } from './collaboration-in-vorgang/collaboration-in-vorgang.component'; +import { CollaborationListContainerComponent } from './collaboration-list-container/collaboration-list-container.component'; describe('CollaborationInVorgangContainerComponent', () => { let component: CollaborationInVorgangContainerComponent; @@ -22,7 +23,11 @@ describe('CollaborationInVorgangContainerComponent', () => { beforeEach(async () => { service = mock(CollaborationService); await TestBed.configureTestingModule({ - declarations: [CollaborationInVorgangContainerComponent, MockComponent(CollaborationInVorgangComponent)], + declarations: [ + CollaborationInVorgangContainerComponent, + MockComponent(CollaborationListContainerComponent), + MockComponent(CollaborationInVorgangComponent), + ], providers: [ { provide: CollaborationService, diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-list-container.component.html b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-list-container.component.html new file mode 100644 index 0000000000000000000000000000000000000000..46094ca0c480d3579ff92ede7e7ca66afdc55691 --- /dev/null +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-list-container.component.html @@ -0,0 +1,20 @@ +<ozgcloud-spinner [stateResource]="collaborationStateListResource"> + @for(collaboration of collaborations; track collaboration.zustaendigeStelle){ + @if(collaboration.collaborationLevel === CollaborationLevels.ORGANISATIONS_EINHEIT){ + <alfa-organisations-einheit-list-item-container + [organisationsEinheitResourceUri]="collaboration.zustaendigeStelle" + data-test-id="organisations-einheit-list-item" + > + <alfa-collaboration-request [collaboration]="collaboration"/> + </alfa-organisations-einheit-list-item-container> + } + @if(collaboration.collaborationLevel === CollaborationLevels.EXTERNE_FACHSTELLE){ + <alfa-externe-fachstelle-list-item-container + [externeFachstelleResourceUri] = "collaboration.zustaendigeStelle" + data-test-id="externe-fachstelle-list-item" + > + <alfa-collaboration-request [collaboration]="collaboration"/> + </alfa-externe-fachstelle-list-item-container> + } + } +</ozgcloud-spinner> \ No newline at end of file diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-list-container.component.spec.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-list-container.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..4d31e3de38064a86ea5a602f987b8336bac5d1e5 --- /dev/null +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-list-container.component.spec.ts @@ -0,0 +1,101 @@ +import { + CollaborationLevels, + CollaborationListLinkRel, + CollaborationListResource, + CollaborationResource, +} from '@alfa-client/collaboration-shared'; +import { createEmptyStateResource, createStateResource } from '@alfa-client/tech-shared'; +import { SpinnerComponent } from '@alfa-client/ui'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { createCollaboration, createCollaborationListResource } from 'libs/collaboration-shared/test/collaboration'; +import { + ExterneFachstelleListItemContainerComponent, +} from 'libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item-container.component'; +import { + OrganisationsEinheitListItemContainerComponent, +} from 'libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item-container.component'; +import { MockComponent } from 'ng-mocks'; +import { CollaborationListContainerComponent } from './collaboration-list-container.component'; +import { toResource } from 'libs/tech-shared/test/resource'; +import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; +import { existsAsHtmlElement } from '@alfa-client/test-utils'; +import { CollaborationRequestComponent } from './collaboration-request/collaboration-request.component'; + +describe('CollaborationListContainerComponent', () => { + let component: CollaborationListContainerComponent; + let fixture: ComponentFixture<CollaborationListContainerComponent>; + + const organisationsEinheitListItem: string = getDataTestIdOf('organisations-einheit-list-item'); + const externeFachstelleListItem: string = getDataTestIdOf('externe-fachstelle-list-item'); + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ + CollaborationListContainerComponent, + MockComponent(OrganisationsEinheitListItemContainerComponent), + MockComponent(ExterneFachstelleListItemContainerComponent), + MockComponent(CollaborationRequestComponent), + MockComponent(SpinnerComponent), + ], + }).compileComponents(); + + fixture = TestBed.createComponent(CollaborationListContainerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + describe('template', () => { + const collaboration: CollaborationResource = toResource(createCollaboration()); + + beforeEach(() => { + component.collaborations = [collaboration]; + }) + + describe('alfa-organisations-einheit-list-item-container', () => { + it('should be rendered if collaborationLevel is ORGANISATIONS_EINHEIT', () => { + collaboration.collaborationLevel = CollaborationLevels.ORGANISATIONS_EINHEIT; + fixture.detectChanges(); + + existsAsHtmlElement(fixture, organisationsEinheitListItem); + }); + }) + + describe('alfa-externe-fachstelle-list-item-container', () => { + it('should be rendered if collaborationLevel is EXTERNE_FACHSTELLE', () => { + collaboration.collaborationLevel = CollaborationLevels.EXTERNE_FACHSTELLE; + fixture.detectChanges(); + + existsAsHtmlElement(fixture, externeFachstelleListItem); + }); + }) + }) + + describe('component', () => { + describe('getCollaborations', () => { + it('should return empty array if state resource is null', () => { + component.collaborationStateListResource = null; + + expect(component.getCollaborations()).toEqual([]); + }); + + it('should return empty array if resource is null', () => { + component.collaborationStateListResource = createEmptyStateResource(); + + expect(component.getCollaborations()).toEqual([]); + }); + + it('should return embedded resource', () => { + const collaborationListResource: CollaborationListResource = createCollaborationListResource(); + component.collaborationStateListResource = createStateResource(collaborationListResource); + + expect(component.getCollaborations()).toEqual( + collaborationListResource._embedded[CollaborationListLinkRel.COLLABORATION_LIST], + ); + }); + }); + }); +}); diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-list-container.component.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-list-container.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..81608691c46baf38806ac682d54e4f182f18fae2 --- /dev/null +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-list-container.component.ts @@ -0,0 +1,28 @@ +import { + CollaborationLevels, + CollaborationListLinkRel, + CollaborationListResource, + CollaborationResource, +} from '@alfa-client/collaboration-shared'; +import { getEmbeddedResources, StateResource } from '@alfa-client/tech-shared'; +import { Component, Input, OnChanges } from '@angular/core'; + +@Component({ + selector: 'alfa-collaboration-list-container', + templateUrl: './collaboration-list-container.component.html', +}) +export class CollaborationListContainerComponent implements OnChanges { + @Input() public collaborationStateListResource: StateResource<CollaborationListResource>; + + public collaborations: CollaborationResource[]; + + ngOnChanges(): void { + this.collaborations = this.getCollaborations(); + } + + getCollaborations(): CollaborationResource[] { + return getEmbeddedResources(this.collaborationStateListResource, CollaborationListLinkRel.COLLABORATION_LIST); + } + + protected readonly CollaborationLevels = CollaborationLevels; +} diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-request/collaboration-request.component.html b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-request/collaboration-request.component.html new file mode 100644 index 0000000000000000000000000000000000000000..e3cc98d70a5ff4414e8d7b174cc0c83c210809a7 --- /dev/null +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-request/collaboration-request.component.html @@ -0,0 +1,6 @@ +<div class="block bg-white p-4 m-2 mt-4" role="region" aria-labelledby="collaboration-title"> + <h2 id="collaboration-title" class="mb-4 text-xl text-text"> + <span class="font-semibold">{{ collaboration.titel }}</span> + </h2> + <p class="whitespace-pre-line">{{ collaboration.beschreibung }}</p> +</div> diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-request/collaboration-request.component.spec.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-request/collaboration-request.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..f71e02109844e9cb70d3bcf4e0c17400be4c63e5 --- /dev/null +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-request/collaboration-request.component.spec.ts @@ -0,0 +1,28 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CollaborationResource } from '@alfa-client/collaboration-shared'; +import { createCollaboration } from 'libs/collaboration-shared/test/collaboration'; +import { toResource } from 'libs/tech-shared/test/resource'; +import { CollaborationRequestComponent } from './collaboration-request.component'; + +describe('CollaborationRequestComponent', () => { + let component: CollaborationRequestComponent; + let fixture: ComponentFixture<CollaborationRequestComponent>; + + const collaboration: CollaborationResource = toResource(createCollaboration()); + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [CollaborationRequestComponent], + }).compileComponents(); + + fixture = TestBed.createComponent(CollaborationRequestComponent); + component = fixture.componentInstance; + component.collaboration = collaboration; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-request/collaboration-request.component.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-request/collaboration-request.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..7da73df01b0fe0fbcf58bfb228b364d43c4e6a4e --- /dev/null +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-list-container/collaboration-request/collaboration-request.component.ts @@ -0,0 +1,10 @@ +import { CollaborationResource } from '@alfa-client/collaboration-shared'; +import { Component, Input } from '@angular/core'; + +@Component({ + selector: 'alfa-collaboration-request', + templateUrl: './collaboration-request.component.html', +}) +export class CollaborationRequestComponent { + @Input() public collaboration: CollaborationResource; +} diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.spec.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.spec.ts index 937e26e70400fd6f5ba7dbe931e6ce28a11ff3cb..0688eb4db4e249d6fd12760e752c831db9a0de1e 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.spec.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.spec.ts @@ -1,9 +1,9 @@ import { CollaborationListResource } from '@alfa-client/collaboration-shared'; -import { CommandResource } from '@alfa-client/command-shared'; -import { StateResource, createEmptyStateResource, createStateResource } from '@alfa-client/tech-shared'; -import { Mock, mock } from '@alfa-client/test-utils'; import { SnackBarService } from '@alfa-client/ui'; import { TestBed } from '@angular/core/testing'; +import { CommandLinkRel, CommandResource } from '@alfa-client/command-shared'; +import { StateResource, createEmptyStateResource, createStateResource } from '@alfa-client/tech-shared'; +import { Mock, mock, useFromMock } from '@alfa-client/test-utils'; import { UntypedFormBuilder } from '@angular/forms'; import { CollaborationService } from 'libs/collaboration-shared/src/lib/collaboration.service'; import { createCollaborationListResource } from 'libs/collaboration-shared/test/collaboration'; @@ -56,7 +56,9 @@ describe('CollaborationRequestFormService', () => { }); describe('do submit', () => { - const stateCommandResource: StateResource<CommandResource> = createStateResource(createCommandResource()); + const stateCommandResource: StateResource<CommandResource> = createStateResource( + createCommandResource([CommandLinkRel.EFFECTED_RESOURCE]), + ); beforeEach(() => { formService.listResource = collaborationListResource; @@ -69,6 +71,12 @@ describe('CollaborationRequestFormService', () => { expect(service.create).toHaveBeenCalledWith(collaborationListResource, formService.form.value); }); + it('should call service refresh', () => { + formService.submit().subscribe(); + + expect(service.refreshList).toHaveBeenCalled(); + }); + it('should call handleCommandError', () => { const handleCommanErrorSpy = jest.spyOn(formService as any, 'handleCommandError'); diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.ts index 5bcba2a2d33982dbfcf5a24f1ef29f5824dcbe6a..71dd8739c3b80fafbcef6dc4e534daaee16f267a 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/collaboration.request.formservice.ts @@ -1,5 +1,5 @@ import { CollaborationListResource } from '@alfa-client/collaboration-shared'; -import { CommandResource, hasCommandError } from '@alfa-client/command-shared'; +import { CommandResource, hasCommandError, tapOnCommandSuccessfullyDone } from '@alfa-client/command-shared'; import { AbstractFormService, StateResource } from '@alfa-client/tech-shared'; import { SnackBarService } from '@alfa-client/ui'; import { Injectable } from '@angular/core'; @@ -39,6 +39,7 @@ export class CollaborationRequestFormService extends AbstractFormService<Command protected doSubmit(): Observable<StateResource<CommandResource>> { return this.service.create(this.listResource, this.getFormValue()).pipe( + tapOnCommandSuccessfullyDone(() => this.service.refreshList()), tap((commandStateResource: StateResource<CommandResource>) => { this.handleCommandError(commandStateResource.resource); }), diff --git a/alfa-client/libs/collaboration/src/lib/collaboration.module.ts b/alfa-client/libs/collaboration/src/lib/collaboration.module.ts index d9d38c700855608e944c4960c591c7b6f49e9b56..8f56a952d926473e36d9e40381c595ea136866d5 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration.module.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration.module.ts @@ -1,5 +1,6 @@ import { CollaborationSharedModule } from '@alfa-client/collaboration-shared'; import { TechSharedModule } from '@alfa-client/tech-shared'; +import { UiModule } from '@alfa-client/ui'; import { ZustaendigeStelleModule } from '@alfa-client/zustaendige-stelle'; import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; @@ -15,11 +16,15 @@ import { SearchIconComponent, UsersIconComponent, } from '@ods/system'; +import { ExterneFachstelleListItemContainerComponent } from 'libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item-container.component'; +import { OrganisationsEinheitListItemContainerComponent } from 'libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item-container.component'; import { CollaborationInVorgangContainerComponent } from './collaboration-in-vorgang-container/collaboration-in-vorgang-container.component'; import { AnfrageErstellenButtonComponent } from './collaboration-in-vorgang-container/collaboration-in-vorgang/anfrage-erstellen-button/anfrage-erstellen-button.component'; import { CollaborationInVorgangComponent } from './collaboration-in-vorgang-container/collaboration-in-vorgang/collaboration-in-vorgang.component'; import { ExterneFachstelleContainerComponent } from './collaboration-in-vorgang-container/collaboration-in-vorgang/externe-fachstelle-container/externe-fachstelle-container.component'; import { OrganisationsEinheitContainerComponent } from './collaboration-in-vorgang-container/collaboration-in-vorgang/organisations-einheit-container/organisations-einheit-container.component'; +import { CollaborationListContainerComponent } from './collaboration-in-vorgang-container/collaboration-list-container/collaboration-list-container.component'; +import { CollaborationRequestComponent } from './collaboration-in-vorgang-container/collaboration-list-container/collaboration-request/collaboration-request.component'; import { CollaborationRequestFormComponent } from './collaboration-in-vorgang-container/collaboration-request-form/collaboration-request-form.component'; @NgModule({ @@ -41,6 +46,9 @@ import { CollaborationRequestFormComponent } from './collaboration-in-vorgang-co OfficeIconComponent, ExternalUnitIconComponent, PublicAdministrationIconComponent, + OrganisationsEinheitListItemContainerComponent, + ExterneFachstelleListItemContainerComponent, + UiModule, ], declarations: [ CollaborationInVorgangContainerComponent, @@ -49,6 +57,8 @@ import { CollaborationRequestFormComponent } from './collaboration-in-vorgang-co AnfrageErstellenButtonComponent, OrganisationsEinheitContainerComponent, ExterneFachstelleContainerComponent, + CollaborationListContainerComponent, + CollaborationRequestComponent, ], exports: [CollaborationInVorgangContainerComponent], }) diff --git a/alfa-client/libs/externe-fachstelle-shared/.eslintrc.json b/alfa-client/libs/externe-fachstelle-shared/.eslintrc.json new file mode 100644 index 0000000000000000000000000000000000000000..b953e5d37d40148217ab14a01859ea0cb43d9ebc --- /dev/null +++ b/alfa-client/libs/externe-fachstelle-shared/.eslintrc.json @@ -0,0 +1,33 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + } + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/alfa-client/libs/externe-fachstelle-shared/README.md b/alfa-client/libs/externe-fachstelle-shared/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a4fdfbae7ccdb38ba3c32d6ce362939dcfea797c --- /dev/null +++ b/alfa-client/libs/externe-fachstelle-shared/README.md @@ -0,0 +1,7 @@ +# externe-fachstelle-shared + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test externe-fachstelle-shared` to execute the unit tests. diff --git a/alfa-client/libs/externe-fachstelle-shared/jest.config.ts b/alfa-client/libs/externe-fachstelle-shared/jest.config.ts new file mode 100644 index 0000000000000000000000000000000000000000..321388b287187df0ed066b00efd6716431ab7a16 --- /dev/null +++ b/alfa-client/libs/externe-fachstelle-shared/jest.config.ts @@ -0,0 +1,21 @@ +export default { + displayName: 'externe-fachstelle-shared', + preset: '../../jest.preset.js', + setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'], + coverageDirectory: '../../coverage/libs/externe-fachstelle-shared', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '<rootDir>/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + }, + ], + }, + transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], + snapshotSerializers: [ + 'jest-preset-angular/build/serializers/no-ng-attributes', + 'jest-preset-angular/build/serializers/ng-snapshot', + 'jest-preset-angular/build/serializers/html-comment', + ], +}; diff --git a/alfa-client/libs/externe-fachstelle-shared/project.json b/alfa-client/libs/externe-fachstelle-shared/project.json new file mode 100644 index 0000000000000000000000000000000000000000..e9172474937fac28e4ed17b094fbee5f24a024e1 --- /dev/null +++ b/alfa-client/libs/externe-fachstelle-shared/project.json @@ -0,0 +1,22 @@ +{ + "name": "externe-fachstelle-shared", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/externe-fachstelle-shared/src", + "prefix": "alfa", + "projectType": "library", + "tags": [], + "targets": { + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "tsConfig": "libs/externe-fachstelle-shared/tsconfig.spec.json", + "jestConfig": "libs/externe-fachstelle-shared/jest.config.ts" + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"] + } + } +} diff --git a/alfa-client/libs/externe-fachstelle-shared/src/index.ts b/alfa-client/libs/externe-fachstelle-shared/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..df6d664a0acf84e56bffd755e96ac5803f518850 --- /dev/null +++ b/alfa-client/libs/externe-fachstelle-shared/src/index.ts @@ -0,0 +1 @@ +export * from './lib/externe-fachstelle-resource.service'; diff --git a/alfa-client/libs/externe-fachstelle-shared/src/lib/externe-fachstelle-resource.service.spec.ts b/alfa-client/libs/externe-fachstelle-shared/src/lib/externe-fachstelle-resource.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..d2fa0f86a7dd1fb592c214d048caae584bc70a8b --- /dev/null +++ b/alfa-client/libs/externe-fachstelle-shared/src/lib/externe-fachstelle-resource.service.spec.ts @@ -0,0 +1,39 @@ +import { CollaborationListResourceService } from '@alfa-client/collaboration-shared'; +import { ResourceListService } from '@alfa-client/tech-shared'; +import { mock, Mock } from '@alfa-client/test-utils'; +import { TestBed } from '@angular/core/testing'; +import { faker } from '@faker-js/faker/locale/de'; +import { ExterneFachstelleResourceService } from './externe-fachstelle-resource.service'; + +describe('externeFachstelleResourceService', () => { + let service: ExterneFachstelleResourceService; + let collaborationListResourceService: Mock<CollaborationListResourceService>; + + const resourceUri = faker.internet.url(); + + beforeEach(() => { + // todo: repariere mock funktion zum mocken extendeter Klassen? Dann kann hier auch CollaborationListResourceService verwendet werden + collaborationListResourceService = mock(ResourceListService); + + TestBed.configureTestingModule({ + providers: [ + ExterneFachstelleResourceService, + { provide: CollaborationListResourceService, useValue: collaborationListResourceService }, + ], + }); + + service = TestBed.inject(ExterneFachstelleResourceService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); + + describe('getOrganisationsEinheit', () => { + it('should call collaborationListService getLinkedResource', () => { + service.getExterneFachstelle(resourceUri); + + expect(collaborationListResourceService.getLinkedResource).toHaveBeenCalledWith(resourceUri); + }); + }); +}); diff --git a/alfa-client/libs/externe-fachstelle-shared/src/lib/externe-fachstelle-resource.service.ts b/alfa-client/libs/externe-fachstelle-shared/src/lib/externe-fachstelle-resource.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..241728abe5f58dcf19622f256c4a1016ec7a2187 --- /dev/null +++ b/alfa-client/libs/externe-fachstelle-shared/src/lib/externe-fachstelle-resource.service.ts @@ -0,0 +1,14 @@ +import { CollaborationListResourceService } from '@alfa-client/collaboration-shared'; +import { StateResource } from '@alfa-client/tech-shared'; +import { ExterneFachstelleResource } from '@alfa-client/zustaendige-stelle-shared'; +import { inject, Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; + +@Injectable() +export class ExterneFachstelleResourceService { + private collaborationListResourceService = inject(CollaborationListResourceService); + + getExterneFachstelle(resourceUri: string): Observable<StateResource<ExterneFachstelleResource>> { + return this.collaborationListResourceService.getLinkedResource<ExterneFachstelleResource>(resourceUri); + } +} diff --git a/alfa-client/libs/externe-fachstelle-shared/src/test-setup.ts b/alfa-client/libs/externe-fachstelle-shared/src/test-setup.ts new file mode 100644 index 0000000000000000000000000000000000000000..c408668266d2fec3a9803c0ec044bc163fb987fe --- /dev/null +++ b/alfa-client/libs/externe-fachstelle-shared/src/test-setup.ts @@ -0,0 +1,12 @@ +import '@testing-library/jest-dom'; +import 'jest-preset-angular/setup-jest'; + +import { getTestBed } from '@angular/core/testing'; +import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; + +getTestBed().resetTestEnvironment(); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { + teardown: { destroyAfterEach: false }, + errorOnUnknownProperties: true, + errorOnUnknownElements: true, +}); diff --git a/alfa-client/libs/externe-fachstelle-shared/tsconfig.json b/alfa-client/libs/externe-fachstelle-shared/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..7cc6baf2f58ed5ccfba098131996f579979e9f18 --- /dev/null +++ b/alfa-client/libs/externe-fachstelle-shared/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ], + "compilerOptions": { + "target": "es2022" + } +} diff --git a/alfa-client/libs/externe-fachstelle-shared/tsconfig.lib.json b/alfa-client/libs/externe-fachstelle-shared/tsconfig.lib.json new file mode 100644 index 0000000000000000000000000000000000000000..464f01e6b2b218c0f70e15ac25dd8580bdc38f6e --- /dev/null +++ b/alfa-client/libs/externe-fachstelle-shared/tsconfig.lib.json @@ -0,0 +1,19 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "target": "es2015", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [], + "lib": ["dom", "es2018"] + }, + "angularCompilerOptions": { + "skipTemplateCodegen": true, + "strictMetadataEmit": true, + "enableResourceInlining": true + }, + "exclude": ["src/test-setup.ts", "**/*.spec.ts", "jest.config.ts"], + "include": ["**/*.ts"] +} diff --git a/alfa-client/libs/externe-fachstelle-shared/tsconfig.spec.json b/alfa-client/libs/externe-fachstelle-shared/tsconfig.spec.json new file mode 100644 index 0000000000000000000000000000000000000000..3a690070a7f5e48080dd36522d6a0db384d940aa --- /dev/null +++ b/alfa-client/libs/externe-fachstelle-shared/tsconfig.spec.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"], + "target": "ES2022", + "useDefineForClassFields": false + }, + "files": ["src/test-setup.ts"], + "include": ["**/*.spec.ts", "**/*.d.ts", "jest.config.ts"] +} diff --git a/alfa-client/libs/externe-fachstelle/.eslintrc.json b/alfa-client/libs/externe-fachstelle/.eslintrc.json new file mode 100644 index 0000000000000000000000000000000000000000..b953e5d37d40148217ab14a01859ea0cb43d9ebc --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/.eslintrc.json @@ -0,0 +1,33 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + } + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/alfa-client/libs/externe-fachstelle/README.md b/alfa-client/libs/externe-fachstelle/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0f36f981258b8af46c41a27ea6ba0d66da26fdeb --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/README.md @@ -0,0 +1,7 @@ +# externe-fachstelle + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test externe-fachstelle` to execute the unit tests. diff --git a/alfa-client/libs/externe-fachstelle/jest.config.ts b/alfa-client/libs/externe-fachstelle/jest.config.ts new file mode 100644 index 0000000000000000000000000000000000000000..af45bef01829bb546e83a4e299bcd41fd6e2a08a --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/jest.config.ts @@ -0,0 +1,21 @@ +export default { + displayName: 'externe-fachstelle', + preset: '../../jest.preset.js', + setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'], + coverageDirectory: '../../coverage/libs/externe-fachstelle', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '<rootDir>/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + }, + ], + }, + transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], + snapshotSerializers: [ + 'jest-preset-angular/build/serializers/no-ng-attributes', + 'jest-preset-angular/build/serializers/ng-snapshot', + 'jest-preset-angular/build/serializers/html-comment', + ], +}; diff --git a/alfa-client/libs/externe-fachstelle/project.json b/alfa-client/libs/externe-fachstelle/project.json new file mode 100644 index 0000000000000000000000000000000000000000..9d431136f2beb5714fca8d0edb7e83a71c4fef04 --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/project.json @@ -0,0 +1,22 @@ +{ + "name": "externe-fachstelle", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/externe-fachstelle/src", + "prefix": "alfa", + "projectType": "library", + "tags": [], + "targets": { + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "tsConfig": "libs/externe-fachstelle/tsconfig.spec.json", + "jestConfig": "libs/externe-fachstelle/jest.config.ts" + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"] + } + } +} diff --git a/alfa-client/libs/externe-fachstelle/src/index.ts b/alfa-client/libs/externe-fachstelle/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item-container.component.html b/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item-container.component.html new file mode 100644 index 0000000000000000000000000000000000000000..692d4c37bf16026abb0e8348d4f59bcafdeb7f29 --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item-container.component.html @@ -0,0 +1,3 @@ +<alfa-externe-fachstelle-list-item [externeFachstelleStateResource]="externeFachstelleStateResource$ | async"> + <ng-content /> +</alfa-externe-fachstelle-list-item> \ No newline at end of file diff --git a/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item-container.component.spec.ts b/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item-container.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f1cf590cfdea34c7ad7c856d0d8779b2c6770a7 --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item-container.component.spec.ts @@ -0,0 +1,51 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ExterneFachstelleResourceService } from '@alfa-client/externe-fachstelle-shared'; +import { createStateResource } from '@alfa-client/tech-shared'; +import { mock, Mock } from '@alfa-client/test-utils'; +import { createExterneFachstelle } from 'libs/zustaendige-stelle-shared/test/externe-fachstelle'; +import { of } from 'rxjs'; +import { ExterneFachstelleListItemContainerComponent } from './externe-fachstelle-list-item-container.component'; + +describe('ExterneFachstelleListItemContainerComponent', () => { + let component: ExterneFachstelleListItemContainerComponent; + let fixture: ComponentFixture<ExterneFachstelleListItemContainerComponent>; + + let externeFachstelleResourceService: Mock<ExterneFachstelleResourceService>; + + const externeFachstelle = createExterneFachstelle(); + const externeFachstelleStateResource = createStateResource(externeFachstelle); + + beforeEach(async () => { + externeFachstelleResourceService = { + ...mock(ExterneFachstelleResourceService), + getExterneFachstelle: jest.fn().mockReturnValue(of(externeFachstelleStateResource)), + }; + + await TestBed.configureTestingModule({ imports: [ExterneFachstelleListItemContainerComponent] }) + .overrideComponent(ExterneFachstelleListItemContainerComponent, { + set: { + providers: [{ provide: ExterneFachstelleResourceService, useValue: externeFachstelleResourceService }], + }, + }) + .compileComponents(); + + fixture = TestBed.createComponent(ExterneFachstelleListItemContainerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + describe('component', () => { + describe('ngOnInit', () => { + it('should call externeFachstelleResourceService getExterneFachstelle Resource', () => { + component.ngOnInit(); + + expect(externeFachstelleResourceService.getExterneFachstelle).toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item-container.component.ts b/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item-container.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..263fc45cfd4794b3dfdabc94a8af6a2b8b7895db --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item-container.component.ts @@ -0,0 +1,30 @@ +import { ExterneFachstelleResourceService } from '@alfa-client/externe-fachstelle-shared'; +import { createEmptyStateResource, StateResource } from '@alfa-client/tech-shared'; +import { ExterneFachstelleResource } from '@alfa-client/zustaendige-stelle-shared'; +import { CommonModule } from '@angular/common'; +import { Component, inject, Input, OnInit } from '@angular/core'; +import { ResourceUri } from '@ngxp/rest'; +import { Observable, of } from 'rxjs'; +import { ExterneFachstelleListItemComponent } from './externe-fachstelle-list-item/externe-fachstelle-list-item.component'; + +@Component({ + selector: 'alfa-externe-fachstelle-list-item-container', + standalone: true, + imports: [CommonModule, ExterneFachstelleListItemComponent], + providers: [ExterneFachstelleResourceService], + templateUrl: './externe-fachstelle-list-item-container.component.html', +}) +export class ExterneFachstelleListItemContainerComponent implements OnInit { + private externeFachstelleResourceService: ExterneFachstelleResourceService = inject(ExterneFachstelleResourceService); + + @Input() externeFachstelleResourceUri: ResourceUri; + + externeFachstelleStateResource$: Observable<StateResource<ExterneFachstelleResource>> = + of(createEmptyStateResource<ExterneFachstelleResource>()); + + ngOnInit() { + this.externeFachstelleStateResource$ = this.externeFachstelleResourceService.getExterneFachstelle( + this.externeFachstelleResourceUri, + ); + } +} diff --git a/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item/externe-fachstelle-list-item.component.html b/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item/externe-fachstelle-list-item.component.html new file mode 100644 index 0000000000000000000000000000000000000000..dccd1f674994ac6f110c1a93c53fcba67ee9ab72 --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item/externe-fachstelle-list-item.component.html @@ -0,0 +1,20 @@ +<ozgcloud-spinner [stateResource]="externeFachstelleStateResource"> + @if (externeFachstelleStateResource.resource; as resource) { + <div class="border border-grayborder bg-background-100 p-4 shadow shadow-grayborder"> + <div class="flex flex-1 gap-6"> + <div class="flex flex-1 gap-3"> + <ods-external-unit-icon /> + <div class="flex flex-1 flex-col text-base"> + <p class="text-primary">Externe Fachstelle</p> + <p class="text-text font-bold">{{ resource.name }}</p> + </div> + </div> + <div class="flex-1"> + <div class="block">{{ resource.anschrift }}</div> + <div class="block">Email: {{ resource.email }}</div> + </div> + </div> + <ng-content /> + </div> + } +</ozgcloud-spinner> diff --git a/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item/externe-fachstelle-list-item.component.spec.ts b/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item/externe-fachstelle-list-item.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..5d78cea53d3030937c85d2c66e7a065243ca9fda --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item/externe-fachstelle-list-item.component.spec.ts @@ -0,0 +1,30 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { createStateResource, StateResource } from '@alfa-client/tech-shared'; +import { ExterneFachstelleResource } from '@alfa-client/zustaendige-stelle-shared'; +import { toResource } from 'libs/tech-shared/test/resource'; +import { createExterneFachstelle } from 'libs/zustaendige-stelle-shared/test/externe-fachstelle'; +import { ExterneFachstelleListItemComponent } from './externe-fachstelle-list-item.component'; + +describe('ExterneFachstelleListItemComponent', () => { + let component: ExterneFachstelleListItemComponent; + let fixture: ComponentFixture<ExterneFachstelleListItemComponent>; + + const externeFachstelle: ExterneFachstelleResource = toResource(createExterneFachstelle()); + const externeFachstelleState: StateResource<ExterneFachstelleResource> = createStateResource(externeFachstelle); + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ExterneFachstelleListItemComponent], + }).compileComponents(); + + fixture = TestBed.createComponent(ExterneFachstelleListItemComponent); + component = fixture.componentInstance; + component.externeFachstelleStateResource = externeFachstelleState; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item/externe-fachstelle-list-item.component.ts b/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item/externe-fachstelle-list-item.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..efbcedd1d9319ba969614e302b2a754b3e6e1fd4 --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item/externe-fachstelle-list-item.component.ts @@ -0,0 +1,15 @@ +import { StateResource } from '@alfa-client/tech-shared'; +import { UiModule } from '@alfa-client/ui'; +import { ExterneFachstelleResource } from '@alfa-client/zustaendige-stelle-shared'; +import { Component, Input } from '@angular/core'; +import { ExternalUnitIconComponent, PublicAdministrationIconComponent } from '@ods/system'; + +@Component({ + selector: 'alfa-externe-fachstelle-list-item', + standalone: true, + imports: [PublicAdministrationIconComponent, ExternalUnitIconComponent, UiModule], + templateUrl: './externe-fachstelle-list-item.component.html', +}) +export class ExterneFachstelleListItemComponent { + @Input() externeFachstelleStateResource: StateResource<ExterneFachstelleResource>; +} diff --git a/alfa-client/libs/externe-fachstelle/src/test-setup.ts b/alfa-client/libs/externe-fachstelle/src/test-setup.ts new file mode 100644 index 0000000000000000000000000000000000000000..c408668266d2fec3a9803c0ec044bc163fb987fe --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/src/test-setup.ts @@ -0,0 +1,12 @@ +import '@testing-library/jest-dom'; +import 'jest-preset-angular/setup-jest'; + +import { getTestBed } from '@angular/core/testing'; +import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; + +getTestBed().resetTestEnvironment(); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { + teardown: { destroyAfterEach: false }, + errorOnUnknownProperties: true, + errorOnUnknownElements: true, +}); diff --git a/alfa-client/libs/externe-fachstelle/tsconfig.json b/alfa-client/libs/externe-fachstelle/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..7cc6baf2f58ed5ccfba098131996f579979e9f18 --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ], + "compilerOptions": { + "target": "es2022" + } +} diff --git a/alfa-client/libs/externe-fachstelle/tsconfig.lib.json b/alfa-client/libs/externe-fachstelle/tsconfig.lib.json new file mode 100644 index 0000000000000000000000000000000000000000..464f01e6b2b218c0f70e15ac25dd8580bdc38f6e --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/tsconfig.lib.json @@ -0,0 +1,19 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "target": "es2015", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [], + "lib": ["dom", "es2018"] + }, + "angularCompilerOptions": { + "skipTemplateCodegen": true, + "strictMetadataEmit": true, + "enableResourceInlining": true + }, + "exclude": ["src/test-setup.ts", "**/*.spec.ts", "jest.config.ts"], + "include": ["**/*.ts"] +} diff --git a/alfa-client/libs/externe-fachstelle/tsconfig.spec.json b/alfa-client/libs/externe-fachstelle/tsconfig.spec.json new file mode 100644 index 0000000000000000000000000000000000000000..3a690070a7f5e48080dd36522d6a0db384d940aa --- /dev/null +++ b/alfa-client/libs/externe-fachstelle/tsconfig.spec.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"], + "target": "ES2022", + "useDefineForClassFields": false + }, + "files": ["src/test-setup.ts"], + "include": ["**/*.spec.ts", "**/*.d.ts", "jest.config.ts"] +} diff --git a/alfa-client/libs/organisations-einheit-shared/.eslintrc.json b/alfa-client/libs/organisations-einheit-shared/.eslintrc.json new file mode 100644 index 0000000000000000000000000000000000000000..b953e5d37d40148217ab14a01859ea0cb43d9ebc --- /dev/null +++ b/alfa-client/libs/organisations-einheit-shared/.eslintrc.json @@ -0,0 +1,33 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + } + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/alfa-client/libs/organisations-einheit-shared/README.md b/alfa-client/libs/organisations-einheit-shared/README.md new file mode 100644 index 0000000000000000000000000000000000000000..547b880702166961734aa02432e2c0c99a585d5f --- /dev/null +++ b/alfa-client/libs/organisations-einheit-shared/README.md @@ -0,0 +1,7 @@ +# organisations-einheit-shared + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test organisations-einheit-shared` to execute the unit tests. diff --git a/alfa-client/libs/organisations-einheit-shared/jest.config.ts b/alfa-client/libs/organisations-einheit-shared/jest.config.ts new file mode 100644 index 0000000000000000000000000000000000000000..02c5e876cde8bafdb85a41cce363cd62343481fb --- /dev/null +++ b/alfa-client/libs/organisations-einheit-shared/jest.config.ts @@ -0,0 +1,21 @@ +export default { + displayName: 'organisations-einheit-shared', + preset: '../../jest.preset.js', + setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'], + coverageDirectory: '../../coverage/libs/organisations-einheit-shared', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '<rootDir>/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + }, + ], + }, + transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], + snapshotSerializers: [ + 'jest-preset-angular/build/serializers/no-ng-attributes', + 'jest-preset-angular/build/serializers/ng-snapshot', + 'jest-preset-angular/build/serializers/html-comment', + ], +}; diff --git a/alfa-client/libs/organisations-einheit-shared/project.json b/alfa-client/libs/organisations-einheit-shared/project.json new file mode 100644 index 0000000000000000000000000000000000000000..e90e8c4db621944785370a8cdd0300a56afe45f2 --- /dev/null +++ b/alfa-client/libs/organisations-einheit-shared/project.json @@ -0,0 +1,22 @@ +{ + "name": "organisations-einheit-shared", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/organisations-einheit-shared/src", + "prefix": "alfa", + "projectType": "library", + "tags": [], + "targets": { + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "tsConfig": "libs/organisations-einheit-shared/tsconfig.spec.json", + "jestConfig": "libs/organisations-einheit-shared/jest.config.ts" + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"] + } + } +} diff --git a/alfa-client/libs/organisations-einheit-shared/src/index.ts b/alfa-client/libs/organisations-einheit-shared/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..e4eb22d93c7255a283414670958912bc7022f28d --- /dev/null +++ b/alfa-client/libs/organisations-einheit-shared/src/index.ts @@ -0,0 +1 @@ +export * from './lib/organisations-einheit-resource.service'; diff --git a/alfa-client/libs/organisations-einheit-shared/src/lib/organisations-einheit-resource.service.spec.ts b/alfa-client/libs/organisations-einheit-shared/src/lib/organisations-einheit-resource.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..35b493a26600d5421be996df95e66e967ae8ce66 --- /dev/null +++ b/alfa-client/libs/organisations-einheit-shared/src/lib/organisations-einheit-resource.service.spec.ts @@ -0,0 +1,39 @@ +import { CollaborationListResourceService } from '@alfa-client/collaboration-shared'; +import { ResourceListService } from '@alfa-client/tech-shared'; +import { mock, Mock } from '@alfa-client/test-utils'; +import { TestBed } from '@angular/core/testing'; +import { faker } from '@faker-js/faker/locale/de'; +import { OrganisationsEinheitResourceService } from './organisations-einheit-resource.service'; + +describe('externeFachstelleResourceService', () => { + let service: OrganisationsEinheitResourceService; + let collaborationListResourceService: Mock<CollaborationListResourceService>; + + const resourceUri = faker.internet.url(); + + beforeEach(() => { + // todo: repariere mock funktion zum mocken extendeter Klassen? Dann kann hier auch CollaborationListResourceService verwendet werden + collaborationListResourceService = mock(ResourceListService); + + TestBed.configureTestingModule({ + providers: [ + OrganisationsEinheitResourceService, + { provide: CollaborationListResourceService, useValue: collaborationListResourceService }, + ], + }); + + service = TestBed.inject(OrganisationsEinheitResourceService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); + + describe('getOrganisationsEinheit', () => { + it('should call collaborationListService getLinkedResource', () => { + service.getOrganisationsEinheit(resourceUri); + + expect(collaborationListResourceService.getLinkedResource).toHaveBeenCalledWith(resourceUri); + }); + }); +}); diff --git a/alfa-client/libs/organisations-einheit-shared/src/lib/organisations-einheit-resource.service.ts b/alfa-client/libs/organisations-einheit-shared/src/lib/organisations-einheit-resource.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ce86469eabfbe4bd953b5c0e69dd6a887cdf851 --- /dev/null +++ b/alfa-client/libs/organisations-einheit-shared/src/lib/organisations-einheit-resource.service.ts @@ -0,0 +1,14 @@ +import { CollaborationListResourceService } from '@alfa-client/collaboration-shared'; +import { StateResource } from '@alfa-client/tech-shared'; +import { OrganisationsEinheitResource } from '@alfa-client/zustaendige-stelle-shared'; +import { inject, Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; + +@Injectable() +export class OrganisationsEinheitResourceService { + private collaborationListResourceService = inject(CollaborationListResourceService); + + getOrganisationsEinheit(resourceUri: string): Observable<StateResource<OrganisationsEinheitResource>> { + return this.collaborationListResourceService.getLinkedResource<OrganisationsEinheitResource>(resourceUri); + } +} diff --git a/alfa-client/libs/organisations-einheit-shared/src/test-setup.ts b/alfa-client/libs/organisations-einheit-shared/src/test-setup.ts new file mode 100644 index 0000000000000000000000000000000000000000..c408668266d2fec3a9803c0ec044bc163fb987fe --- /dev/null +++ b/alfa-client/libs/organisations-einheit-shared/src/test-setup.ts @@ -0,0 +1,12 @@ +import '@testing-library/jest-dom'; +import 'jest-preset-angular/setup-jest'; + +import { getTestBed } from '@angular/core/testing'; +import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; + +getTestBed().resetTestEnvironment(); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { + teardown: { destroyAfterEach: false }, + errorOnUnknownProperties: true, + errorOnUnknownElements: true, +}); diff --git a/alfa-client/libs/organisations-einheit-shared/tsconfig.json b/alfa-client/libs/organisations-einheit-shared/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..7cc6baf2f58ed5ccfba098131996f579979e9f18 --- /dev/null +++ b/alfa-client/libs/organisations-einheit-shared/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ], + "compilerOptions": { + "target": "es2022" + } +} diff --git a/alfa-client/libs/organisations-einheit-shared/tsconfig.lib.json b/alfa-client/libs/organisations-einheit-shared/tsconfig.lib.json new file mode 100644 index 0000000000000000000000000000000000000000..464f01e6b2b218c0f70e15ac25dd8580bdc38f6e --- /dev/null +++ b/alfa-client/libs/organisations-einheit-shared/tsconfig.lib.json @@ -0,0 +1,19 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "target": "es2015", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [], + "lib": ["dom", "es2018"] + }, + "angularCompilerOptions": { + "skipTemplateCodegen": true, + "strictMetadataEmit": true, + "enableResourceInlining": true + }, + "exclude": ["src/test-setup.ts", "**/*.spec.ts", "jest.config.ts"], + "include": ["**/*.ts"] +} diff --git a/alfa-client/libs/organisations-einheit-shared/tsconfig.spec.json b/alfa-client/libs/organisations-einheit-shared/tsconfig.spec.json new file mode 100644 index 0000000000000000000000000000000000000000..3a690070a7f5e48080dd36522d6a0db384d940aa --- /dev/null +++ b/alfa-client/libs/organisations-einheit-shared/tsconfig.spec.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"], + "target": "ES2022", + "useDefineForClassFields": false + }, + "files": ["src/test-setup.ts"], + "include": ["**/*.spec.ts", "**/*.d.ts", "jest.config.ts"] +} diff --git a/alfa-client/libs/organisations-einheit/.eslintrc.json b/alfa-client/libs/organisations-einheit/.eslintrc.json new file mode 100644 index 0000000000000000000000000000000000000000..b953e5d37d40148217ab14a01859ea0cb43d9ebc --- /dev/null +++ b/alfa-client/libs/organisations-einheit/.eslintrc.json @@ -0,0 +1,33 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + } + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/alfa-client/libs/organisations-einheit/README.md b/alfa-client/libs/organisations-einheit/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b9448bd56f8ab68884bf1b91f12b11efbc3125b0 --- /dev/null +++ b/alfa-client/libs/organisations-einheit/README.md @@ -0,0 +1,7 @@ +# organisations-einheit + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test organisations-einheit` to execute the unit tests. diff --git a/alfa-client/libs/organisations-einheit/jest.config.ts b/alfa-client/libs/organisations-einheit/jest.config.ts new file mode 100644 index 0000000000000000000000000000000000000000..e6c9a97beadf6ca3349773fad970e6d5b10595de --- /dev/null +++ b/alfa-client/libs/organisations-einheit/jest.config.ts @@ -0,0 +1,21 @@ +export default { + displayName: 'organisations-einheit', + preset: '../../jest.preset.js', + setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'], + coverageDirectory: '../../coverage/libs/organisations-einheit', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '<rootDir>/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + }, + ], + }, + transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], + snapshotSerializers: [ + 'jest-preset-angular/build/serializers/no-ng-attributes', + 'jest-preset-angular/build/serializers/ng-snapshot', + 'jest-preset-angular/build/serializers/html-comment', + ], +}; diff --git a/alfa-client/libs/organisations-einheit/project.json b/alfa-client/libs/organisations-einheit/project.json new file mode 100644 index 0000000000000000000000000000000000000000..9fdc22773ddc51c57a9f84e937fdedbb76fabb80 --- /dev/null +++ b/alfa-client/libs/organisations-einheit/project.json @@ -0,0 +1,22 @@ +{ + "name": "organisations-einheit", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/organisations-einheit/src", + "prefix": "alfa", + "projectType": "library", + "tags": [], + "targets": { + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "tsConfig": "libs/organisations-einheit/tsconfig.spec.json", + "jestConfig": "libs/organisations-einheit/jest.config.ts" + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"] + } + } +} diff --git a/alfa-client/libs/organisations-einheit/src/index.ts b/alfa-client/libs/organisations-einheit/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item-container.component.html b/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item-container.component.html new file mode 100644 index 0000000000000000000000000000000000000000..fb9f5afd36f5f354c9e3dbee3b558431ef598c00 --- /dev/null +++ b/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item-container.component.html @@ -0,0 +1,3 @@ +<alfa-organisations-einheit-list-item [organisationsEinheitStateResource]="organisationsEinheitStateResource$ | async"> + <ng-content /> +</alfa-organisations-einheit-list-item> diff --git a/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item-container.component.spec.ts b/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item-container.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6b0570ed3e929c4f4d59080785fd3cbd53c3887 --- /dev/null +++ b/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item-container.component.spec.ts @@ -0,0 +1,53 @@ +import { OrganisationsEinheitResourceService } from '@alfa-client/organisations-einheit-shared'; +import { createStateResource, StateResource } from '@alfa-client/tech-shared'; +import { mock, Mock } from '@alfa-client/test-utils'; +import { OrganisationsEinheitResource } from '@alfa-client/zustaendige-stelle-shared'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { toResource } from 'libs/tech-shared/test/resource'; +import { createOrganisationsEinheit } from 'libs/zustaendige-stelle-shared/test/organisations-einheit'; +import { of } from 'rxjs'; +import { OrganisationsEinheitListItemContainerComponent } from './organisations-einheit-list-item-container.component'; + +describe('OrganisationsEinheitListItemContainerComponent', () => { + let component: OrganisationsEinheitListItemContainerComponent; + let fixture: ComponentFixture<OrganisationsEinheitListItemContainerComponent>; + + let organisationsEinheitResourceService: Mock<OrganisationsEinheitResourceService>; + + const organisationsEinheit: OrganisationsEinheitResource = toResource(createOrganisationsEinheit()); + const organisationsEInheitStateResource: StateResource<OrganisationsEinheitResource> = + createStateResource(organisationsEinheit); + + beforeEach(async () => { + organisationsEinheitResourceService = { + ...mock(OrganisationsEinheitResourceService), + getOrganisationsEinheit: jest.fn().mockReturnValue(of(organisationsEInheitStateResource)), + }; + + await TestBed.configureTestingModule({ imports: [OrganisationsEinheitListItemContainerComponent] }) + .overrideComponent(OrganisationsEinheitListItemContainerComponent, { + set: { + providers: [{ provide: OrganisationsEinheitResourceService, useValue: organisationsEinheitResourceService }], + }, + }) + .compileComponents(); + + fixture = TestBed.createComponent(OrganisationsEinheitListItemContainerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + describe('component', () => { + describe('ngOnInit', () => { + it('should call organisationsEinheitResourceService getOrganisationsEinheit Resource', () => { + component.ngOnInit(); + + expect(organisationsEinheitResourceService.getOrganisationsEinheit).toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item-container.component.ts b/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item-container.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..e2465c76a0159ff7dca9b2157777e945e8e958a4 --- /dev/null +++ b/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item-container.component.ts @@ -0,0 +1,30 @@ +import { OrganisationsEinheitResourceService } from '@alfa-client/organisations-einheit-shared'; +import { createEmptyStateResource, StateResource } from '@alfa-client/tech-shared'; +import { OrganisationsEinheitResource } from '@alfa-client/zustaendige-stelle-shared'; +import { CommonModule } from '@angular/common'; +import { Component, inject, Input, OnInit } from '@angular/core'; +import { ResourceUri } from '@ngxp/rest'; +import { Observable, of } from 'rxjs'; +import { OrganisationsEinheitListItemComponent } from './organisations-einheit-list-item/organisations-einheit-list-item.component'; + +@Component({ + selector: 'alfa-organisations-einheit-list-item-container', + standalone: true, + imports: [CommonModule, OrganisationsEinheitListItemComponent], + providers: [OrganisationsEinheitResourceService], + templateUrl: './organisations-einheit-list-item-container.component.html', +}) +export class OrganisationsEinheitListItemContainerComponent implements OnInit { + private organisationsEinheitResourceService: OrganisationsEinheitResourceService = inject(OrganisationsEinheitResourceService); + + @Input() organisationsEinheitResourceUri: ResourceUri; + + organisationsEinheitStateResource$: Observable<StateResource<OrganisationsEinheitResource>> = + of(createEmptyStateResource<OrganisationsEinheitResource>()); + + ngOnInit() { + this.organisationsEinheitStateResource$ = this.organisationsEinheitResourceService.getOrganisationsEinheit( + this.organisationsEinheitResourceUri, + ); + } +} diff --git a/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item/organisations-einheit-list-item.component.html b/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item/organisations-einheit-list-item.component.html new file mode 100644 index 0000000000000000000000000000000000000000..82c11eb054b6aabb65632aec9890ede2b537bb5b --- /dev/null +++ b/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item/organisations-einheit-list-item.component.html @@ -0,0 +1,22 @@ +<ozgcloud-spinner [stateResource]="organisationsEinheitStateResource"> + @if (organisationsEinheitStateResource.resource; as resource) { + <div class="border border-grayborder bg-background-100 p-4 shadow shadow-grayborder"> + <div class="flex flex-1 gap-6"> + <div class="flex flex-1 gap-3"> + <ods-public-administration-icon /> + <div class="flex flex-1 flex-col text-base"> + <p class="text-primary">Organisationseinheit</p> + <p class="font-bold text-text">{{ resource.name }}</p> + </div> + </div> + <div class="block flex-1"> + <div class="block"> + {{ resource.anschrift.strasse }} {{ resource.anschrift.hausnummer }}, {{ resource.anschrift.plz }} + {{ resource.anschrift.ort }} + </div> + </div> + </div> + <ng-content /> + </div> + } +</ozgcloud-spinner> diff --git a/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item/organisations-einheit-list-item.component.spec.ts b/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item/organisations-einheit-list-item.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..5982e818f36bd67e592538be278768d22634d2a8 --- /dev/null +++ b/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item/organisations-einheit-list-item.component.spec.ts @@ -0,0 +1,31 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { createStateResource, StateResource } from '@alfa-client/tech-shared'; +import { OrganisationsEinheitResource } from '@alfa-client/zustaendige-stelle-shared'; +import { toResource } from 'libs/tech-shared/test/resource'; +import { createOrganisationsEinheit } from 'libs/zustaendige-stelle-shared/test/organisations-einheit'; +import { OrganisationsEinheitListItemComponent } from './organisations-einheit-list-item.component'; + +describe('OrganisationsEinheitListItemComponent', () => { + let component: OrganisationsEinheitListItemComponent; + let fixture: ComponentFixture<OrganisationsEinheitListItemComponent>; + + const organisationsEinheitResource: OrganisationsEinheitResource = toResource(createOrganisationsEinheit()); + const organisationsEinheitStateResource: StateResource<OrganisationsEinheitResource> = + createStateResource(organisationsEinheitResource); + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [OrganisationsEinheitListItemComponent], + }).compileComponents(); + + fixture = TestBed.createComponent(OrganisationsEinheitListItemComponent); + component = fixture.componentInstance; + component.organisationsEinheitStateResource = organisationsEinheitStateResource; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item/organisations-einheit-list-item.component.ts b/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item/organisations-einheit-list-item.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..dd4344670644c7facae2212d848f3aedd58fe9a0 --- /dev/null +++ b/alfa-client/libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item/organisations-einheit-list-item.component.ts @@ -0,0 +1,15 @@ +import { StateResource } from '@alfa-client/tech-shared'; +import { UiModule } from '@alfa-client/ui'; +import { OrganisationsEinheitResource } from '@alfa-client/zustaendige-stelle-shared'; +import { Component, Input } from '@angular/core'; +import { ExternalUnitIconComponent, PublicAdministrationIconComponent } from '@ods/system'; + +@Component({ + selector: 'alfa-organisations-einheit-list-item', + standalone: true, + imports: [ExternalUnitIconComponent, PublicAdministrationIconComponent, UiModule], + templateUrl: './organisations-einheit-list-item.component.html', +}) +export class OrganisationsEinheitListItemComponent { + @Input() organisationsEinheitStateResource: StateResource<OrganisationsEinheitResource>; +} diff --git a/alfa-client/libs/organisations-einheit/src/test-setup.ts b/alfa-client/libs/organisations-einheit/src/test-setup.ts new file mode 100644 index 0000000000000000000000000000000000000000..c408668266d2fec3a9803c0ec044bc163fb987fe --- /dev/null +++ b/alfa-client/libs/organisations-einheit/src/test-setup.ts @@ -0,0 +1,12 @@ +import '@testing-library/jest-dom'; +import 'jest-preset-angular/setup-jest'; + +import { getTestBed } from '@angular/core/testing'; +import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; + +getTestBed().resetTestEnvironment(); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { + teardown: { destroyAfterEach: false }, + errorOnUnknownProperties: true, + errorOnUnknownElements: true, +}); diff --git a/alfa-client/libs/organisations-einheit/tsconfig.json b/alfa-client/libs/organisations-einheit/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..7cc6baf2f58ed5ccfba098131996f579979e9f18 --- /dev/null +++ b/alfa-client/libs/organisations-einheit/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ], + "compilerOptions": { + "target": "es2022" + } +} diff --git a/alfa-client/libs/organisations-einheit/tsconfig.lib.json b/alfa-client/libs/organisations-einheit/tsconfig.lib.json new file mode 100644 index 0000000000000000000000000000000000000000..464f01e6b2b218c0f70e15ac25dd8580bdc38f6e --- /dev/null +++ b/alfa-client/libs/organisations-einheit/tsconfig.lib.json @@ -0,0 +1,19 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "target": "es2015", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [], + "lib": ["dom", "es2018"] + }, + "angularCompilerOptions": { + "skipTemplateCodegen": true, + "strictMetadataEmit": true, + "enableResourceInlining": true + }, + "exclude": ["src/test-setup.ts", "**/*.spec.ts", "jest.config.ts"], + "include": ["**/*.ts"] +} diff --git a/alfa-client/libs/organisations-einheit/tsconfig.spec.json b/alfa-client/libs/organisations-einheit/tsconfig.spec.json new file mode 100644 index 0000000000000000000000000000000000000000..3a690070a7f5e48080dd36522d6a0db384d940aa --- /dev/null +++ b/alfa-client/libs/organisations-einheit/tsconfig.spec.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"], + "target": "ES2022", + "useDefineForClassFields": false + }, + "files": ["src/test-setup.ts"], + "include": ["**/*.spec.ts", "**/*.d.ts", "jest.config.ts"] +} diff --git a/alfa-client/libs/tech-shared/src/lib/resource/list-resource.service.spec.ts b/alfa-client/libs/tech-shared/src/lib/resource/list-resource.service.spec.ts index 0864617da8cadf79db67003fb5fcae343da2ee68..cb9d49425985f881841855c13e7127663638826a 100644 --- a/alfa-client/libs/tech-shared/src/lib/resource/list-resource.service.spec.ts +++ b/alfa-client/libs/tech-shared/src/lib/resource/list-resource.service.spec.ts @@ -31,6 +31,8 @@ describe('ListResourceService', () => { baseStateResource, ); + const linkedResourceUri = faker.internet.url(); + beforeEach(() => { config = { baseResource: baseResourceSubj, @@ -231,6 +233,61 @@ describe('ListResourceService', () => { }); }); + describe('getLinkedResource', () => { + beforeEach(() => { + service.linkedResources[linkedResourceUri] = new BehaviorSubject(createEmptyStateResource()); + }); + + it('should call createIfNotExist ', () => { + service.createIfNotExist = jest.fn(); + service.loadLinkedResoure = jest.fn(); + + service.getLinkedResource(linkedResourceUri); + + expect(service.createIfNotExist).toHaveBeenCalled(); + }); + }); + + describe('createIfNotExists', () => { + it('should create linked resource if none exists', () => { + service.createIfNotExist(linkedResourceUri); + + expect(service.linkedResources[linkedResourceUri].value).toEqual(createEmptyStateResource()); + }); + }); + + describe('loadLinkedResourceIfRequired', () => { + it('should set Loading in Linked Resource', () => { + service.createIfNotExist(linkedResourceUri); + service.setLinkedResourceLoading = jest.fn(); + service.loadLinkedResoure = jest.fn(); + + service.getLinkedResource(linkedResourceUri); + + expect(service.setLinkedResourceLoading).toHaveBeenCalledWith(linkedResourceUri); + }); + + it('should call loadLinkedResource if loading is required', () => { + service.createIfNotExist(linkedResourceUri); + service.loadLinkedResoure = jest.fn(); + + service.getLinkedResource(linkedResourceUri); + + expect(service.loadLinkedResoure).toHaveBeenCalledWith(linkedResourceUri); + }); + }); + + describe('loadLinkedResource', () => { + it('should call repository getResource', () => { + resourceRepository.getResource = jest.fn().mockReturnValue(of(createDummyResource())); + service.createIfNotExist(linkedResourceUri); + + service.loadLinkedResoure(linkedResourceUri); + + expect(resourceRepository.getResource).toHaveBeenCalledWith(linkedResourceUri); + }); + }); + describe('create', () => { const toCreate: unknown = {}; diff --git a/alfa-client/libs/tech-shared/src/lib/resource/list-resource.service.ts b/alfa-client/libs/tech-shared/src/lib/resource/list-resource.service.ts index 4bb6beecc38df96224fa5adf1b4ede5ed4729039..6a82f7f88560bd1dd8fc3b3ad9fa6595913f3e9f 100644 --- a/alfa-client/libs/tech-shared/src/lib/resource/list-resource.service.ts +++ b/alfa-client/libs/tech-shared/src/lib/resource/list-resource.service.ts @@ -1,5 +1,5 @@ import { Resource, ResourceUri, getUrl, hasLink } from '@ngxp/rest'; -import { isEqual, isNull } from 'lodash-es'; +import { isEqual, isNil, isNull } from 'lodash-es'; import { BehaviorSubject, Observable, combineLatest, filter, first, map, startWith, tap } from 'rxjs'; import { isNotNull, isNotUndefined } from '../tech.util'; import { CreateResourceData, ListItemResource, ListResourceServiceConfig } from './resource.model'; @@ -10,6 +10,7 @@ import { StateResource, createEmptyStateResource, createStateResource, + doIfLoadingRequired, getEmbeddedResources, isEmptyStateResource, isInvalidResourceCombination, @@ -31,6 +32,7 @@ export class ResourceListService<B extends Resource, T extends ListResource, I e readonly selectedResource: BehaviorSubject<StateResource<I>> = new BehaviorSubject(createEmptyStateResource()); baseResource: B = null; + linkedResources = {}; constructor( private config: ListResourceServiceConfig<B>, @@ -181,6 +183,34 @@ export class ResourceListService<B extends Resource, T extends ListResource, I e this.listResource.next(createStateResource(listResource)); } + public getLinkedResource<F extends Resource>(resourceUri: ResourceUri): Observable<StateResource<F>> { + this.createIfNotExist(resourceUri); + this.loadLinkedResourceIfRequired(resourceUri); + return this.linkedResources[resourceUri].asObservable(); + } + + createIfNotExist(uri: ResourceUri): void { + if (isNil(this.linkedResources[uri])) this.linkedResources[uri] = new BehaviorSubject(createEmptyStateResource()); + } + + loadLinkedResourceIfRequired(resourceUri: ResourceUri): void { + doIfLoadingRequired(this.linkedResources[resourceUri].value, () => { + this.setLinkedResourceLoading(resourceUri); + this.loadLinkedResoure(resourceUri); + }); + } + + loadLinkedResoure(resourceUri: ResourceUri): void { + this.repository + .getResource(resourceUri) + .pipe(first()) + .subscribe((loadedResource: any) => this.linkedResources[resourceUri].next(createStateResource(loadedResource))); + } + + setLinkedResourceLoading(resourceUri: ResourceUri): void { + this.linkedResources[resourceUri].next(createEmptyStateResource(true)); + } + private throwErrorOn(condition: boolean, errorMsg: string): void { if (condition) throw Error(errorMsg); } diff --git a/alfa-client/libs/tech-shared/src/lib/resource/resource.service.spec.ts b/alfa-client/libs/tech-shared/src/lib/resource/resource.service.spec.ts index 1a7c4254c31475dde3488c115c80245b758d0145..3bfa20b1819b5ef0fae27344f1736379b268f011 100644 --- a/alfa-client/libs/tech-shared/src/lib/resource/resource.service.spec.ts +++ b/alfa-client/libs/tech-shared/src/lib/resource/resource.service.spec.ts @@ -2,9 +2,9 @@ import { Mock, mock, useFromMock } from '@alfa-client/test-utils'; import { HttpErrorResponse } from '@angular/common/http'; import { fakeAsync, tick } from '@angular/core/testing'; import { faker } from '@faker-js/faker'; -import { Resource, ResourceUri, getUrl } from '@ngxp/rest'; +import { getUrl, Resource, ResourceUri } from '@ngxp/rest'; import { cold } from 'jest-marbles'; -import { Observable, lastValueFrom, of, throwError } from 'rxjs'; +import { lastValueFrom, Observable, of, throwError } from 'rxjs'; import { createProblemDetail } from '../../../test//error'; import { singleCold, singleHot } from '../../../test/marbles'; import { createDummyResource } from '../../../test/resource'; @@ -12,9 +12,8 @@ import { ProblemDetail } from '../tech.model'; import { LinkRelationName, ResourceServiceConfig } from './resource.model'; import { ResourceRepository } from './resource.repository'; import { ResourceService } from './resource.service'; -import { StateResource, createEmptyStateResource, createErrorStateResource, createStateResource } from './resource.util'; - import * as ResourceUtil from './resource.util'; +import { createEmptyStateResource, createErrorStateResource, createStateResource, StateResource } from './resource.util'; describe('ResourceService', () => { let service: DummyResourceService<Resource, Resource>; diff --git a/alfa-client/libs/zustaendige-stelle-shared/project.json b/alfa-client/libs/zustaendige-stelle-shared/project.json index 16d8b42f87c70ddf052d1b6b4b4ae71a30eeae98..41de7b5591e52e18f8b185e924a4e6498fd24cda 100644 --- a/alfa-client/libs/zustaendige-stelle-shared/project.json +++ b/alfa-client/libs/zustaendige-stelle-shared/project.json @@ -10,11 +10,13 @@ "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "libs/zustaendige-stelle-shared/jest.config.ts" + "jestConfig": "libs/zustaendige-stelle-shared/jest.config.ts", + "tsConfig": "libs/zustaendige-stelle-shared/tsconfig.spec.json" } }, "lint": { - "executor": "@nx/eslint:lint" + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"] } } } diff --git a/alfa-client/libs/zustaendige-stelle-shared/src/test-setup.ts b/alfa-client/libs/zustaendige-stelle-shared/src/test-setup.ts index 12fa19564300d506f71206e28de6cfa4a933bc59..c408668266d2fec3a9803c0ec044bc163fb987fe 100644 --- a/alfa-client/libs/zustaendige-stelle-shared/src/test-setup.ts +++ b/alfa-client/libs/zustaendige-stelle-shared/src/test-setup.ts @@ -1,3 +1,6 @@ +import '@testing-library/jest-dom'; +import 'jest-preset-angular/setup-jest'; + import { getTestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; diff --git a/alfa-client/package-lock.json b/alfa-client/package-lock.json index 09bd435b8c06a60a20879e3777b41c782d858868..f6b22e828615c42e63ca3439490623f5cdbd35e6 100644 --- a/alfa-client/package-lock.json +++ b/alfa-client/package-lock.json @@ -76,6 +76,9 @@ "@storybook/addon-interactions": "^8.4.2", "@storybook/angular": "^8.4.2", "@storybook/core-server": "^8.4.2", + "@swc-node/register": "~1.9.1", + "@swc/core": "~1.5.7", + "@swc/helpers": "~0.5.11", "@testing-library/jest-dom": "^6.4.5", "@types/file-saver": "2.0.7", "@types/jest": "29.5.13", @@ -12363,17 +12366,268 @@ "storybook": "^8.2.0 || ^8.3.0-0 || ^8.4.0-0 || ^8.5.0-0 || ^8.6.0-0" } }, + "node_modules/@swc-node/core": { + "version": "1.13.3", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc-node/core/-/core-1.13.3.tgz", + "integrity": "sha512-OGsvXIid2Go21kiNqeTIn79jcaX4l0G93X2rAnas4LFoDyA9wAwVK7xZdm+QsKoMn5Mus2yFLCc4OtX2dD/PWA==", + "devOptional": true, + "engines": { + "node": ">= 10" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@swc/core": ">= 1.4.13", + "@swc/types": ">= 0.1" + } + }, + "node_modules/@swc-node/register": { + "version": "1.9.2", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc-node/register/-/register-1.9.2.tgz", + "integrity": "sha512-BBjg0QNuEEmJSoU/++JOXhrjWdu3PTyYeJWsvchsI0Aqtj8ICkz/DqlwtXbmZVZ5vuDPpTfFlwDBZe81zgShMA==", + "devOptional": true, + "dependencies": { + "@swc-node/core": "^1.13.1", + "@swc-node/sourcemap-support": "^0.5.0", + "colorette": "^2.0.20", + "debug": "^4.3.4", + "pirates": "^4.0.6", + "tslib": "^2.6.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@swc/core": ">= 1.4.13", + "typescript": ">= 4.3" + } + }, + "node_modules/@swc-node/sourcemap-support": { + "version": "0.5.1", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc-node/sourcemap-support/-/sourcemap-support-0.5.1.tgz", + "integrity": "sha512-JxIvIo/Hrpv0JCHSyRpetAdQ6lB27oFYhv0PKCNf1g2gUXOjpeR1exrXccRxLMuAV5WAmGFBwRnNOJqN38+qtg==", + "devOptional": true, + "dependencies": { + "source-map-support": "^0.5.21", + "tslib": "^2.6.3" + } + }, + "node_modules/@swc/core": { + "version": "1.5.29", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/core/-/core-1.5.29.tgz", + "integrity": "sha512-nvTtHJI43DUSOAf3h9XsqYg8YXKc0/N4il9y4j0xAkO0ekgDNo+3+jbw6MInawjKJF9uulyr+f5bAutTsOKVlw==", + "devOptional": true, + "hasInstallScript": true, + "dependencies": { + "@swc/counter": "^0.1.3", + "@swc/types": "^0.1.8" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/swc" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "1.5.29", + "@swc/core-darwin-x64": "1.5.29", + "@swc/core-linux-arm-gnueabihf": "1.5.29", + "@swc/core-linux-arm64-gnu": "1.5.29", + "@swc/core-linux-arm64-musl": "1.5.29", + "@swc/core-linux-x64-gnu": "1.5.29", + "@swc/core-linux-x64-musl": "1.5.29", + "@swc/core-win32-arm64-msvc": "1.5.29", + "@swc/core-win32-ia32-msvc": "1.5.29", + "@swc/core-win32-x64-msvc": "1.5.29" + }, + "peerDependencies": { + "@swc/helpers": "*" + }, + "peerDependenciesMeta": { + "@swc/helpers": { + "optional": true + } + } + }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.5.29", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/core-darwin-arm64/-/core-darwin-arm64-1.5.29.tgz", + "integrity": "sha512-6F/sSxpHaq3nzg2ADv9FHLi4Fu2A8w8vP8Ich8gIl16D2htStlwnaPmCLjRswO+cFkzgVqy/l01gzNGWd4DFqA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.5.29", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/core-darwin-x64/-/core-darwin-x64-1.5.29.tgz", + "integrity": "sha512-rF/rXkvUOTdTIfoYbmszbSUGsCyvqACqy1VeP3nXONS+LxFl4bRmRcUTRrblL7IE5RTMCKUuPbqbQSE2hK7bqg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.5.29", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.5.29.tgz", + "integrity": "sha512-2OAPL8iWBsmmwkjGXqvuUhbmmoLxS1xNXiMq87EsnCNMAKohGc7wJkdAOUL6J/YFpean/vwMWg64rJD4pycBeg==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.5.29", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.5.29.tgz", + "integrity": "sha512-eH/Q9+8O5qhSxMestZnhuS1xqQMr6M7SolZYxiXJqxArXYILLCF+nq2R9SxuMl0CfjHSpb6+hHPk/HXy54eIRA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.5.29", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.5.29.tgz", + "integrity": "sha512-TERh2OICAJz+SdDIK9+0GyTUwF6r4xDlFmpoiHKHrrD/Hh3u+6Zue0d7jQ/he/i80GDn4tJQkHlZys+RZL5UZg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.5.29", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.5.29.tgz", + "integrity": "sha512-WMDPqU7Ji9dJpA+Llek2p9t7pcy7Bob8ggPUvgsIlv3R/eesF9DIzSbrgl6j3EAEPB9LFdSafsgf6kT/qnvqFg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.5.29", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.5.29.tgz", + "integrity": "sha512-DO14glwpdKY4POSN0201OnGg1+ziaSVr6/RFzuSLggshwXeeyVORiHv3baj7NENhJhWhUy3NZlDsXLnRFkmhHQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.5.29", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.5.29.tgz", + "integrity": "sha512-V3Y1+a1zG1zpYXUMqPIHEMEOd+rHoVnIpO/KTyFwAmKVu8v+/xPEVx/AGoYE67x4vDAAvPQrKI3Aokilqa5yVg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.5.29", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.5.29.tgz", + "integrity": "sha512-OrM6yfXw4wXhnVFosOJzarw0Fdz5Y0okgHfn9oFbTPJhoqxV5Rdmd6kXxWu2RiVKs6kGSJFZXHDeUq2w5rTIMg==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.5.29", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.5.29.tgz", + "integrity": "sha512-eD/gnxqKyZQQR0hR7TMkIlJ+nCF9dzYmVVNbYZWuA1Xy94aBPUsEk3Uw3oG7q6R3ErrEUPP0FNf2ztEnv+I+dw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/counter": { + "version": "0.1.3", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/counter/-/counter-0.1.3.tgz", + "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==", + "devOptional": true + }, "node_modules/@swc/helpers": { "version": "0.5.13", "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/helpers/-/helpers-0.5.13.tgz", "integrity": "sha512-UoKGxQ3r5kYI9dALKJapMmuK+1zWM/H17Z1+iwnNmzcJRnfFuevZs375TA5rW31pu4BS4NoSy1fRsexDXfWn5w==", - "dev": true, + "devOptional": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "tslib": "^2.4.0" } }, + "node_modules/@swc/types": { + "version": "0.1.17", + "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@swc/types/-/types-0.1.17.tgz", + "integrity": "sha512-V5gRru+aD8YVyCOMAjMpWR1Ui577DD5KSJsHP8RAxopAH22jFz6GZd/qxqjO6MJHQhcsjvjOFXyDhyLQUnMveQ==", + "devOptional": true, + "dependencies": { + "@swc/counter": "^0.1.3" + } + }, "node_modules/@testing-library/dom": { "version": "10.4.0", "resolved": "http://nexus.ozg-sh.de/repository/npm-proxy/@testing-library/dom/-/dom-10.4.0.tgz", diff --git a/alfa-client/package.json b/alfa-client/package.json index b972e5b175fe0800f1a897ab356d6781ae034383..b73e4360607a5574783ccd3c8749c75d20cbac43 100644 --- a/alfa-client/package.json +++ b/alfa-client/package.json @@ -118,6 +118,9 @@ "@storybook/addon-interactions": "^8.4.2", "@storybook/angular": "^8.4.2", "@storybook/core-server": "^8.4.2", + "@swc-node/register": "~1.9.1", + "@swc/core": "~1.5.7", + "@swc/helpers": "~0.5.11", "@testing-library/jest-dom": "^6.4.5", "@types/file-saver": "2.0.7", "@types/jest": "29.5.13", diff --git a/alfa-client/pom.xml b/alfa-client/pom.xml index bc81db6f0027dec1daf0f85400b260d2e7a65201..0466ba5fcf5a6efed1b783ef07a11cf7b5013b88 100644 --- a/alfa-client/pom.xml +++ b/alfa-client/pom.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - Copyright (C) 2022 Das Land Schleswig-Holstein vertreten durch den + Copyright (C) 2023 Das Land Schleswig-Holstein vertreten durch den Ministerpräsidenten des Landes Schleswig-Holstein Staatskanzlei Abteilung Digitalisierung und zentrales IT-Management der Landesregierung @@ -24,111 +24,113 @@ unter der Lizenz sind dem Lizenztext zu entnehmen. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>de.ozgcloud.alfa</groupId> - <artifactId>alfa</artifactId> - <version>2.17.0-SNAPSHOT</version> - </parent> + <parent> + <groupId>de.ozgcloud.alfa</groupId> + <artifactId>alfa</artifactId> + <version>2.17.0-SNAPSHOT</version> + </parent> - <modelVersion>4.0.0</modelVersion> - <artifactId>alfa-client</artifactId> - <name>Alfa Client</name> - <packaging>pom</packaging> + <modelVersion>4.0.0</modelVersion> + <artifactId>alfa-client</artifactId> + <name>Alfa Client</name> + <packaging>pom</packaging> + <inceptionYear>2020</inceptionYear> - <build> + <build> + <plugins> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <configuration> + <filesets> + <fileset> + <directory>dist</directory> + <includes> + <include>*</include> + <include>**/*</include> + </includes> + </fileset> + </filesets> + </configuration> + </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>3.0.0</version> + <executions> + <execution> + <id>test-application</id> + <phase>test</phase> + <configuration> + <workingDirectory>./</workingDirectory> + <executable>npm</executable> + <arguments> + <argument>run</argument> + <argument>test</argument> + </arguments> + <skip>${skipTests}</skip> + </configuration> + <goals> + <goal>exec</goal> + </goals> + </execution> + <execution> + <id>build-application</id> + <phase>compile</phase> + <configuration> + <workingDirectory>./</workingDirectory> + <executable>npm</executable> + <arguments> + <argument>run</argument> + <argument>ci-build</argument> + </arguments> + </configuration> + <goals> + <goal>exec</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <activation> + <property> + <name>!skipNpmInstall</name> + </property> + </activation> + <id>npmInstall</id> + <build> <plugins> - <plugin> - <artifactId>maven-clean-plugin</artifactId> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>3.0.0</version> + <executions> + <execution> + <id>install-dependencies</id> + <phase>generate-sources</phase> <configuration> - <filesets> - <fileset> - <directory>dist</directory> - <includes> - <include>*</include> - <include>**/*</include> - </includes> - </fileset> - </filesets> + <workingDirectory>./</workingDirectory> + <executable>npm</executable> + <arguments> + <argument>install</argument> + </arguments> </configuration> - </plugin> - - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>3.0.0</version> - <executions> - <execution> - <id>test-application</id> - <phase>test</phase> - <configuration> - <workingDirectory>./</workingDirectory> - <executable>npm</executable> - <arguments> - <argument>run</argument> - <argument>test</argument> - </arguments> - <skip>${skipTests}</skip> - </configuration> - <goals> - <goal>exec</goal> - </goals> - </execution> - <execution> - <id>build-application</id> - <phase>compile</phase> - <configuration> - <workingDirectory>./</workingDirectory> - <executable>npm</executable> - <arguments> - <argument>run</argument> - <argument>ci-build</argument> - </arguments> - </configuration> - <goals> - <goal>exec</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <activation> - <property> - <name>!skipNpmInstall</name> - </property> - </activation> - <id>npmInstall</id> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>3.0.0</version> - <executions> - <execution> - <id>install-dependencies</id> - <phase>generate-sources</phase> - <configuration> - <workingDirectory>./</workingDirectory> - <executable>npm</executable> - <arguments> - <argument>install</argument> - </arguments> - </configuration> - <goals> - <goal>exec</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> + <goals> + <goal>exec</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project> diff --git a/alfa-client/tsconfig.base.json b/alfa-client/tsconfig.base.json index 63b6a42cd7681cb3f77bb8a38a1eea56cc5a527b..c5305dcc83a25e9d9243459743806ce905bdbaa8 100644 --- a/alfa-client/tsconfig.base.json +++ b/alfa-client/tsconfig.base.json @@ -28,6 +28,8 @@ "@alfa-client/command-shared": ["libs/command-shared/src/index.ts"], "@alfa-client/common": ["libs/common/src/index.ts"], "@alfa-client/environment-shared": ["libs/environment-shared/src/index.ts"], + "@alfa-client/externe-fachstelle": ["libs/externe-fachstelle/src/index.ts"], + "@alfa-client/externe-fachstelle-shared": ["libs/externe-fachstelle-shared/src/index.ts"], "@alfa-client/forwarding": ["libs/forwarding/src/index.ts"], "@alfa-client/forwarding-shared": ["libs/forwarding-shared/src/index.ts"], "@alfa-client/hint": ["libs/hint/src/index.ts"], @@ -40,6 +42,8 @@ "@alfa-client/loesch-anforderung-shared": ["libs/loesch-anforderung-shared/src/index.ts"], "@alfa-client/navigation": ["libs/navigation/src/index.ts"], "@alfa-client/navigation-shared": ["libs/navigation-shared/src/index.ts"], + "@alfa-client/organisations-einheit": ["libs/organisations-einheit/src/index.ts"], + "@alfa-client/organisations-einheit-shared": ["libs/organisations-einheit-shared/src/index.ts"], "@alfa-client/postfach": ["libs/postfach/src/index.ts"], "@alfa-client/postfach-shared": ["libs/postfach-shared/src/index.ts"], "@alfa-client/resource-redirect": ["libs/resource-redirect/src/index.ts"], @@ -62,7 +66,7 @@ "@alfa-client/zustaendige-stelle-shared": ["libs/zustaendige-stelle-shared/src/index.ts"], "@ods/component": ["libs/design-component/src/index.ts"], "@ods/system": ["libs/design-system/src/index.ts"], - "authentication": ["libs/authentication/src/index.ts"] + "authentication": ["libs/authentication/src/index.ts"], } }, "exclude": ["node_modules", "tmp"] diff --git a/alfa-server/pom.xml b/alfa-server/pom.xml index 705a71a68fbff91a3dabdc0e701109e77daf6af8..994cf4071ac404fb093799a0fa27dcc3ab24fcde 100644 --- a/alfa-server/pom.xml +++ b/alfa-server/pom.xml @@ -1,4 +1,29 @@ <?xml version="1.0"?> +<!-- + + Copyright (C) 2023 Das Land Schleswig-Holstein vertreten durch den + Ministerpräsidenten des Landes Schleswig-Holstein + Staatskanzlei + Abteilung Digitalisierung und zentrales IT-Management der Landesregierung + + Lizenziert unter der EUPL, Version 1.2 oder - sobald + diese von der Europäischen Kommission genehmigt wurden - + Folgeversionen der EUPL ("Lizenz"); + Sie dürfen dieses Werk ausschließlich gemäß + dieser Lizenz nutzen. + Eine Kopie der Lizenz finden Sie hier: + + https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 + + Sofern nicht durch anwendbare Rechtsvorschriften + gefordert oder in schriftlicher Form vereinbart, wird + die unter der Lizenz verbreitete Software "so wie sie + ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - + ausdrücklich oder stillschweigend - verbreitet. + Die sprachspezifischen Genehmigungen und Beschränkungen + unter der Lizenz sind dem Lizenztext zu entnehmen. + +--> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> @@ -10,6 +35,7 @@ <artifactId>alfa-server</artifactId> <name>Alfa Server</name> + <inceptionYear>2020</inceptionYear> <properties> <maven.compiler.source>${java.version}</maven.compiler.source> diff --git a/alfa-server/src/main/resources/application-local.yml b/alfa-server/src/main/resources/application-local.yml index 55772b0d1f753624c45b82c5f343f689cdf96eb7..48d45f7c8f167f2cdfed114c5b34929437d9663b 100644 --- a/alfa-server/src/main/resources/application-local.yml +++ b/alfa-server/src/main/resources/application-local.yml @@ -10,12 +10,13 @@ server: grpc: client: user-manager: - address: static://127.0.0.1:9000 negotiationType: PLAINTEXT vorgang-manager: negotiationType: PLAINTEXT zufi-manager: negotiationType: PLAINTEXT + collaboration-manager: + negotiationType: PLAINTEXT archive-manager: negotiationType: PLAINTEXT diff --git a/alfa-server/src/main/resources/application.yml b/alfa-server/src/main/resources/application.yml index 38c43bdefbee0c9befc41ed5a8f12cafc11a8aae..14fb3b10fdecfbcd1383fb0030be1e1ba3ed33ab 100644 --- a/alfa-server/src/main/resources/application.yml +++ b/alfa-server/src/main/resources/application.yml @@ -66,6 +66,9 @@ grpc: zufi-manager: address: static://127.0.0.1:9190 negotiationType: TLS + collaboration-manager: + address: static://127.0.0.1:9090 + negotiationType: TLS archive-manager: address: static://127.0.0.1:9090 negotiationType: TLS diff --git a/alfa-service/pom.xml b/alfa-service/pom.xml index 488cb1b698bcc7e8c5602cfadfc1848a1a3ed93a..c96920e46157e7702b661e03dae86d3e99a049e2 100644 --- a/alfa-service/pom.xml +++ b/alfa-service/pom.xml @@ -1,7 +1,7 @@ <?xml version="1.0"?> <!-- - Copyright (C) 2022 Das Land Schleswig-Holstein vertreten durch den + Copyright (C) 2023 Das Land Schleswig-Holstein vertreten durch den Ministerpräsidenten des Landes Schleswig-Holstein Staatskanzlei Abteilung Digitalisierung und zentrales IT-Management der Landesregierung @@ -24,7 +24,8 @@ unter der Lizenz sind dem Lizenztext zu entnehmen. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> @@ -38,6 +39,7 @@ <name>Alfa Service</name> <description>Alfa Service implementation</description> <packaging>jar</packaging> + <inceptionYear>2020</inceptionYear> <properties> <maven.compiler.source>${java.version}</maven.compiler.source> @@ -135,6 +137,10 @@ <groupId>de.ozgcloud.zufi</groupId> <artifactId>zufi-manager-interface</artifactId> </dependency> + <dependency> + <groupId>de.ozgcloud.collaboration</groupId> + <artifactId>collaboration-manager-interface</artifactId> + </dependency> <dependency> <groupId>de.ozgcloud.archive</groupId> <artifactId>archive-manager-interface</artifactId> diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/GrpcConfiguration.java b/alfa-service/src/main/java/de/ozgcloud/alfa/GrpcConfiguration.java index 97cac2f8ea30484287afa30ab96bf522d1034bd9..c2465218de5d0d97a0065a2112607497632131ab 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/GrpcConfiguration.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/GrpcConfiguration.java @@ -13,11 +13,9 @@ import org.springframework.context.annotation.Configuration; net.devh.boot.grpc.client.autoconfigure.GrpcClientMetricAutoConfiguration.class, net.devh.boot.grpc.client.autoconfigure.GrpcClientHealthAutoConfiguration.class, net.devh.boot.grpc.client.autoconfigure.GrpcClientSecurityAutoConfiguration.class, - net.devh.boot.grpc.client.autoconfigure.GrpcClientTraceAutoConfiguration.class, net.devh.boot.grpc.client.autoconfigure.GrpcDiscoveryClientAutoConfiguration.class, net.devh.boot.grpc.common.autoconfigure.GrpcCommonCodecAutoConfiguration.class, - net.devh.boot.grpc.common.autoconfigure.GrpcCommonTraceAutoConfiguration.class }) public class GrpcConfiguration { } diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/JwtTokenUtil.java b/alfa-service/src/main/java/de/ozgcloud/alfa/JwtTokenUtil.java index 00cf59574f2d66748cdca97065e1104073e74868..1478ecbd5b6770353999c7950476f0552332a1f2 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/JwtTokenUtil.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/JwtTokenUtil.java @@ -73,7 +73,7 @@ public class JwtTokenUtil { } public Optional<Claims> getAllClaimsFromToken(String token) { - return Optional.of(Jwts.parser().setSigningKey(downloadTokenProperties.getSecret().getBytes()).parseClaimsJws(token).getBody()); + return Optional.of(Jwts.parser().setSigningKey(downloadTokenProperties.getSecret().getBytes()).build().parseSignedClaims(token).getPayload()); } public List<SimpleGrantedAuthority> getRolesFromToken(String token) { diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/Collaboration.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/Collaboration.java index b062636d2f66051bde94792e7904d7d40a67acba..e08743eef041fb3c8eb87521da09994806ffabb2 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/Collaboration.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/Collaboration.java @@ -1,25 +1,18 @@ package de.ozgcloud.alfa.collaboration; -import com.fasterxml.jackson.annotation.JsonIgnore; +public interface Collaboration { -import de.ozgcloud.alfa.common.LinkedResource; -import de.ozgcloud.alfa.common.command.CommandBody; -import lombok.Builder; -import lombok.Getter; + String getId(); -@Getter -@Builder -public class Collaboration implements CommandBody { + String getVorgangId(); - @JsonIgnore - private String vorgangId; - @JsonIgnore - private String collaborationVorgangId; + String getCollaborationVorgangId(); - private String titel; - private String beschreibung; - private int collaborationLevel; + String getTitel(); - @LinkedResource(controllerClass = OrganisationsEinheitController.class) - private String zustaendigeStelle; + String getBeschreibung(); + + long getCollaborationLevel(); + + String getZustaendigeStelle(); } diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationCommandBody.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationCommandBody.java new file mode 100644 index 0000000000000000000000000000000000000000..d6e68b1a0fa90122853a966ac35c6205e40322e0 --- /dev/null +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationCommandBody.java @@ -0,0 +1,24 @@ +package de.ozgcloud.alfa.collaboration; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import de.ozgcloud.alfa.common.LinkedResourceDeserializer; +import de.ozgcloud.alfa.common.command.CommandBody; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CollaborationCommandBody implements CommandBody { + + private String titel; + private String beschreibung; + private long collaborationLevel; + + @JsonDeserialize(using = LinkedResourceDeserializer.class) + private String zustaendigeStelle; +} diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationController.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationController.java index 63a1fa8edc08547408395b4b70739cd766ef27fe..394074c9e1e6b1c7b815d558f64570ae02a7d65a 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationController.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationController.java @@ -1,7 +1,10 @@ package de.ozgcloud.alfa.collaboration; +import java.util.Optional; + import org.springframework.hateoas.CollectionModel; import org.springframework.hateoas.EntityModel; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -17,10 +20,26 @@ public class CollaborationController { private final CollaborationModelAssembler assembler; private final CollaborationService service; - static final String PATH = "/api/vorgangs"; // NOSONAR + static final String PATH = "/api/collaborations"; // NOSONAR + + @GetMapping("/{collaborationId}") + public ResponseEntity<EntityModel<Collaboration>> getById(@PathVariable String collaborationId) { + return ResponseEntity.of(Optional.of(service.getById(collaborationId)).map(assembler::toModel)); + } + + @RestController + @RequestMapping(CollaborationByVorgangController.PATH) + @RequiredArgsConstructor + public static class CollaborationByVorgangController { + + static final String PATH = "/api/vorgangs"; + + private final CollaborationModelAssembler assembler; + private final CollaborationService service; - @GetMapping("/{vorgangId}/collaborations") - public CollectionModel<EntityModel<Collaboration>> getAllByVorgangId(@PathVariable String vorgangId) { - return assembler.toCollectionModel(service.getCollaborations(vorgangId), vorgangId); + @GetMapping("/{vorgangId}/collaborations") + public CollectionModel<EntityModel<Collaboration>> getAllByVorgangId(@PathVariable String vorgangId) { + return assembler.toCollectionModel(service.getCollaborations(vorgangId), vorgangId); + } } } diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationMapper.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..6488d9881cdc964bcaf54e4dbb9dcc4cfb1a01a3 --- /dev/null +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationMapper.java @@ -0,0 +1,26 @@ +package de.ozgcloud.alfa.collaboration; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.NullValueCheckStrategy; +import org.mapstruct.ReportingPolicy; + +import de.ozgcloud.collaboration.request.GrpcCollaborationRequest; + +@Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR, nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS) +interface CollaborationMapper { + + default Collaboration fromCollaborationRequest(GrpcCollaborationRequest request) { + return isFachstelle(request) ? fromFachstelleRequest(request) : fromOrganisationsEinheitRequest(request); + } + + default boolean isFachstelle(GrpcCollaborationRequest request) { + return Long.valueOf(4).equals(request.getCollaborationLevel()); + } + + @Mapping(target = "vorgangId", ignore = true) + OrganisationsEinheitCollaboration fromOrganisationsEinheitRequest(GrpcCollaborationRequest request); + + @Mapping(target = "vorgangId", ignore = true) + FachstelleCollaboration fromFachstelleRequest(GrpcCollaborationRequest request); +} diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationModelAssembler.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationModelAssembler.java index 0323c66fe4fa72971c00afc34815b8d92a064670..b85d9d2f8141ed86a177e74acda70821acd6e6c0 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationModelAssembler.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationModelAssembler.java @@ -11,6 +11,8 @@ import org.springframework.hateoas.LinkRelation; import org.springframework.hateoas.server.RepresentationModelAssembler; import org.springframework.stereotype.Component; +import de.ozgcloud.alfa.collaboration.CollaborationController.CollaborationByVorgangController; +import de.ozgcloud.alfa.common.CollectionModelBuilder; import de.ozgcloud.alfa.common.ModelBuilder; import de.ozgcloud.alfa.common.command.CommandController; import de.ozgcloud.alfa.vorgang.VorgangController; @@ -26,17 +28,23 @@ class CollaborationModelAssembler implements RepresentationModelAssembler<Collab @Override public EntityModel<Collaboration> toModel(Collaboration collaboration) { + var selfLink = linkTo(methodOn(CollaborationController.class).getById(collaboration.getId())).withSelfRel(); + return ModelBuilder.fromEntity(collaboration) - // TODO: Wenn Schnittstelle zum laden der Collaboration existiert, muss self - // link ergänzt werden + .addLink(selfLink) .buildModel(); } public CollectionModel<EntityModel<Collaboration>> toCollectionModel(Stream<? extends Collaboration> entities, String vorgangId) { - var collectionModel = CollectionModel.of(entities.map(this::toModel).toList()) - .add(linkTo(methodOn(CollaborationController.class).getAllByVorgangId(vorgangId)).withSelfRel()); - return collectionModel - .addIf(collectionModel.getContent().isEmpty(), () -> buildCreateCollaborationRequestLink(vorgangId)); + var entityModels = entities.map(this::toModel).toList(); + + var selfLink = linkTo(methodOn(CollaborationByVorgangController.class).getAllByVorgangId(vorgangId)).withSelfRel(); + + return CollectionModelBuilder.fromEntities(entityModels) + .addLink(selfLink) + .ifMatch(entityModels::isEmpty) + .addLink(() -> buildCreateCollaborationRequestLink(vorgangId)) + .buildModel(); } Link buildCreateCollaborationRequestLink(String vorgangId) { diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteService.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteService.java index a81de9638ea305b333fbebb229520bb0d42ad33c..6d5d3aaac904485012d7f280a03e55ebe207740f 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteService.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteService.java @@ -2,13 +2,39 @@ package de.ozgcloud.alfa.collaboration; import java.util.stream.Stream; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import de.ozgcloud.alfa.common.GrpcUtil; +import de.ozgcloud.collaboration.request.CollaborationRequestServiceGrpc.CollaborationRequestServiceBlockingStub; +import de.ozgcloud.collaboration.request.GrpcFindRequestsRequest; +import de.ozgcloud.collaboration.request.GrpcGetRequestRequest; +import net.devh.boot.grpc.client.inject.GrpcClient; + @Service public class CollaborationRemoteService { + @GrpcClient(GrpcUtil.COLLABORATION_MANAGER_GRPC_CLIENT) + private CollaborationRequestServiceBlockingStub serviceStub; + + @Autowired + private CollaborationMapper mapper; + + public Collaboration getById(String collaborationId) { + return mapper.fromCollaborationRequest(serviceStub.getRequest(buildGetRequest(collaborationId)).getRequest()); + } + public Stream<Collaboration> getCollaborations(String vorgangId) { - // TODO: Replace Dummy Data with real grpc call - return Stream.empty(); + return serviceStub.findRequests(buildSearchRequest(vorgangId)) + .getRequestsList().stream() + .map(mapper::fromCollaborationRequest); + } + + GrpcGetRequestRequest buildGetRequest(String collaborationId) { + return GrpcGetRequestRequest.newBuilder().setId(collaborationId).build(); + } + + GrpcFindRequestsRequest buildSearchRequest(String vorgangId) { + return GrpcFindRequestsRequest.newBuilder().setVorgangId(vorgangId).build(); } } diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationService.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationService.java index 8b4406b926453d570d635b13a556ef6e9050b65b..eafbaabcd5266ebda59baf71c29755c4b250340e 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationService.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationService.java @@ -12,6 +12,10 @@ class CollaborationService { private final CollaborationRemoteService remoteService; + public Collaboration getById(String collaborationId) { + return remoteService.getById(collaborationId); + } + public Stream<Collaboration> getCollaborations(String vorgangId) { return remoteService.getCollaborations(vorgangId); } diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationVorgangProcessor.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationVorgangProcessor.java index 2f8f332a5e4ebdf81d10932bdf138c53767de8cf..96805f72229e992c97f725a98525cef4844547fe 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationVorgangProcessor.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationVorgangProcessor.java @@ -11,6 +11,7 @@ import org.springframework.hateoas.LinkRelation; import org.springframework.hateoas.server.RepresentationModelProcessor; import org.springframework.stereotype.Component; +import de.ozgcloud.alfa.collaboration.CollaborationController.CollaborationByVorgangController; import de.ozgcloud.alfa.common.ModelBuilder; import de.ozgcloud.alfa.common.user.CurrentUserService; import de.ozgcloud.alfa.common.user.UserRole; @@ -40,7 +41,7 @@ class CollaborationVorgangProcessor implements RepresentationModelProcessor<Enti return ModelBuilder.fromModel(model) .ifMatch(() -> !collaborationService.hasCollaboration(vorgang.getId())) .addLinks(buildSearchOrganisationsEinheitLink(), buildSearchFachstelleLink()) - .addLink(linkTo(methodOn(CollaborationController.class).getAllByVorgangId(vorgang.getId())).withRel(REL_COLLABORATIONS)) + .addLink(linkTo(methodOn(CollaborationByVorgangController.class).getAllByVorgangId(vorgang.getId())).withRel(REL_COLLABORATIONS)) .buildModel(); } diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/FachstelleCollaboration.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/FachstelleCollaboration.java new file mode 100644 index 0000000000000000000000000000000000000000..ebf3e374bbab517011f00785e95ea5750dad225e --- /dev/null +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/FachstelleCollaboration.java @@ -0,0 +1,33 @@ +package de.ozgcloud.alfa.collaboration; + +import org.springframework.hateoas.server.core.Relation; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import de.ozgcloud.alfa.common.LinkedResource; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Relation(itemRelation = "collaboration", collectionRelation = "collaborationList") +public class FachstelleCollaboration implements Collaboration { + + @JsonIgnore + private String id; + @JsonIgnore + private String vorgangId; + @JsonIgnore + private String collaborationVorgangId; + + private String titel; + private String beschreibung; + private long collaborationLevel; + + @LinkedResource(controllerClass = FachstelleController.class) + private String zustaendigeStelle; +} diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheit.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheit.java index 33bbb03f0d3e3ccfb854740dd9d97e9316d0a691..4b1d781c03c2631c3fd6e39afcbdbb705ca40779 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheit.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheit.java @@ -11,4 +11,6 @@ class OrganisationsEinheit { private String id; private XzufiId xzufiId; + private String name; + private Anschrift anschrift; } diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitCollaboration.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitCollaboration.java new file mode 100644 index 0000000000000000000000000000000000000000..9564d5d293a6b84889d7ec7b04c0db45a3663424 --- /dev/null +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitCollaboration.java @@ -0,0 +1,33 @@ +package de.ozgcloud.alfa.collaboration; + +import org.springframework.hateoas.server.core.Relation; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import de.ozgcloud.alfa.common.LinkedResource; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Relation(itemRelation = "collaboration", collectionRelation = "collaborationList") +public class OrganisationsEinheitCollaboration implements Collaboration { + + @JsonIgnore + private String id; + @JsonIgnore + private String vorgangId; + @JsonIgnore + private String collaborationVorgangId; + + private String titel; + private String beschreibung; + private long collaborationLevel; + + @LinkedResource(controllerClass = OrganisationsEinheitController.class) + private String zustaendigeStelle; +} diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/common/CollectionModelBuilder.java b/alfa-service/src/main/java/de/ozgcloud/alfa/common/CollectionModelBuilder.java index 0a61151ea2eb7ad0c600621cccdc23382d2512ba..01ceb2d404037d97e024e9ff33baa69b6cc88607 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/common/CollectionModelBuilder.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/common/CollectionModelBuilder.java @@ -27,6 +27,7 @@ import java.util.LinkedList; import java.util.List; import java.util.function.BooleanSupplier; import java.util.function.Predicate; +import java.util.function.Supplier; import java.util.stream.Stream; import org.springframework.hateoas.CollectionModel; @@ -82,5 +83,12 @@ public class CollectionModelBuilder<T> { } return CollectionModelBuilder.this; } + + public CollectionModelBuilder<T> addLink(Supplier<Link> linkSupplier) { + if (conditionFulfilled) { + links.add(linkSupplier.get()); + } + return CollectionModelBuilder.this; + } } } \ No newline at end of file diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/common/GrpcUtil.java b/alfa-service/src/main/java/de/ozgcloud/alfa/common/GrpcUtil.java index 610a0cc4324df0ed3d3a7bd110b4a13b2b7ebfe3..ace3a64eadc3bcda17e605f199cd2bc91fca635d 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/common/GrpcUtil.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/common/GrpcUtil.java @@ -37,8 +37,8 @@ import lombok.NoArgsConstructor; public class GrpcUtil { public static final String VORGANG_MANAGER_GRPC_CLIENT = "vorgang-manager"; - public static final String ZUFI_MANAGER_GRPC_CLIENT = "zufi-manager"; + public static final String COLLABORATION_MANAGER_GRPC_CLIENT = "collaboration-manager"; public static final String ARCHIVE_MANAGER_GRPC_CLIENT = "archive-manager"; diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/common/command/CommandBody.java b/alfa-service/src/main/java/de/ozgcloud/alfa/common/command/CommandBody.java index 42f3ec714dd2a8c466b34cf2670977e2eba6d45a..8b610f6bd4eecebcb9d32127b85aea8f200d1a63 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/common/command/CommandBody.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/common/command/CommandBody.java @@ -29,7 +29,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes.Type; import de.ozgcloud.alfa.aktenzeichen.AktenzeichenCommandBody; import de.ozgcloud.alfa.bescheid.Bescheid; import de.ozgcloud.alfa.bescheid.BescheidDocumentFromFileBody; -import de.ozgcloud.alfa.collaboration.Collaboration; +import de.ozgcloud.alfa.collaboration.CollaborationCommandBody; import de.ozgcloud.alfa.kommentar.Kommentar; import de.ozgcloud.alfa.loeschanforderung.DeleteLoeschAnforderung; import de.ozgcloud.alfa.loeschanforderung.LoeschAnforderung; @@ -56,7 +56,7 @@ import de.ozgcloud.alfa.wiedervorlage.Wiedervorlage; @Type(value = ProcessVorgangBody.class, name = "PROCESS_VORGANG"), @Type(value = AktenzeichenCommandBody.class, name = "SET_AKTENZEICHEN"), @Type(value = BescheidDocumentFromFileBody.class, name = "CREATE_BESCHEID_DOCUMENT_FROM_FILE"), - @Type(value = Collaboration.class, name = "CREATE_COLLABORATION_REQUEST") + @Type(value = CollaborationCommandBody.class, name = "CREATE_COLLABORATION_REQUEST") }) public interface CommandBody { } diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/common/command/CommandModelAssembler.java b/alfa-service/src/main/java/de/ozgcloud/alfa/common/command/CommandModelAssembler.java index d8825572907482b5b7acaae723eea79c2cde445b..bf60adfa089d3533a786e81ed04b39b3c77f5277 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/common/command/CommandModelAssembler.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/common/command/CommandModelAssembler.java @@ -38,7 +38,7 @@ import org.springframework.stereotype.Component; import de.ozgcloud.alfa.bescheid.BescheidController; import de.ozgcloud.alfa.bescheid.DocumentController; -import de.ozgcloud.alfa.collaboration.CollaborationController; +import de.ozgcloud.alfa.collaboration.CollaborationController.CollaborationByVorgangController; import de.ozgcloud.alfa.common.ModelBuilder; import de.ozgcloud.alfa.kommentar.KommentarController; import de.ozgcloud.alfa.postfach.PostfachMailController; @@ -83,7 +83,7 @@ class CommandModelAssembler implements RepresentationModelAssembler<Command, Ent case WIEDERVORLAGE -> linkTo(WiedervorlageController.class).slash(entity.getRelationId()); case BESCHEID -> linkTo(methodOn(BescheidController.class).getDraft(entity.getVorgangId())); case DOCUMENT -> linkTo(DocumentController.class).slash(entity.getCreatedResource()); - case COLLABORATION -> linkTo(methodOn(CollaborationController.class).getAllByVorgangId(entity.getVorgangId())); + case COLLABORATION -> linkTo(methodOn(CollaborationByVorgangController.class).getAllByVorgangId(entity.getVorgangId())); case NONE -> throw new IllegalArgumentException("Unknown CommandOrder: " + entity.getOrder()); }; diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/JwtTokenUtilTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/JwtTokenUtilTest.java index 3f1cec61922fc4b62939c88a165ad734fe72a023..c05212e3b1aff78136eb19a4dde41110557080cc 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/JwtTokenUtilTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/JwtTokenUtilTest.java @@ -105,7 +105,7 @@ class JwtTokenUtilTest { } private Claims getParsedBody() { - return Jwts.parser().setSigningKey(TOKEN_SECRET.getBytes()).parseClaimsJws(generatedToken).getBody(); + return Jwts.parser().setSigningKey(TOKEN_SECRET.getBytes()).build().parseSignedClaims(generatedToken).getPayload(); } } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationAssertions.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationAssertions.java new file mode 100644 index 0000000000000000000000000000000000000000..1afbee05856e5cb5b28e4d0738b1b75fec51984f --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationAssertions.java @@ -0,0 +1,45 @@ +package de.ozgcloud.alfa.collaboration; + +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.result.JsonPathResultMatchers; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; +import org.springframework.web.util.UriComponentsBuilder; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +class CollaborationAssertions { + + private final boolean collectionModel; + + void assertHasFields(ResultActions response) throws Exception { + response.andExpect(jsonPath("id").doesNotExist()) + .andExpect(jsonPath("vorgangId").doesNotExist()) + .andExpect(jsonPath("collaborationVorgangId").doesNotExist()) + .andExpect(jsonPath("titel").value(OrganisationsEinheitCollaborationTestFactory.TITEL)) + .andExpect(jsonPath("beschreibung").value(OrganisationsEinheitCollaborationTestFactory.BESCHREIBUNG)) + .andExpect(jsonPath("collaborationLevel").value(OrganisationsEinheitCollaborationTestFactory.COLLABORATION_LEVEL)); + } + + void assertHasZustaendigeStelleLink(ResultActions response, String controllerPath, String zustaendigeStelle) throws Exception { + var expectedLink = UriComponentsBuilder + .fromUriString("http://localhost") + .path(controllerPath) + .pathSegment(zustaendigeStelle) + .build(); + + response.andExpect(jsonPath("zustaendigeStelle").value(expectedLink.toString())); + } + + private JsonPathResultMatchers jsonPath(String expression, Object... args) { + return MockMvcResultMatchers.jsonPath(jsonPathPrefix() + expression, args); + } + + private String jsonPathPrefix() { + var prefix = "$."; + if (collectionModel) { + prefix += "content[0]."; + } + return prefix; + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationByVorgangControllerTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationByVorgangControllerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cc009ac044d4710239eb8163876e9f20f6f7a339 --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationByVorgangControllerTest.java @@ -0,0 +1,109 @@ +package de.ozgcloud.alfa.collaboration; + +import static org.mockito.Mockito.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.util.Collections; +import java.util.stream.Stream; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; + +import de.ozgcloud.alfa.collaboration.CollaborationController.CollaborationByVorgangController; +import de.ozgcloud.alfa.vorgang.VorgangHeaderTestFactory; +import lombok.SneakyThrows; + +class CollaborationByVorgangControllerTest { + + @InjectMocks + private CollaborationByVorgangController controller; + + @Mock + private CollaborationService service; + + @Mock + private CollaborationModelAssembler assembler; + + private MockMvc mockMvc; + + private static final String VORGANG_ID = VorgangHeaderTestFactory.ID; + + @BeforeEach + void initTest() { + mockMvc = MockMvcBuilders.standaloneSetup(controller).build(); + } + + @Nested + class TestGetAllByVorgangId { + + private final Collaboration collaboration = OrganisationsEinheitCollaborationTestFactory.create(); + + @Test + void shouldCallCollaborationService() { + performRequest(); + + verify(service).getCollaborations(VORGANG_ID); + } + + @Nested + class TestOnExistingCollaboration { + + private final CollaborationAssertions collaborationAssertions = new CollaborationAssertions(true); + private final Stream<Collaboration> collaborations = Stream.of(collaboration); + + @BeforeEach + void mock() { + when(service.getCollaborations(VORGANG_ID)).thenReturn(collaborations); + when(assembler.toCollectionModel(collaborations, VORGANG_ID)) + .thenReturn(CollectionModel.of(Collections.singletonList(EntityModel.of(collaboration)))); + } + + @Test + void shouldCallAssembler() { + performRequest(); + + verify(assembler).toCollectionModel(collaborations, VORGANG_ID); + } + + @SneakyThrows + @Test + void shouldReturnStatusOk() { + var response = performRequest(); + + response.andExpect(status().isOk()); + } + + @SneakyThrows + @Test + void shouldHaveContentWithFields() { + var response = performRequest(); + + collaborationAssertions.assertHasFields(response); + } + + @SneakyThrows + @Test + void shouldHaveZustaendigeStelleLink() { + var response = performRequest(); + + collaborationAssertions.assertHasZustaendigeStelleLink(response, OrganisationsEinheitController.PATH, + OrganisationsEinheitCollaborationTestFactory.ZUSTAENDIGE_STELLE); + } + } + + @SneakyThrows + private ResultActions performRequest() { + return mockMvc.perform( + get(CollaborationByVorgangController.PATH + "/" + VORGANG_ID + "/collaborations")); + } + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationControllerTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationControllerTest.java index 71f1d8153365c3971e4333b3a7bc48789ba34447..6a887588e965c538d4b509f4aec2cfc61943d439 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationControllerTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationControllerTest.java @@ -4,20 +4,15 @@ import static org.mockito.Mockito.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import java.util.Collections; -import java.util.stream.Stream; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.springframework.hateoas.CollectionModel; import org.springframework.hateoas.EntityModel; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.util.UriComponentsBuilder; import lombok.SneakyThrows; @@ -40,109 +35,92 @@ class CollaborationControllerTest { } @Nested - class TestGetAllByVorgangId { - - private final Collaboration collaboration = CollaborationTestFactory.create(); + class TestGetById { - @SneakyThrows - @Test - void shouldCallCollaborationService() { - performRequest(); - - verify(service).getCollaborations(CollaborationTestFactory.VORGANG_ID); - } + private final CollaborationAssertions collaborationAssertions = new CollaborationAssertions(false); @Nested - class TestOnExistingCollaboration { + class OnOrganisationsEinheitCollaboration { - private final Stream<Collaboration> collaborations = Stream.of(collaboration); + public static final String COLLABORATION_ID = OrganisationsEinheitCollaborationTestFactory.ID; + private final Collaboration collaboration = OrganisationsEinheitCollaborationTestFactory.create(); @BeforeEach - void mock() { - when(service.getCollaborations(CollaborationTestFactory.VORGANG_ID)).thenReturn(collaborations); + void init() { + when(service.getById(OrganisationsEinheitCollaborationTestFactory.ID)).thenReturn(collaboration); + when(assembler.toModel(collaboration)).thenReturn(EntityModel.of(collaboration)); + } + + @Test + void shouldCallCollaborationService() { + performRequest(); + + verify(service).getById(COLLABORATION_ID); } @Test - void shouldCallAssembler() { + void shouldCreateModel() { performRequest(); - verify(assembler).toCollectionModel(collaborations, CollaborationTestFactory.VORGANG_ID); + verify(assembler).toModel(collaboration); } @SneakyThrows @Test void shouldReturnStatusOk() { - when(assembler.toCollectionModel(collaborations, CollaborationTestFactory.VORGANG_ID)) - .thenReturn(CollectionModel.of(Collections.singletonList(EntityModel.of(collaboration)))); - var response = performRequest(); response.andExpect(status().isOk()); } - @Nested - class TestResponseBody { - - @BeforeEach - void mockAssembler() { - when(assembler.toCollectionModel(collaborations, CollaborationTestFactory.VORGANG_ID)) - .thenReturn(CollectionModel.of(Collections.singletonList(EntityModel.of(collaboration)))); - } - - @SneakyThrows - @Test - void shouldNotHaveVorgangId() { - var response = performRequest(); - - response.andExpect(jsonPath("$.vorgangId").doesNotExist()); - } - - @SneakyThrows - @Test - void shouldNotHaveCollaborationVorgangId() { - var response = performRequest(); + @SneakyThrows + @Test + void shouldHaveContentWithFields() { + var response = performRequest(); - response.andExpect(jsonPath("$.collaborationVorgangId").doesNotExist()); - } + collaborationAssertions.assertHasFields(response); + } - @SneakyThrows - @Test - void shouldHaveTitel() { - var response = performRequest(); + @SneakyThrows + @Test + void shouldHaveZustaendigeStelleLink() { + var response = performRequest(); - response.andExpect(jsonPath("$.content[0].titel").value(CollaborationTestFactory.TITEL)); - } + collaborationAssertions.assertHasZustaendigeStelleLink(response, OrganisationsEinheitController.PATH, + OrganisationsEinheitCollaborationTestFactory.ZUSTAENDIGE_STELLE); + } - @SneakyThrows - @Test - void shouldHaveBeschreibung() { - var response = performRequest(); + @SneakyThrows + private ResultActions performRequest() { + return mockMvc.perform(get(CollaborationController.PATH + "/" + COLLABORATION_ID)); + } + } - System.out.println(response.andReturn().getResponse().getContentAsString()); + @Nested + class OnFachstelleCollaboration { - response.andExpect(jsonPath("$.content[0].beschreibung").value(CollaborationTestFactory.BESCHREIBUNG)); - } + public static final String COLLABORATION_ID = FachstelleCollaborationTestFactory.ID; + private final Collaboration collaboration = FachstelleCollaborationTestFactory.create(); - @SneakyThrows - @Test - void shouldHaveZustaendigeStelle() { - var expectedLink = UriComponentsBuilder - .fromUriString("http://localhost") - .path(OrganisationsEinheitController.PATH) - .pathSegment(CollaborationTestFactory.ZUSTAENDIGE_STELLE) - .build(); + @BeforeEach + void init() { + when(service.getById(FachstelleCollaborationTestFactory.ID)).thenReturn(collaboration); + when(assembler.toModel(collaboration)).thenReturn(EntityModel.of(collaboration)); + } - var response = performRequest(); + @SneakyThrows + @Test + void shouldHaveContentWithLink() { + var response = performRequest(); - response.andExpect(jsonPath("$.content[0].zustaendigeStelle") - .value(expectedLink.toString())); - } + collaborationAssertions.assertHasZustaendigeStelleLink(response, FachstelleController.PATH, + FachstelleCollaborationTestFactory.ZUSTAENDIGE_STELLE); } - } - @SneakyThrows - private ResultActions performRequest() { - return mockMvc.perform(get(CollaborationController.PATH + "/" + CollaborationTestFactory.VORGANG_ID + "/collaborations")); + @SneakyThrows + private ResultActions performRequest() { + return mockMvc.perform(get(CollaborationController.PATH + "/" + COLLABORATION_ID)); + } } } } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationMapperTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationMapperTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2008deaf8d53ccb0b0720024b2b859455c6494b5 --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationMapperTest.java @@ -0,0 +1,130 @@ +package de.ozgcloud.alfa.collaboration; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.mapstruct.factory.Mappers; +import org.mockito.Spy; + +import de.ozgcloud.collaboration.request.GrpcCollaborationRequest; + +class CollaborationMapperTest { + + @Spy + private CollaborationMapper mapper = Mappers.getMapper(CollaborationMapper.class); + + @Nested + class TestFromCollaborationRequest { + + @Nested + class OnOrganisationsEinheitRequest { + + public final GrpcCollaborationRequest request = GrpcFindRequestsResponseTestFactory.COLLABORATION_REQUEST; + public final OrganisationsEinheitCollaboration collaboration = OrganisationsEinheitCollaborationTestFactory.create(); + + @BeforeEach + void init() { + doReturn(false).when(mapper).isFachstelle(request); + doReturn(collaboration).when(mapper).fromOrganisationsEinheitRequest(request); + } + + @Test + void shouldCheckForFachstelleRequest() { + mapper.fromCollaborationRequest(request); + + verify(mapper).isFachstelle(request); + } + + @Test + void shouldMapToOrganisationsEinheitCollaboration() { + mapper.fromCollaborationRequest(request); + + verify(mapper).fromOrganisationsEinheitRequest(request); + } + + @Test + void shouldReturnOrganisationsEinheitCollaboration() { + var mapped = mapper.fromCollaborationRequest(request); + + assertThat(mapped).isEqualTo(collaboration); + } + } + + @Nested + class OnFachstelleRequest { + + public final GrpcCollaborationRequest request = GrpcFindRequestsResponseTestFactory.COLLABORATION_REQUEST; + public final FachstelleCollaboration collaboration = FachstelleCollaborationTestFactory.create(); + + @BeforeEach + void init() { + doReturn(true).when(mapper).isFachstelle(request); + doReturn(collaboration).when(mapper).fromFachstelleRequest(request); + } + + @Test + void shouldCheckForFachstelleRequest() { + mapper.fromCollaborationRequest(request); + + verify(mapper).isFachstelle(request); + } + + @Test + void shouldMapToFachstelleCollaboration() { + mapper.fromCollaborationRequest(request); + + verify(mapper).fromFachstelleRequest(request); + } + + @Test + void shouldReturnFachstelleCollaboration() { + var mapped = mapper.fromCollaborationRequest(request); + + assertThat(mapped).isEqualTo(collaboration); + } + } + } + + @Nested + class TestIsFachstelle { + + @Test + void shouldReturnTrue() { + var fachstelle = mapper.isFachstelle(GrpcCollaborationRequestForFachstelleTestFactory.create()); + + assertThat(fachstelle).isTrue(); + } + + @Test + void shouldReturnFalse() { + var fachstelle = mapper.isFachstelle(GrpcCollaborationRequestForOrganisationsEinheitTestFactory.create()); + + assertThat(fachstelle).isFalse(); + } + } + + @Nested + class TestFromOrganisationsEinheitRequest { + + @Test + void shouldMap() { + var collaboration = mapper.fromOrganisationsEinheitRequest(GrpcCollaborationRequestForOrganisationsEinheitTestFactory.create()); + + assertThat(collaboration).usingRecursiveComparison().isEqualTo(OrganisationsEinheitCollaborationTestFactory.create()); + } + } + + @Nested + class TestFromFachstelleRequest { + + @Test + void shouldMap() { + var collaboration = mapper.fromFachstelleRequest(GrpcCollaborationRequestForFachstelleTestFactory.create()); + + assertThat(collaboration).usingRecursiveComparison().isEqualTo(FachstelleCollaborationTestFactory.create()); + } + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationModelAssemblerTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationModelAssemblerTest.java index 42ccdb43a2d39ed2bf5f6f71874eec71e57d36ed..c2e4a7d26085f49987d665331226f0c8a6ad3da6 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationModelAssemblerTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationModelAssemblerTest.java @@ -17,6 +17,7 @@ import org.springframework.hateoas.IanaLinkRelations; import org.springframework.hateoas.Link; import org.springframework.hateoas.UriTemplate; +import de.ozgcloud.alfa.collaboration.CollaborationController.CollaborationByVorgangController; import de.ozgcloud.alfa.common.ModelBuilder; import de.ozgcloud.alfa.common.command.CommandController.CommandByRelationController; import de.ozgcloud.alfa.vorgang.VorgangController; @@ -37,31 +38,61 @@ class CollaborationModelAssemblerTest { class TestToModel { private static final String REL_ZUSTAENDIGE_STELLE = "zustaendigeStelle"; - private final Collaboration collaboration = CollaborationTestFactory.create(); - @Test - void shouldHaveContent() { - var entityModel = callAssembler(); + @Nested + class OnOrganisationsEinheitCollaboration { - assertThat(entityModel.getContent()).isEqualTo(collaboration); - } + private final OrganisationsEinheitCollaboration collaboration = OrganisationsEinheitCollaborationTestFactory.create(); - @Test - void shouldHaveLinkToOrganisationsEinheit() { - var entityModel = callAssembler(); + @Test + void shouldHaveContent() { + var entityModel = callAssembler(); + + assertThat(entityModel.getContent()).isEqualTo(collaboration); + } + + @Test + void shouldHaveLinkToOrganisationsEinheit() { + var entityModel = callAssembler(); - assertThat(entityModel.getLink(REL_ZUSTAENDIGE_STELLE)).get().extracting(Link::getHref) - .isEqualTo(OrganisationsEinheitController.PATH + "/" + OrganisationsEinheitTestFactory.ID); + assertThat(entityModel.getLink(REL_ZUSTAENDIGE_STELLE)).get().extracting(Link::getHref) + .isEqualTo(OrganisationsEinheitController.PATH + "/" + OrganisationsEinheitTestFactory.ID); + } + + private EntityModel<Collaboration> callAssembler() { + return assembler.toModel(collaboration); + } } - private EntityModel<Collaboration> callAssembler() { - return assembler.toModel(collaboration); + @Nested + class OnFachstelleCollaboration { + + private final FachstelleCollaboration collaboration = FachstelleCollaborationTestFactory.create(); + + @Test + void shouldHaveContent() { + var entityModel = callAssembler(); + + assertThat(entityModel.getContent()).isEqualTo(collaboration); + } + + @Test + void shouldHaveLinkToFachstelle() { + var entityModel = callAssembler(); + + assertThat(entityModel.getLink(REL_ZUSTAENDIGE_STELLE)).get().extracting(Link::getHref) + .isEqualTo(FachstelleController.PATH + "/" + FachstelleTestFactory.ID); + } + + private EntityModel<Collaboration> callAssembler() { + return assembler.toModel(collaboration); + } } } @Nested class TestToCollectionModel { - private final Collaboration collaboration = CollaborationTestFactory.create(); + private final Collaboration collaboration = FachstelleCollaborationTestFactory.create(); @Nested class OnNonEmptyCollaborationList { @@ -88,7 +119,7 @@ class CollaborationModelAssemblerTest { var collectionModel = callAssembler(); assertThat(collectionModel.getLink(IanaLinkRelations.SELF_VALUE)).get().extracting(Link::getHref) - .isEqualTo(CollaborationController.PATH + "/" + VorgangHeaderTestFactory.ID + "/collaborations"); + .isEqualTo(CollaborationByVorgangController.PATH + "/" + VorgangHeaderTestFactory.ID + "/collaborations"); } @Test @@ -126,7 +157,7 @@ class CollaborationModelAssemblerTest { var collectionModel = callAssembler(); assertThat(collectionModel.getLink(IanaLinkRelations.SELF_VALUE)).get().extracting(Link::getHref) - .isEqualTo(CollaborationController.PATH + "/" + VorgangHeaderTestFactory.ID + "/collaborations"); + .isEqualTo(CollaborationByVorgangController.PATH + "/" + VorgangHeaderTestFactory.ID + "/collaborations"); } @Test diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteServiceTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteServiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..15d95d8a80969d824bfa6d7e4fce83d5d26f8771 --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteServiceTest.java @@ -0,0 +1,137 @@ +package de.ozgcloud.alfa.collaboration; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; + +import de.ozgcloud.alfa.vorgang.VorgangHeaderTestFactory; +import de.ozgcloud.collaboration.request.CollaborationRequestServiceGrpc.CollaborationRequestServiceBlockingStub; +import de.ozgcloud.collaboration.request.GrpcFindRequestsRequest; +import de.ozgcloud.collaboration.request.GrpcGetRequestRequest; + +class CollaborationRemoteServiceTest { + + @Spy + @InjectMocks + private CollaborationRemoteService service; + @Mock + private CollaborationRequestServiceBlockingStub stub; + @Mock + private CollaborationMapper mapper; + + @Nested + class TestGetById { + + public static final String COLLABORATION_ID = GrpcGetRequestRequestTestFactory.COLLABORATION_ID; + + private final GrpcGetRequestRequest request = GrpcGetRequestRequestTestFactory.create(); + private final Collaboration collaboration = OrganisationsEinheitCollaborationTestFactory.create(); + + @BeforeEach + void init() { + when(stub.getRequest(request)).thenReturn(GrpcGetRequestResponseTestFactory.create()); + when(mapper.fromCollaborationRequest(GrpcGetRequestResponseTestFactory.COLLABORATION_REQUEST)).thenReturn(collaboration); + } + + @Test + void shouldBuildGetRequest() { + service.getById(COLLABORATION_ID); + + verify(service).buildGetRequest(COLLABORATION_ID); + } + + @Test + void shouldGetRequest() { + service.getById(COLLABORATION_ID); + + verify(stub).getRequest(request); + } + + @Test + void shouldMapFromCollaborationRequest() { + service.getById(COLLABORATION_ID); + + verify(mapper).fromCollaborationRequest(GrpcGetRequestResponseTestFactory.COLLABORATION_REQUEST); + } + + @Test + void shouldReturnCollaboration() { + var collaborationById = service.getById(COLLABORATION_ID); + + assertThat(collaborationById).isEqualTo(collaboration); + } + } + + @Nested + class TestGetCollaborations { + + public static final String VORGANG_ID = VorgangHeaderTestFactory.ID; + + private final GrpcFindRequestsRequest searchRequest = GrpcFindRequestsRequestTestFactory.create(); + private final Collaboration collaboration = OrganisationsEinheitCollaborationTestFactory.create(); + + @BeforeEach + void init() { + doReturn(searchRequest).when(service).buildSearchRequest(VORGANG_ID); + when(stub.findRequests(searchRequest)).thenReturn(GrpcFindRequestsResponseTestFactory.create()); + when(mapper.fromCollaborationRequest(GrpcFindRequestsResponseTestFactory.COLLABORATION_REQUEST)).thenReturn(collaboration); + } + + @Test + void shouldBuildSearchRequest() { + service.getCollaborations(VORGANG_ID).toList(); + + verify(service).buildSearchRequest(VORGANG_ID); + } + + @Test + void shouldFindRequests() { + service.getCollaborations(VORGANG_ID).toList(); + + verify(stub).findRequests(searchRequest); + } + + @Test + void shouldMapFromCollaborationRequest() { + service.getCollaborations(VORGANG_ID).toList(); + + verify(mapper).fromCollaborationRequest(GrpcFindRequestsResponseTestFactory.COLLABORATION_REQUEST); + } + + + @Test + void shouldReturnCollaborations() { + var collaborations = service.getCollaborations(VORGANG_ID).toList(); + + assertThat(collaborations).containsExactly(collaboration); + } + } + + @Nested + class TestBuildGetRequest { + + @Test + void shouldSetCollaborationId() { + var request = service.buildGetRequest(GrpcGetRequestRequestTestFactory.COLLABORATION_ID); + + assertThat(request.getId()).isEqualTo(GrpcGetRequestRequestTestFactory.COLLABORATION_ID); + } + } + + @Nested + class TestBuildSearchRequest { + + @Test + void shouldSetVorgangId() { + var request = service.buildSearchRequest(GrpcFindRequestsRequestTestFactory.VORGANG_ID); + + assertThat(request).usingRecursiveComparison().isEqualTo(GrpcFindRequestsRequestTestFactory.create()); + } + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationServiceTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationServiceTest.java index 2659c7fce3f402080694a5b38cdd0fe11f3507f1..4537ab0f45ee341180e57e22cad4113ec98b92f3 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationServiceTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationServiceTest.java @@ -19,22 +19,45 @@ class CollaborationServiceTest { @Mock private CollaborationRemoteService remoteService; + @Nested + class TestGetById { + + public static final String COLLABORATION_ID = FachstelleCollaborationTestFactory.ID; + + @Test + void shouldCallRemoteService() { + service.getById(COLLABORATION_ID); + + verify(remoteService).getById(COLLABORATION_ID); + } + + @Test + void shouldReturnCollaboration() { + var expected = FachstelleCollaborationTestFactory.create(); + when(remoteService.getById(COLLABORATION_ID)).thenReturn(expected); + + var collaboration = service.getById(COLLABORATION_ID); + + assertThat(collaboration).isEqualTo(expected); + } + } + @Nested class TestGetCollaborations { - private final String id = UUID.randomUUID().toString(); + private static final String VORGANG_ID = UUID.randomUUID().toString(); @Test void shouldCallRemoteService() { callService(); - verify(remoteService).getCollaborations(id); + verify(remoteService).getCollaborations(VORGANG_ID); } @Test void shouldReturnCollaboration() { - var collaboration = CollaborationTestFactory.create(); - when(remoteService.getCollaborations(id)).thenReturn(Stream.of(collaboration)); + var collaboration = FachstelleCollaborationTestFactory.create(); + when(remoteService.getCollaborations(VORGANG_ID)).thenReturn(Stream.of(collaboration)); var returnedCollaboration = callService(); @@ -42,7 +65,7 @@ class CollaborationServiceTest { } private Stream<Collaboration> callService() { - return service.getCollaborations(id); + return service.getCollaborations(VORGANG_ID); } } @@ -60,7 +83,7 @@ class CollaborationServiceTest { @Test void shouldReturnTrue() { - var collaboration = CollaborationTestFactory.create(); + var collaboration = FachstelleCollaborationTestFactory.create(); when(remoteService.getCollaborations(id)).thenReturn(Stream.of(collaboration)); var hasCollaboration = callService(); diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationVorgangProcessorTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationVorgangProcessorTest.java index 3405bc823306e74d16121db6f7b4d4ebfce30213..b12560c84636b325966eeb37e3a4cb15127c4fce 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationVorgangProcessorTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationVorgangProcessorTest.java @@ -14,6 +14,7 @@ import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.Link; import org.springframework.web.util.UriComponentsBuilder; +import de.ozgcloud.alfa.collaboration.CollaborationController.CollaborationByVorgangController; import de.ozgcloud.alfa.common.EntityModelTestFactory; import de.ozgcloud.alfa.common.UserProfileUrlProvider; import de.ozgcloud.alfa.common.user.CurrentUserService; @@ -108,7 +109,7 @@ class CollaborationVorgangProcessorTest { assertThat(model.getLink(CollaborationVorgangProcessor.REL_COLLABORATIONS)).get() .extracting(Link::getHref) - .isEqualTo(CollaborationController.PATH + "/" + VorgangHeaderTestFactory.ID + "/collaborations"); + .isEqualTo(CollaborationByVorgangController.PATH + "/" + VorgangHeaderTestFactory.ID + "/collaborations"); } } @@ -155,7 +156,7 @@ class CollaborationVorgangProcessorTest { @Test void shouldAddCollaborationsLink() { - var expectedHref = UriComponentsBuilder.fromUriString(CollaborationController.PATH) + var expectedHref = UriComponentsBuilder.fromUriString(CollaborationByVorgangController.PATH) .pathSegment(VorgangHeaderTestFactory.ID, "collaborations") .build().toString(); diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/FachstelleCollaborationTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/FachstelleCollaborationTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..826182491686f8c99fb3b26ea674577db7c3f961 --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/FachstelleCollaborationTestFactory.java @@ -0,0 +1,32 @@ +package de.ozgcloud.alfa.collaboration; + +import java.util.UUID; + +import com.thedeanda.lorem.LoremIpsum; + +import de.ozgcloud.alfa.collaboration.FachstelleCollaboration.FachstelleCollaborationBuilder; + +public class FachstelleCollaborationTestFactory { + + public static final String ID = UUID.randomUUID().toString(); + public static final String COLLABORATION_VORGANG_ID = UUID.randomUUID().toString(); + public static final long COLLABORATION_LEVEL = 4L; + public static final String TITEL = LoremIpsum.getInstance().getWords(7); + public static final String BESCHREIBUNG = LoremIpsum.getInstance().getParagraphs(2, 5); + public static final String ZUSTAENDIGE_STELLE = FachstelleTestFactory.ID; + + public static FachstelleCollaboration create() { + return createBuilder() + .build(); + } + + private static FachstelleCollaborationBuilder createBuilder() { + return FachstelleCollaboration.builder() + .id(ID) + .collaborationVorgangId(COLLABORATION_VORGANG_ID) + .collaborationLevel(COLLABORATION_LEVEL) + .titel(TITEL) + .beschreibung(BESCHREIBUNG) + .zustaendigeStelle(ZUSTAENDIGE_STELLE); + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestForFachstelleTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestForFachstelleTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..acab0e537c3fae1c888940931970114c1cd7a55f --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestForFachstelleTestFactory.java @@ -0,0 +1,27 @@ +package de.ozgcloud.alfa.collaboration; + +import de.ozgcloud.collaboration.request.GrpcCollaborationRequest; + +class GrpcCollaborationRequestForFachstelleTestFactory { + + public static final String ID = FachstelleCollaborationTestFactory.ID; + public static final String COLLABORATION_VORGANG_ID = FachstelleCollaborationTestFactory.COLLABORATION_VORGANG_ID; + public static final String TITEL = FachstelleCollaborationTestFactory.TITEL; + public static final String BESCHREIBUNG = FachstelleCollaborationTestFactory.BESCHREIBUNG; + public static final String ZUSTAENDIGE_STELLE = FachstelleCollaborationTestFactory.ZUSTAENDIGE_STELLE; + + public static GrpcCollaborationRequest create() { + return createBuilder() + .setCollaborationLevel(FachstelleCollaborationTestFactory.COLLABORATION_LEVEL) + .build(); + } + + public static GrpcCollaborationRequest.Builder createBuilder() { + return GrpcCollaborationRequest.newBuilder() + .setId(ID) + .setCollaborationVorgangId(COLLABORATION_VORGANG_ID) + .setTitel(TITEL) + .setBeschreibung(BESCHREIBUNG) + .setZustaendigeStelle(ZUSTAENDIGE_STELLE); + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestForOrganisationsEinheitTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestForOrganisationsEinheitTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..e60a7e5a2411ec02ae2abf69db1108d677a91e27 --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestForOrganisationsEinheitTestFactory.java @@ -0,0 +1,27 @@ +package de.ozgcloud.alfa.collaboration; + +import de.ozgcloud.collaboration.request.GrpcCollaborationRequest; + +class GrpcCollaborationRequestForOrganisationsEinheitTestFactory { + + public static final String ID = OrganisationsEinheitCollaborationTestFactory.ID; + public static final String COLLABORATION_VORGANG_ID = OrganisationsEinheitCollaborationTestFactory.COLLABORATION_VORGANG_ID; + public static final String TITEL = OrganisationsEinheitCollaborationTestFactory.TITEL; + public static final String BESCHREIBUNG = OrganisationsEinheitCollaborationTestFactory.BESCHREIBUNG; + public static final String ZUSTAENDIGE_STELLE = OrganisationsEinheitCollaborationTestFactory.ZUSTAENDIGE_STELLE; + + public static GrpcCollaborationRequest create() { + return createBuilder() + .setCollaborationLevel(OrganisationsEinheitCollaborationTestFactory.COLLABORATION_LEVEL) + .build(); + } + + public static GrpcCollaborationRequest.Builder createBuilder() { + return GrpcCollaborationRequest.newBuilder() + .setId(ID) + .setCollaborationVorgangId(COLLABORATION_VORGANG_ID) + .setTitel(TITEL) + .setBeschreibung(BESCHREIBUNG) + .setZustaendigeStelle(ZUSTAENDIGE_STELLE); + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcFindRequestsRequestTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcFindRequestsRequestTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..5a8eeeb6f9b16e18eb7ec7ec08ef1285d20132ad --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcFindRequestsRequestTestFactory.java @@ -0,0 +1,17 @@ +package de.ozgcloud.alfa.collaboration; + +import de.ozgcloud.alfa.vorgang.VorgangHeaderTestFactory; +import de.ozgcloud.collaboration.request.GrpcFindRequestsRequest; + +class GrpcFindRequestsRequestTestFactory { + + public static final String VORGANG_ID = VorgangHeaderTestFactory.ID; + + public static GrpcFindRequestsRequest create() { + return createBuilder().build(); + } + + public static GrpcFindRequestsRequest.Builder createBuilder() { + return GrpcFindRequestsRequest.newBuilder().setVorgangId(VORGANG_ID); + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcFindRequestsResponseTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcFindRequestsResponseTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..b48f634f815b9e249031445f369ff603215cad7a --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcFindRequestsResponseTestFactory.java @@ -0,0 +1,17 @@ +package de.ozgcloud.alfa.collaboration; + +import de.ozgcloud.collaboration.request.GrpcCollaborationRequest; +import de.ozgcloud.collaboration.request.GrpcFindRequestsResponse; + +class GrpcFindRequestsResponseTestFactory { + + public static final GrpcCollaborationRequest COLLABORATION_REQUEST = GrpcCollaborationRequestForOrganisationsEinheitTestFactory.create(); + + public static GrpcFindRequestsResponse create() { + return createBuilder().build(); + } + + public static GrpcFindRequestsResponse.Builder createBuilder() { + return GrpcFindRequestsResponse.newBuilder().addRequests(COLLABORATION_REQUEST); + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcGetRequestRequestTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcGetRequestRequestTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..793f7c1dffd5b8de535daea6a131b2a2ceb8e358 --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcGetRequestRequestTestFactory.java @@ -0,0 +1,18 @@ +package de.ozgcloud.alfa.collaboration; + +import java.util.UUID; + +import de.ozgcloud.collaboration.request.GrpcGetRequestRequest; + +class GrpcGetRequestRequestTestFactory { + + public static final String COLLABORATION_ID = UUID.randomUUID().toString(); + + public static GrpcGetRequestRequest create() { + return createBuilder().build(); + } + + public static GrpcGetRequestRequest.Builder createBuilder() { + return GrpcGetRequestRequest.newBuilder().setId(COLLABORATION_ID); + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcGetRequestResponseTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcGetRequestResponseTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..dff32b134152c7d16f10bff311d72391841e4b76 --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcGetRequestResponseTestFactory.java @@ -0,0 +1,17 @@ +package de.ozgcloud.alfa.collaboration; + +import de.ozgcloud.collaboration.request.GrpcCollaborationRequest; +import de.ozgcloud.collaboration.request.GrpcGetRequestResponse; + +class GrpcGetRequestResponseTestFactory { + + public static final GrpcCollaborationRequest COLLABORATION_REQUEST = GrpcCollaborationRequestForOrganisationsEinheitTestFactory.create(); + + public static GrpcGetRequestResponse create() { + return createBuilder().build(); + } + + public static GrpcGetRequestResponse.Builder createBuilder() { + return GrpcGetRequestResponse.newBuilder().setRequest(COLLABORATION_REQUEST); + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcOrganisationsEinheitTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcOrganisationsEinheitTestFactory.java index 7cb95a9e54f601044af15c30c06e783fdf50a09e..d986949d8a2aeeae2042f43bb283aa262bc608c1 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcOrganisationsEinheitTestFactory.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcOrganisationsEinheitTestFactory.java @@ -9,9 +9,9 @@ import de.ozgcloud.zufi.grpc.organisationseinheit.GrpcXzufiId; import de.ozgcloud.zufi.grpc.organisationseinheit.GrpcZustaendigkeit; public class GrpcOrganisationsEinheitTestFactory { - public static final String ID = OrganisationsEinheitHeaderTestFactory.ID; + public static final String ID = OrganisationsEinheitTestFactory.ID; public static final GrpcXzufiId XZUFI_ID = GrpcXzufiIdTestFactory.create(); - public static final String NAME = OrganisationsEinheitHeaderTestFactory.NAME; + public static final String NAME = OrganisationsEinheitTestFactory.NAME; public static final String SYNONYME = LoremIpsum.getInstance().getWords(5); public static final String VORGANG_MANAGER_ADDRESS = LoremIpsum.getInstance().getUrl(); public static final GrpcAnschrift ANSCHRIFT = GrpcAnschriftTestFactory.create(); diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitCollaborationTestFactory.java similarity index 54% rename from alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationTestFactory.java rename to alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitCollaborationTestFactory.java index 9959f1a2b18e38db081c5bb62847213b3353a81f..2509c88512190118b8bd3b20de203739ce50402d 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationTestFactory.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitCollaborationTestFactory.java @@ -4,25 +4,27 @@ import java.util.UUID; import com.thedeanda.lorem.LoremIpsum; -import de.ozgcloud.alfa.collaboration.Collaboration.CollaborationBuilder; +import de.ozgcloud.alfa.collaboration.OrganisationsEinheitCollaboration.OrganisationsEinheitCollaborationBuilder; -public class CollaborationTestFactory { +public class OrganisationsEinheitCollaborationTestFactory { - public static final String VORGANG_ID = UUID.randomUUID().toString(); + public static final String ID = UUID.randomUUID().toString(); public static final String COLLABORATION_VORGANG_ID = UUID.randomUUID().toString(); + public static final long COLLABORATION_LEVEL = 1L; public static final String TITEL = LoremIpsum.getInstance().getWords(7); public static final String BESCHREIBUNG = LoremIpsum.getInstance().getParagraphs(2, 5); public static final String ZUSTAENDIGE_STELLE = OrganisationsEinheitTestFactory.ID; - public static Collaboration create() { + public static OrganisationsEinheitCollaboration create() { return createBuilder() .build(); } - private static CollaborationBuilder createBuilder() { - return Collaboration.builder() - .vorgangId(VORGANG_ID) + private static OrganisationsEinheitCollaborationBuilder createBuilder() { + return OrganisationsEinheitCollaboration.builder() + .id(ID) .collaborationVorgangId(COLLABORATION_VORGANG_ID) + .collaborationLevel(COLLABORATION_LEVEL) .titel(TITEL) .beschreibung(BESCHREIBUNG) .zustaendigeStelle(ZUSTAENDIGE_STELLE); diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitHeaderTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitHeaderTestFactory.java index 4eef705ebdb94c9d108aab2312d070d6aa63f2ce..81ac634cb448240003e751ec677a618ecbc84959 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitHeaderTestFactory.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitHeaderTestFactory.java @@ -23,15 +23,13 @@ */ package de.ozgcloud.alfa.collaboration; -import java.util.UUID; +import de.ozgcloud.alfa.collaboration.OrganisationsEinheitHeader.OrganisationsEinheitHeaderBuilder; -import com.thedeanda.lorem.LoremIpsum; - -import de.ozgcloud.alfa.collaboration.OrganisationsEinheitHeader.OrganisationsEinheitHeaderBuilder;; +; public class OrganisationsEinheitHeaderTestFactory { - public static final String ID = UUID.randomUUID().toString(); - public static final String NAME = LoremIpsum.getInstance().getName(); + public static final String ID = OrganisationsEinheitTestFactory.ID; + public static final String NAME = OrganisationsEinheitTestFactory.NAME; public static final Anschrift ANSCHRIFT = AnschriftTestFactory.create(); public static OrganisationsEinheitHeader create() { diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitTestFactory.java index 59c6f03c06961983f4eefbe169474118e11b1087..89d8fd9e1f0ffad09f85ab9f929363c5a1c56b52 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitTestFactory.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitTestFactory.java @@ -23,12 +23,18 @@ */ package de.ozgcloud.alfa.collaboration; +import java.util.UUID; + +import com.thedeanda.lorem.LoremIpsum; + import de.ozgcloud.alfa.collaboration.OrganisationsEinheit.OrganisationsEinheitBuilder; public class OrganisationsEinheitTestFactory { - public static final String ID = OrganisationsEinheitHeaderTestFactory.ID; + public static final String ID = UUID.randomUUID().toString(); public static final XzufiId XZUFI_ID = XzufiIdTestFactory.create(); + public static final String NAME = LoremIpsum.getInstance().getName(); + public static final Anschrift ANSCHRIFT = AnschriftTestFactory.create(); public static OrganisationsEinheit create() { return createBuilder().build(); @@ -37,6 +43,8 @@ public class OrganisationsEinheitTestFactory { public static OrganisationsEinheitBuilder createBuilder() { return OrganisationsEinheit.builder() .id(ID) - .xzufiId(XZUFI_ID); + .xzufiId(XZUFI_ID) + .name(NAME) + .anschrift(ANSCHRIFT); } } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/common/CollectionModelBuilderTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/common/CollectionModelBuilderTest.java index 9a17c28370aeb3e29aa4e4f5066d05996d529470..76abf923218502732baf4b7657921f928bef713d 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/common/CollectionModelBuilderTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/common/CollectionModelBuilderTest.java @@ -1,12 +1,15 @@ package de.ozgcloud.alfa.common; import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; import java.util.List; +import java.util.function.Supplier; import java.util.stream.Stream; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.mockito.Mock; import org.springframework.hateoas.Link; import de.ozgcloud.alfa.vorgang.VorgangHeaderTestFactory; @@ -88,6 +91,36 @@ class CollectionModelBuilderTest { assertThat(model.getLinks()).isEmpty(); } } + + @Nested + class TestWithLinkSupplier { + + @Mock + private Supplier<Link> linkSupplier; + + @Test + void shouldAddLink() { + when(linkSupplier.get()).thenReturn(Link.of(HREF, REL)); + + var model = CollectionModelBuilder.fromEntities(List.of()).ifMatch(() -> true).addLink(linkSupplier).buildModel(); + + assertThat(model.getLinks()).hasSize(1).first().extracting(Link::getHref, link -> link.getRel().value()).containsExactly(HREF, REL); + } + + @Test + void shouldNotCallLinkSupplier() { + CollectionModelBuilder.fromEntities(List.of()).ifMatch(() -> false).addLink(linkSupplier).buildModel(); + + verify(linkSupplier, never()).get(); + } + + @Test + void shouldNotAddLink() { + var model = CollectionModelBuilder.fromEntities(List.of()).ifMatch(() -> false).addLink(linkSupplier).buildModel(); + + assertThat(model.getLinks()).isEmpty(); + } + } } } \ No newline at end of file diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/postfach/PostfachMailModelAssemblerTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/postfach/PostfachMailModelAssemblerTest.java index 1338bf82ddf79b9680a48e3dd866eb6d93f46f90..c16a03624a9b4f6ee9811752a99867281a3d31e1 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/postfach/PostfachMailModelAssemblerTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/postfach/PostfachMailModelAssemblerTest.java @@ -45,6 +45,7 @@ import org.springframework.hateoas.mediatype.hal.HalModelBuilder; import org.springframework.web.util.UriComponentsBuilder; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import de.ozgcloud.alfa.common.user.UserId; @@ -376,7 +377,7 @@ class PostfachMailModelAssemblerTest { @Test @SneakyThrows void shouldContainPostfachMails() { - var objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); + var objectMapper = new ObjectMapper().registerModules(new JavaTimeModule(), new Jdk8Module()); doReturn(EntityModel.of(postfachMail)).when(modelAssembler).toModel(postfachMail); var model = callModelAssembler(); diff --git a/pom.xml b/pom.xml index 7f69ffa8ae1f29dd9c9639eb30745f4882866662..36c76f59140543a6a8875bc5556ae8f38063b57e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ <?xml version="1.0"?> <!-- - Copyright (C) 2022 Das Land Schleswig-Holstein vertreten durch den + Copyright (C) 2020 Das Land Schleswig-Holstein vertreten durch den Ministerpräsidenten des Landes Schleswig-Holstein Staatskanzlei Abteilung Digitalisierung und zentrales IT-Management der Landesregierung @@ -30,7 +30,7 @@ <parent> <groupId>de.ozgcloud.common</groupId> <artifactId>ozgcloud-common-parent</artifactId> - <version>4.3.2</version> + <version>4.6.0</version> </parent> <groupId>de.ozgcloud.alfa</groupId> @@ -38,6 +38,7 @@ <version>2.17.0-SNAPSHOT</version> <name>Alfa Parent</name> <packaging>pom</packaging> + <inceptionYear>2020</inceptionYear> <modules> <module>alfa-client</module> @@ -54,11 +55,12 @@ <ozgcloud-common-pdf.version>3.0.1</ozgcloud-common-pdf.version> <user-manager.version>2.8.0</user-manager.version> <zufi-manager.version>1.5.0</zufi-manager.version> + <collaboration-manager.version>0.5.0</collaboration-manager.version> <archive-manager.version>0.1.0-SNAPSHOT</archive-manager.version> <spring-cloud-config-client.version>4.1.3</spring-cloud-config-client.version> <!-- TODO: die Version über ozgcloud-common ziehen --> - <jjwt.version>0.11.5</jjwt.version> + <jjwt.version>0.12.6</jjwt.version> </properties> <build> @@ -67,32 +69,6 @@ <plugin> <groupId>com.mycila</groupId> <artifactId>license-maven-plugin</artifactId> - <version>4.1</version> - <configuration> - <mapping> - <ts>SLASHSTAR_STYLE</ts> - <config>SCRIPT_STYLE</config> - </mapping> - <licenseSets> - <licenseSet> - <header>license/eupl_v1_2_de/header.txt</header> - <excludes> - <exclude>**/README</exclude> - <exclude>src/test/resources/**</exclude> - <exclude>src/main/resources/**</exclude> - <exclude>**/alfa-e2e/reports/videos/**</exclude> - <exclude>**/.angular/cache/**</exclude> - </excludes> - </licenseSet> - </licenseSets> - </configuration> - <dependencies> - <dependency> - <groupId>de.ozgcloud.common</groupId> - <artifactId>ozgcloud-common-license</artifactId> - <version>${ozgcloud.license.version}</version> - </dependency> - </dependencies> </plugin> </plugins> </pluginManagement> @@ -140,6 +116,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>de.ozgcloud.collaboration</groupId> + <artifactId>collaboration-manager-interface</artifactId> + <version>${collaboration-manager.version}</version> + </dependency> <dependency> <groupId>de.ozgcloud.archive</groupId> <artifactId>archive-manager-interface</artifactId> diff --git a/src/main/helm/templates/_helpers.tpl b/src/main/helm/templates/_helpers.tpl index d372c36a7bf03ba41f97df64697eda36d8ecf120..64c85fafbe6136a318679fcbc9cbf97c6added85 100644 --- a/src/main/helm/templates/_helpers.tpl +++ b/src/main/helm/templates/_helpers.tpl @@ -61,6 +61,10 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} {{ printf "dns:///%s.%s:9000" ( coalesce .Values.usermanagerName "user-manager" ) .Release.Namespace }} {{- end -}} +{{- define "app.grpc_client_collaboration-manager_address" -}} +{{ printf "dns:///%s.%s:9090" ( coalesce .Values.collaborationManagerName "vorgang-manager" ) .Release.Namespace | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end -}} + {{- define "app.spring_cloud_config_administration_address" -}} {{ printf "http://%s.%s:8080" ( coalesce .Values.administrationName "administration" ) .Release.Namespace }} {{- end -}} diff --git a/src/main/helm/templates/deployment.yaml b/src/main/helm/templates/deployment.yaml index 56cf8d1ddfb07bb62b2d40af8a67d031e9c3fef6..6a6605eec6fa1436022ef090c6bb235b1b4d7c49 100644 --- a/src/main/helm/templates/deployment.yaml +++ b/src/main/helm/templates/deployment.yaml @@ -78,6 +78,10 @@ spec: value: {{ include "app.grpc_client_user-manager_address" . }} - name: grpc_client_user-manager_negotiationType value: {{ (.Values.userManager).grpcClientNegotiationType | default "TLS" }} + - name: grpc_client_collaboration-manager_address + value: {{ include "app.grpc_client_collaboration-manager_address" . }} + - name: grpc_client_collaboration-manager_negotiationType + value: {{ (.Values.collaborationManager).grpcClientNegotiationType | default "TLS" }} - name: grpc_client_archive-manager_address value: {{ include "app.grpc_client_archive_manager_address" . }} - name: grpc_client_archive-manager_negotiationType diff --git a/src/test/helm/deployment_collaboration_manager_address_env_test.yaml b/src/test/helm/deployment_collaboration_manager_address_env_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d5b281eb44b0a152bad1bc5c37c693da23959dbe --- /dev/null +++ b/src/test/helm/deployment_collaboration_manager_address_env_test.yaml @@ -0,0 +1,49 @@ +# +# Copyright (C) 2024 Das Land Schleswig-Holstein vertreten durch den +# Ministerpräsidenten des Landes Schleswig-Holstein +# Staatskanzlei +# Abteilung Digitalisierung und zentrales IT-Management der Landesregierung +# +# Lizenziert unter der EUPL, Version 1.2 oder - sobald +# diese von der Europäischen Kommission genehmigt wurden - +# Folgeversionen der EUPL ("Lizenz"); +# Sie dürfen dieses Werk ausschließlich gemäß +# dieser Lizenz nutzen. +# Eine Kopie der Lizenz finden Sie hier: +# +# https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 +# +# Sofern nicht durch anwendbare Rechtsvorschriften +# gefordert oder in schriftlicher Form vereinbart, wird +# die unter der Lizenz verbreitete Software "so wie sie +# ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - +# ausdrücklich oder stillschweigend - verbreitet. +# Die sprachspezifischen Genehmigungen und Beschränkungen +# unter der Lizenz sind dem Lizenztext zu entnehmen. +# + +suite: test deployment collaboration-manager address +release: + name: alfa + namespace: sh-helm-test +templates: + - templates/deployment.yaml +set: + baseUrl: test.company.local + ozgcloud: + environment: test + bundesland: sh + bezeichner: helm + sso: + serverUrl: https://sso.company.local + imagePullSecret: image-pull-secret +tests: + - it: should set the collaboration-manager name + set: + collaborationManagerName: my-test-collaboration-manager-name + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: grpc_client_collaboration-manager_address + value: dns:///my-test-collaboration-manager-name.sh-helm-test:9090 diff --git a/src/test/helm/deployment_defaults_env_test.yaml b/src/test/helm/deployment_defaults_env_test.yaml index ec868f133c64569d5ddf0cf73c8dc2c1cde3e9b8..2ae7c0e36565b549e69d1f87d9a467e69d2d5e10 100644 --- a/src/test/helm/deployment_defaults_env_test.yaml +++ b/src/test/helm/deployment_defaults_env_test.yaml @@ -54,6 +54,11 @@ tests: content: name: grpc_client_user-manager_address value: dns:///user-manager.sh-helm-test:9000 + - contains: + path: spec.template.spec.containers[0].env + content: + name: grpc_client_collaboration-manager_address + value: dns:///vorgang-manager.sh-helm-test:9090 - contains: path: spec.template.spec.containers[0].env content: @@ -155,6 +160,23 @@ tests: content: name: grpc_client_vorgang-manager_negotiationType value: TLS + - it: should set collaboration-manager negotiationType plaintext + set: + collaborationManager.grpcClientNegotiationType: PLAINTEXT + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: grpc_client_collaboration-manager_negotiationType + value: PLAINTEXT + + - it: should contain default collaboration-manager negotiationType tls + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: grpc_client_collaboration-manager_negotiationType + value: TLS - it: should set archive-manager negotiationType plaintext set: