Skip to content

Commit

Permalink
feature(policy): #832 fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-mmaul committed Jun 19, 2024
1 parent 3b2bb92 commit 9ed8dd9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,4 @@ describe('getOperatorTypeSign', () => {
expect(getOperatorTypeSign(OperatorType.GTEQ)).toBe('>=');
});

it('should return the string representation of the type for unknown types', () => {
expect(getOperatorTypeSign('UNKNOWN' as OperatorType)).toBe('UNKNOWN');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const mockedPolicies = {
{
leftOperand: 'PURPOSE',
operator: {
id: OperatorType.IN,
id: OperatorType.EQ,
},
rightOperand: 'BMW',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import { Component } from '@angular/core';
import { FormArray, FormBuilder, FormControl, FormGroup, ValidationErrors, Validators } from '@angular/forms';
import {
AbstractControl,
FormArray,
FormBuilder,
FormControl,
FormGroup,
ValidationErrors,
ValidatorFn,
Validators,
} from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { bpnListRegex, bpnRegex } from '@page/admin/presentation/bpn-configuration/bpn-configuration.component';
import { PoliciesFacade } from '@page/admin/presentation/policy-management/policies/policies.facade';
Expand Down Expand Up @@ -52,7 +61,7 @@ export class PolicyEditorComponent {


this.policyForm = this.fb.group({
policyName: new FormControl('', [ Validators.required, Validators.minLength(8), Validators.maxLength(40) ]),
policyName: new FormControl('', [ Validators.required, Validators.minLength(8), Validators.maxLength(40), this.noSpacesValidator() ]),
validUntil: new FormControl('', [ Validators.required, this.futureDateValidator ]),
bpns: new FormControl('', [ Validators.required, this.viewMode === ViewMode.CREATE ? BaseInputHelper.getCustomPatternValidator(bpnRegex, 'bpn') : BaseInputHelper.getCustomPatternValidator(bpnListRegex, 'bpn') ]),
accessType: new FormControl<string>(PolicyAction.ACCESS),
Expand Down Expand Up @@ -317,6 +326,13 @@ export class PolicyEditorComponent {
return null;
};

private noSpacesValidator(): ValidatorFn {
return (control: AbstractControl): ValidationErrors | null => {
const hasSpaces = (control.value || '').includes(' ');
return hasSpaces ? { noSpaces: true } : null;
};
}


protected readonly ViewMode = ViewMode;
protected readonly OperatorTypesAsSelectOptionsList = OperatorTypesAsSelectOptionsList;
Expand Down
9 changes: 0 additions & 9 deletions frontend/src/app/modules/page/policies/model/policy.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,6 @@ export enum OperatorType {
GT = 'GT',
LTEQ = 'LTEQ',
GTEQ = 'GTEQ',
IN = 'IN',
ISA = 'ISA',
HASPART = 'HASPART',
ISPARTOF = 'ISPARTOF',
ISONEOF = 'ISONEOF',
ISALLOF = 'ISALLOF',
ISNONEOF = 'ISNONEOF',
}

const OperatorSignsToTypes: { [key: string]: OperatorType } = {
Expand Down Expand Up @@ -132,8 +125,6 @@ export function getOperatorTypeSign(type: OperatorType): string {
return '<=';
case OperatorType.GTEQ:
return '>=';
default:
return type.toString();
}
}

Expand Down

0 comments on commit 9ed8dd9

Please sign in to comment.