AcknowledgementAdapter implements Adapter<Acknowledgement> { @Override public Adaptable toAdaptable(final Acknowledgement acknowledgement, final TopicPath.Channel channel) { if (DittoAcknowledgementLabel.contains(acknowledgement.getLabel())) { throw new DittoAcknowledgementLabelExternalUseForbiddenException(acknowledgement.getLabel()); } return Adaptable.newBuilder(getTopicPath(acknowledgement, channel)) .withPayload(getPayload(acknowledgement)) .withHeaders(getExternalHeaders(acknowledgement.getDittoHeaders())) .build(); } private  AcknowledgementAdapter(final HeaderTranslator headerTranslator); @Override Acknowledgement fromAdaptable(final Adaptable adaptable); @Override Adaptable toAdaptable(final Acknowledgement acknowledgement, final TopicPath.Channel channel); @Override Set<TopicPath.Group> getGroups(); @Override Set<TopicPath.Channel> getChannels(); @Override Set<TopicPath.Criterion> getCriteria(); @Override Set<TopicPath.Action> getActions(); @Override boolean isForResponses(); @Override boolean requiresSubject();  }
@Test public void acknowledgementToAdaptable() { final DittoHeaders dittoHeaders = DittoHeaders.newBuilder().randomCorrelationId().build(); final JsonValue customAckPayload = JsonObject.newBuilder().set("foo", "bar").build(); final HttpStatusCode status = HttpStatusCode.BAD_REQUEST; final Acknowledgement acknowledgement = ThingAcknowledgementFactory.newAcknowledgement(KNOWN_CUSTOM_LABEL, TestConstants.THING_ID, status, dittoHeaders, customAckPayload); final Adaptable expected = Adaptable.newBuilder(topicPathMyCustomAck) .withPayload(Payload.newBuilder(JsonPointer.empty()) .withValue(customAckPayload) .withStatus(status) .build()) .withHeaders(dittoHeaders) .build(); final Adaptable actual = underTest.toAdaptable(acknowledgement); assertWithExternalHeadersThat(actual).isEqualTo(expected); }