Search in sources :

Example 1 with DeploymentBuilder

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

the class DeploymentResourceImpl method tryToRedeploy.

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();
}
Also used : DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 2 with DeploymentBuilder

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

the class TestHelper method annotationDeploymentSetUp.

public static String annotationDeploymentSetUp(ProcessEngine processEngine, Class<?> testClass, String methodName, Deployment deploymentAnnotation) {
    String deploymentId = null;
    Method method = null;
    boolean onMethod = true;
    try {
        method = getMethod(testClass, methodName);
    } catch (Exception e) {
        if (deploymentAnnotation == null) {
            // we have neither the annotation, nor can look it up from the method
            return null;
        }
    }
    if (deploymentAnnotation == null) {
        deploymentAnnotation = method.getAnnotation(Deployment.class);
    }
    // if not found on method, try on class level
    if (deploymentAnnotation == null) {
        onMethod = false;
        Class<?> lookForAnnotationClass = testClass;
        while (lookForAnnotationClass != Object.class) {
            deploymentAnnotation = lookForAnnotationClass.getAnnotation(Deployment.class);
            if (deploymentAnnotation != null) {
                testClass = lookForAnnotationClass;
                break;
            }
            lookForAnnotationClass = lookForAnnotationClass.getSuperclass();
        }
    }
    if (deploymentAnnotation != null) {
        LOG.debug("annotation @Deployment creates deployment for {}.{}", ClassNameUtil.getClassNameWithoutPackage(testClass), methodName);
        String[] resources = deploymentAnnotation.resources();
        if (resources.length == 0 && method != null) {
            String name = onMethod ? method.getName() : null;
            String resource = getBpmnProcessDefinitionResource(testClass, name);
            resources = new String[] { resource };
        }
        DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment().name(ClassNameUtil.getClassNameWithoutPackage(testClass) + "." + methodName);
        for (String resource : resources) {
            deploymentBuilder.addClasspathResource(resource);
        }
        deploymentId = deploymentBuilder.deploy().getId();
    }
    return deploymentId;
}
Also used : Deployment(org.camunda.bpm.engine.test.Deployment) Method(java.lang.reflect.Method) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder)

Example 3 with DeploymentBuilder

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

the class HistoricExternalTaskLogAuthorizationTest method setUp.

@Override
public void setUp() throws Exception {
    DeploymentBuilder deploymentbuilder = repositoryService.createDeployment();
    BpmnModelInstance defaultModel = createDefaultExternalTaskModel().build();
    BpmnModelInstance modifiedModel = createDefaultExternalTaskModel().processKey(ANOTHER_PROCESS_KEY).build();
    deploymentId = deployment(deploymentbuilder, defaultModel, modifiedModel);
    super.setUp();
}
Also used : BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder)

Example 4 with DeploymentBuilder

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

the class ProcessDefinitionCandidateTest method shouldPropagateTenantIdToCandidateStarterGroups.

@Test
public void shouldPropagateTenantIdToCandidateStarterGroups() {
    // when
    DeploymentBuilder builder = repositoryService.createDeployment().addClasspathResource(CANDIDATE_STARTER_GROUPS).tenantId(TENANT_ONE);
    testRule.deploy(builder);
    // then
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());
    assertEquals(3, links.size());
    for (IdentityLink link : links) {
        assertNotNull(link.getTenantId());
        assertEquals(TENANT_ONE, link.getTenantId());
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) IdentityLink(org.camunda.bpm.engine.task.IdentityLink) DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder) Test(org.junit.Test)

Example 5 with DeploymentBuilder

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

the class ProcessDefinitionCandidateTest method shouldPropagateTenantIdToCandidateStarterUsers.

@Test
public void shouldPropagateTenantIdToCandidateStarterUsers() {
    // when
    DeploymentBuilder builder = repositoryService.createDeployment().addClasspathResource(CANDIDATE_STARTER_USERS).tenantId(TENANT_ONE);
    testRule.deploy(builder);
    // then
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());
    assertEquals(3, links.size());
    for (IdentityLink link : links) {
        assertNotNull(link.getTenantId());
        assertEquals(TENANT_ONE, link.getTenantId());
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) IdentityLink(org.camunda.bpm.engine.task.IdentityLink) DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder) Test(org.junit.Test)

Aggregations

DeploymentBuilder (org.camunda.bpm.engine.repository.DeploymentBuilder)26 Test (org.junit.Test)14 Deployment (org.camunda.bpm.engine.repository.Deployment)11 InputStream (java.io.InputStream)10 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)10 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)8 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 IdentityLink (org.camunda.bpm.engine.task.IdentityLink)4 IOException (java.io.IOException)3 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)2 RepositoryService (org.camunda.bpm.engine.RepositoryService)2 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)2 NotValidException (org.camunda.bpm.engine.exception.NotValidException)2 Method (java.lang.reflect.Method)1 ZipInputStream (java.util.zip.ZipInputStream)1 Deployment (org.camunda.bpm.engine.test.Deployment)1 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)1 ByteArrayResource (org.springframework.core.io.ByteArrayResource)1 ContextResource (org.springframework.core.io.ContextResource)1