use of org.eclipse.ditto.protocol.TopicPath in project ditto by eclipse.
the class ThingModifyCommandAdapterTest method deleteFeatureDefinitionFromAdaptable.
@Test
public void deleteFeatureDefinitionFromAdaptable() {
final DeleteFeatureDefinition expected = DeleteFeatureDefinition.of(TestConstants.THING_ID, TestConstants.FEATURE_ID, TestConstants.DITTO_HEADERS_V_2);
final TopicPath topicPath = topicPath(TopicPath.Action.DELETE);
final JsonPointer path = JsonPointer.of("/features/" + TestConstants.FEATURE_ID + "/definition");
final Adaptable adaptable = Adaptable.newBuilder(topicPath).withPayload(Payload.newBuilder(path).build()).withHeaders(TestConstants.HEADERS_V_2).build();
final ThingModifyCommand<?> actual = underTest.fromAdaptable(adaptable);
assertWithExternalHeadersThat(actual).isEqualTo(expected);
}
use of org.eclipse.ditto.protocol.TopicPath in project ditto by eclipse.
the class ThingModifyCommandAdapterTest method modifyAttributeFromAdaptable.
@Test
public void modifyAttributeFromAdaptable() {
final ModifyAttribute expected = ModifyAttribute.of(TestConstants.THING_ID, TestConstants.ATTRIBUTE_POINTER, TestConstants.ATTRIBUTE_VALUE, TestConstants.DITTO_HEADERS_V_2);
final TopicPath topicPath = topicPath(TopicPath.Action.MODIFY);
final JsonPointer path = JsonPointer.of("/attributes" + TestConstants.ATTRIBUTE_POINTER);
final Adaptable adaptable = Adaptable.newBuilder(topicPath).withPayload(Payload.newBuilder(path).withValue(TestConstants.ATTRIBUTE_VALUE).build()).withHeaders(TestConstants.HEADERS_V_2).build();
final ThingModifyCommand<?> actual = underTest.fromAdaptable(adaptable);
assertWithExternalHeadersThat(actual).isEqualTo(expected);
}
use of org.eclipse.ditto.protocol.TopicPath in project ditto by eclipse.
the class ThingModifyCommandAdapterTest method deleteAttributesToAdaptable.
@Test
public void deleteAttributesToAdaptable() {
final TopicPath topicPath = topicPath(TopicPath.Action.DELETE);
final JsonPointer path = JsonPointer.of("/attributes");
final Adaptable expected = Adaptable.newBuilder(topicPath).withPayload(Payload.newBuilder(path).build()).withHeaders(TestConstants.HEADERS_V_2).build();
final DeleteAttributes deleteAttributes = DeleteAttributes.of(TestConstants.THING_ID, TestConstants.HEADERS_V_2_NO_CONTENT_TYPE);
final Adaptable actual = underTest.toAdaptable(deleteAttributes, channel);
assertWithExternalHeadersThat(actual).isEqualTo(expected);
}
use of org.eclipse.ditto.protocol.TopicPath in project ditto by eclipse.
the class ThingModifyCommandAdapterTest method modifyThingFromAdaptableWithPolicyIdToCopy.
@Test
public void modifyThingFromAdaptableWithPolicyIdToCopy() {
final String policyIdToCopy = "someNameSpace:someId";
final ModifyThing expected = ModifyThing.of(TestConstants.THING_ID, TestConstants.THING, null, policyIdToCopy, TestConstants.DITTO_HEADERS_V_2);
final TopicPath topicPath = topicPath(TopicPath.Action.MODIFY);
final JsonPointer path = JsonPointer.empty();
final Adaptable adaptable = Adaptable.newBuilder(topicPath).withPayload(Payload.newBuilder(path).withValue(TestConstants.THING.toJson(FieldType.regularOrSpecial()).set(ModifyThing.JSON_COPY_POLICY_FROM, policyIdToCopy)).build()).withHeaders(TestConstants.HEADERS_V_2).build();
final ThingModifyCommand<?> actual = underTest.fromAdaptable(adaptable);
assertWithExternalHeadersThat(actual).isEqualTo(expected);
}
use of org.eclipse.ditto.protocol.TopicPath in project ditto by eclipse.
the class ThingModifyCommandAdapterTest method deleteAttributesFromAdaptable.
@Test
public void deleteAttributesFromAdaptable() {
final DeleteAttributes expected = DeleteAttributes.of(TestConstants.THING_ID, TestConstants.DITTO_HEADERS_V_2);
final TopicPath topicPath = topicPath(TopicPath.Action.DELETE);
final JsonPointer path = JsonPointer.of("/attributes");
final Adaptable adaptable = Adaptable.newBuilder(topicPath).withPayload(Payload.newBuilder(path).build()).withHeaders(TestConstants.HEADERS_V_2).build();
final ThingModifyCommand<?> actual = underTest.fromAdaptable(adaptable);
assertWithExternalHeadersThat(actual).isEqualTo(expected);
}
Aggregations