Skip to content

Commit

Permalink
Removed bidirectional from http (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
codepitbull authored Dec 19, 2024
1 parent 5627715 commit 2e5bdfa
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
/**
* @author HiveMQ Adapter Generator
*/
public class HttpProtocolAdapter implements PollingProtocolAdapter, WritingProtocolAdapter {
public class HttpProtocolAdapter implements PollingProtocolAdapter {

private static final @NotNull Logger log = LoggerFactory.getLogger(HttpProtocolAdapter.class);

Expand Down Expand Up @@ -303,7 +303,7 @@ public int getMaxPollingErrorsBeforeRemoval() {
return adapterConfig.getHttpToMqttConfig().getMaxPollingErrorsBeforeRemoval();
}

@Override
//Deactivated for now
public void write(final @NotNull WritingInput writingInput, final @NotNull WritingOutput writingOutput) {
if (httpClient == null) {
writingOutput.fail(new ProtocolAdapterException(), "No response was created, because the client is null.");
Expand Down Expand Up @@ -373,11 +373,6 @@ public void createTagSchema(
output.finish(JsonSchema.createJsonSchema());
}

@Override
public @NotNull Class<? extends WritingPayload> getMqttPayloadClass() {
return HttpPayload.class;
}

private static boolean isSuccessStatusCode(final int statusCode) {
return statusCode >= 200 && statusCode <= 299;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.hivemq.adapter.sdk.api.ProtocolAdapterTag;
import com.hivemq.adapter.sdk.api.config.ProtocolSpecificAdapterConfig;
import com.hivemq.adapter.sdk.api.tag.Tag;
import com.hivemq.edge.adapters.http.config.BidirectionalHttpSpecificAdapterConfig;
import com.hivemq.edge.adapters.http.config.HttpSpecificAdapterConfig;
import com.hivemq.edge.adapters.http.tag.HttpTag;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -131,6 +130,6 @@ public List<ProtocolAdapterTag> getTags() {

@Override
public @NotNull Class<? extends ProtocolSpecificAdapterConfig> configurationClassNorthAndSouthbound() {
return BidirectionalHttpSpecificAdapterConfig.class;
return HttpSpecificAdapterConfig.class;
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
import com.hivemq.configuration.reader.ConfigFileReaderWriter;
import com.hivemq.configuration.reader.ConfigurationFile;
import com.hivemq.edge.adapters.http.HttpProtocolAdapterFactory;
import com.hivemq.edge.adapters.http.config.HttpSpecificAdapterConfig.HttpHeader;
import com.hivemq.edge.adapters.http.config.http2mqtt.HttpToMqttConfig;
import com.hivemq.edge.adapters.http.config.mqtt2http.MqttToHttpConfig;
import com.hivemq.edge.adapters.http.config.mqtt2http.MqttToHttpMapping;
import com.hivemq.edge.adapters.http.tag.HttpTag;
import com.hivemq.exceptions.UnrecoverableException;
import com.hivemq.persistence.mappings.NorthboundMapping;
Expand Down Expand Up @@ -93,8 +90,8 @@ public void convertConfigObject_defaults() throws Exception {
final HttpProtocolAdapterFactory httpProtocolAdapterFactory =
new HttpProtocolAdapterFactory(mockInput);

final BidirectionalHttpSpecificAdapterConfig config =
(BidirectionalHttpSpecificAdapterConfig)httpProtocolAdapterFactory.convertConfigObject(mapper, adapter.getConfig(), true);
final HttpSpecificAdapterConfig config =
(HttpSpecificAdapterConfig)httpProtocolAdapterFactory.convertConfigObject(mapper, adapter.getConfig(), true);

final List<Map<String, Object>> tagMaps =
adapter.getTags().stream().map(tagEntity -> tagEntity.toMap()).collect(Collectors.toList());
Expand Down Expand Up @@ -153,7 +150,7 @@ public void convertConfigObject_emptyHeaders() throws Exception {
assertThat(protocolAdapterConfig.missingTags())
.isEmpty();

final BidirectionalHttpSpecificAdapterConfig config = (BidirectionalHttpSpecificAdapterConfig) protocolAdapterConfig.getAdapterConfig();
final HttpSpecificAdapterConfig config = (HttpSpecificAdapterConfig) protocolAdapterConfig.getAdapterConfig();

assertThat(protocolAdapterConfig.getAdapterId()).isEqualTo("my-protocol-adapter");
assertThat(config.getHttpConnectTimeoutSeconds()).isEqualTo(50);
Expand Down Expand Up @@ -182,7 +179,7 @@ public void convertConfigObject_full() throws Exception {
assertThat(protocolAdapterConfig.missingTags())
.isEmpty();

final BidirectionalHttpSpecificAdapterConfig config = (BidirectionalHttpSpecificAdapterConfig) protocolAdapterConfig.getAdapterConfig();
final HttpSpecificAdapterConfig config = (HttpSpecificAdapterConfig) protocolAdapterConfig.getAdapterConfig();

assertThat(protocolAdapterConfig.getAdapterId()).isEqualTo("my-protocol-adapter");
assertThat(config.getHttpToMqttConfig().isHttpPublishSuccessStatusCodeOnly()).isTrue();
Expand Down Expand Up @@ -281,37 +278,14 @@ public void convertConfigObject_full() throws Exception {
@Test
public void unconvertConfigObject_full() throws Exception {

final BidirectionalHttpSpecificAdapterConfig httpAdapterConfig = new BidirectionalHttpSpecificAdapterConfig(
final HttpSpecificAdapterConfig httpAdapterConfig = new HttpSpecificAdapterConfig(
50,
new HttpToMqttConfig(
1337,
11,
true,
true
),
new MqttToHttpConfig(List.of(
new MqttToHttpMapping(
"tag3",
"my0/#",
1,
POST,
12,
List.of(
new HttpHeader("foo 1", "bar 1"),
new HttpHeader("foo 2", "bar 2")
)
),
new MqttToHttpMapping(
"tag4",
"my1/#",
2,
POST,
11,
List.of(
new HttpHeader("foo 1", "bar 1"),
new HttpHeader("foo 2", "bar 2")
)
))),
true
);

Expand Down Expand Up @@ -345,23 +319,14 @@ public void unconvertConfigObject_full() throws Exception {
@Test
public void unconvertConfigObject_defaults() {

final BidirectionalHttpSpecificAdapterConfig httpAdapterConfig = new BidirectionalHttpSpecificAdapterConfig(
final HttpSpecificAdapterConfig httpAdapterConfig = new HttpSpecificAdapterConfig(
null,
new HttpToMqttConfig(
null,
null,
null,
null
),
new MqttToHttpConfig(List.of(
new MqttToHttpMapping(
"tag1",
"my/#",
null,
null,
null,
null
))),
null
);

Expand Down

0 comments on commit 2e5bdfa

Please sign in to comment.