use of com.facebook.buck.bser.BserSerializer in project buck by facebook.
the class WatchmanTest method bserSerialized.
private static ByteBuffer bserSerialized(Object obj) throws IOException {
ByteBuffer buf = ByteBuffer.allocate(256).order(ByteOrder.nativeOrder());
ByteBuffer result = new BserSerializer().serializeToBuffer(obj, buf);
// Prepare the buffer for reading.
result.flip();
return result;
}
use of com.facebook.buck.bser.BserSerializer in project buck by facebook.
the class ProjectBuildFileParserTest method fakeProcessWithBserOutput.
private static FakeProcess fakeProcessWithBserOutput(int returnCode, List<Object> values, Optional<List<Object>> diagnostics, Optional<String> stdout) {
BserSerializer bserSerializer = new BserSerializer();
ByteBuffer buffer = ByteBuffer.allocate(512).order(ByteOrder.nativeOrder());
try {
Map<String, Object> outputToSerialize = new LinkedHashMap<>();
outputToSerialize.put("values", values);
if (diagnostics.isPresent()) {
outputToSerialize.put("diagnostics", diagnostics.get());
}
buffer = bserSerializer.serializeToBuffer(outputToSerialize, buffer);
} catch (IOException e) {
throw new RuntimeException(e);
}
buffer.flip();
return new FakeProcess(returnCode, new ByteArrayOutputStream(), new ByteArrayInputStream(buffer.array()), new ByteArrayInputStream(stdout.orElse("").getBytes(StandardCharsets.UTF_8)));
}
Aggregations