This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch SP-1065
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to refs/heads/SP-1065 by this push:
new 609b3f379 [SP-1065] Add e2e test for csv format
609b3f379 is described below
commit 609b3f3793a5f420baadd408f2db1803eb876b0e
Author: Philipp Zehnder <[email protected]>
AuthorDate: Tue Jan 10 11:29:49 2023 +0100
[SP-1065] Add e2e test for csv format
---
.../connect/adapter/format/csv/CsvParser.java | 4 +-
.../fixtures/connect/format/csvWithComma.csv | 2 +
.../fixtures/connect/format/csvWithHeader.csv | 2 +
.../fixtures/connect/format/csvWithoutHeader.csv | 1 +
.../{format.smoke.spec.ts => format.spec.ts} | 64 ++++++++++++++++++++++
5 files changed, 71 insertions(+), 2 deletions(-)
diff --git
a/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/connect/adapter/format/csv/CsvParser.java
b/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/connect/adapter/format/csv/CsvParser.java
index 9cc68f6dc..a0a68d963 100644
---
a/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/connect/adapter/format/csv/CsvParser.java
+++
b/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/connect/adapter/format/csv/CsvParser.java
@@ -108,11 +108,11 @@ public class CsvParser extends Parser {
EventSchema resultSchema = new EventSchema();
for (int i = 0; i < keys.length; i++) {
EventPropertyPrimitive p = new EventPropertyPrimitive();
- var runtimeType = DatatypeUtils.getXsdDatatype(data[i], true);
+ var runtimeType = DatatypeUtils.getXsdDatatype(data[i], false);
var convertedValue = DatatypeUtils.convertValue(data[i], runtimeType);
p.setRuntimeName(keys[i]);
p.setRuntimeType(runtimeType);
- sample.put(keys[i], new
GuessTypeInfo(DatatypeUtils.getCanonicalTypeClassName(data[i], true),
convertedValue));
+ sample.put(keys[i], new
GuessTypeInfo(DatatypeUtils.getCanonicalTypeClassName(data[i], false),
convertedValue));
resultSchema.addEventProperty(p);
}
diff --git a/ui/cypress/fixtures/connect/format/csvWithComma.csv
b/ui/cypress/fixtures/connect/format/csvWithComma.csv
new file mode 100644
index 000000000..4074abda6
--- /dev/null
+++ b/ui/cypress/fixtures/connect/format/csvWithComma.csv
@@ -0,0 +1,2 @@
+timestamp,v1,v2,v3,v4
+1667904471000,4.1,"abc",true,1
diff --git a/ui/cypress/fixtures/connect/format/csvWithHeader.csv
b/ui/cypress/fixtures/connect/format/csvWithHeader.csv
new file mode 100644
index 000000000..bc3032b57
--- /dev/null
+++ b/ui/cypress/fixtures/connect/format/csvWithHeader.csv
@@ -0,0 +1,2 @@
+timestamp;v1;v2;v3;v4
+1667904471000;4.1;"abc";true;1
diff --git a/ui/cypress/fixtures/connect/format/csvWithoutHeader.csv
b/ui/cypress/fixtures/connect/format/csvWithoutHeader.csv
new file mode 100644
index 000000000..56c17007f
--- /dev/null
+++ b/ui/cypress/fixtures/connect/format/csvWithoutHeader.csv
@@ -0,0 +1 @@
+1667904471000;4.1;"abc";true;1
diff --git a/ui/cypress/tests/adapter/formats/format.smoke.spec.ts
b/ui/cypress/tests/adapter/formats/format.spec.ts
similarity index 69%
rename from ui/cypress/tests/adapter/formats/format.smoke.spec.ts
rename to ui/cypress/tests/adapter/formats/format.spec.ts
index df48f0cf7..08d2cab7f 100644
--- a/ui/cypress/tests/adapter/formats/format.smoke.spec.ts
+++ b/ui/cypress/tests/adapter/formats/format.spec.ts
@@ -115,6 +115,70 @@ describe('Test adapter formats', () => {
// Validate result
validateResult(expected);
});
+
+ it('Test csv format with header', () => {
+ // Set up test
+ FileManagementUtils.addFile(baseDir + 'csvWithHeader.csv');
+ navigateToFormatSelection();
+
+ // Set format configuration
+ ConnectBtns.csv().click();
+ const delimiterInputField = UserInputBuilder.create()
+ .add('input', 'delimiter', ';')
+ .build();
+ StaticPropertyUtils.input(delimiterInputField);
+ const headerInputField = UserInputBuilder.create()
+ .add('checkbox', 'header', 'check')
+ .build();
+ StaticPropertyUtils.input(headerInputField);
+
+ // Validate result
+ validateResult(expected);
+ });
+
+ it('Test csv format without header', () => {
+ // Set up test
+ FileManagementUtils.addFile(baseDir + 'csvWithoutHeader.csv');
+ navigateToFormatSelection();
+
+ // Set format configuration
+ ConnectBtns.csv().click();
+ const delimiterInputField = UserInputBuilder.create()
+ .add('input', 'delimiter', ';')
+ .build();
+ StaticPropertyUtils.input(delimiterInputField);
+
+ const expectedNoHeader = {
+ key_0: 1667904471000,
+ key_1: 4.1,
+ key_2: 'abc',
+ key_3: true,
+ key_4: 1,
+ };
+
+ // Validate result
+ validateResult(expectedNoHeader);
+ });
+
+ it('Test csv format with comma', () => {
+ // Set up test
+ FileManagementUtils.addFile(baseDir + 'csvWithComma.csv');
+ navigateToFormatSelection();
+
+ // Set format configuration
+ ConnectBtns.csv().click();
+ const delimiterInputField = UserInputBuilder.create()
+ .add('input', 'delimiter', ',')
+ .build();
+ StaticPropertyUtils.input(delimiterInputField);
+ const headerInputField = UserInputBuilder.create()
+ .add('checkbox', 'header', 'check')
+ .build();
+ StaticPropertyUtils.input(headerInputField);
+
+ // Validate result
+ validateResult(expected);
+ });
});
const navigateToFormatSelection = () => {