Search in sources :

Example 1 with TopicPath

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);
}
Also used : TopicPath(org.eclipse.ditto.protocol.TopicPath) DeleteFeatureDefinition(org.eclipse.ditto.things.model.signals.commands.modify.DeleteFeatureDefinition) JsonPointer(org.eclipse.ditto.json.JsonPointer) Adaptable(org.eclipse.ditto.protocol.Adaptable) ProtocolAdapterTest(org.eclipse.ditto.protocol.adapter.ProtocolAdapterTest) LiveTwinTest(org.eclipse.ditto.protocol.LiveTwinTest) Test(org.junit.Test)

Example 2 with TopicPath

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);
}
Also used : TopicPath(org.eclipse.ditto.protocol.TopicPath) ModifyAttribute(org.eclipse.ditto.things.model.signals.commands.modify.ModifyAttribute) JsonPointer(org.eclipse.ditto.json.JsonPointer) Adaptable(org.eclipse.ditto.protocol.Adaptable) ProtocolAdapterTest(org.eclipse.ditto.protocol.adapter.ProtocolAdapterTest) LiveTwinTest(org.eclipse.ditto.protocol.LiveTwinTest) Test(org.junit.Test)

Example 3 with TopicPath

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);
}
Also used : TopicPath(org.eclipse.ditto.protocol.TopicPath) DeleteAttributes(org.eclipse.ditto.things.model.signals.commands.modify.DeleteAttributes) JsonPointer(org.eclipse.ditto.json.JsonPointer) Adaptable(org.eclipse.ditto.protocol.Adaptable) ProtocolAdapterTest(org.eclipse.ditto.protocol.adapter.ProtocolAdapterTest) LiveTwinTest(org.eclipse.ditto.protocol.LiveTwinTest) Test(org.junit.Test)

Example 4 with TopicPath

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);
}
Also used : TopicPath(org.eclipse.ditto.protocol.TopicPath) ModifyThing(org.eclipse.ditto.things.model.signals.commands.modify.ModifyThing) JsonPointer(org.eclipse.ditto.json.JsonPointer) Adaptable(org.eclipse.ditto.protocol.Adaptable) ProtocolAdapterTest(org.eclipse.ditto.protocol.adapter.ProtocolAdapterTest) LiveTwinTest(org.eclipse.ditto.protocol.LiveTwinTest) Test(org.junit.Test)

Example 5 with TopicPath

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);
}
Also used : TopicPath(org.eclipse.ditto.protocol.TopicPath) DeleteAttributes(org.eclipse.ditto.things.model.signals.commands.modify.DeleteAttributes) JsonPointer(org.eclipse.ditto.json.JsonPointer) Adaptable(org.eclipse.ditto.protocol.Adaptable) ProtocolAdapterTest(org.eclipse.ditto.protocol.adapter.ProtocolAdapterTest) LiveTwinTest(org.eclipse.ditto.protocol.LiveTwinTest) Test(org.junit.Test)

Aggregations

TopicPath (org.eclipse.ditto.protocol.TopicPath)243 Test (org.junit.Test)222 Adaptable (org.eclipse.ditto.protocol.Adaptable)208 JsonPointer (org.eclipse.ditto.json.JsonPointer)207 ProtocolAdapterTest (org.eclipse.ditto.protocol.adapter.ProtocolAdapterTest)190 LiveTwinTest (org.eclipse.ditto.protocol.LiveTwinTest)164 JsonifiableAdaptable (org.eclipse.ditto.protocol.JsonifiableAdaptable)34 DittoHeaders (org.eclipse.ditto.base.model.headers.DittoHeaders)16 JsonFieldSelector (org.eclipse.ditto.json.JsonFieldSelector)15 JsonObject (org.eclipse.ditto.json.JsonObject)11 ModifyThing (org.eclipse.ditto.things.model.signals.commands.modify.ModifyThing)8 Payload (org.eclipse.ditto.protocol.Payload)7 ThingId (org.eclipse.ditto.things.model.ThingId)7 RetrieveThing (org.eclipse.ditto.things.model.signals.commands.query.RetrieveThing)4 Collections (java.util.Collections)3 Set (java.util.Set)3 CommandResponse (org.eclipse.ditto.base.model.signals.commands.CommandResponse)3 ExternalMessage (org.eclipse.ditto.connectivity.api.ExternalMessage)3 MessageDirection (org.eclipse.ditto.messages.model.MessageDirection)3 MessagePath (org.eclipse.ditto.protocol.MessagePath)3