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);
}
}
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();
}
};
}
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();
}
};
}
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();
}
};
}
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);
}
Aggregations