diff --git a/hivemq-edge/src/test/java/com/hivemq/adapter/AdapterConfigModelTest.java b/hivemq-edge/src/test/java/com/hivemq/adapter/AdapterConfigModelTest.java index 8ceafb74b1..543cfafbdf 100644 --- a/hivemq-edge/src/test/java/com/hivemq/adapter/AdapterConfigModelTest.java +++ b/hivemq-edge/src/test/java/com/hivemq/adapter/AdapterConfigModelTest.java @@ -25,7 +25,7 @@ import com.google.common.base.Preconditions; import com.hivemq.edge.modules.adapters.annotations.ModuleConfigField; import com.hivemq.edge.modules.config.AdapterSubscription; -import com.hivemq.edge.modules.config.impl.AbstractPollingProtocolAdapterConfig; +import com.hivemq.edge.modules.config.CustomConfig; import com.hivemq.edge.modules.config.impl.AdapterSubscriptionImpl; import com.hivemq.edge.modules.config.impl.UserPropertyImpl; import com.hivemq.extension.sdk.api.annotations.NotNull; @@ -89,12 +89,17 @@ private static boolean hasImmediateChild(final @NotNull JsonNode parent, final @ return parent.get(nodeName) != null; } - static class AdapterConfiguration extends AbstractPollingProtocolAdapterConfig { + static class AdapterConfiguration implements CustomConfig { @JsonProperty("subscriptions") @ModuleConfigField(title = "Subscriptions", description = "List of subscriptions for the simulation", required = true) private @NotNull List subscriptions = new ArrayList<>(); + + @Override + public @NotNull String getId() { + return "id"; + } } } diff --git a/hivemq-edge/src/test/java/com/hivemq/adapter/SchemaNodeGeneratorTest.java b/hivemq-edge/src/test/java/com/hivemq/adapter/SchemaNodeGeneratorTest.java index 48315c4d7b..df442bd9c6 100644 --- a/hivemq-edge/src/test/java/com/hivemq/adapter/SchemaNodeGeneratorTest.java +++ b/hivemq-edge/src/test/java/com/hivemq/adapter/SchemaNodeGeneratorTest.java @@ -26,7 +26,7 @@ import com.hivemq.api.json.CustomConfigSchemaGenerator; import com.hivemq.edge.modules.adapters.annotations.ModuleConfigField; import com.hivemq.edge.modules.config.AdapterSubscription; -import com.hivemq.edge.modules.config.impl.AbstractProtocolAdapterConfig; +import com.hivemq.edge.modules.config.CustomConfig; import com.hivemq.extension.sdk.api.annotations.NotNull; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -36,6 +36,8 @@ import java.util.Iterator; import java.util.List; +import static com.hivemq.edge.HiveMQEdgeConstants.ID_REGEX; + /** * @author Simon L Johnson @@ -110,7 +112,17 @@ private static boolean hasImmediateChild(final @NotNull JsonNode parent, final @ } @JsonPropertyOrder({"startIdx", "endIdx"}) - static class TestOrderingConfig extends AbstractProtocolAdapterConfig { + static class TestOrderingConfig implements CustomConfig { + + @JsonProperty(value = "id", required = true) + @ModuleConfigField(title = "Identifier", + description = "Unique identifier for this protocol adapter", + format = ModuleConfigField.FieldType.IDENTIFIER, + required = true, + stringPattern = ID_REGEX, + stringMinLength = 1, + stringMaxLength = 1024) + protected @NotNull String id; @JsonProperty(value = "startIdx") @ModuleConfigField(title = "Start Index") @@ -119,9 +131,14 @@ static class TestOrderingConfig extends AbstractProtocolAdapterConfig { @JsonProperty(value = "endIdx") @ModuleConfigField(title = "End Index") int endIdx; + + @Override + public @NotNull String getId() { + return id; + } } - static class TestNestedEntity extends AbstractProtocolAdapterConfig { + static class TestNestedEntity implements CustomConfig { @JsonProperty("subscriptions") @ModuleConfigField(title = "Subscriptions", @@ -130,5 +147,20 @@ static class TestNestedEntity extends AbstractProtocolAdapterConfig { }) private @NotNull List subscriptions = new ArrayList<>(); + + @JsonProperty(value = "id", required = true) + @ModuleConfigField(title = "Identifier", + description = "Unique identifier for this protocol adapter", + format = ModuleConfigField.FieldType.IDENTIFIER, + required = true, + stringPattern = ID_REGEX, + stringMinLength = 1, + stringMaxLength = 1024) + protected @NotNull String id; + + @Override + public @NotNull String getId() { + return id; + } } } diff --git a/modules/hivemq-edge-module-http/src/test/java/com/hivemq/edge/adapters/http/HttpProtocolAdapterTest.java b/modules/hivemq-edge-module-http/src/test/java/com/hivemq/edge/adapters/http/HttpProtocolAdapterTest.java index 6a5f42a559..6e2702be56 100644 --- a/modules/hivemq-edge-module-http/src/test/java/com/hivemq/edge/adapters/http/HttpProtocolAdapterTest.java +++ b/modules/hivemq-edge-module-http/src/test/java/com/hivemq/edge/adapters/http/HttpProtocolAdapterTest.java @@ -69,7 +69,7 @@ void setUp() { @Test void test_captureDataSample_expectedPayloadPresent() throws ExecutionException, InterruptedException { final AdapterSubscription subscription = new AdapterSubscriptionImpl("topic", 2, null); - final HttpData httpData = new HttpData("http://localhost:8080", 200, "text/plain", new TestDataPointFactory()); + final HttpData httpData = new HttpData(new AdapterSubscriptionImpl(), "http://localhost:8080", 200, "text/plain", new TestDataPointFactory()); httpData.addDataPoint(RESPONSE_DATA, "hello world"); httpProtocolAdapter.poll().get(); @@ -82,8 +82,8 @@ void test_captureDataSample_expectedPayloadPresent() throws ExecutionException, @Test void test_captureDataSample_errorPayloadFormat() throws ExecutionException, InterruptedException { final AdapterSubscription subscription = new AdapterSubscriptionImpl("topic", 2, null); - final HttpData httpData = new HttpData("http://localhost:8080", 200, "text/plain", new TestDataPointFactory()); - final HttpData payload = new HttpData("http://localhost:8080", 404, "text/plain", new TestDataPointFactory()); + final HttpData httpData = new HttpData(new AdapterSubscriptionImpl(),"http://localhost:8080", 200, "text/plain", new TestDataPointFactory()); + final HttpData payload = new HttpData(new AdapterSubscriptionImpl(),"http://localhost:8080", 404, "text/plain", new TestDataPointFactory()); httpData.addDataPoint(RESPONSE_DATA, payload); httpProtocolAdapter.poll().get();