Search in sources :

Example 31 with EntityRecord

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));
}
Also used : EntityRecord(io.spine.server.entity.EntityRecord) EntityColumn(io.spine.server.entity.storage.EntityColumn) ColumnFilter(io.spine.client.ColumnFilter) QueryParameters(io.spine.server.entity.storage.QueryParameters) EntityRecordWithColumns(io.spine.server.entity.storage.EntityRecordWithColumns) CompositeQueryParameter(io.spine.server.entity.storage.CompositeQueryParameter) Test(org.junit.Test)

Example 32 with EntityRecord

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());
}
Also used : EntityRecord(io.spine.server.entity.EntityRecord) StandStorage(io.spine.server.stand.StandStorage) TypeUrl(io.spine.type.TypeUrl) Any(com.google.protobuf.Any)

Example 33 with EntityRecord

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());
}
Also used : EntityRecord(io.spine.server.entity.EntityRecord) StandStorage(io.spine.server.stand.StandStorage) Test(org.junit.Test)

Example 34 with EntityRecord

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));
}
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)

Example 35 with EntityRecord

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);
}
Also used : EntityRecord(io.spine.server.entity.EntityRecord) Test(org.junit.Test)

Aggregations

EntityRecord (io.spine.server.entity.EntityRecord)55 Test (org.junit.Test)34 Any (com.google.protobuf.Any)24 EntityRecordWithColumns (io.spine.server.entity.storage.EntityRecordWithColumns)15 Message (com.google.protobuf.Message)10 Project (io.spine.test.storage.Project)10 TypeUrl (io.spine.type.TypeUrl)9 FieldMask (com.google.protobuf.FieldMask)7 EntityFilters (io.spine.client.EntityFilters)7 ProjectId (io.spine.test.storage.ProjectId)7 ColumnFilter (io.spine.client.ColumnFilter)5 EntityIdFilter (io.spine.client.EntityIdFilter)4 LinkedList (java.util.LinkedList)4 CompositeColumnFilter (io.spine.client.CompositeColumnFilter)3 Version (io.spine.core.Version)3 CompositeQueryParameter (io.spine.server.entity.storage.CompositeQueryParameter)3 EntityColumn (io.spine.server.entity.storage.EntityColumn)3 QueryParameters (io.spine.server.entity.storage.QueryParameters)3 StandStorage (io.spine.server.stand.StandStorage)3 ImmutableList (com.google.common.collect.ImmutableList)2