use of org.camunda.bpm.engine.impl.variable.serializer.ValueFields 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.impl.variable.serializer.ValueFields in project camunda-bpm-platform by camunda.
the class FileValueSerializerTest method testWriteMimetypeAndFilenameValue.
@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));
}
use of org.camunda.bpm.engine.impl.variable.serializer.ValueFields in project camunda-bpm-platform by camunda.
the class FileValueSerializerTest method testWriteFilenameOnlyValue.
@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()));
}
use of org.camunda.bpm.engine.impl.variable.serializer.ValueFields in project camunda-bpm-platform by camunda.
the class FileValueSerializerTest method testWriteMimetypeFilenameAndBytesValueWithShortcutMethod.
@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));
}
use of org.camunda.bpm.engine.impl.variable.serializer.ValueFields in project camunda-bpm-platform by camunda.
the class FileValueSerializerTest method testWriteFilenameAndEncodingValue.
@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));
}
Aggregations