use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project core-java by SpineEventEngine.
the class MetadataConverter method toMetadata.
/**
* Returns the {@link Metadata}, containing the {@link Error} as a byte array.
*
* @param error the error to convert
* @return the metadata containing error
*/
public static Metadata toMetadata(Error error) {
checkNotNull(error);
final Metadata metadata = new Metadata();
metadata.put(KEY, error.toByteArray());
return metadata;
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project core-java by SpineEventEngine.
the class MetadataConverterShould method return_metadata_containing_error.
// A part of the test.
@SuppressWarnings("ConstantConditions")
@Test
public void return_metadata_containing_error() throws InvalidProtocolBufferException {
final Error error = Error.getDefaultInstance();
final Metadata metadata = MetadataConverter.toMetadata(error);
final byte[] bytes = metadata.get(MetadataConverter.KEY);
assertEquals(error, Error.parseFrom(bytes));
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project core-java by SpineEventEngine.
the class MetadataConverterShould method return_absent_if_metadata_is_empty.
@Test
public void return_absent_if_metadata_is_empty() {
final Metadata metadata = new Metadata();
assertFalse(MetadataConverter.toError(metadata).isPresent());
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project core-java by SpineEventEngine.
the class MetadataConverterShould method return_error_extracted_form_metadata.
@Test
public void return_error_extracted_form_metadata() {
final Error expectedError = Error.getDefaultInstance();
final Metadata metadata = MetadataConverter.toMetadata(expectedError);
assertEquals(expectedError, MetadataConverter.toError(metadata).get());
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project core-java by SpineEventEngine.
the class StreamObserversShould method return_absent_if_there_is_no_error_in_metadata.
@Test
public void return_absent_if_there_is_no_error_in_metadata() {
final Metadata emptyMetadata = new Metadata();
final Throwable statusRuntimeEx = INVALID_ARGUMENT.asRuntimeException(emptyMetadata);
assertFalse(StreamObservers.fromStreamError(statusRuntimeEx).isPresent());
}
Aggregations