Search in sources :

Example 1 with ValidatorSet

use of org.activiti.validation.validator.ValidatorSet in project Activiti by Activiti.

the class ProcessEngineAutoConfigurationTest method shouldAddAsyncPropertyValidatorWhenAsyncExecutorIsEnabled.

@Test
public void shouldAddAsyncPropertyValidatorWhenAsyncExecutorIsEnabled() {
    // given
    ActivitiProperties activitiProperties = new ActivitiProperties();
    activitiProperties.setAsyncExecutorActivate(false);
    SpringProcessEngineConfiguration conf = new SpringProcessEngineConfiguration(applicationUpgradeContextServiceMock);
    // when
    processEngineAutoConfiguration.addAsyncPropertyValidator(activitiProperties, conf);
    // then
    ProcessValidator processValidator = conf.getProcessValidator();
    assertThat(processValidator).isNotNull();
    assertThat(processValidator.getValidatorSets()).flatExtracting(ValidatorSet::getValidators).haveExactly(1, new Condition<>(validator -> validator instanceof AsyncPropertyValidator, "instance of AsyncPropertyValidator"));
}
Also used : SpringProcessEngineConfiguration(org.activiti.spring.SpringProcessEngineConfiguration) Test(org.junit.jupiter.api.Test) InjectMocks(org.mockito.InjectMocks) ApplicationUpgradeContextService(org.activiti.core.common.spring.project.ApplicationUpgradeContextService) BeforeEach(org.junit.jupiter.api.BeforeEach) MockitoAnnotations.initMocks(org.mockito.MockitoAnnotations.initMocks) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ValidatorSet(org.activiti.validation.validator.ValidatorSet) Condition(org.assertj.core.api.Condition) AsyncPropertyValidator(org.activiti.spring.boot.process.validation.AsyncPropertyValidator) ProcessValidator(org.activiti.validation.ProcessValidator) SpringProcessEngineConfiguration(org.activiti.spring.SpringProcessEngineConfiguration) ProcessValidator(org.activiti.validation.ProcessValidator) AsyncPropertyValidator(org.activiti.spring.boot.process.validation.AsyncPropertyValidator) Test(org.junit.jupiter.api.Test)

Example 2 with ValidatorSet

use of org.activiti.validation.validator.ValidatorSet in project Activiti by Activiti.

the class ProcessEngineAutoConfiguration method addAsyncPropertyValidator.

protected void addAsyncPropertyValidator(ActivitiProperties activitiProperties, SpringProcessEngineConfiguration conf) {
    if (!activitiProperties.isAsyncExecutorActivate()) {
        ValidatorSet springBootStarterValidatorSet = new ValidatorSet("activiti-spring-boot-starter");
        springBootStarterValidatorSet.addValidator(new AsyncPropertyValidator());
        if (conf.getProcessValidator() == null) {
            ProcessValidatorImpl processValidator = new ProcessValidatorImpl();
            processValidator.addValidatorSet(springBootStarterValidatorSet);
            conf.setProcessValidator(processValidator);
        } else {
            conf.getProcessValidator().getValidatorSets().add(springBootStarterValidatorSet);
        }
    }
}
Also used : ProcessValidatorImpl(org.activiti.validation.ProcessValidatorImpl) ValidatorSet(org.activiti.validation.validator.ValidatorSet) AsyncPropertyValidator(org.activiti.spring.boot.process.validation.AsyncPropertyValidator)

Example 3 with ValidatorSet

use of org.activiti.validation.validator.ValidatorSet in project Activiti by Activiti.

the class ProcessValidatorImpl method validate.

@Override
public List<ValidationError> validate(BpmnModel bpmnModel) {
    List<ValidationError> allErrors = new ArrayList<ValidationError>();
    for (ValidatorSet validatorSet : validatorSets) {
        for (Validator validator : validatorSet.getValidators()) {
            List<ValidationError> validatorErrors = new ArrayList<ValidationError>();
            validator.validate(bpmnModel, validatorErrors);
            if (!validatorErrors.isEmpty()) {
                for (ValidationError error : validatorErrors) {
                    error.setValidatorSetName(validatorSet.getName());
                }
                allErrors.addAll(validatorErrors);
            }
        }
    }
    return allErrors;
}
Also used : ValidatorSet(org.activiti.validation.validator.ValidatorSet) ArrayList(java.util.ArrayList) Validator(org.activiti.validation.validator.Validator)

Aggregations

ValidatorSet (org.activiti.validation.validator.ValidatorSet)3 AsyncPropertyValidator (org.activiti.spring.boot.process.validation.AsyncPropertyValidator)2 ArrayList (java.util.ArrayList)1 ApplicationUpgradeContextService (org.activiti.core.common.spring.project.ApplicationUpgradeContextService)1 SpringProcessEngineConfiguration (org.activiti.spring.SpringProcessEngineConfiguration)1 ProcessValidator (org.activiti.validation.ProcessValidator)1 ProcessValidatorImpl (org.activiti.validation.ProcessValidatorImpl)1 Validator (org.activiti.validation.validator.Validator)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Condition (org.assertj.core.api.Condition)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 InjectMocks (org.mockito.InjectMocks)1 Mock (org.mockito.Mock)1 MockitoAnnotations.initMocks (org.mockito.MockitoAnnotations.initMocks)1