RetrieveThing extends AbstractCommand<RetrieveThing> implements ThingQueryCommand<RetrieveThing> { @Deprecated public static Builder getBuilder(final CharSequence thingId, final DittoHeaders dittoHeaders) { return getBuilder(ThingId.of(thingId), dittoHeaders); } private  RetrieveThing(final Builder builder); @Deprecated static RetrieveThing of(final CharSequence thingId, final DittoHeaders dittoHeaders); static RetrieveThing of(final ThingId thingId, final DittoHeaders dittoHeaders); @Deprecated static Builder getBuilder(final CharSequence thingId, final DittoHeaders dittoHeaders); static Builder getBuilder(final ThingId thingId, final DittoHeaders dittoHeaders); static RetrieveThing fromJson(final String jsonString, final DittoHeaders dittoHeaders); static RetrieveThing fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders); @Override Optional<JsonFieldSelector> getSelectedFields(); @Override ThingId getThingEntityId(); @Override JsonPointer getResourcePath(); @Override RetrieveThing setDittoHeaders(final DittoHeaders dittoHeaders); @Nonnull Optional<Long> getSnapshotRevision(); @Override int hashCode(); @SuppressWarnings({"squid:MethodCyclomaticComplexity", "squid:S1067", "OverlyComplexMethod"}) @Override boolean equals(@Nullable final Object obj); @Override String toString(); static final String NAME; static final String TYPE; }
@SuppressWarnings("ConstantConditions") @Test public void tryToGetBuilderWithNullThingId() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> RetrieveThing.getBuilder(null, DittoHeaders.empty())) .withNoCause(); }
@SuppressWarnings("ConstantConditions") @Test public void tryToGetBuilderWithNullDittoHeaders() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> RetrieveThing.getBuilder(TestConstants.Thing.THING_ID, null)) .withNoCause(); }
@Test public void jsonSerializationWorksAsExpectedWithSelectedFields() { final RetrieveThing underTest = RetrieveThing.getBuilder(TestConstants.Thing.THING_ID, DittoHeaders.empty()) .withSelectedFields(JSON_FIELD_SELECTOR) .build(); final JsonObject actualJson = underTest.toJson(FieldType.regularOrSpecial()); assertThat(actualJson).isEqualTo(KNOWN_JSON_WITH_FIELD_SELECTION); }
@Test public void jsonSerializationWithSnapshotRevisionWorksAsExpected() { final RetrieveThing underTest = RetrieveThing.getBuilder(TestConstants.Thing.THING_ID, DittoHeaders.empty()) .withSnapshotRevision(SNAPSHOT_REVISION) .build(); final JsonObject actualJson = underTest.toJson(FieldType.regularOrSpecial()); assertThat(actualJson).isEqualTo(KNOWN_JSON_WITH_SNAPSHOT_REVISION); }