QueryThings extends AbstractCommand<QueryThings> implements ThingSearchQueryCommand<QueryThings> { public static QueryThings of(@Nullable final String filter, @Nullable final List<String> options, @Nullable final JsonFieldSelector fields, @Nullable final Set<String> namespaces, final DittoHeaders dittoHeaders) { return new QueryThings(dittoHeaders, filter, options, fields, namespaces); } private  QueryThings(final DittoHeaders dittoHeaders,
            @Nullable final String filter,
            @Nullable final List<String> options,
            @Nullable final JsonFieldSelector fields,
            @Nullable final Collection<String> namespaces); static QueryThings of(@Nullable final String filter, @Nullable final List<String> options,
            @Nullable final JsonFieldSelector fields, @Nullable final Set<String> namespaces,
            final DittoHeaders dittoHeaders); static QueryThings of(final DittoHeaders dittoHeaders); static QueryThings fromJson(final String jsonString, final DittoHeaders dittoHeaders); static QueryThings fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders); @Override Optional<String> getFilter(); Optional<List<String>> getOptions(); Optional<JsonFieldSelector> getFields(); @Override Optional<Set<String>> getNamespaces(); @Override QueryThings setNamespaces(@Nullable final Collection<String> namespaces); @Override QueryThings setDittoHeaders(final DittoHeaders dittoHeaders); @Override boolean equals(@Nullable final Object o); @Override int hashCode(); @Override String toString(); static final String NAME; static final String TYPE; }
@Test public void toJsonWithAllFieldsSetV2() { final QueryThings command = QueryThings.of(TestConstants.KNOWN_FILTER_STR, Arrays.asList(TestConstants.KNOWN_OPT_1, TestConstants.KNOWN_OPT_2), JsonFactory.newFieldSelector(KNOWN_FIELDS, TestConstants.JSON_PARSE_OPTIONS), TestConstants.KNOWN_NAMESPACES_SET, DittoHeaders.empty()); final String json = command.toJsonString(); assertThat(json).isEqualTo(JSON_ALL_FIELDS_V2); }
@Test public void toJsonWithAllFieldsSetV1() { final QueryThings command = QueryThings.of(TestConstants.KNOWN_FILTER_STR, Arrays.asList(TestConstants.KNOWN_OPT_1, TestConstants.KNOWN_OPT_2), JsonFactory.newFieldSelector(KNOWN_FIELDS, TestConstants.JSON_PARSE_OPTIONS), TestConstants.KNOWN_NAMESPACES_SET, DittoHeaders.empty()); final String json = command.toJsonString(JsonSchemaVersion.V_1, FieldType.regularOrSpecial()); assertThat(json).isEqualTo(JSON_ALL_FIELDS_V1); }
@Test public void toJsonWithOnlyRequiredFieldsSetV1() { final QueryThings command = QueryThings.of(DittoHeaders.empty()); final String json = command.toJsonString(JsonSchemaVersion.V_1, FieldType.regularOrSpecial()); assertThat(json).isEqualTo(JSON_MINIMAL_V1); }
@Test public void toJsonWithOnlyRequiredFieldsSetV2() { final QueryThings command = QueryThings.of(DittoHeaders.empty()); final String json = command.toJsonString(); assertThat(json).isEqualTo(JSON_MINIMAL_V2); }