use of org.eclipse.ditto.json.JsonFieldSelector in project ditto by eclipse.
the class ThingQueryCommandAdapterTest method retrieveFeatureDesiredPropertiesWithFieldsToAdaptable.
@Test
public void retrieveFeatureDesiredPropertiesWithFieldsToAdaptable() {
final JsonFieldSelector selectedFields = JsonFieldSelector.newInstance("foo");
final TopicPath topicPath = topicPath(TopicPath.Action.RETRIEVE);
final JsonPointer path = JsonPointer.of("/features/" + TestConstants.FEATURE_ID + "/desiredProperties");
final Adaptable expected = Adaptable.newBuilder(topicPath).withPayload(Payload.newBuilder(path).withFields(selectedFields).build()).withHeaders(TestConstants.HEADERS_V_2).build();
final RetrieveFeatureDesiredProperties retrieveFeatureDesiredProperties = RetrieveFeatureDesiredProperties.of(TestConstants.THING_ID, TestConstants.FEATURE_ID, selectedFields, TestConstants.HEADERS_V_2_NO_CONTENT_TYPE);
final Adaptable actual = underTest.toAdaptable(retrieveFeatureDesiredProperties, channel);
assertWithExternalHeadersThat(actual).isEqualTo(expected);
}
use of org.eclipse.ditto.json.JsonFieldSelector in project ditto by eclipse.
the class ThingQueryCommandAdapterTest method retrieveThingWithFieldsFromAdaptable.
@Test
public void retrieveThingWithFieldsFromAdaptable() {
final JsonFieldSelector selectedFields = JsonFieldSelector.newInstance("thingId");
final RetrieveThing expected = RetrieveThing.getBuilder(TestConstants.THING_ID, TestConstants.DITTO_HEADERS_V_2).withSelectedFields(selectedFields).build();
final TopicPath topicPath = topicPath(TopicPath.Action.RETRIEVE);
final JsonPointer path = JsonPointer.empty();
final Adaptable adaptable = Adaptable.newBuilder(topicPath).withPayload(Payload.newBuilder(path).withFields(selectedFields).build()).withHeaders(TestConstants.HEADERS_V_2).build();
final ThingQueryCommand<?> actual = underTest.fromAdaptable(adaptable);
assertWithExternalHeadersThat(actual).isEqualTo(expected);
}
use of org.eclipse.ditto.json.JsonFieldSelector in project ditto by eclipse.
the class ThingQueryCommandAdapterTest method retrieveAttributesWithFieldsToAdaptable.
@Test
public void retrieveAttributesWithFieldsToAdaptable() {
final JsonFieldSelector selectedFields = JsonFieldSelector.newInstance("foo");
final TopicPath topicPath = topicPath(TopicPath.Action.RETRIEVE);
final JsonPointer path = JsonPointer.of("/attributes");
final Adaptable expected = Adaptable.newBuilder(topicPath).withPayload(Payload.newBuilder(path).withFields(selectedFields).build()).withHeaders(TestConstants.HEADERS_V_2).build();
final RetrieveAttributes retrieveAttributes = RetrieveAttributes.of(TestConstants.THING_ID, selectedFields, TestConstants.HEADERS_V_2_NO_CONTENT_TYPE);
final Adaptable actual = underTest.toAdaptable(retrieveAttributes, channel);
assertWithExternalHeadersThat(actual).isEqualTo(expected);
}
use of org.eclipse.ditto.json.JsonFieldSelector in project ditto by eclipse.
the class ThingQueryCommandAdapterTest method retrieveFeaturePropertiesWithFieldsToAdaptable.
@Test
public void retrieveFeaturePropertiesWithFieldsToAdaptable() {
final JsonFieldSelector selectedFields = JsonFieldSelector.newInstance("foo");
final TopicPath topicPath = topicPath(TopicPath.Action.RETRIEVE);
final JsonPointer path = JsonPointer.of("/features/" + TestConstants.FEATURE_ID + "/properties");
final Adaptable expected = Adaptable.newBuilder(topicPath).withPayload(Payload.newBuilder(path).withFields(selectedFields).build()).withHeaders(TestConstants.HEADERS_V_2).build();
final RetrieveFeatureProperties retrieveFeatureProperties = RetrieveFeatureProperties.of(TestConstants.THING_ID, TestConstants.FEATURE_ID, selectedFields, TestConstants.HEADERS_V_2_NO_CONTENT_TYPE);
final Adaptable actual = underTest.toAdaptable(retrieveFeatureProperties, channel);
assertWithExternalHeadersThat(actual).isEqualTo(expected);
}
use of org.eclipse.ditto.json.JsonFieldSelector in project ditto by eclipse.
the class ThingQueryCommandAdapterTest method retrieveFeatureDesiredPropertiesWithFieldsFromAdaptable.
@Test
public void retrieveFeatureDesiredPropertiesWithFieldsFromAdaptable() {
final JsonFieldSelector selectedFields = JsonFieldSelector.newInstance("foo");
final RetrieveFeatureDesiredProperties expected = RetrieveFeatureDesiredProperties.of(TestConstants.THING_ID, TestConstants.FEATURE_ID, selectedFields, TestConstants.DITTO_HEADERS_V_2);
final TopicPath topicPath = topicPath(TopicPath.Action.RETRIEVE);
final JsonPointer path = JsonPointer.of("/features/" + TestConstants.FEATURE_ID + "/desiredProperties");
final Adaptable adaptable = Adaptable.newBuilder(topicPath).withPayload(Payload.newBuilder(path).withFields(selectedFields).build()).withHeaders(TestConstants.HEADERS_V_2).build();
final ThingQueryCommand<?> actual = underTest.fromAdaptable(adaptable);
assertWithExternalHeadersThat(actual).isEqualTo(expected);
}
Aggregations