This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch 2246-refactor-influxstore-class
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to
refs/heads/2246-refactor-influxstore-class by this push:
new f98fc0e25 refactor(#2246): Add unit tests for InfluxStore.onEvent
f98fc0e25 is described below
commit f98fc0e2524305e6cf555785b0f958b5cb4a8b6a
Author: Philipp Zehnder <[email protected]>
AuthorDate: Thu Nov 30 09:17:49 2023 +0100
refactor(#2246): Add unit tests for InfluxStore.onEvent
---
streampipes-data-explorer-commons/pom.xml | 12 +-
.../dataexplorer/commons/influx/InfluxStore.java | 117 +++++--
.../commons/influx/InfluxStoreTest.java | 388 +++++++++++++++++++++
...lder.java => EventPropertyListTestBuilder.java} | 31 +-
.../EventPropertyPrimitiveTestBuilder.java | 11 +
5 files changed, 507 insertions(+), 52 deletions(-)
diff --git a/streampipes-data-explorer-commons/pom.xml
b/streampipes-data-explorer-commons/pom.xml
index cfcbea0c2..0377e69c6 100644
--- a/streampipes-data-explorer-commons/pom.xml
+++ b/streampipes-data-explorer-commons/pom.xml
@@ -42,13 +42,23 @@
<artifactId>streampipes-commons</artifactId>
<version>0.95.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.streampipes</groupId>
+ <artifactId>streampipes-test-utils</artifactId>
+ <version>0.95.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
<!-- Others -->
<dependency>
diff --git
a/streampipes-data-explorer-commons/src/main/java/org/apache/streampipes/dataexplorer/commons/influx/InfluxStore.java
b/streampipes-data-explorer-commons/src/main/java/org/apache/streampipes/dataexplorer/commons/influx/InfluxStore.java
index 4abb33d67..a3337a9ae 100644
---
a/streampipes-data-explorer-commons/src/main/java/org/apache/streampipes/dataexplorer/commons/influx/InfluxStore.java
+++
b/streampipes-data-explorer-commons/src/main/java/org/apache/streampipes/dataexplorer/commons/influx/InfluxStore.java
@@ -50,20 +50,32 @@ public class InfluxStore {
private RawFieldSerializer rawFieldSerializer = new RawFieldSerializer();
- public InfluxStore(DataLakeMeasure measure,
- InfluxConnectionSettings settings) {
+ /**
+ * This constructor is used for testing purposes
+ */
+ public InfluxStore(
+ DataLakeMeasure measure,
+ InfluxDB influxDb
+ ) {
this.measure = measure;
- // store sanitized target property runtime names in local variable
- measure.getEventSchema()
- .getEventProperties()
- .forEach(ep -> sanitizedRuntimeNames.put(ep.getRuntimeName(),
- InfluxNameSanitizer.renameReservedKeywords(ep.getRuntimeName())));
+ this.influxDb = influxDb;
+ sanitizeMeasure(measure);
+ }
+
+ public InfluxStore(
+ DataLakeMeasure measure,
+ InfluxConnectionSettings settings
+ ) {
+ this.measure = measure;
+ sanitizeMeasure(measure);
connect(settings);
}
- public InfluxStore(DataLakeMeasure measure,
- Environment environment) throws SpRuntimeException {
+ public InfluxStore(
+ DataLakeMeasure measure,
+ Environment environment
+ ) throws SpRuntimeException {
this(measure, InfluxConnectionSettings.from(environment));
}
@@ -78,7 +90,8 @@ public class InfluxStore {
// Checking, if server is available
var response = influxDb.ping();
- if (response.getVersion().equalsIgnoreCase("unknown")) {
+ if (response.getVersion()
+ .equalsIgnoreCase("unknown")) {
throw new SpRuntimeException("Could not connect to InfluxDb Server: " +
settings.getConnectionUrl());
}
@@ -123,39 +136,49 @@ public class InfluxStore {
}
// sanitize event
- for (var key : event.getRaw().keySet()) {
- if (InfluxDbReservedKeywords.KEYWORD_LIST.stream().anyMatch(k ->
k.equalsIgnoreCase(key))) {
+ for (var key : event.getRaw()
+ .keySet()) {
+ if (InfluxDbReservedKeywords.KEYWORD_LIST.stream()
+ .anyMatch(k ->
k.equalsIgnoreCase(key))) {
event.renameFieldByRuntimeName(key, key + "_");
}
}
- var timestampValue =
event.getFieldBySelector(measure.getTimestampField()).getAsPrimitive().getAsLong();
+ var timestampValue = event.getFieldBySelector(measure.getTimestampField())
+ .getAsPrimitive()
+ .getAsLong();
var point =
- Point.measurement(measure.getMeasureName()).time((long)
timestampValue, TimeUnit.MILLISECONDS);
+ Point.measurement(measure.getMeasureName())
+ .time((long) timestampValue, TimeUnit.MILLISECONDS);
- for (var ep : measure.getEventSchema().getEventProperties()) {
+ for (var ep : measure.getEventSchema()
+ .getEventProperties()) {
var runtimeName = ep.getRuntimeName();
// timestamp should not be added as a field
- if (!measure.getTimestampField().endsWith(runtimeName)) {
+ if (!measure.getTimestampField()
+ .endsWith(runtimeName)) {
var sanitizedRuntimeName = sanitizedRuntimeNames.get(runtimeName);
var field = event.getOptionalFieldByRuntimeName(runtimeName);
try {
if (ep instanceof EventPropertyPrimitive) {
if (field.isPresent()) {
- var eventPropertyPrimitiveField = field.get().getAsPrimitive();
+ var eventPropertyPrimitiveField = field.get()
+ .getAsPrimitive();
if (eventPropertyPrimitiveField.getRawValue() == null) {
nullFields.add(sanitizedRuntimeName);
} else {
// store property as tag when the field is a dimension property
- if
(PropertyScope.DIMENSION_PROPERTY.name().equals(ep.getPropertyScope())) {
+ if (PropertyScope.DIMENSION_PROPERTY.name()
+
.equals(ep.getPropertyScope())) {
point.tag(sanitizedRuntimeName,
eventPropertyPrimitiveField.getAsString());
} else {
handleMeasurementProperty(
point,
(EventPropertyPrimitive) ep,
sanitizedRuntimeName,
- eventPropertyPrimitiveField);
+ eventPropertyPrimitiveField
+ );
}
}
} else {
@@ -172,15 +195,18 @@ public class InfluxStore {
}
} catch (SpRuntimeException iae) {
LOG.warn("Runtime exception while extracting field value of field {}
- this field will be ignored",
- runtimeName, iae);
+ runtimeName, iae
+ );
}
}
}
if (missingFields.size() > 0) {
- LOG.debug("Ignored {} fields which were present in the schema, but not
in the provided event: {}",
+ LOG.debug(
+ "Ignored {} fields which were present in the schema, but not in the
provided event: {}",
missingFields.size(),
- String.join(", ", missingFields));
+ String.join(", ", missingFields)
+ );
}
if (nullFields.size() > 0) {
@@ -190,30 +216,37 @@ public class InfluxStore {
influxDb.write(point.build());
}
- private void handleMeasurementProperty(Point.Builder p,
- @NotNull EventPropertyPrimitive ep,
- String preparedRuntimeName,
- PrimitiveField
eventPropertyPrimitiveField) {
+ private void handleMeasurementProperty(
+ Point.Builder p,
+ @NotNull EventPropertyPrimitive ep,
+ String preparedRuntimeName,
+ PrimitiveField eventPropertyPrimitiveField
+ ) {
try {
// Store property according to property type
var runtimeType = ep.getRuntimeType();
- if (XSD.INTEGER.toString().equals(runtimeType)) {
+ if (XSD.INTEGER.toString()
+ .equals(runtimeType)) {
try {
p.addField(preparedRuntimeName,
eventPropertyPrimitiveField.getAsInt());
} catch (NumberFormatException ef) {
p.addField(preparedRuntimeName,
eventPropertyPrimitiveField.getAsFloat());
}
- } else if (XSD.LONG.toString().equals(runtimeType)) {
+ } else if (XSD.LONG.toString()
+ .equals(runtimeType)) {
try {
p.addField(preparedRuntimeName,
eventPropertyPrimitiveField.getAsLong());
} catch (NumberFormatException ef) {
p.addField(preparedRuntimeName,
eventPropertyPrimitiveField.getAsFloat());
}
- } else if (XSD.FLOAT.toString().equals(runtimeType)) {
+ } else if (XSD.FLOAT.toString()
+ .equals(runtimeType)) {
p.addField(preparedRuntimeName,
eventPropertyPrimitiveField.getAsFloat());
- } else if (XSD.DOUBLE.toString().equals(runtimeType)) {
+ } else if (XSD.DOUBLE.toString()
+ .equals(runtimeType)) {
p.addField(preparedRuntimeName,
eventPropertyPrimitiveField.getAsDouble());
- } else if (XSD.BOOLEAN.toString().equals(runtimeType)) {
+ } else if (XSD.BOOLEAN.toString()
+ .equals(runtimeType)) {
p.addField(preparedRuntimeName,
eventPropertyPrimitiveField.getAsBoolean());
} else if (SO.NUMBER.equals(runtimeType)) {
p.addField(preparedRuntimeName,
eventPropertyPrimitiveField.getAsDouble());
@@ -225,9 +258,14 @@ public class InfluxStore {
}
}
- private void handleNonPrimitiveMeasurementProperty(Point.Builder p, Event
event, String preparedRuntimeName) {
+ private void handleNonPrimitiveMeasurementProperty(
+ Point.Builder p,
+ Event event,
+ String preparedRuntimeName
+ ) {
try {
- var json =
rawFieldSerializer.serialize(event.getRaw().get(preparedRuntimeName));
+ var json = rawFieldSerializer.serialize(event.getRaw()
+ .get(preparedRuntimeName));
p.addField(preparedRuntimeName, json);
} catch (SpRuntimeException e) {
LOG.warn("Failed to serialize field {}, ignoring.", preparedRuntimeName);
@@ -246,4 +284,17 @@ public class InfluxStore {
}
influxDb.close();
}
+
+
+ /**
+ * store sanitized target property runtime names in local variable
+ */
+ private void sanitizeMeasure(DataLakeMeasure measure) {
+ measure.getEventSchema()
+ .getEventProperties()
+ .forEach(ep -> sanitizedRuntimeNames.put(
+ ep.getRuntimeName(),
+ InfluxNameSanitizer.renameReservedKeywords(ep.getRuntimeName())
+ ));
+ }
}
diff --git
a/streampipes-data-explorer-commons/src/test/java/org/apache/streampipes/dataexplorer/commons/influx/InfluxStoreTest.java
b/streampipes-data-explorer-commons/src/test/java/org/apache/streampipes/dataexplorer/commons/influx/InfluxStoreTest.java
new file mode 100644
index 000000000..4659df1ff
--- /dev/null
+++
b/streampipes-data-explorer-commons/src/test/java/org/apache/streampipes/dataexplorer/commons/influx/InfluxStoreTest.java
@@ -0,0 +1,388 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.dataexplorer.commons.influx;
+
+
+import org.apache.streampipes.commons.exceptions.SpRuntimeException;
+import
org.apache.streampipes.dataexplorer.commons.influx.serializer.RawFieldSerializer;
+import org.apache.streampipes.model.datalake.DataLakeMeasure;
+import org.apache.streampipes.model.runtime.Event;
+import org.apache.streampipes.model.runtime.EventFactory;
+import org.apache.streampipes.model.runtime.SchemaInfo;
+import org.apache.streampipes.model.runtime.SourceInfo;
+import org.apache.streampipes.model.schema.EventSchema;
+import org.apache.streampipes.model.schema.PropertyScope;
+import org.apache.streampipes.test.generator.EventPropertyListTestBuilder;
+import org.apache.streampipes.test.generator.EventPropertyNestedTestBuilder;
+import org.apache.streampipes.test.generator.EventPropertyPrimitiveTestBuilder;
+import org.apache.streampipes.test.generator.EventSchemaTestBuilder;
+import org.apache.streampipes.vocabulary.SO;
+import org.apache.streampipes.vocabulary.XSD;
+
+import org.influxdb.InfluxDB;
+import org.influxdb.dto.Point;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public class InfluxStoreTest {
+
+ private InfluxDB influxDBMock;
+
+ private RawFieldSerializer serializer;
+
+ private static final String EXPECTED_MEASUREMENT = "testMeasure";
+ private static final String FIELD_NAME = "testId";
+ private static final String TIMESTAMP = "timestamp";
+ private static final long SAMPLE_TIMESTAMP = 1701270890000L;
+
+ @Before
+ public void setUp() {
+ influxDBMock = mock(InfluxDB.class);
+ serializer = new RawFieldSerializer();
+ }
+
+ @Test
+ public void onEventNull() {
+ var influxStore = getInfluxStore(new EventSchema());
+ assertThrows(SpRuntimeException.class, () -> influxStore.onEvent(null));
+ }
+
+
+ @Test
+ public void onEventWithInteger() {
+ var expected = getPointBuilderWithTimestamp()
+ .addField(FIELD_NAME, 1)
+ .build();
+
+ var actualPoint = testEventWithOneField(XSD.INTEGER, 1);
+
+ assertEquals(expected, actualPoint);
+ }
+
+ @Test
+ public void onEventWithIntegerFloatValue() {
+ var expected = getPointBuilderWithTimestamp()
+ .addField(FIELD_NAME, 1.0f)
+ .build();
+
+ var actualPoint = testEventWithOneField(XSD.INTEGER, 1.0f);
+
+ assertEquals(expected, actualPoint);
+ }
+
+ @Test
+ public void onEventWithLong() {
+ var expected = getPointBuilderWithTimestamp()
+ .addField(FIELD_NAME, 1L)
+ .build();
+
+ var actualPoint = testEventWithOneField(XSD.LONG, 1L);
+
+ assertEquals(expected, actualPoint);
+ }
+
+ @Test
+ public void onEventWithLongFloatValue() {
+ var expected = getPointBuilderWithTimestamp()
+ .addField(FIELD_NAME, 1.0f)
+ .build();
+
+ var actualPoint = testEventWithOneField(XSD.LONG, 1.0f);
+
+ assertEquals(expected, actualPoint);
+ }
+
+ @Test
+ public void onEventWithFloat() {
+ var expected = getPointBuilderWithTimestamp()
+ .addField(FIELD_NAME, 1.0f)
+ .build();
+
+ var actualPoint = testEventWithOneField(XSD.FLOAT, 1.0f);
+
+ assertEquals(expected, actualPoint);
+ }
+
+ @Test
+ public void onEventWithDouble() {
+ var expected = getPointBuilderWithTimestamp()
+ .addField(FIELD_NAME, 1.0)
+ .build();
+
+ var actualPoint = testEventWithOneField(XSD.DOUBLE, 1.0);
+
+ assertEquals(expected, actualPoint);
+ }
+
+ @Test
+ public void onEventWithBoolean() {
+ var expected = getPointBuilderWithTimestamp()
+ .addField(FIELD_NAME, true)
+ .build();
+
+ var actualPoint = testEventWithOneField(XSD.BOOLEAN, true);
+
+ assertEquals(expected, actualPoint);
+ }
+
+ @Test
+ public void onEventWithNumber() throws URISyntaxException {
+ var expected = getPointBuilderWithTimestamp()
+ .addField(FIELD_NAME, 1.0)
+ .build();
+
+ var actualPoint = testEventWithOneField(new URI(SO.NUMBER), 1.0);
+
+ assertEquals(expected, actualPoint);
+ }
+
+ @Test
+ public void onEventWithString() {
+ var expected = getPointBuilderWithTimestamp()
+ .addField(FIELD_NAME, "testValue")
+ .build();
+
+ var actualPoint = testEventWithOneField(XSD.STRING, "testValue");
+
+ assertEquals(expected, actualPoint);
+ }
+
+ @Test
+ public void onEventReservedKeyWord() {
+ // name is a reserved keyword
+ var fieldName = "name";
+ var sanitizedFieldName = "name_";
+ var value = 1;
+
+ var expected = getPointBuilderWithTimestamp()
+ .addField(sanitizedFieldName, value)
+ .build();
+
+ var eventSchema = getEventSchemaBuilderWithTimestamp()
+ .withEventProperty(
+ EventPropertyPrimitiveTestBuilder
+ .create()
+ .withRuntimeName(sanitizedFieldName)
+ .withRuntimeType(XSD.INTEGER)
+ .build())
+ .build();
+
+ var event = getEvent(eventSchema, Map.of(fieldName, value));
+
+ var influxStore = getInfluxStore(eventSchema);
+
+ var actualPoint = executeOnEvent(influxStore, event);
+
+ assertEquals(expected, actualPoint);
+ }
+
+ @Test
+ public void onEventWithTag() {
+ var expected = getPointBuilderWithTimestamp()
+ .addField(FIELD_NAME, "value")
+ .tag("id", "id1")
+ .build();
+
+ var eventSchema = getEventSchemaBuilderWithTimestamp()
+ .withEventProperty(
+ EventPropertyPrimitiveTestBuilder
+ .create()
+ .withRuntimeName(FIELD_NAME)
+ .withRuntimeType(XSD.STRING)
+ .build())
+ .withEventProperty(
+ EventPropertyPrimitiveTestBuilder
+ .create()
+ .withRuntimeName("id")
+ .withRuntimeType(XSD.STRING)
+ .withPropertyScope(PropertyScope.DIMENSION_PROPERTY)
+ .build())
+ .build();
+
+ var event = getEvent(eventSchema, Map.of(FIELD_NAME, "value", "id",
"id1"));
+
+ var influxStore = getInfluxStore(eventSchema);
+
+ var actualPoint = executeOnEvent(influxStore, event);
+
+ assertEquals(expected, actualPoint);
+ }
+
+
+ @Test
+ public void onEventWithNestedProperty() {
+ Map<String, Object> value = new HashMap<>();
+ value.put("one", "two");
+
+ var expected = getPointBuilderWithTimestamp()
+ .addField(FIELD_NAME, serializer.serialize(value))
+ .build();
+
+ var eventSchema = getEventSchemaBuilderWithTimestamp()
+ .withEventProperty(
+ EventPropertyNestedTestBuilder
+ .create()
+ .withRuntimeName(FIELD_NAME)
+ .build())
+ .build();
+
+ var event = getEvent(eventSchema, Map.of(FIELD_NAME, value));
+
+ var influxStore = getInfluxStore(eventSchema);
+
+ var actualPoint = executeOnEvent(influxStore, event);
+
+ assertEquals(expected, actualPoint);
+ }
+
+ @Test
+ public void onEventWithListProperty() {
+ String[] value = {"one", "two"};
+ var expected = getPointBuilderWithTimestamp()
+ .addField(FIELD_NAME, serializer.serialize(value))
+ .build();
+
+ var eventSchema = getEventSchemaBuilderWithTimestamp()
+ .withEventProperty(
+ EventPropertyListTestBuilder
+ .create()
+ .withRuntimeName(FIELD_NAME)
+ .build())
+ .build();
+
+ var event = getEvent(eventSchema, Map.of(FIELD_NAME, value));
+
+ var influxStore = getInfluxStore(eventSchema);
+
+ var actualPoint = executeOnEvent(influxStore, event);
+
+ assertEquals(expected, actualPoint);
+ }
+
+ /**
+ * Initialize a Point builder with a timestamp
+ */
+ private Point.Builder getPointBuilderWithTimestamp() {
+ return Point.measurement(EXPECTED_MEASUREMENT)
+ .time(SAMPLE_TIMESTAMP, TimeUnit.MILLISECONDS);
+ }
+
+
+ /**
+ * Executes the onEvent method and returns the resuting data point using an
argument captor
+ */
+ private Point executeOnEvent(InfluxStore influxStore, Event event) {
+ influxStore.onEvent(event);
+ var pointArgumentCaptor = ArgumentCaptor.forClass(Point.class);
+
+ verify(influxDBMock).write(pointArgumentCaptor.capture());
+
+ var actualPoint = pointArgumentCaptor.getValue();
+ return actualPoint;
+ }
+
+ /**
+ * Creates an event with the given data and a timestamp
+ */
+ private Event getEvent(EventSchema eventSchema, Map<String, Object>
inputData) {
+ Map<String, Object> data = new HashMap<>();
+ data.put(TIMESTAMP, SAMPLE_TIMESTAMP);
+ data.putAll(inputData);
+
+ return EventFactory.fromMap(
+ data,
+ new SourceInfo("test-topic", "s0"),
+ new SchemaInfo(eventSchema, new ArrayList<>())
+ );
+ }
+
+
+ /**
+ * This convenience method is used to test all cases for the different
supported data types
+ */
+ private Point testEventWithOneField(
+ URI type,
+ Object value
+ ) {
+
+ var eventSchema = getEventSchemaBuilderWithTimestamp()
+ .withEventProperty(
+ EventPropertyPrimitiveTestBuilder
+ .create()
+ .withRuntimeName(FIELD_NAME)
+ .withRuntimeType(type)
+ .build())
+ .build();
+
+
+ var event = EventFactory.fromMap(
+ Map.of(TIMESTAMP, SAMPLE_TIMESTAMP, FIELD_NAME, value),
+ new SourceInfo("test-topic", "s0"),
+ new SchemaInfo(eventSchema, new ArrayList<>())
+ );
+
+ var influxStore = getInfluxStore(eventSchema);
+
+ influxStore.onEvent(event);
+ var pointArgumentCaptor = ArgumentCaptor.forClass(Point.class);
+
+ verify(influxDBMock).write(pointArgumentCaptor.capture());
+ return pointArgumentCaptor.getValue();
+ }
+
+ /**
+ * Returns the event schema builder with a default timestamp property
+ */
+ private EventSchemaTestBuilder getEventSchemaBuilderWithTimestamp() {
+ return EventSchemaTestBuilder
+ .create()
+ .withEventProperty(
+ EventPropertyPrimitiveTestBuilder
+ .create()
+ .withRuntimeName(TIMESTAMP)
+ .build());
+ }
+
+ /**
+ * Initializes an influx store with the given event schema
+ */
+ private InfluxStore getInfluxStore(EventSchema eventSchema) {
+ DataLakeMeasure measure = new DataLakeMeasure(
+ EXPECTED_MEASUREMENT,
+ "s0::%s".formatted(TIMESTAMP),
+ eventSchema
+ );
+
+ return new InfluxStore(measure, influxDBMock);
+ }
+
+}
\ No newline at end of file
diff --git
a/streampipes-test-utils/src/main/java/org/apache/streampipes/test/generator/EventPropertyPrimitiveTestBuilder.java
b/streampipes-test-utils/src/main/java/org/apache/streampipes/test/generator/EventPropertyListTestBuilder.java
similarity index 55%
copy from
streampipes-test-utils/src/main/java/org/apache/streampipes/test/generator/EventPropertyPrimitiveTestBuilder.java
copy to
streampipes-test-utils/src/main/java/org/apache/streampipes/test/generator/EventPropertyListTestBuilder.java
index 8fd69330d..2ac224a05 100644
---
a/streampipes-test-utils/src/main/java/org/apache/streampipes/test/generator/EventPropertyPrimitiveTestBuilder.java
+++
b/streampipes-test-utils/src/main/java/org/apache/streampipes/test/generator/EventPropertyListTestBuilder.java
@@ -15,35 +15,30 @@
* limitations under the License.
*
*/
-package org.apache.streampipes.test.generator;
-import org.apache.streampipes.model.schema.EventPropertyPrimitive;
+package org.apache.streampipes.test.generator;
-import java.net.URI;
-import java.util.List;
+import org.apache.streampipes.model.schema.EventPropertyList;
-public class EventPropertyPrimitiveTestBuilder
- extends EventPropertyTestBuilder<EventPropertyPrimitive,
EventPropertyPrimitiveTestBuilder> {
+public class EventPropertyListTestBuilder
+ extends EventPropertyTestBuilder<EventPropertyList,
EventPropertyListTestBuilder> {
- protected EventPropertyPrimitiveTestBuilder() {
- super(new EventPropertyPrimitive());
+ protected EventPropertyListTestBuilder() {
+ super(new EventPropertyList());
}
- public EventPropertyPrimitiveTestBuilder withSemanticType(String
semanticType) {
- this.eventProperty.setDomainProperties(List.of(URI.create(semanticType)));
- return this;
+ public static EventPropertyNestedTestBuilder create() {
+ return new EventPropertyNestedTestBuilder();
}
- public static EventPropertyPrimitiveTestBuilder create() {
- return new EventPropertyPrimitiveTestBuilder();
+ @Override
+ protected EventPropertyListTestBuilder me() {
+ return this;
}
@Override
- public EventPropertyPrimitive build() {
+ public EventPropertyList build() {
return eventProperty;
}
- protected EventPropertyPrimitiveTestBuilder me() {
- return this;
- }
-}
+}
\ No newline at end of file
diff --git
a/streampipes-test-utils/src/main/java/org/apache/streampipes/test/generator/EventPropertyPrimitiveTestBuilder.java
b/streampipes-test-utils/src/main/java/org/apache/streampipes/test/generator/EventPropertyPrimitiveTestBuilder.java
index 8fd69330d..fc5c1babc 100644
---
a/streampipes-test-utils/src/main/java/org/apache/streampipes/test/generator/EventPropertyPrimitiveTestBuilder.java
+++
b/streampipes-test-utils/src/main/java/org/apache/streampipes/test/generator/EventPropertyPrimitiveTestBuilder.java
@@ -18,6 +18,7 @@
package org.apache.streampipes.test.generator;
import org.apache.streampipes.model.schema.EventPropertyPrimitive;
+import org.apache.streampipes.model.schema.PropertyScope;
import java.net.URI;
import java.util.List;
@@ -29,6 +30,16 @@ public class EventPropertyPrimitiveTestBuilder
super(new EventPropertyPrimitive());
}
+ public EventPropertyPrimitiveTestBuilder withRuntimeType(URI runtimeType) {
+ this.eventProperty.setRuntimeType(runtimeType.toString());
+ return this;
+ }
+
+ public EventPropertyPrimitiveTestBuilder withPropertyScope(PropertyScope
propertyScope) {
+ this.eventProperty.setPropertyScope(propertyScope.toString());
+ return this;
+ }
+
public EventPropertyPrimitiveTestBuilder withSemanticType(String
semanticType) {
this.eventProperty.setDomainProperties(List.of(URI.create(semanticType)));
return this;