use of com.google.protobuf.Any in project core-java by SpineEventEngine.
the class SubscriptionRecordShould method fail_to_match_improper_type.
@Test
public void fail_to_match_improper_type() {
final SubscriptionRecord notMatchingRecord = new SubscriptionRecord(Given.subscription(), Given.target(), Given.TYPE);
final Project entityState = Project.getDefaultInstance();
final Any wrappedState = AnyPacker.pack(entityState);
final ProjectId redundantId = ProjectId.getDefaultInstance();
final boolean matchResult = notMatchingRecord.matches(Given.OTHER_TYPE, redundantId, wrappedState);
assertFalse(matchResult);
}
use of com.google.protobuf.Any in project core-java by SpineEventEngine.
the class SubscriptionRecordShould method fail_to_match_improper_target.
@Test
public void fail_to_match_improper_target() {
final ProjectId nonExistingId = ProjectId.newBuilder().setId("never-existed").build();
final SubscriptionRecord notMatchingRecord = new SubscriptionRecord(Given.subscription(), Given.target(nonExistingId), Given.TYPE);
final Project entityState = Project.getDefaultInstance();
final Any wrappedState = AnyPacker.pack(entityState);
final ProjectId redundantId = ProjectId.getDefaultInstance();
final boolean matchResult = notMatchingRecord.matches(Given.TYPE, redundantId, wrappedState);
assertFalse(matchResult);
}
use of com.google.protobuf.Any in project core-java by SpineEventEngine.
the class StandShould method checkAndGetMessageList.
private static List<Any> checkAndGetMessageList(MemoizeQueryResponseObserver responseObserver) {
assertTrue("Query has not completed successfully", responseObserver.isCompleted);
assertNull("Throwable has been caught upon query execution", responseObserver.throwable);
final QueryResponse response = responseObserver.responseHandled;
assertEquals("Query response is not OK", Responses.ok(), response.getResponse());
assertNotNull("Query response must not be null", response);
final List<Any> messageList = response.getMessagesList();
assertNotNull("Query response has null message list", messageList);
return messageList;
}
use of com.google.protobuf.Any in project core-java by SpineEventEngine.
the class FloatFieldValidatorShould method wrap_to_any.
@Test
public void wrap_to_any() {
final Any any = validator.wrap(VALUE);
final FloatValue msg = AnyPacker.unpack(any);
assertEquals(VALUE, (Float) msg.getValue());
}
use of com.google.protobuf.Any 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 Map<Column<?>, Object> params = ImmutableMap.of();
final EntityQuery<?> query = EntityQuery.of(idFilter, params);
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));
}
Aggregations