Search in sources :

Example 6 with Resource

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

the class RedeploymentTest method testRedeployProcessApplicationDeploymentResumePreviousVersions.

public void testRedeployProcessApplicationDeploymentResumePreviousVersions() {
    // given
    EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication();
    // first deployment
    BpmnModelInstance model = createProcessWithServiceTask(PROCESS_KEY);
    ProcessApplicationDeployment deployment1 = repositoryService.createDeployment(processApplication.getReference()).name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_NAME, model).enableDuplicateFiltering(true).deploy();
    Resource resource1 = getResourceByName(deployment1.getId(), RESOURCE_NAME);
    // second deployment
    model = createProcessWithUserTask(PROCESS_KEY);
    ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.getReference()).name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_NAME, model).enableDuplicateFiltering(true).deploy();
    // when
    ProcessApplicationDeployment deployment3 = repositoryService.createDeployment(processApplication.getReference()).name(DEPLOYMENT_NAME).resumePreviousVersions().addDeploymentResourceById(deployment1.getId(), resource1.getId()).deploy();
    // then
    // old deployments was resumed
    ProcessApplicationRegistration registration = deployment3.getProcessApplicationRegistration();
    Set<String> deploymentIds = registration.getDeploymentIds();
    assertEquals(3, deploymentIds.size());
    deleteDeployments(deployment1, deployment2, deployment3);
}
Also used : ProcessApplicationRegistration(org.camunda.bpm.application.ProcessApplicationRegistration) ProcessApplicationDeployment(org.camunda.bpm.engine.repository.ProcessApplicationDeployment) EmbeddedProcessApplication(org.camunda.bpm.application.impl.EmbeddedProcessApplication) Resource(org.camunda.bpm.engine.repository.Resource) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 7 with Resource

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

the class RedeploymentTest method testRedeployDeploymentResourceByIdAndNameMultiple.

public void testRedeployDeploymentResourceByIdAndNameMultiple() {
    // given
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
    BpmnModelInstance model1 = createProcessWithServiceTask(PROCESS_1_KEY);
    BpmnModelInstance model2 = createProcessWithUserTask(PROCESS_2_KEY);
    // first deployment
    Deployment deployment1 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_1_NAME, model1).addModelInstance(RESOURCE_2_NAME, model2).deploy();
    verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1);
    verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 1);
    Resource resource1 = getResourceByName(deployment1.getId(), RESOURCE_1_NAME);
    Resource resource2 = getResourceByName(deployment1.getId(), RESOURCE_2_NAME);
    // second deployment
    model1 = createProcessWithScriptTask(PROCESS_1_KEY);
    model2 = createProcessWithReceiveTask(PROCESS_2_KEY);
    Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_1_NAME, model1).addModelInstance(RESOURCE_2_NAME, model2).deploy();
    verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 2);
    verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 2);
    // when
    Deployment deployment3 = repositoryService.createDeployment().addDeploymentResourcesById(deployment1.getId(), Arrays.asList(resource1.getId())).addDeploymentResourcesByName(deployment1.getId(), Arrays.asList(resource2.getName())).deploy();
    // then
    verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 3);
    verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 3);
    deleteDeployments(deployment1, deployment2, deployment3);
}
Also used : Resource(org.camunda.bpm.engine.repository.Resource) ProcessApplicationDeployment(org.camunda.bpm.engine.repository.ProcessApplicationDeployment) Deployment(org.camunda.bpm.engine.repository.Deployment) ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 8 with Resource

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

the class RedeploymentTest method testRedeployDeploymentResource.

public void testRedeployDeploymentResource() {
    // given
    // first deployment
    BpmnModelInstance model = createProcessWithServiceTask(PROCESS_KEY);
    Deployment deployment1 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_NAME, model).deploy();
    Resource resource1 = getResourceByName(deployment1.getId(), RESOURCE_NAME);
    // second deployment
    model = createProcessWithUserTask(PROCESS_KEY);
    Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_NAME, model).deploy();
    Resource resource2 = getResourceByName(deployment2.getId(), RESOURCE_NAME);
    // when
    Deployment deployment3 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addDeploymentResources(deployment1.getId()).deploy();
    // then
    Resource resource3 = getResourceByName(deployment3.getId(), RESOURCE_NAME);
    assertNotNull(resource3);
    // id
    assertNotNull(resource3.getId());
    assertFalse(resource1.getId().equals(resource3.getId()));
    // deployment id
    assertEquals(deployment3.getId(), resource3.getDeploymentId());
    // name
    assertEquals(resource1.getName(), resource3.getName());
    // bytes
    byte[] bytes1 = ((ResourceEntity) resource1).getBytes();
    byte[] bytes2 = ((ResourceEntity) resource2).getBytes();
    byte[] bytes3 = ((ResourceEntity) resource3).getBytes();
    assertTrue(Arrays.equals(bytes1, bytes3));
    assertFalse(Arrays.equals(bytes2, bytes3));
    deleteDeployments(deployment1, deployment2, deployment3);
}
Also used : Resource(org.camunda.bpm.engine.repository.Resource) ResourceEntity(org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity) ProcessApplicationDeployment(org.camunda.bpm.engine.repository.ProcessApplicationDeployment) Deployment(org.camunda.bpm.engine.repository.Deployment) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 9 with Resource

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

the class MultiTenancyDeploymentCmdsTenantCheckTest method getResourceAsStreamByIdWithAuthenticatedTenant.

@Test
public void getResourceAsStreamByIdWithAuthenticatedTenant() {
    Deployment deployment = testRule.deployForTenant(TENANT_ONE, emptyProcess);
    Resource resource = repositoryService.getDeploymentResources(deployment.getId()).get(0);
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    InputStream inputStream = repositoryService.getResourceAsStreamById(deployment.getId(), resource.getId());
    assertThat(inputStream, notNullValue());
}
Also used : InputStream(java.io.InputStream) Resource(org.camunda.bpm.engine.repository.Resource) Deployment(org.camunda.bpm.engine.repository.Deployment) Test(org.junit.Test)

Example 10 with Resource

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

the class MultiTenancyDeploymentCmdsTenantCheckTest method getResourceAsStreamWithAuthenticatedTenant.

@Test
public void getResourceAsStreamWithAuthenticatedTenant() {
    Deployment deployment = testRule.deployForTenant(TENANT_ONE, emptyProcess);
    Resource resource = repositoryService.getDeploymentResources(deployment.getId()).get(0);
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    InputStream inputStream = repositoryService.getResourceAsStream(deployment.getId(), resource.getName());
    assertThat(inputStream, notNullValue());
}
Also used : InputStream(java.io.InputStream) Resource(org.camunda.bpm.engine.repository.Resource) Deployment(org.camunda.bpm.engine.repository.Deployment) Test(org.junit.Test)

Aggregations

Resource (org.camunda.bpm.engine.repository.Resource)27 Deployment (org.camunda.bpm.engine.repository.Deployment)19 ProcessApplicationDeployment (org.camunda.bpm.engine.repository.ProcessApplicationDeployment)14 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)12 ProcessDefinitionQuery (org.camunda.bpm.engine.repository.ProcessDefinitionQuery)9 Test (org.junit.Test)9 InputStream (java.io.InputStream)6 ProcessApplicationRegistration (org.camunda.bpm.application.ProcessApplicationRegistration)3 EmbeddedProcessApplication (org.camunda.bpm.application.impl.EmbeddedProcessApplication)3 ArrayList (java.util.ArrayList)1 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 ResourceEntity (org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity)1 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1 DeploymentResourceDto (org.camunda.bpm.engine.rest.dto.repository.DeploymentResourceDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 DeploymentResourcesResource (org.camunda.bpm.engine.rest.sub.repository.DeploymentResourcesResource)1 Deployment (org.camunda.bpm.engine.test.Deployment)1 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)1