RetrieveThings extends AbstractCommand<RetrieveThings> implements ThingQueryCommand<RetrieveThings>, WithNamespace { @Deprecated public static Builder getBuilder(final String... thingIds) { final List<ThingId> thingIdList = Arrays.stream(checkNotNull(thingIds, "thing ids")) .map(ThingId::of) .collect(Collectors.toList()); return new Builder(thingIdList); } private  RetrieveThings(final Builder builder); private  RetrieveThings(final List<ThingId> thingIds,
            @Nullable final JsonFieldSelector selectedFields,
            @Nullable final String namespace,
            final DittoHeaders dittoHeaders); @Deprecated static Builder getBuilder(final String... thingIds); static Builder getBuilder(final ThingId... thingIds); static Builder getBuilder(final List<ThingId> thingIds); static Builder getBuilder(final RetrieveThings retrieveThings); static RetrieveThings fromJson(final String jsonString, final DittoHeaders dittoHeaders); static RetrieveThings fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders); @Deprecated List<String> getThingIds(); List<ThingId> getThingEntityIds(); @Override Optional<String> getNamespace(); @Override Optional<JsonFieldSelector> getSelectedFields(); @Override ThingId getThingEntityId(); @Override JsonPointer getResourcePath(); @Override RetrieveThings setDittoHeaders(final DittoHeaders dittoHeaders); @Override int hashCode(); @SuppressWarnings({"squid:MethodCyclomaticComplexity", "squid:S1067", "pmd:SimplifyConditional"}) @Override boolean equals(@Nullable final Object obj); @Override String toString(); static final String NAME; static final String TYPE; static final JsonFieldDefinition<JsonArray> JSON_THING_IDS; }
@Test public void toJsonReturnsExpectedWithNamespace() { final RetrieveThings underTest = RetrieveThings.getBuilder(getThingIdsWithDistinctNamespace()).namespace("example.com").build(); final JsonObject actualJson = underTest.toJson(FieldType.regularOrSpecial()); assertThat(actualJson).isEqualTo(KNOWN_JSON_WITH_DISTINCT_NAMESPACE); }
@Test public void checkRetrieveThingsWithEmptyJsonFieldSelectorBehavesEquallyAsOmittingFields() { final JsonFieldSelector selectedFields = JsonFactory.newFieldSelector(null, JSON_PARSE_OPTIONS); final RetrieveThings retrieveThings = RetrieveThings .getBuilder(TestConstants.Thing.THING_ID, ThingId.inDefaultNamespace("AnotherThingId")) .selectedFields(selectedFields) .build(); final RetrieveThings retrieveThings2 = RetrieveThings.getBuilder(TestConstants.Thing.THING_ID, ThingId.inDefaultNamespace("AnotherThingId")) .build(); assertThat(retrieveThings).isEqualTo(retrieveThings2); }
@Test(expected = NullPointerException.class) public void initializationWithNullForThingIdsArrayThrowsNullPointerException(){ RetrieveThings.getBuilder((ThingId[]) null).build(); }
@Test(expected = NullPointerException.class) public void initializationWithNullForThingIdsStringArrayThrowsNullPointerException(){ RetrieveThings.getBuilder((String[]) null).build(); }
@Test(expected = NullPointerException.class) public void initializationWithNullForThingIdsListThrowsNullPointerException(){ RetrieveThings.getBuilder((List<ThingId>) null).build(); }
@Test(expected = MissingThingIdsException.class) public void initializationWithoutThingIdsThrowsMissingThingIdsException(){ RetrieveThings.getBuilder(Collections.emptyList()).build(); }
@Test(expected = MissingThingIdsException.class) public void initializationWithEmptyThingIdsListThrowsMissingThingIdsException(){ RetrieveThings.getBuilder(new ArrayList<>()).build(); }