public static ChannelQueryModel of() { return new ChannelQueryModel(null, null); }
public static ChannelQueryModel model() { return ChannelQueryModel.get(); } }
default ChannelQuery byKey(final String key) { return withPredicates(m -> m.key().is(key)); } }
@Test public void queryByNameAndDescription() { final LocalizedString name = randomSlug(); final LocalizedString description = randomSlug(); final ChannelDraft channelDraft = ChannelDraft.of(randomKey()) .withName(name) .withDescription(description); withChannel(client(), channelDraft, channel -> { final ChannelQuery query = ChannelQuery.of() .plusPredicates(m -> m.is(channel)) .plusPredicates(m -> m.name().locale(ENGLISH).is(name.get(ENGLISH))) .plusPredicates(m -> m.description().locale(ENGLISH).is(description.get(ENGLISH))); final List<Channel> results = client().executeBlocking(query).getResults(); assertThat(results).hasSize(1); }); }
ChannelQueryImpl(){ super("/channels", ChannelQuery.resultTypeReference(), ChannelQueryModel.of(), ChannelExpansionModel.of(), ChannelQueryImpl::new); }
@Test public void queryByGeoLocation() { final Point geoLocation = Point.of(52.0, 40.0); final ChannelDraft channelDraft = ChannelDraft.of(randomKey()) .withGeoLocation(geoLocation); withChannel(client(), channelDraft, channel -> { final ChannelQuery withinCircleQuery = ChannelQuery.of() .plusPredicates(m -> m.is(channel)) .plusPredicates(m -> m.geoLocation().withinCircle(geoLocation, 1.0)); final List<Channel> withinCircleResults = client().executeBlocking(withinCircleQuery).getResults(); assertThat(withinCircleResults).hasSize(1); assertThat(withinCircleResults.get(0)).isEqualTo(channel); final ChannelQuery isPresentQuery = ChannelQuery.of() .plusPredicates(m -> m.is(channel)) .plusPredicates(m -> m.geoLocation().isPresent()); final List<Channel> isPresentResults = client().executeBlocking(isPresentQuery).getResults(); assertThat(isPresentResults).hasSize(1); assertThat(isPresentResults.get(0)).isEqualTo(channel); }); } }
default ChannelQuery byKey(final String key) { return withPredicates(m -> m.key().is(key)); }
ChannelQueryImpl(){ super(ChannelEndpoint.ENDPOINT.endpoint(), ChannelQuery.resultTypeReference(), ChannelQueryModel.of(), ChannelExpansionModel.of(), ChannelQueryImpl::new); }
public QueryDsl<Channel> byKey(final String key) { return withPredicate(model().key().is(key)); }
static ChannelQueryModel get() { return new ChannelQueryModel(Optional.<QueryModel<Channel>>empty(), Optional.<String>empty()); }
public static ChannelQueryModel model() { return ChannelQueryModel.get(); }
public QueryDsl<Channel> byKey(final String key) { return withPredicate(model().key().is(key)); }
static ChannelQueryModel get() { return new ChannelQueryModel(Optional.<QueryModel<Channel>>empty(), Optional.<String>empty()); }
@Before @After public void cleanUp() throws Exception { final ChannelQuery query = ChannelQuery.of() .withPredicates(m -> m.key().isIn(asList("demo-key", "example-channel-key"))); final PagedQueryResult<Channel> queryResult = client().executeBlocking(query); queryResult.getResults().forEach(c -> client().executeBlocking(ChannelDeleteCommand.of(c))); }