org.camunda.bpm.engine.RepositoryService Java Examples

The following examples show how to use org.camunda.bpm.engine.RepositoryService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CmmnDeployerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testCmmnDeployment() {
  String deploymentId = processEngine
      .getRepositoryService()
      .createDeployment()
      .addClasspathResource("org/camunda/bpm/engine/test/cmmn/deployment/CmmnDeploymentTest.testSimpleDeployment.cmmn")
      .deploy()
      .getId();

  // there should be one deployment
  RepositoryService repositoryService = processEngine.getRepositoryService();
  DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery();

  assertEquals(1, deploymentQuery.count());

  // there should be one case definition
  CaseDefinitionQuery query = processEngine.getRepositoryService().createCaseDefinitionQuery();
  assertEquals(1, query.count());

  CaseDefinition caseDefinition = query.singleResult();
  assertEquals("Case_1", caseDefinition.getKey());

  processEngine.getRepositoryService().deleteDeployment(deploymentId);
}
 
Example #2
Source File: TestWarDeploymentDeployChangedOnly.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@OperateOnDeployment(value=PA2)
public void testDeployProcessArchive() {
  Assert.assertNotNull(processEngine);
  RepositoryService repositoryService = processEngine.getRepositoryService();
  long count = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("testDeployProcessArchive")
    .count();

  Assert.assertEquals(2, count);

  count = repositoryService.createProcessDefinitionQuery()
      .processDefinitionKey("testDeployProcessArchiveUnchanged")
      .count();

  Assert.assertEquals(1, count);
}
 
Example #3
Source File: PathCoverageExecutionListener.java    From camunda-bpm-process-test-coverage with Apache License 2.0 6 votes vote down vote up
/**
 * Events aren't reported like SequenceFlows and Activities, so we need
 * special handling. If a sequence flow has an event as the source or the
 * target, we add it to the coverage. It's pretty straight forward if a
 * sequence flow is active, then it's source has been covered anyway and it
 * will most definitely arrive at its target.
 * 
 * @param transitionId
 * @param processDefinition
 * @param repositoryService
 */
private void handleEvent(String transitionId, ProcessDefinition processDefinition,
        RepositoryService repositoryService) {

    final BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinition.getId());

    final ModelElementInstance modelElement = modelInstance.getModelElementById(transitionId);
    if (modelElement.getElementType().getInstanceType() == SequenceFlow.class) {

        final SequenceFlow sequenceFlow = (SequenceFlow) modelElement;

        // If there is an event at the sequence flow source add it to the
        // coverage
        final FlowNode source = sequenceFlow.getSource();
        addEventToCoverage(processDefinition, source);

        // If there is an event at the sequence flow target add it to the
        // coverage
        final FlowNode target = sequenceFlow.getTarget();
        addEventToCoverage(processDefinition, target);

    }

}
 
Example #4
Source File: TestAdditionalResourceSuffixes.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeployProcessArchive() {
  assertNotNull(processEngine);
  RepositoryService repositoryService = processEngine.getRepositoryService();

  ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("invoice-it");

  assertEquals(1, processDefinitionQuery.count());
  ProcessDefinition processDefinition = processDefinitionQuery.singleResult();

  String deploymentId = repositoryService.createDeploymentQuery()
    .deploymentId(processDefinition.getDeploymentId())
    .singleResult()
    .getId();
  List<Resource> deploymentResources = repositoryService.getDeploymentResources(deploymentId);
  assertEquals(3, deploymentResources.size());
}
 
Example #5
Source File: PathCoverageExecutionListener.java    From camunda-bpm-process-test-coverage with Apache License 2.0 6 votes vote down vote up
@Override
public void notify(DelegateExecution execution) throws Exception {

    if (coverageTestRunState == null) {
        logger.warning("Coverage execution listener in use but no coverage run state assigned!");
        return;
    }

    final RepositoryService repositoryService = execution.getProcessEngineServices().getRepositoryService();

    // Get the process definition in order to obtain the key
    final ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(
            execution.getProcessDefinitionId()).singleResult();

    final String transitionId = execution.getCurrentTransitionId();

    // Record sequence flow coverage
    final CoveredSequenceFlow coveredSequenceFlow = new CoveredSequenceFlow(processDefinition.getKey(),
            transitionId);
    coverageTestRunState.addCoveredElement(coveredSequenceFlow);

    // Record possible event coverage
    handleEvent(transitionId, processDefinition, repositoryService);

}
 
Example #6
Source File: CaseDefinitionRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
private void setUpRuntimeData(CaseDefinition mockCaseDefinition) {
  repositoryServiceMock = mock(RepositoryService.class);

  when(processEngine.getRepositoryService()).thenReturn(repositoryServiceMock);
  when(repositoryServiceMock.getCaseDefinition(eq(MockProvider.EXAMPLE_CASE_DEFINITION_ID))).thenReturn(mockCaseDefinition);
  when(repositoryServiceMock.getCaseModel(eq(MockProvider.EXAMPLE_CASE_DEFINITION_ID))).thenReturn(createMockCaseDefinitionCmmnXml());

  caseDefinitionQueryMock = mock(CaseDefinitionQuery.class);
  when(caseDefinitionQueryMock.caseDefinitionKey(MockProvider.EXAMPLE_CASE_DEFINITION_KEY)).thenReturn(caseDefinitionQueryMock);
  when(caseDefinitionQueryMock.tenantIdIn(anyString())).thenReturn(caseDefinitionQueryMock);
  when(caseDefinitionQueryMock.withoutTenantId()).thenReturn(caseDefinitionQueryMock);
  when(caseDefinitionQueryMock.latestVersion()).thenReturn(caseDefinitionQueryMock);
  when(caseDefinitionQueryMock.singleResult()).thenReturn(mockCaseDefinition);
  when(caseDefinitionQueryMock.list()).thenReturn(Collections.singletonList(mockCaseDefinition));
  when(repositoryServiceMock.createCaseDefinitionQuery()).thenReturn(caseDefinitionQueryMock);
}
 
Example #7
Source File: SelectorBuilderTest.java    From camunda-bpm-reactor with Apache License 2.0 6 votes vote down vote up
@Test
public void creates_key_for_task() {
  ProcessDefinition processDefinition = CamundaReactorTestHelper.processDefinition();
  final DelegateTask task = mock(DelegateTask.class, RETURNS_DEEP_STUBS);

  RepositoryService repositoryService = mock(RepositoryService.class);
  when(repositoryService.getProcessDefinition(processDefinition.getId())).thenReturn(processDefinition);
  when(task.getProcessEngineServices().getRepositoryService()).thenReturn(repositoryService);

  when(task.getBpmnModelElementInstance().getElementType().getTypeName()).thenReturn("userTask");
  when(task.getProcessDefinitionId()).thenReturn("process:1:1");

  when(task.getEventName()).thenReturn("create");
  when(task.getTaskDefinitionKey()).thenReturn("task1");

  assertThat(SelectorBuilder.selector(task).key()).isEqualTo("/camunda/task/{type}/process/task1/create");
}
 
Example #8
Source File: InvoiceProcessApplication.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void createDeployment(String processArchiveName, DeploymentBuilder deploymentBuilder) {
  ProcessEngine processEngine = BpmPlatform.getProcessEngineService().getProcessEngine("default");

  // Hack: deploy the first version of the invoice process once before the process application
  //   is deployed the first time
  if (processEngine != null) {

    RepositoryService repositoryService = processEngine.getRepositoryService();

    if (!isProcessDeployed(repositoryService, "invoice")) {
      ClassLoader classLoader = getProcessApplicationClassloader();

      repositoryService.createDeployment(this.getReference())
        .addInputStream("invoice.v1.bpmn", classLoader.getResourceAsStream("invoice.v1.bpmn"))
        .addInputStream("invoiceBusinessDecisions.dmn", classLoader.getResourceAsStream("invoiceBusinessDecisions.dmn"))
        .addInputStream("reviewInvoice.bpmn", classLoader.getResourceAsStream("reviewInvoice.bpmn"))
        .deploy();
    }
  }
}
 
Example #9
Source File: AbstractAuthenticationFilterTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
  authorizationServiceMock = mock(AuthorizationServiceImpl.class);
  identityServiceMock = mock(IdentityServiceImpl.class);
  repositoryServiceMock = mock(RepositoryService.class);

  when(processEngine.getAuthorizationService()).thenReturn(authorizationServiceMock);
  when(processEngine.getIdentityService()).thenReturn(identityServiceMock);
  when(processEngine.getRepositoryService()).thenReturn(repositoryServiceMock);

  // for authentication
  userMock = MockProvider.createMockUser();

  List<Group> groupMocks = MockProvider.createMockGroups();
  groupIds = setupGroupQueryMock(groupMocks);

  List<Tenant> tenantMocks = Collections.singletonList(MockProvider.createMockTenant());
  tenantIds = setupTenantQueryMock(tenantMocks);

  // example method
  ProcessDefinition mockDefinition = MockProvider.createMockDefinition();
  List<ProcessDefinition> mockDefinitions = Arrays.asList(mockDefinition);
  ProcessDefinitionQuery mockQuery = mock(ProcessDefinitionQuery.class);
  when(repositoryServiceMock.createProcessDefinitionQuery()).thenReturn(mockQuery);
  when(mockQuery.list()).thenReturn(mockDefinitions);
}
 
Example #10
Source File: MockedProcessEngineProvider.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
private void mockServices(ProcessEngine engine) {
  RepositoryService repoService = mock(RepositoryService.class);
  IdentityService identityService = mock(IdentityService.class);
  TaskService taskService = mock(TaskService.class);
  RuntimeService runtimeService = mock(RuntimeService.class);
  FormService formService = mock(FormService.class);
  HistoryService historyService = mock(HistoryService.class);
  ManagementService managementService = mock(ManagementService.class);
  CaseService caseService = mock(CaseService.class);
  FilterService filterService = mock(FilterService.class);
  ExternalTaskService externalTaskService = mock(ExternalTaskService.class);

  when(engine.getRepositoryService()).thenReturn(repoService);
  when(engine.getIdentityService()).thenReturn(identityService);
  when(engine.getTaskService()).thenReturn(taskService);
  when(engine.getRuntimeService()).thenReturn(runtimeService);
  when(engine.getFormService()).thenReturn(formService);
  when(engine.getHistoryService()).thenReturn(historyService);
  when(engine.getManagementService()).thenReturn(managementService);
  when(engine.getCaseService()).thenReturn(caseService);
  when(engine.getFilterService()).thenReturn(filterService);
  when(engine.getExternalTaskService()).thenReturn(externalTaskService);
}
 
Example #11
Source File: DecisionDefinitionRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
private void setUpRuntimeData(DecisionDefinition mockDecisionDefinition) {
  repositoryServiceMock = mock(RepositoryService.class);

  when(processEngine.getRepositoryService()).thenReturn(repositoryServiceMock);
  when(repositoryServiceMock.getDecisionDefinition(eq(MockProvider.EXAMPLE_DECISION_DEFINITION_ID))).thenReturn(mockDecisionDefinition);
  when(repositoryServiceMock.getDecisionModel(eq(MockProvider.EXAMPLE_DECISION_DEFINITION_ID))).thenReturn(createMockDecisionDefinitionDmnXml());

  decisionDefinitionQueryMock = mock(DecisionDefinitionQuery.class);
  when(decisionDefinitionQueryMock.decisionDefinitionKey(MockProvider.EXAMPLE_DECISION_DEFINITION_KEY)).thenReturn(decisionDefinitionQueryMock);
  when(decisionDefinitionQueryMock.tenantIdIn(anyString())).thenReturn(decisionDefinitionQueryMock);
  when(decisionDefinitionQueryMock.withoutTenantId()).thenReturn(decisionDefinitionQueryMock);
  when(decisionDefinitionQueryMock.latestVersion()).thenReturn(decisionDefinitionQueryMock);
  when(decisionDefinitionQueryMock.singleResult()).thenReturn(mockDecisionDefinition);
  when(decisionDefinitionQueryMock.list()).thenReturn(Collections.singletonList(mockDecisionDefinition));
  when(repositoryServiceMock.createDecisionDefinitionQuery()).thenReturn(decisionDefinitionQueryMock);
}
 
Example #12
Source File: DecisionRequirementsDefinitionRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void setUpRuntimeData(DecisionRequirementsDefinition mockDecisionRequirementsDefinition) throws FileNotFoundException, URISyntaxException {
  repositoryServiceMock = mock(RepositoryService.class);

  when(processEngine.getRepositoryService()).thenReturn(repositoryServiceMock);
  when(repositoryServiceMock.getDecisionRequirementsDefinition(eq(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID))).thenReturn(mockDecisionRequirementsDefinition);
  when(repositoryServiceMock.getDecisionRequirementsModel(eq(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID))).thenReturn(createMockDecisionRequirementsDefinitionDmnXml());
  when(repositoryServiceMock.getDecisionRequirementsDiagram(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID)).thenReturn(createMockDecisionRequirementsDiagram());

  decisionRequirementsDefinitionQueryMock = mock(DecisionRequirementsDefinitionQuery.class);
  when(decisionRequirementsDefinitionQueryMock.decisionRequirementsDefinitionKey(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_KEY)).thenReturn(decisionRequirementsDefinitionQueryMock);
  when(decisionRequirementsDefinitionQueryMock.tenantIdIn(anyString())).thenReturn(decisionRequirementsDefinitionQueryMock);
  when(decisionRequirementsDefinitionQueryMock.withoutTenantId()).thenReturn(decisionRequirementsDefinitionQueryMock);
  when(decisionRequirementsDefinitionQueryMock.latestVersion()).thenReturn(decisionRequirementsDefinitionQueryMock);
  when(decisionRequirementsDefinitionQueryMock.singleResult()).thenReturn(mockDecisionRequirementsDefinition);
  when(decisionRequirementsDefinitionQueryMock.list()).thenReturn(Collections.singletonList(mockDecisionRequirementsDefinition));
  when(repositoryServiceMock.createDecisionRequirementsDefinitionQuery()).thenReturn(decisionRequirementsDefinitionQueryMock);
}
 
Example #13
Source File: DeployCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void scheduleProcessDefinitionActivation(CommandContext commandContext,
    DeploymentWithDefinitions deployment) {

  if (deploymentBuilder.getProcessDefinitionsActivationDate() != null) {
    RepositoryService repositoryService = commandContext.getProcessEngineConfiguration()
        .getRepositoryService();

    for (ProcessDefinition processDefinition: getDeployedProcesses(commandContext, deployment)) {

      // If activation date is set, we first suspend all the process definition
      repositoryService
          .updateProcessDefinitionSuspensionState()
          .byProcessDefinitionId(processDefinition.getId())
          .suspend();

      // And we schedule an activation at the provided date
      repositoryService
          .updateProcessDefinitionSuspensionState()
          .byProcessDefinitionId(processDefinition.getId())
          .executionDate(deploymentBuilder.getProcessDefinitionsActivationDate())
          .activate();
    }
  }
}
 
Example #14
Source File: DeploymentResourceImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected DeploymentWithDefinitions tryToRedeploy(RedeploymentDto redeployment) {
  RepositoryService repositoryService = getProcessEngine().getRepositoryService();

  DeploymentBuilder builder = repositoryService.createDeployment();
  builder.nameFromDeployment(deploymentId);

  String tenantId = getDeployment().getTenantId();
  if (tenantId != null) {
    builder.tenantId(tenantId);
  }

  if (redeployment != null) {
    builder = addRedeploymentResources(builder, redeployment);
  } else {
    builder.addDeploymentResources(deploymentId);
  }

  return builder.deployWithResult();
}
 
Example #15
Source File: RedeploymentRegistrationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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();
    }

  };
}
 
Example #16
Source File: RedeploymentRegistrationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected static TestProvider caseDefinitionTestProvider() {
  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();
          CaseDefinitionEntity definition = deploymentCache.findDeployedCaseDefinitionById(definitionId);
          return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
        }
      };
    }

    @Override
    public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
      return repositoryService.createCaseDefinitionQuery().caseDefinitionKey(key).latestVersion().singleResult().getId();
    }

  };
}
 
Example #17
Source File: RedeploymentRegistrationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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();
    }

  };
}
 
Example #18
Source File: RedeploymentRegistrationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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();
    }

  };
}
 
Example #19
Source File: TestWarDeploymentDeployAllOnSingleChange.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@OperateOnDeployment(value=PA2)
public void testDeployProcessArchive() {
  Assert.assertNotNull(processEngine);
  RepositoryService repositoryService = processEngine.getRepositoryService();
  long count = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("testDeployProcessArchive")
    .count();

  Assert.assertEquals(2, count);

  count = repositoryService.createProcessDefinitionQuery()
      .processDefinitionKey("testDeployProcessArchiveUnchanged")
      .count();

  Assert.assertEquals(2, count);
}
 
Example #20
Source File: MockedProcessEngineProvider.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
private void mockServices(ProcessEngine engine) {
  RepositoryService repoService = mock(RepositoryService.class);
  IdentityService identityService = mock(IdentityService.class);
  TaskService taskService = mock(TaskService.class);
  RuntimeService runtimeService = mock(RuntimeService.class);
  FormService formService = mock(FormService.class);
  HistoryService historyService = mock(HistoryService.class);
  ManagementService managementService = mock(ManagementService.class);
  CaseService caseService = mock(CaseService.class);
  FilterService filterService = mock(FilterService.class);
  ExternalTaskService externalTaskService = mock(ExternalTaskService.class);

  when(engine.getRepositoryService()).thenReturn(repoService);
  when(engine.getIdentityService()).thenReturn(identityService);
  when(engine.getTaskService()).thenReturn(taskService);
  when(engine.getRuntimeService()).thenReturn(runtimeService);
  when(engine.getFormService()).thenReturn(formService);
  when(engine.getHistoryService()).thenReturn(historyService);
  when(engine.getManagementService()).thenReturn(managementService);
  when(engine.getCaseService()).thenReturn(caseService);
  when(engine.getFilterService()).thenReturn(filterService);
  when(engine.getExternalTaskService()).thenReturn(externalTaskService);
}
 
Example #21
Source File: TestWarDeploymentResumePreviousOff.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@OperateOnDeployment(value=PA2)
public void testDeployProcessArchive() {
  Assert.assertNotNull(processEngine);
  RepositoryService repositoryService = processEngine.getRepositoryService();
  long count = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("testDeployProcessArchive")
    .count();

  Assert.assertEquals(2, count);

  // validate registrations:
  ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
  Set<String> processApplicationNames = processApplicationService.getProcessApplicationNames();
  for (String paName : processApplicationNames) {
    ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(paName);
    List<ProcessApplicationDeploymentInfo> deploymentInfo = processApplicationInfo.getDeploymentInfo();
    if(deploymentInfo.size() == 2) {
      Assert.fail("Previous version of the deployment must not be resumed");
    }
  }

}
 
Example #22
Source File: TestWarDeploymentIsDeployChangedOnly.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
@OperateOnDeployment(value=PA2)
public void testDeployProcessArchive() {
  Assert.assertNotNull(processEngine);
  RepositoryService repositoryService = processEngine.getRepositoryService();
  long count = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("testDeployProcessArchive")
    .count();

  Assert.assertEquals(1, count);

  // validate registrations:
  ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
  Set<String> processApplicationNames = processApplicationService.getProcessApplicationNames();
  boolean resumedRegistrationFound = false;
  for (String paName : processApplicationNames) {
    ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(paName);
    List<ProcessApplicationDeploymentInfo> deploymentInfo = processApplicationInfo.getDeploymentInfo();
    if(deploymentInfo.size() == 2) {
      if(resumedRegistrationFound) {
        Assert.fail("Cannot have two registrations");
      }
      resumedRegistrationFound = true;
    }
  }
  Assert.assertTrue("Previous version of the deployment was not resumed", resumedRegistrationFound);

}
 
Example #23
Source File: DeploymentResourceImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public DeploymentDto getDeployment() {
  RepositoryService repositoryService = getProcessEngine().getRepositoryService();
  Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();

  if (deployment == null) {
    throw new InvalidRequestException(Status.NOT_FOUND, "Deployment with id '" + deploymentId + "' does not exist");
  }

  return DeploymentDto.fromDeployment(deployment);
}
 
Example #24
Source File: SpringTransactionsProcessEngineConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void autoDeployResources(ProcessEngine processEngine) {
  if (deploymentResources!=null && deploymentResources.length>0) {
    RepositoryService repositoryService = processEngine.getRepositoryService();

    DeploymentBuilder deploymentBuilder = repositoryService
      .createDeployment()
      .enableDuplicateFiltering(deployChangedOnly)
      .name(deploymentName)
      .tenantId(deploymentTenantId);

    for (Resource resource : deploymentResources) {
      String resourceName = null;

      if (resource instanceof ContextResource) {
        resourceName = ((ContextResource) resource).getPathWithinContext();

      } else if (resource instanceof ByteArrayResource) {
        resourceName = resource.getDescription();

      } else {
        resourceName = getFileResourceName(resource);
      }

      try {
        if ( resourceName.endsWith(".bar")
             || resourceName.endsWith(".zip")
             || resourceName.endsWith(".jar") ) {
          deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream()));
        } else {
          deploymentBuilder.addInputStream(resourceName, resource.getInputStream());
        }
      } catch (IOException e) {
        throw new ProcessEngineException("couldn't auto deploy resource '"+resource+"': "+e.getMessage(), e);
      }
    }

    deploymentBuilder.deploy();
  }
}
 
Example #25
Source File: TestResourceName.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testResourceName() {
  ProcessEngine processEngine = ProgrammaticBeanLookup.lookup(ProcessEngine.class);
  Assert.assertNotNull(processEngine);

  RepositoryService repositoryService = processEngine.getRepositoryService();

  ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();

  ProcessDefinition definition = query.processDefinitionKey("process-0").singleResult();
  Assert.assertEquals("process0.bpmn", definition.getResourceName());

  definition = query.processDefinitionKey("process-1").singleResult();
  Assert.assertEquals("processes/process1.bpmn", definition.getResourceName());

  definition = query.processDefinitionKey("process-2").singleResult();
  Assert.assertEquals("process2.bpmn", definition.getResourceName());

  definition = query.processDefinitionKey("process-3").singleResult();
  Assert.assertEquals("subDirectory/process3.bpmn", definition.getResourceName());

  definition = query.processDefinitionKey("process-4").singleResult();
  Assert.assertEquals("process4.bpmn", definition.getResourceName());

  definition = query.processDefinitionKey("process-5").singleResult();
  Assert.assertEquals("subDirectory/process5.bpmn", definition.getResourceName());
}
 
Example #26
Source File: HalProcessDefinitionResolver.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) {
  RepositoryService repositoryService = processEngine.getRepositoryService();

  List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
    .processDefinitionIdIn(linkedIds)
    .listPage(0, linkedIds.length);

  List<HalResource<?>> resolved = new ArrayList<HalResource<?>>();
  for (ProcessDefinition procDef : processDefinitions) {
    resolved.add(HalProcessDefinition.fromProcessDefinition(procDef, processEngine));
  }

  return resolved;
}
 
Example #27
Source File: TestWarDeployment.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeployProcessArchive() {
  Assert.assertNotNull(processEngine);
  RepositoryService repositoryService = processEngine.getRepositoryService();
  long count = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("testDeployProcessArchive")
    .count();

  Assert.assertEquals(1, count);
}
 
Example #28
Source File: TestFoxPlatformClientAsLibInWebModule.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeployProcessArchive() {
  ProcessEngine processEngine = ProgrammaticBeanLookup.lookup(ProcessEngine.class);
  Assert.assertNotNull(processEngine);
  RepositoryService repositoryService = processEngine.getRepositoryService();
  long count = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("testDeployProcessArchive")
    .count();
  
  Assert.assertEquals(1, count);
}
 
Example #29
Source File: ProcessDefinitionResourceImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessDefinitionDto getProcessDefinition() {
  RepositoryService repoService = engine.getRepositoryService();

  ProcessDefinition definition;
  try {
    definition = repoService.getProcessDefinition(processDefinitionId);
  } catch (ProcessEngineException e) {
    throw new InvalidRequestException(Status.NOT_FOUND, e, "No matching definition with id " + processDefinitionId);
  }

  ProcessDefinitionDto result = ProcessDefinitionDto.fromProcessDefinition(definition);

  return result;
}
 
Example #30
Source File: HalCaseDefinitionResolver.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) {
  RepositoryService repositoryService = processEngine.getRepositoryService();

  List<CaseDefinition> caseDefinitions = repositoryService.createCaseDefinitionQuery()
    .caseDefinitionIdIn(linkedIds)
    .listPage(0, linkedIds.length);

  List<HalResource<?>> resolved = new ArrayList<HalResource<?>>();
  for (CaseDefinition caseDefinition : caseDefinitions) {
    resolved.add(HalCaseDefinition.fromCaseDefinition(caseDefinition, processEngine));
  }

  return resolved;
}