public static DeploymentResourceDto fromResources(Resource resource) { DeploymentResourceDto dto = new DeploymentResourceDto(); dto.id = resource.getId(); dto.name = resource.getName(); dto.deploymentId = resource.getDeploymentId(); return dto; } }
@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()); }
protected Resource getResourceByName(String deploymentId, String resourceName) { List<Resource> resources = repositoryService.getDeploymentResources(deploymentId); for (Resource resource : resources) { if (resource.getName().equals(resourceName)) { return resource; } } return null; }
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml"}) public void testDeploymentIdOfResource() { String deploymentId = repositoryService.createDeploymentQuery().singleResult().getId(); List<Resource> resources = repositoryService.getDeploymentResources(deploymentId); assertEquals(1, resources.size()); Resource resource = resources.get(0); assertEquals(deploymentId, resource.getDeploymentId()); }
@Test public void getResourceAsStreamByIdDisabledTenantCheck() { Deployment deploymentOne = testRule.deployForTenant(TENANT_ONE, emptyProcess); Deployment deploymentTwo = testRule.deployForTenant(TENANT_TWO, startEndProcess); Resource resourceOne = repositoryService.getDeploymentResources(deploymentOne.getId()).get(0); Resource resourceTwo = repositoryService.getDeploymentResources(deploymentTwo.getId()).get(0); processEngineConfiguration.setTenantCheckEnabled(false); identityService.setAuthentication("user", null, null); InputStream inputStream = repositoryService.getResourceAsStreamById(deploymentOne.getId(), resourceOne.getId()); assertThat(inputStream, notNullValue()); inputStream = repositoryService.getResourceAsStreamById(deploymentTwo.getId(), resourceTwo.getId()); assertThat(inputStream, notNullValue()); }
@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()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml"}) public void testDeploymentIdOfResource() { String deploymentId = repositoryService.createDeploymentQuery().singleResult().getId(); List<Resource> resources = repositoryService.getDeploymentResources(deploymentId); assertEquals(1, resources.size()); Resource resource = resources.get(0); assertEquals(deploymentId, resource.getDeploymentId()); }
public static DeploymentResourceDto fromResources(Resource resource) { DeploymentResourceDto dto = new DeploymentResourceDto(); dto.id = resource.getId(); dto.name = resource.getName(); dto.deploymentId = resource.getDeploymentId(); return dto; } }
public void testGetResourceAsStreamByIdWithReadPermissionOnDeployment() { // given String deploymentId = createDeployment(null); createGrantAuthorization(DEPLOYMENT, deploymentId, userId, READ); disableAuthorization(); List<Resource> resources = repositoryService.getDeploymentResources(deploymentId); enableAuthorization(); String resourceId = resources.get(0).getId(); // when InputStream stream = repositoryService.getResourceAsStreamById(deploymentId, resourceId); // then assertNotNull(stream); deleteDeployment(deploymentId); }
@Test public void getResourceAsStreamDisabledTenantCheck() { Deployment deploymentOne = testRule.deployForTenant(TENANT_ONE, emptyProcess); Deployment deploymentTwo = testRule.deployForTenant(TENANT_TWO, startEndProcess); Resource resourceOne = repositoryService.getDeploymentResources(deploymentOne.getId()).get(0); Resource resourceTwo = repositoryService.getDeploymentResources(deploymentTwo.getId()).get(0); processEngineConfiguration.setTenantCheckEnabled(false); identityService.setAuthentication("user", null, null); InputStream inputStream = repositoryService.getResourceAsStream(deploymentOne.getId(), resourceOne.getName()); assertThat(inputStream, notNullValue()); inputStream = repositoryService.getResourceAsStream(deploymentTwo.getId(), resourceTwo.getName()); assertThat(inputStream, notNullValue()); }
public static Resource createMockDeploymentJpeResource() { Resource mockResource = mock(ResourceEntity.class); when(mockResource.getId()).thenReturn(EXAMPLE_DEPLOYMENT_JPE_RESOURCE_ID); when(mockResource.getName()).thenReturn(EXAMPLE_DEPLOYMENT_JPE_RESOURCE_NAME); when(mockResource.getDeploymentId()).thenReturn(EXAMPLE_DEPLOYMENT_ID); return mockResource; }
public void testGetResourceAsStreamByIdWithReadPermissionOnAnyDeployment() { // given String deploymentId = createDeployment(null); createGrantAuthorization(DEPLOYMENT, ANY, userId, READ); disableAuthorization(); List<Resource> resources = repositoryService.getDeploymentResources(deploymentId); enableAuthorization(); String resourceId = resources.get(0).getId(); // when InputStream stream = repositoryService.getResourceAsStreamById(deploymentId, resourceId); // then assertNotNull(stream); deleteDeployment(deploymentId); }
@Test public void failToGetResourceAsStreamNoAuthenticatedTenant() { Deployment deployment = testRule.deployForTenant(TENANT_ONE, emptyProcess); Resource resource = repositoryService.getDeploymentResources(deployment.getId()).get(0); identityService.setAuthentication("user", null, null); // declare expected exception thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot get the deployment"); repositoryService.getResourceAsStream(deployment.getId(), resource.getName()); }
public static Resource createMockDeploymentCmmnXmlResource() { Resource mockResource = mock(ResourceEntity.class); when(mockResource.getId()).thenReturn(EXAMPLE_DEPLOYMENT_CMMN_XML_RESOURCE_ID); when(mockResource.getName()).thenReturn(EXAMPLE_DEPLOYMENT_CMMN_XML_RESOURCE_NAME); when(mockResource.getDeploymentId()).thenReturn(EXAMPLE_DEPLOYMENT_ID); return mockResource; }
@Test public void failToGetResourceAsStreamByIdNoAuthenticatedTenant() { Deployment deployment = testRule.deployForTenant(TENANT_ONE, emptyProcess); Resource resource = repositoryService.getDeploymentResources(deployment.getId()).get(0); identityService.setAuthentication("user", null, null); // declare expected exception thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot get the deployment"); repositoryService.getResourceAsStreamById(deployment.getId(), resource.getId()); }
protected Resource getResourceByName(String deploymentId, String resourceName) { List<Resource> resources = repositoryService.getDeploymentResources(deploymentId); for (Resource resource : resources) { if (resource.getName().equals(resourceName)) { return resource; } } return null; }