Search in sources :

Example 1 with ProcessDefinitionEntityImpl

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityImpl in project Activiti by Activiti.

the class ProcessRuntimeImplTest method should_throwActivitiUnprocessableEntryException_when_processDefinitionAppVersionDiffersFromCurrentDeploymentVersion.

@Test
public void should_throwActivitiUnprocessableEntryException_when_processDefinitionAppVersionDiffersFromCurrentDeploymentVersion() {
    String processDefinitionId = "processDefinitionId";
    ProcessDefinitionEntityImpl processDefinition = new ProcessDefinitionEntityImpl();
    processDefinition.setId(processDefinitionId);
    processDefinition.setAppVersion(1);
    List<ProcessDefinition> findProcessDefinitionResult = singletonList(processDefinition);
    Deployment latestDeploymentEntity = new DeploymentEntityImpl();
    DeploymentImpl latestDeployment = new DeploymentImpl();
    latestDeployment.setVersion(2);
    given(deploymentConverter.from(latestDeploymentEntity)).willReturn(latestDeployment);
    given(commandExecutor.execute(any())).willReturn(findProcessDefinitionResult).willReturn(latestDeploymentEntity).willReturn(latestDeployment);
    Throwable exception = catchThrowable(() -> processRuntime.processDefinition(processDefinitionId));
    assertThat(exception).isInstanceOf(UnprocessableEntityException.class).hasMessage("Process definition with the given id:'processDefinitionId' belongs to a different application version.");
}
Also used : UnprocessableEntityException(org.activiti.api.runtime.shared.UnprocessableEntityException) ProcessDefinitionEntityImpl(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityImpl) Deployment(org.activiti.engine.repository.Deployment) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) DeploymentImpl(org.activiti.api.runtime.model.impl.DeploymentImpl) DeploymentEntityImpl(org.activiti.engine.impl.persistence.entity.DeploymentEntityImpl) Test(org.junit.jupiter.api.Test)

Example 2 with ProcessDefinitionEntityImpl

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityImpl in project Activiti by Activiti.

the class ProcessRuntimeImplTest method should_getProcessDefinitionById_when_appVersionIsNull.

@Test
public void should_getProcessDefinitionById_when_appVersionIsNull() {
    String processDefinitionId = "processDefinitionId";
    String processDefinitionKey = "processDefinitionKey";
    ProcessDefinitionEntityImpl processDefinition = new ProcessDefinitionEntityImpl();
    processDefinition.setId(processDefinitionId);
    processDefinition.setKey(processDefinitionKey);
    processDefinition.setAppVersion(null);
    List<ProcessDefinition> findProcessDefinitionResult = singletonList(processDefinition);
    given(commandExecutor.execute(any())).willReturn(findProcessDefinitionResult);
    given(securityPoliciesManager.canRead(processDefinitionKey)).willReturn(true);
    processRuntime.processDefinition(processDefinitionId);
    verify(processDefinitionConverter).from(processDefinition);
    verifyZeroInteractions(deploymentConverter);
}
Also used : ProcessDefinitionEntityImpl(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityImpl) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) Test(org.junit.jupiter.api.Test)

Example 3 with ProcessDefinitionEntityImpl

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityImpl in project Activiti by Activiti.

the class BpmnDeployerTest method makeProcessDefinitionsConsistentWithPersistedVersions_should_setAppVersion.

@Test
public void makeProcessDefinitionsConsistentWithPersistedVersions_should_setAppVersion() {
    // given
    ParsedDeployment parsedDeployment = mock(ParsedDeployment.class);
    ProcessDefinitionEntityImpl parsedProcessDefinition = new ProcessDefinitionEntityImpl();
    given(parsedDeployment.getAllProcessDefinitions()).willReturn(singletonList(parsedProcessDefinition));
    ProcessDefinitionEntityImpl persistedProcessDefinition = new ProcessDefinitionEntityImpl();
    persistedProcessDefinition.setId("procId");
    persistedProcessDefinition.setVersion(1);
    persistedProcessDefinition.setAppVersion(2);
    given(bpmnDeploymentHelper.getPersistedInstanceOfProcessDefinition(parsedProcessDefinition)).willReturn(persistedProcessDefinition);
    // when
    bpmnDeployer.makeProcessDefinitionsConsistentWithPersistedVersions(parsedDeployment);
    // then
    assertThat(parsedProcessDefinition.getId()).isEqualTo(persistedProcessDefinition.getId());
    assertThat(parsedProcessDefinition.getVersion()).isEqualTo(persistedProcessDefinition.getVersion());
    assertThat(parsedProcessDefinition.getAppVersion()).isEqualTo(persistedProcessDefinition.getAppVersion());
    assertThat(parsedProcessDefinition.getSuspensionState()).isEqualTo(persistedProcessDefinition.getSuspensionState());
}
Also used : ProcessDefinitionEntityImpl(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityImpl) Test(org.junit.Test)

Example 4 with ProcessDefinitionEntityImpl

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityImpl in project Activiti by Activiti.

the class ProcessRuntimeImplTest method should_throwActivitiObjectNotFoundException_when_canReadFalse.

@Test
public void should_throwActivitiObjectNotFoundException_when_canReadFalse() {
    String processDefinitionId = "processDefinitionId";
    String processDefinitionKey = "processDefinitionKey";
    ProcessDefinitionEntityImpl processDefinition = new ProcessDefinitionEntityImpl();
    processDefinition.setId(processDefinitionId);
    processDefinition.setKey(processDefinitionKey);
    processDefinition.setAppVersion(1);
    List<ProcessDefinition> findProcessDefinitionResult = singletonList(processDefinition);
    Deployment latestDeploymentEntity = new DeploymentEntityImpl();
    DeploymentImpl deployment = new DeploymentImpl();
    deployment.setVersion(1);
    given(deploymentConverter.from(latestDeploymentEntity)).willReturn(deployment);
    given(commandExecutor.execute(any())).willReturn(findProcessDefinitionResult).willReturn(latestDeploymentEntity);
    given(securityPoliciesManager.canRead(processDefinitionKey)).willReturn(false);
    Throwable exception = catchThrowable(() -> processRuntime.processDefinition(processDefinitionId));
    assertThat(exception).isInstanceOf(ActivitiObjectNotFoundException.class).hasMessage("Unable to find process definition for the given id:'processDefinitionId'");
}
Also used : ProcessDefinitionEntityImpl(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityImpl) Deployment(org.activiti.engine.repository.Deployment) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) DeploymentImpl(org.activiti.api.runtime.model.impl.DeploymentImpl) DeploymentEntityImpl(org.activiti.engine.impl.persistence.entity.DeploymentEntityImpl) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessDefinitionEntityImpl (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityImpl)4 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)3 Test (org.junit.jupiter.api.Test)3 DeploymentImpl (org.activiti.api.runtime.model.impl.DeploymentImpl)2 DeploymentEntityImpl (org.activiti.engine.impl.persistence.entity.DeploymentEntityImpl)2 Deployment (org.activiti.engine.repository.Deployment)2 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)2 UnprocessableEntityException (org.activiti.api.runtime.shared.UnprocessableEntityException)1 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 Test (org.junit.Test)1