本文整理了Java中org.camunda.bpm.engine.variable.Variables.fileValue()
方法的一些代码示例,展示了Variables.fileValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Variables.fileValue()
方法的具体详情如下:
包路径:org.camunda.bpm.engine.variable.Variables
类名称:Variables
方法名:fileValue
[英]Shortcut for calling Variables.fileValue(name).file(file).mimeType(type).create(). The name is set to the file name and the mime type is detected via MimetypesFileTypeMap.
[中]调用变量的快捷方式。文件值(名称)。文件。mimeType(类型)。创建()。名称设置为文件名,mime类型通过MimetypesFileTypeMap检测。
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Returns a builder to create a new {@link FileValue} with the given
* {@code filename}.
*/
public static FileValueBuilder fileValue(String filename) {
return fileValue(filename, false);
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* @return
*/
protected FileValue createDefaultFileValue() {
FileValue fileValue = Variables.fileValue("tst.txt").file("somebytes".getBytes()).create();
return fileValue;
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testWriteMimetypeFilenameAndBytesValueWithShortcutMethod() throws URISyntaxException, UnsupportedEncodingException {
File file = new File(this.getClass().getClassLoader().getResource("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt").toURI());
FileValue fileValue = Variables.fileValue(file);
ValueFields valueFields = new MockValueFields();
serializer.writeValue(fileValue, valueFields);
assertThat(new String(valueFields.getByteArrayValue(), "UTF-8"), is("text"));
assertThat(valueFields.getTextValue(), is("simpleFile.txt"));
assertThat(valueFields.getTextValue2(), is("text/plain" + SEPARATOR));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test(expected = IllegalArgumentException.class)
public void testSerializeFileValueWithoutName() {
Variables.fileValue((String) null).file("abc".getBytes()).create();
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected FileValue createFile() {
String fileName = "text.txt";
String encoding = "crazy-encoding";
String mimeType = "martini/dry";
FileValue fileValue = Variables
.fileValue(fileName)
.file("ABC".getBytes())
.encoding(encoding)
.mimeType(mimeType)
.create();
return fileValue;
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected FileValue createFile() {
String fileName = "text.txt";
String encoding = "crazy-encoding";
String mimeType = "martini/dry";
FileValue fileValue = Variables
.fileValue(fileName)
.file("ABC".getBytes())
.encoding(encoding)
.mimeType(mimeType)
.create();
return fileValue;
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public FileValue readValue(ValueFields valueFields, boolean deserializeValue) {
FileValueBuilder builder = Variables.fileValue(valueFields.getTextValue());
if (valueFields.getByteArrayValue() != null) {
builder.file(valueFields.getByteArrayValue());
}
// to ensure the same array size all the time
if (valueFields.getTextValue2() != null) {
String[] split = Arrays.copyOf(valueFields.getTextValue2().split(MIMETYPE_ENCODING_SEPARATOR, NR_OF_VALUES_IN_TEXTFIELD2), NR_OF_VALUES_IN_TEXTFIELD2);
String mimeType = returnNullIfEmptyString(split[0]);
String encoding = returnNullIfEmptyString(split[1]);
builder.mimeType(mimeType);
builder.encoding(encoding);
}
return builder.create();
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected FileValue fileValueWithDecodedString(FileValue fileValue, String value) {
return Variables.fileValue(fileValue.getFilename())
.file(Base64.decodeBase64(value))
.mimeType(fileValue.getMimeType())
.encoding(fileValue.getEncoding())
.create();
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testWriteMimetypeFilenameBytesValueAndEncoding() throws UnsupportedEncodingException {
String filename = "test.txt";
String mimeType = "text/json";
Charset encoding = Charset.forName("UTF-8");
InputStream is = this.getClass().getClassLoader().getResourceAsStream("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt");
FileValue fileValue = Variables.fileValue(filename).mimeType(mimeType).encoding(encoding).file(is).create();
ValueFields valueFields = new MockValueFields();
serializer.writeValue(fileValue, valueFields);
assertThat(new String(valueFields.getByteArrayValue(), "UTF-8"), is("text"));
assertThat(valueFields.getTextValue(), is(filename));
assertThat(valueFields.getTextValue2(), is(mimeType + SEPARATOR + encoding.name()));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testWriteMimetypeFilenameAndBytesValue() throws UnsupportedEncodingException {
String filename = "test.txt";
String mimeType = "text/json";
InputStream is = this.getClass().getClassLoader().getResourceAsStream("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt");
FileValue fileValue = Variables.fileValue(filename).mimeType(mimeType).file(is).create();
ValueFields valueFields = new MockValueFields();
serializer.writeValue(fileValue, valueFields);
assertThat(new String(valueFields.getByteArrayValue(), "UTF-8"), is("text"));
assertThat(valueFields.getTextValue(), is(filename));
assertThat(valueFields.getTextValue2(), is(mimeType + SEPARATOR));
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected FileValue fileValueWithDecodedString(FileValue fileValue, String value) {
return Variables.fileValue(fileValue.getFilename())
.file(Base64.decodeBase64(value))
.mimeType(fileValue.getMimeType())
.encoding(fileValue.getEncoding())
.create();
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testWriteFilenameOnlyValue() {
String filename = "test.txt";
FileValue fileValue = Variables.fileValue(filename).create();
ValueFields valueFields = new MockValueFields();
serializer.writeValue(fileValue, valueFields);
assertThat(valueFields.getByteArrayValue(), is(nullValue()));
assertThat(valueFields.getTextValue(), is(filename));
assertThat(valueFields.getTextValue2(), is(nullValue()));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testWriteMimetypeAndFilenameValue() {
String filename = "test.txt";
String mimeType = "text/json";
FileValue fileValue = Variables.fileValue(filename).mimeType(mimeType).create();
ValueFields valueFields = new MockValueFields();
serializer.writeValue(fileValue, valueFields);
assertThat(valueFields.getByteArrayValue(), is(nullValue()));
assertThat(valueFields.getTextValue(), is(filename));
assertThat(valueFields.getTextValue2(), is(mimeType + SEPARATOR));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testWriteFilenameAndEncodingValue() {
String filename = "test.txt";
String encoding = "UTF-8";
FileValue fileValue = Variables.fileValue(filename).encoding(encoding).create();
ValueFields valueFields = new MockValueFields();
serializer.writeValue(fileValue, valueFields);
assertThat(valueFields.getByteArrayValue(), is(nullValue()));
assertThat(valueFields.getTextValue(), is(filename));
assertThat(valueFields.getTextValue2(), is(SEPARATOR + encoding));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testGetFileVariableDownloadWithType() {
String variableKey = "aVariableKey";
final byte[] byteContent = "some bytes".getBytes();
String filename = "test.txt";
FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.toString()).create();
when(taskServiceMock.getVariableTyped(eq(EXAMPLE_TASK_ID), eq(variableKey), anyBoolean())).thenReturn(variableValue);
given()
.pathParam("id", EXAMPLE_TASK_ID)
.pathParam("varId", variableKey)
.then().expect()
.statusCode(Status.OK.getStatusCode())
.contentType(ContentType.TEXT.toString())
.and()
.body(is(equalTo(new String(byteContent))))
.when().get(SINGLE_TASK_SINGLE_BINARY_VARIABLE_URL);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testGetFileVariable() {
String variableKey = "aVariableKey";
final byte[] byteContent = "some bytes".getBytes();
String filename = "test.txt";
String mimeType = "text/plain";
FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(mimeType).create();
when(taskServiceMock.getVariableLocalTyped(eq(EXAMPLE_TASK_ID), eq(variableKey), anyBoolean())).thenReturn(variableValue);
given().pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey)
.then().expect()
.statusCode(Status.OK.getStatusCode())
.contentType(ContentType.JSON.toString())
.and()
.body("valueInfo.mimeType", equalTo(mimeType))
.body("valueInfo.filename", equalTo(filename))
.body("value", nullValue())
.when().get(SINGLE_TASK_SINGLE_VARIABLE_URL);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
@Deployment(resources = ONE_TASK_PROCESS)
public void testSerializeNullEncoding() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess",
Variables.createVariables().putValue("fileVar", Variables.fileValue("test.txt").mimeType("some mimetype").file("ABC".getBytes()).create()));
FileValue fileVar = runtimeService.getVariableTyped(pi.getId(), "fileVar");
assertNull(fileVar.getEncoding());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
@Deployment(resources = ONE_TASK_PROCESS)
public void testSerializeNullMimeType() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess",
Variables.createVariables().putValue("fileVar", Variables.fileValue("test.txt").file("ABC".getBytes()).encoding("UTF-8").create()));
FileValue fileVar = runtimeService.getVariableTyped(pi.getId(), "fileVar");
assertNull(fileVar.getMimeType());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
@Deployment(resources = ONE_TASK_PROCESS)
public void testSerializeNullMimeTypeAndNullEncoding() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess",
Variables.createVariables().putValue("fileVar", Variables.fileValue("test.txt").file("ABC".getBytes()).create()));
FileValue fileVar = runtimeService.getVariableTyped(pi.getId(), "fileVar");
assertNull(fileVar.getMimeType());
assertNull(fileVar.getEncoding());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
@Deployment(resources = ONE_TASK_PROCESS)
public void testSerializeNullValue() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess",
Variables.createVariables().putValue("fileVar", Variables.fileValue("test.txt").create()));
FileValue fileVar = runtimeService.getVariableTyped(pi.getId(), "fileVar");
assertNull(fileVar.getMimeType());
}
内容来源于网络,如有侵权,请联系作者删除!