@Test public void validateHardPassFailTimeout() { AdmissionValidator pass = new PassJobValidator(); AdmissionValidator fail = new FailJobValidator(); AdmissionValidator never = new NeverJobValidator(); AdmissionValidator parallelValidator = new AggregatingValidator( configuration, registry, Arrays.asList(pass, fail, never)); Mono<Set<ValidationError>> mono = parallelValidator.validate(MOCK_JOB); StepVerifier.create(mono) .expectNextMatches(errors -> errors.size() == 2) .verifyComplete(); Set<ValidationError> errors = mono.block(); validateErrorType(errors, ValidationError.Type.HARD); Collection<ValidationError> failErrors = errors.stream() .filter(error -> error.getField().equals(FailJobValidator.ERR_FIELD)) .collect(Collectors.toList()); assertThat(failErrors).hasSize(1); validateFailErrors(failErrors); Collection<ValidationError> timeoutErrors = errors.stream() .filter(error -> error.getField().equals(NeverJobValidator.class.getSimpleName())) .collect(Collectors.toList()); assertThat(timeoutErrors).hasSize(1); validateTimeoutErrors(timeoutErrors); }
@Override public Mono<Set<ValidationError>> validate(JobDescriptor jobDescriptor) { return Mono.zip( getMonos(jobDescriptor, timeout, validators), objects -> Arrays.stream(objects) .map(objectSet -> (Set<ValidationError>) objectSet) .flatMap(Set::stream) .collect(Collectors.toSet())) .defaultIfEmpty(Collections.emptySet()); }
AggregatingValidator implements AdmissionValidator<JobDescriptor> { @Override public Mono<Set<ValidationError>> validate(JobDescriptor jobDescriptor) { return Mono.zip( getMonos(jobDescriptor, timeout, validators), objects -> Arrays.stream(objects) .map(objectSet -> (Set<ValidationError>) objectSet) .flatMap(Set::stream) .collect(Collectors.toSet())) .defaultIfEmpty(Collections.emptySet()); } }
AggregatingValidator implements AdmissionValidator<JobDescriptor> { @Override public Mono<Set<ValidationError>> validate(JobDescriptor jobDescriptor) { return Mono.zip( getMonos(jobDescriptor, timeout, validators), objects -> Arrays.stream(objects) .map(objectSet -> (Set<ValidationError>) objectSet) .flatMap(Set::stream) .collect(Collectors.toSet())) .defaultIfEmpty(Collections.emptySet()); } @Inject  AggregatingValidator(
            TitusValidatorConfiguration configuration,
            Registry registry,
            Collection<? extends AdmissionValidator<JobDescriptor>> validators); }
AggregatingValidator implements AdmissionValidator<JobDescriptor> { @Override public Mono<Set<ValidationError>> validate(JobDescriptor jobDescriptor) { return Mono.zip( getMonos(jobDescriptor, timeout, validators), objects -> Arrays.stream(objects) .map(objectSet -> (Set<ValidationError>) objectSet) .flatMap(Set::stream) .collect(Collectors.toSet())) .defaultIfEmpty(Collections.emptySet()); } @Inject  AggregatingValidator(
            TitusValidatorConfiguration configuration,
            Registry registry,
            Collection<? extends AdmissionValidator<JobDescriptor>> validators); @Override Mono<Set<ValidationError>> validate(JobDescriptor jobDescriptor); @Override ValidationError.Type getErrorType(); static String getTimeoutMsg(Duration timeout); }
AggregatingValidator implements AdmissionValidator<JobDescriptor> { @Override public Mono<Set<ValidationError>> validate(JobDescriptor jobDescriptor) { return Mono.zip( getMonos(jobDescriptor, timeout, validators), objects -> Arrays.stream(objects) .map(objectSet -> (Set<ValidationError>) objectSet) .flatMap(Set::stream) .collect(Collectors.toSet())) .defaultIfEmpty(Collections.emptySet()); } @Inject  AggregatingValidator(
            TitusValidatorConfiguration configuration,
            Registry registry,
            Collection<? extends AdmissionValidator<JobDescriptor>> validators); @Override Mono<Set<ValidationError>> validate(JobDescriptor jobDescriptor); @Override ValidationError.Type getErrorType(); static String getTimeoutMsg(Duration timeout);  }