Search in sources :

Example 81 with Any

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);
}
Also used : Project(io.spine.test.aggregate.Project) ProjectId(io.spine.test.aggregate.ProjectId) Any(com.google.protobuf.Any) Test(org.junit.Test)

Example 82 with Any

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);
}
Also used : Project(io.spine.test.aggregate.Project) ProjectId(io.spine.test.aggregate.ProjectId) Any(com.google.protobuf.Any) Test(org.junit.Test)

Example 83 with Any

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;
}
Also used : QueryResponse(io.spine.client.QueryResponse) Any(com.google.protobuf.Any)

Example 84 with Any

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());
}
Also used : FloatValue(com.google.protobuf.FloatValue) Any(com.google.protobuf.Any) Test(org.junit.Test)

Example 85 with Any

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));
}
Also used : EntityRecord(io.spine.server.entity.EntityRecord) Message(com.google.protobuf.Message) ProjectId(io.spine.test.entity.ProjectId) Any(com.google.protobuf.Any) Test(org.junit.Test)

Aggregations

Any (com.google.protobuf.Any)155 Test (org.junit.Test)44 Message (com.google.protobuf.Message)30 TypeConverter.toAny (io.spine.protobuf.TypeConverter.toAny)27 EntityRecord (io.spine.server.entity.EntityRecord)24 TypeUrl (io.spine.type.TypeUrl)15 Version (io.spine.core.Version)11 Customer (io.spine.test.commandservice.customer.Customer)11 GivenVersion (io.spine.core.given.GivenVersion)9 EntityRecordWithColumns (io.spine.server.entity.storage.EntityRecordWithColumns)8 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)8 CustomerId (io.spine.test.commandservice.customer.CustomerId)8 FieldMask (com.google.protobuf.FieldMask)7 Query (io.spine.client.Query)7 Project (io.spine.test.storage.Project)7 EntityId (io.spine.client.EntityId)6 QueryResponse (io.spine.client.QueryResponse)6 Ack (io.spine.core.Ack)6 Command (io.spine.core.Command)6 EntityFilters (io.spine.client.EntityFilters)5