Search in sources :

Example 51 with RepositoryService

use of org.camunda.bpm.engine.RepositoryService in project camunda-bpm-platform by camunda.

the class TestHelper method assertDiagramIsDeployed.

public static void assertDiagramIsDeployed(boolean deployed, Class<?> clazz, String expectedDiagramResource, String processDefinitionKey) throws IOException {
    ProcessEngine processEngine = ProgrammaticBeanLookup.lookup(ProcessEngine.class);
    Assert.assertNotNull(processEngine);
    RepositoryService repositoryService = processEngine.getRepositoryService();
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey).singleResult();
    assertNotNull(processDefinition);
    InputStream actualStream = null;
    InputStream expectedStream = null;
    try {
        actualStream = repositoryService.getProcessDiagram(processDefinition.getId());
        if (deployed) {
            byte[] actualDiagram = IoUtil.readInputStream(actualStream, "actualStream");
            assertNotNull(actualDiagram);
            assertTrue(actualDiagram.length > 0);
            expectedStream = clazz.getResourceAsStream(expectedDiagramResource);
            byte[] expectedDiagram = IoUtil.readInputStream(expectedStream, "expectedSteam");
            assertNotNull(expectedDiagram);
            assertTrue(isEqual(expectedStream, actualStream));
        } else {
            assertNull(actualStream);
        }
    } finally {
        IoUtil.closeSilently(actualStream);
        IoUtil.closeSilently(expectedStream);
    }
}
Also used : InputStream(java.io.InputStream) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 52 with RepositoryService

use of org.camunda.bpm.engine.RepositoryService in project camunda-bpm-platform by camunda.

the class RedeploymentRegistrationTest method decisionRequirementsDefinitionTestProvider.

protected static TestProvider decisionRequirementsDefinitionTestProvider() {
    return new TestProvider() {

        @Override
        public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
            return new Command<ProcessApplicationReference>() {

                public ProcessApplicationReference execute(CommandContext commandContext) {
                    ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
                    DeploymentCache deploymentCache = configuration.getDeploymentCache();
                    DecisionRequirementsDefinitionEntity definition = deploymentCache.findDeployedDecisionRequirementsDefinitionById(definitionId);
                    return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
                }
            };
        }

        @Override
        public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
            return repositoryService.createDecisionRequirementsDefinitionQuery().decisionRequirementsDefinitionKey(key).latestVersion().singleResult().getId();
        }
    };
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Command(org.camunda.bpm.engine.impl.interceptor.Command) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) DecisionRequirementsDefinitionEntity(org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionRequirementsDefinitionEntity) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 53 with RepositoryService

use of org.camunda.bpm.engine.RepositoryService in project camunda-bpm-platform by camunda.

the class RedeploymentRegistrationTest method processDefinitionTestProvider.

protected static TestProvider processDefinitionTestProvider() {
    return new TestProvider() {

        @Override
        public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
            return new Command<ProcessApplicationReference>() {

                public ProcessApplicationReference execute(CommandContext commandContext) {
                    ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
                    DeploymentCache deploymentCache = configuration.getDeploymentCache();
                    ProcessDefinitionEntity definition = deploymentCache.findDeployedProcessDefinitionById(definitionId);
                    return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
                }
            };
        }

        @Override
        public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
            return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).latestVersion().singleResult().getId();
        }
    };
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Command(org.camunda.bpm.engine.impl.interceptor.Command) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 54 with RepositoryService

use of org.camunda.bpm.engine.RepositoryService in project camunda-bpm-platform by camunda.

the class RedeploymentRegistrationTest method decisionDefinitionTestProvider.

protected static TestProvider decisionDefinitionTestProvider() {
    return new TestProvider() {

        @Override
        public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
            return new Command<ProcessApplicationReference>() {

                public ProcessApplicationReference execute(CommandContext commandContext) {
                    ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
                    DeploymentCache deploymentCache = configuration.getDeploymentCache();
                    DecisionDefinitionEntity definition = deploymentCache.findDeployedDecisionDefinitionById(definitionId);
                    return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
                }
            };
        }

        @Override
        public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
            return repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(key).latestVersion().singleResult().getId();
        }
    };
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Command(org.camunda.bpm.engine.impl.interceptor.Command) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) DecisionDefinitionEntity(org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 55 with RepositoryService

use of org.camunda.bpm.engine.RepositoryService in project camunda-bpm-platform by camunda.

the class MigrateProcessInstanceDelegate method execute.

public void execute(DelegateExecution execution) throws Exception {
    RepositoryService repoService = execution.getProcessEngineServices().getRepositoryService();
    ProcessDefinition targetDefinition = repoService.createProcessDefinitionQuery().latestVersion().singleResult();
    SetProcessDefinitionVersionCmd migrationCommand = new SetProcessDefinitionVersionCmd(execution.getProcessInstanceId(), targetDefinition.getVersion());
    Context.getProcessEngineConfiguration().getCommandExecutorTxRequired().execute(migrationCommand);
}
Also used : SetProcessDefinitionVersionCmd(org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Aggregations

RepositoryService (org.camunda.bpm.engine.RepositoryService)57 Test (org.junit.Test)24 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)23 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)13 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)10 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)9 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)8 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)6 ProcessApplicationService (org.camunda.bpm.ProcessApplicationService)5 ProcessApplicationDeploymentInfo (org.camunda.bpm.application.ProcessApplicationDeploymentInfo)5 ProcessApplicationInfo (org.camunda.bpm.application.ProcessApplicationInfo)5 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)5 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)4 RuntimeService (org.camunda.bpm.engine.RuntimeService)4 Deployment (org.camunda.bpm.engine.repository.Deployment)4 ProcessDefinitionQuery (org.camunda.bpm.engine.repository.ProcessDefinitionQuery)4 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)3 NotValidException (org.camunda.bpm.engine.exception.NotValidException)3