use of io.spine.server.entity.EntityRecord in project core-java by SpineEventEngine.
the class EntityQueryMatcherShould method not_match_by_wrong_field_name.
@Test
public void not_match_by_wrong_field_name() {
final String wrongName = "wrong";
final EntityColumn target = mock(EntityColumn.class);
final Multimap<EntityColumn, ColumnFilter> filters = of(target, eq(wrongName, "any"));
final CompositeQueryParameter parameter = createParams(filters, EITHER);
final QueryParameters params = QueryParameters.newBuilder().add(parameter).build();
final EntityQuery<?> query = createQuery(Collections.emptyList(), params);
final EntityQueryMatcher<?> matcher = new EntityQueryMatcher<>(query);
final EntityRecord record = EntityRecord.newBuilder().setEntityId(Any.getDefaultInstance()).build();
final EntityRecordWithColumns recordWithColumns = of(record);
assertFalse(matcher.apply(recordWithColumns));
}
use of io.spine.server.entity.EntityRecord in project core-java by SpineEventEngine.
the class StandShould method checkEmptyResultForTargetOnEmptyStorage.
private void checkEmptyResultForTargetOnEmptyStorage(Query readCustomersQuery) {
final StandStorage standStorageMock = mock(StandStorage.class);
// Return an empty collection on {@link StandStorage#readAllByType(TypeUrl)} call.
final ImmutableList<EntityRecord> emptyResultList = ImmutableList.<EntityRecord>builder().build();
when(standStorageMock.readAllByType(any(TypeUrl.class))).thenReturn(emptyResultList);
final Stand stand = prepareStandWithAggregateRepo(standStorageMock);
final MemoizeQueryResponseObserver responseObserver = new MemoizeQueryResponseObserver();
stand.execute(readCustomersQuery, responseObserver);
final List<Any> messageList = checkAndGetMessageList(responseObserver);
assertTrue("Query returned a non-empty response message list though the target was empty", messageList.isEmpty());
}
use of io.spine.server.entity.EntityRecord in project core-java by SpineEventEngine.
the class StandStorageShould method retrieve_all_records.
@Test
public void retrieve_all_records() {
final StandStorage storage = getStorage();
final List<AggregateStateId> ids = fill(storage, 10, DEFAULT_ID_SUPPLIER);
final Map<AggregateStateId, EntityRecord> allRecords = storage.readAll();
checkIds(ids, allRecords.values());
}
use of io.spine.server.entity.EntityRecord 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));
}
use of io.spine.server.entity.EntityRecord in project core-java by SpineEventEngine.
the class EntityRecordWithColumnsShould method store_record.
@Test
public void store_record() {
final EntityRecordWithColumns recordWithFields = newRecord();
final EntityRecord record = recordWithFields.getRecord();
assertNotNull(record);
}
Aggregations