DeploymentBuilderImpl implements DeploymentBuilder, Serializable { public DeploymentBuilder addInputStream(String resourceName, InputStream inputStream) { if (inputStream == null) { throw new ActivitiIllegalArgumentException("inputStream for resource '" + resourceName + "' is null"); } byte[] bytes = IoUtil.readInputStream(inputStream, resourceName); ResourceEntity resource = resourceEntityManager.create(); resource.setName(resourceName); resource.setBytes(bytes); deployment.addResource(resource); return this; } DeploymentBuilderImpl(RepositoryServiceImpl repositoryService);  DeploymentBuilderImpl(RepositoryServiceImpl repositoryService,
                               DeploymentEntity deployment,
                               ResourceEntityManager resourceEntityManager); DeploymentBuilder addInputStream(String resourceName, InputStream inputStream); DeploymentBuilder setProjectManifest(ProjectManifest projectManifest); ProjectManifest getProjectManifest(); boolean hasProjectManifestSet(); DeploymentBuilder setEnforcedAppVersion(Integer enforcedAppVersion); Integer getEnforcedAppVersion(); boolean hasEnforcedAppVersion(); @Override DeploymentBuilder addInputStream(String resourceName,
                                          Resource resource); DeploymentBuilder addClasspathResource(String resource); DeploymentBuilder addString(String resourceName, String text); DeploymentBuilder addBytes(String resourceName, byte[] bytes); DeploymentBuilder addZipInputStream(ZipInputStream zipInputStream); DeploymentBuilder addBpmnModel(String resourceName, BpmnModel bpmnModel); DeploymentBuilder name(String name); DeploymentBuilder category(String category); DeploymentBuilder key(String key); DeploymentBuilder disableBpmnValidation(); DeploymentBuilder disableSchemaValidation(); DeploymentBuilder tenantId(String tenantId); DeploymentBuilder enableDuplicateFiltering(); DeploymentBuilder activateProcessDefinitionsOn(Date date); @Override DeploymentBuilder deploymentProperty(String propertyKey, Object propertyValue); Deployment deploy(); DeploymentEntity getDeployment(); boolean isProcessValidationEnabled(); boolean isBpmn20XsdValidationEnabled(); boolean isDuplicateFilterEnabled(); Date getProcessDefinitionsActivationDate(); Map<String, Object> getDeploymentProperties();  }
@Test public void addInputStreamShouldAddNormalImportStreamWhenITsNotAZipLike() throws Exception { String resourceName = "any.xml"; InputStream inputStream = mock(InputStream.class); given(resource.getInputStream()).willReturn(inputStream); doReturn(deploymentBuilder).when(deploymentBuilder).addInputStream(resourceName, inputStream); deploymentBuilder.addInputStream(resourceName, resource); verify(deploymentBuilder).addInputStream(resourceName, inputStream); }
@Test public void addInputStreamShouldThrowActivitiExceptionWhenIOExceptionIsThrown() throws Exception { given(resource.getInputStream()).willThrow(new IOException()); Throwable thrown = catchThrowable(() -> deploymentBuilder.addInputStream("any.xml", resource)); assertThat(thrown) .isInstanceOf(ActivitiException.class) .hasMessageContaining("Couldn't auto deploy resource"); }