use of com.google.protobuf.Message in project core-java by SpineEventEngine.
the class EntityQueryMatcherShould method match_ids.
@Test
public void match_ids() {
final Message genericId = Sample.messageOfType(ProjectId.class);
final Collection<Object> idFilter = Collections.<Object>singleton(genericId);
final Any entityId = AnyPacker.pack(genericId);
final EntityQuery<?> query = createQuery(idFilter, defaultQueryParameters());
final EntityQueryMatcher<?> matcher = new EntityQueryMatcher<>(query);
final EntityRecord matching = EntityRecord.newBuilder().setEntityId(entityId).build();
final Any otherEntityId = AnyPacker.pack(Sample.messageOfType(ProjectId.class));
final EntityRecord nonMatching = EntityRecord.newBuilder().setEntityId(otherEntityId).build();
final EntityRecordWithColumns matchingRecord = of(matching);
final EntityRecordWithColumns nonMatchingRecord = of(nonMatching);
assertTrue(matcher.apply(matchingRecord));
assertFalse(matcher.apply(nonMatchingRecord));
}
use of com.google.protobuf.Message in project core-java by SpineEventEngine.
the class PairShould method return_Empty_for_absent_Optional_in_iterator.
@Test
public void return_Empty_for_absent_Optional_in_iterator() {
StringValue a = TestValues.newUuidValue();
Pair<StringValue, Optional<BoolValue>> pair = Pair.withNullable(a, null);
final Iterator<Message> iterator = pair.iterator();
assertEquals(a, iterator.next());
assertEquals(Empty.getDefaultInstance(), iterator.next());
assertFalse(iterator.hasNext());
}
use of com.google.protobuf.Message in project core-java by SpineEventEngine.
the class CommandTestShould method create_different_command_with_timestamp.
@Test
public void create_different_command_with_timestamp() {
final Message anotherCommandMsg = Time.getCurrentTime();
final Timestamp timestamp = TimeTests.Past.minutesAgo(30);
final Command anotherCommand = commandTest.createDifferentCommand(anotherCommandMsg, timestamp);
assertEquals(anotherCommandMsg, Commands.getMessage(anotherCommand));
assertEquals(timestamp, anotherCommand.getContext().getActorContext().getTimestamp());
}
use of com.google.protobuf.Message in project hbase by apache.
the class HBaseAdmin method coprocessorService.
@Override
public // Coprocessor Endpoint against the Master.
CoprocessorRpcChannel coprocessorService() {
return new SyncCoprocessorRpcChannel() {
@Override
protected Message callExecService(final RpcController controller, final Descriptors.MethodDescriptor method, final Message request, final Message responsePrototype) throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Call: " + method.getName() + ", " + request.toString());
}
// Try-with-resources so close gets called when we are done.
try (MasterCallable<CoprocessorServiceResponse> callable = new MasterCallable<CoprocessorServiceResponse>(connection, connection.getRpcControllerFactory()) {
@Override
protected CoprocessorServiceResponse rpcCall() throws Exception {
CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request);
return this.master.execMasterService(getRpcController(), csr);
}
}) {
// TODO: Are we retrying here? Does not seem so. We should use RetryingRpcCaller
callable.prepare(false);
int operationTimeout = connection.getConnectionConfiguration().getOperationTimeout();
CoprocessorServiceResponse result = callable.call(operationTimeout);
return CoprocessorRpcUtils.getResponse(result, responsePrototype);
}
}
};
}
use of com.google.protobuf.Message in project hbase by apache.
the class CoprocessorRpcUtils method getResponse.
public static Message getResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse result, com.google.protobuf.Message responsePrototype) throws IOException {
Message response;
if (result.getValue().hasValue()) {
Message.Builder builder = responsePrototype.newBuilderForType();
builder.mergeFrom(result.getValue().getValue().newInput());
response = builder.build();
} else {
response = responsePrototype.getDefaultInstanceForType();
}
if (LOG.isTraceEnabled()) {
LOG.trace("Master Result is value=" + response);
}
return response;
}
Aggregations