use of org.camunda.bpm.engine.variable.value.FileValue in project camunda-bpm-platform by camunda.
the class TaskQueryTest method testQueryByFileCaseInstanceVariableValueNotEquals.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByFileCaseInstanceVariableValueNotEquals() {
FileValue fileValue = createDefaultFileValue();
String variableName = "aFileValue";
startDefaultCaseWithVariable(fileValue, variableName);
TaskQuery query = taskService.createTaskQuery();
try {
query.caseInstanceVariableValueNotEquals(variableName, fileValue).list();
fail();
} catch (ProcessEngineException e) {
assertThat(e.getMessage(), containsString("Variables of type File cannot be used to query"));
}
}
use of org.camunda.bpm.engine.variable.value.FileValue in project camunda-bpm-platform by camunda.
the class FileValueSerializerTest method testWriteMimetypeFilenameBytesValueAndEncoding.
@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()));
}
use of org.camunda.bpm.engine.variable.value.FileValue in project camunda-bpm-platform by camunda.
the class FileValueSerializerTest method testReadFileNameMimeTypeAndByteArray.
@Test
public void testReadFileNameMimeTypeAndByteArray() throws IOException {
InputStream is = this.getClass().getClassLoader().getResourceAsStream("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt");
byte[] data = new byte[is.available()];
DataInputStream dataInputStream = new DataInputStream(is);
dataInputStream.readFully(data);
dataInputStream.close();
MockValueFields valueFields = new MockValueFields();
String filename = "file.txt";
valueFields.setTextValue(filename);
valueFields.setByteArrayValue(data);
String mimeType = "text/plain";
valueFields.setTextValue2(mimeType + SEPARATOR);
FileValue fileValue = serializer.readValue(valueFields, true);
assertThat(fileValue.getFilename(), is(filename));
assertThat(fileValue.getMimeType(), is(mimeType));
checkStreamFromValue(fileValue, "text");
}
use of org.camunda.bpm.engine.variable.value.FileValue in project camunda-bpm-platform by camunda.
the class FileValueSerializerTest method testReadFullValue.
@Test
public void testReadFullValue() throws IOException {
InputStream is = this.getClass().getClassLoader().getResourceAsStream("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt");
byte[] data = new byte[is.available()];
DataInputStream dataInputStream = new DataInputStream(is);
dataInputStream.readFully(data);
dataInputStream.close();
MockValueFields valueFields = new MockValueFields();
String filename = "file.txt";
valueFields.setTextValue(filename);
valueFields.setByteArrayValue(data);
String mimeType = "text/plain";
String encoding = "UTF-16";
valueFields.setTextValue2(mimeType + SEPARATOR + encoding);
FileValue fileValue = serializer.readValue(valueFields, true);
assertThat(fileValue.getFilename(), is(filename));
assertThat(fileValue.getMimeType(), is(mimeType));
assertThat(fileValue.getEncoding(), is("UTF-16"));
assertThat(fileValue.getEncodingAsCharset(), is(Charset.forName("UTF-16")));
checkStreamFromValue(fileValue, "text");
}
use of org.camunda.bpm.engine.variable.value.FileValue in project camunda-bpm-platform by camunda.
the class FileValueSerializerTest method testReadFilenameAndByteArrayValue.
@Test
public void testReadFilenameAndByteArrayValue() throws IOException {
InputStream is = this.getClass().getClassLoader().getResourceAsStream("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt");
byte[] data = new byte[is.available()];
DataInputStream dataInputStream = new DataInputStream(is);
dataInputStream.readFully(data);
dataInputStream.close();
MockValueFields valueFields = new MockValueFields();
String filename = "file.txt";
valueFields.setTextValue(filename);
valueFields.setByteArrayValue(data);
FileValue fileValue = serializer.readValue(valueFields, true);
assertThat(fileValue.getFilename(), is(filename));
assertThat(fileValue.getMimeType(), is(nullValue()));
checkStreamFromValue(fileValue, "text");
}
Aggregations