@Test @DisplayName("match IDs") void matchIds() { Message genericId = Sample.messageOfType(ProjectId.class); Collection<Object> idFilter = singleton(genericId); Any entityId = AnyPacker.pack(genericId); EntityQuery<?> query = createQuery(idFilter, defaultQueryParameters()); EntityQueryMatcher<?> matcher = new EntityQueryMatcher<>(query); EntityRecord matching = EntityRecord.newBuilder() .setEntityId(entityId) .build(); Any otherEntityId = AnyPacker.pack(Sample.messageOfType(ProjectId.class)); EntityRecord nonMatching = EntityRecord.newBuilder() .setEntityId(otherEntityId) .build(); EntityRecordWithColumns matchingRecord = EntityRecordWithColumns.of(matching, Collections.emptyMap()); EntityRecordWithColumns nonMatchingRecord = EntityRecordWithColumns.of(nonMatching, Collections.emptyMap()); assertTrue(matcher.test(matchingRecord)); assertFalse(matcher.test(nonMatchingRecord)); }
@Override public boolean test(@Nullable EntityRecordWithColumns input) { if (input == null) { return false; } boolean result = idMatches(input) && columnValuesMatch(input); return result; }
EntityQueryMatcher implements Predicate<@Nullable EntityRecordWithColumns> { @Override public boolean test(@Nullable EntityRecordWithColumns input) { if (input == null) { return false; } boolean result = idMatches(input) && columnValuesMatch(input); return result; } }
EntityQueryMatcher implements Predicate<@Nullable EntityRecordWithColumns> { @Override public boolean test(@Nullable EntityRecordWithColumns input) { if (input == null) { return false; } boolean result = idMatches(input) && columnValuesMatch(input); return result; } EntityQueryMatcher(EntityQuery<I> query); }
EntityQueryMatcher implements Predicate<@Nullable EntityRecordWithColumns> { @Override public boolean test(@Nullable EntityRecordWithColumns input) { if (input == null) { return false; } boolean result = idMatches(input) && columnValuesMatch(input); return result; } EntityQueryMatcher(EntityQuery<I> query); @Override boolean test(@Nullable EntityRecordWithColumns input); }
EntityQueryMatcher implements Predicate<@Nullable EntityRecordWithColumns> { @Override public boolean test(@Nullable EntityRecordWithColumns input) { if (input == null) { return false; } boolean result = idMatches(input) && columnValuesMatch(input); return result; } EntityQueryMatcher(EntityQuery<I> query); @Override boolean test(@Nullable EntityRecordWithColumns input);  }