Skip to content
Snippets Groups Projects
Commit f6277689 authored by OZGCloud's avatar OZGCloud
Browse files

Merge remote-tracking branch 'origin/master' into...

Merge remote-tracking branch 'origin/master' into OZG-4248-KonkurrierendeAktivitaetenLoeschAnforderungZuruecknehmen
parents f757c852 c4173bd6
No related branches found
No related tags found
No related merge requests found
......@@ -28,12 +28,13 @@ import { LOCALE_ID, NgModule } from '@angular/core';
import { MAT_LEGACY_TOOLTIP_DEFAULT_OPTIONS as MAT_TOOLTIP_DEFAULT_OPTIONS, MatLegacyTooltipDefaultOptions as MatTooltipDefaultOptions } from '@angular/material/legacy-tooltip';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { RouterModule, Routes } from '@angular/router';
import { RouterModule, Routes, UrlSerializer } from '@angular/router';
import { ApiRootModule } from '@goofy-client/api-root-shared';
import { AppSharedModule } from '@goofy-client/app-shared';
import { EnvironmentModule } from '@goofy-client/environment-shared';
import { HintSharedModule } from '@goofy-client/hint-shared';
import { NavigationModule } from '@goofy-client/navigation';
import { OzgCloudUrlSerializer } from '@goofy-client/navigation-shared';
import { UiModule } from '@goofy-client/ui';
import { EffectsModule } from '@ngrx/effects';
import { StoreRouterConnectingModule } from '@ngrx/router-store';
......@@ -99,7 +100,8 @@ const tooltipDefaults: MatTooltipDefaultOptions = {
],
providers: [
{ provide: LOCALE_ID, useValue: 'de' },
{ provide: MAT_TOOLTIP_DEFAULT_OPTIONS, useValue: tooltipDefaults }
{ provide: MAT_TOOLTIP_DEFAULT_OPTIONS, useValue: tooltipDefaults },
{ provide: UrlSerializer, useClass: OzgCloudUrlSerializer }
],
bootstrap: [AppComponent]
})
......
......@@ -28,3 +28,5 @@ export * from './lib/+state/navigation.reducer';
export * from './lib/+state/navigation.selectors';
export * from './lib/navigation-shared.module';
export * from './lib/navigation.service';
export * from './lib/ozgcloud-url-serializer';
import { revertDoubleEncodingOfPercentageSign } from './navigation.util';
describe('decodeEncodedPercentageSign', () => {
it('should remove %25 by %', () => {
const text: string = revertDoubleEncodingOfPercentageSign('Test%25text');
expect(text).toBe('Test%text');
})
})
\ No newline at end of file
......@@ -34,3 +34,7 @@ function getLastFirstChild(route: any) {
while (isNotUndefined(route.firstChild)) route = route.firstChild;
return route;
}
export function revertDoubleEncodingOfPercentageSign(text: string): string {
return text.replace(/%25/g, '%');
}
\ No newline at end of file
import { Router, UrlTree } from '@angular/router';
import { RouterTestingModule } from "@angular/router/testing";
import { faker } from '@faker-js/faker';
import { OzgCloudUrlSerializer } from './ozgcloud-url-serializer';
import { TestBed } from '@angular/core/testing';
import * as NavigationUtil from './navigation.util';
describe('OzgCloudUrlSerializer', () => {
let serializer: OzgCloudUrlSerializer;
let router: Router;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule]
});
router = TestBed.inject(Router);
serializer = new OzgCloudUrlSerializer();
})
it('should be created', () => {
expect(serializer).toBeTruthy();
});
describe('parse', () => {
it('should return URLTree', () => {
const url: string = faker.internet.url();
const urlTree: UrlTree = serializer.parse(url);
expect(urlTree).toBeInstanceOf(UrlTree);
})
})
describe('serialize', () => {
it('should call revertDoubleEncodingOfPercentageSign', () => {
const spy: jest.SpyInstance<string, [text: string]> = jest.spyOn(NavigationUtil, 'revertDoubleEncodingOfPercentageSign');
const urlTree: UrlTree = router.createUrlTree(['/']);
serializer.serialize(urlTree);
expect(spy).toHaveBeenCalled();
})
it('should ensure percentage sign is not double encoded', () => {
const urlTree: UrlTree = router.createUrlTree(['/', '%25']);
const path: string = serializer.serialize(urlTree);
expect(path).toBe('/%25');
})
})
})
\ No newline at end of file
import { DefaultUrlSerializer, UrlTree } from '@angular/router';
import { revertDoubleEncodingOfPercentageSign } from './navigation.util';
export class OzgCloudUrlSerializer extends DefaultUrlSerializer {
parse(url: string) : UrlTree {
return super.parse(url);
}
serialize(tree: UrlTree): string {
const path: string = super.serialize(tree);
return revertDoubleEncodingOfPercentageSign(path);
}
}
......@@ -39,6 +39,8 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
import de.ozgcloud.alfa.common.callcontext.CallContextTestFactory;
import de.ozgcloud.alfa.common.callcontext.ContextService;
import de.ozgcloud.alfa.common.command.Command;
import de.ozgcloud.alfa.common.command.CommandBodyMapper;
import de.ozgcloud.alfa.common.command.CommandOrder;
......@@ -65,6 +67,9 @@ class VorgangAttachedItemServiceTest {
@Mock
private VorgangAttachedItemRemoteService vorgangAttachedItemRemoteService;
@Mock
private ContextService contextService;
@DisplayName("Create new wiedervorlage")
@Nested
class TestCreateNewWiedervorlage {
......@@ -264,6 +269,7 @@ class VorgangAttachedItemServiceTest {
@BeforeEach
void mockServices() {
when(commandBodyMapper.fromObjectToMap(any())).thenReturn(VorgangAttachedItemTestFactory.ITEM);
when(contextService.getClientName()).thenReturn(CallContextTestFactory.CLIENT_NAME);
}
@Test
......@@ -294,6 +300,13 @@ class VorgangAttachedItemServiceTest {
assertThat(vorgangAttachedItem.getItem()).isEqualTo(VorgangAttachedItemTestFactory.ITEM);
}
@Test
void shouldContainsClientName() {
var vorgangAttachedItem = buildVorgangAttachedItem();
assertThat(vorgangAttachedItem.getClient()).isEqualTo(CallContextTestFactory.CLIENT_NAME);
}
private VorgangAttachedItem buildVorgangAttachedItem() {
return service.buildVorgangAttachedItem(BODY, VorgangHeaderTestFactory.ID,
VorgangAttachedItemService.WIEDERVORLAGE_ITEM_NAME);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment