This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch STREAMPIPES-380
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git


The following commit(s) were added to refs/heads/STREAMPIPES-380 by this push:
     new 9f18f70  [STREAMPIPES-380] Adding support for json data files in 
automated tests
9f18f70 is described below

commit 9f18f707cec777dd78362c3a09d8ab5ef9071bb6
Author: Philipp Zehnder <[email protected]>
AuthorDate: Mon Jul 5 22:32:26 2021 +0200

    [STREAMPIPES-380] Adding support for json data files in automated tests
---
 .../splitArray1/description.json                   |  4 +-
 .../pipelineElement/SinglePipelineElement.ts       |  4 +-
 ui/cypress/plugins/index.ts                        | 16 +++++++-
 ui/cypress/support/model/ProcessorTest.ts          |  2 +
 .../support/utils/ProcessingElementTestUtils.ts    | 46 +++++++++++++---------
 .../static-mapping-nary.component.html             |  4 +-
 6 files changed, 50 insertions(+), 26 deletions(-)

diff --git 
a/ui/cypress/fixtures/pipelineElement/transformation-jvm/splitArray1/description.json
 
b/ui/cypress/fixtures/pipelineElement/transformation-jvm/splitArray1/description.json
index 31bf908..b2c3f2f 100644
--- 
a/ui/cypress/fixtures/pipelineElement/transformation-jvm/splitArray1/description.json
+++ 
b/ui/cypress/fixtures/pipelineElement/transformation-jvm/splitArray1/description.json
@@ -1,7 +1,7 @@
 {
  "name": "split_array",
  "config": [
-   {"type":  "radio", "selector": "keep", "value":  "timestamp"},
-   {"type":  "drop-down", "selector": "array-field", "value":  "arrayProperty"}
+   {"type":  "checkbox", "selector": "timestamp", "value":  "check"},
+   {"type":  "select", "selector": "array-field", "value":  "arrayProperty"}
  ]
 }
\ No newline at end of file
diff --git a/ui/cypress/integration/pipelineElement/SinglePipelineElement.ts 
b/ui/cypress/integration/pipelineElement/SinglePipelineElement.ts
index 767bee8..06f7c73 100644
--- a/ui/cypress/integration/pipelineElement/SinglePipelineElement.ts
+++ b/ui/cypress/integration/pipelineElement/SinglePipelineElement.ts
@@ -22,12 +22,12 @@ import { ProcessorTest } from 
'../../support/model/ProcessorTest';
 const allTests = Cypress.env('processingElements');
 
 allTests.forEach(test => {
-  const testName = 'projection1';
+  const testName = 'splitArray1';
 
   const processorTest = test as ProcessorTest;
 
   if (processorTest.name === testName) {
-    describe('Test Processor ' + test['name'], () => {
+    describe('Test Processor ' + test.dir, () => {
 
       it('Login', () => {
         cy.login();
diff --git a/ui/cypress/plugins/index.ts b/ui/cypress/plugins/index.ts
index bcd1c95..362ee93 100644
--- a/ui/cypress/plugins/index.ts
+++ b/ui/cypress/plugins/index.ts
@@ -35,15 +35,27 @@ function readProcessingElements(): ProcessorTest[] {
 
   const allPipelineTests = fs.readdirSync('cypress/fixtures/pipelineElement');
 
-  allPipelineTests.forEach(test => {
-    const testDescription = 
fs.readFileSync('cypress/fixtures/pipelineElement/' + test + 
'/description.json');
+  allPipelineTests.forEach(dir => {
+    const subfolder = fs.readdirSync('cypress/fixtures/pipelineElement/' + 
dir);
+    subfolder.forEach(test => {
+    const testDescription = 
fs.readFileSync('cypress/fixtures/pipelineElement/' + dir + '/' + test + 
'/description.json');
     // @ts-ignore
     const pt = new ProcessorTest();
     pt.name = test;
+    pt.dir = dir + '/' + test;
+
+    const configDir = fs.readdirSync('cypress/fixtures/pipelineElement/' + 
pt.dir );
+    configDir.forEach(file => {
+      if (file.startsWith('input')) {
+        pt.inputFile = file;
+      }
+    });
+
     // @ts-ignore
     pt.processor = JSON.parse(testDescription);
 
     result.push(pt);
+    });
   });
 
   return result;
diff --git a/ui/cypress/support/model/ProcessorTest.ts 
b/ui/cypress/support/model/ProcessorTest.ts
index bd6e40e..e53ac14 100644
--- a/ui/cypress/support/model/ProcessorTest.ts
+++ b/ui/cypress/support/model/ProcessorTest.ts
@@ -20,5 +20,7 @@ import { PipelineElementInput } from './PipelineElementInput';
 
 export class ProcessorTest {
   name: string;
+  dir: string;
+  inputFile: string;
   processor: PipelineElementInput;
 }
diff --git a/ui/cypress/support/utils/ProcessingElementTestUtils.ts 
b/ui/cypress/support/utils/ProcessingElementTestUtils.ts
index 30e9944..18930b5 100644
--- a/ui/cypress/support/utils/ProcessingElementTestUtils.ts
+++ b/ui/cypress/support/utils/ProcessingElementTestUtils.ts
@@ -29,11 +29,14 @@ import { ProcessorTest } from '../model/ProcessorTest';
 export class ProcessingElementTestUtils {
 
     public static testElement(pipelineElementTest: ProcessorTest) {
-    // public static testElement(testName: string, inputFile: string, 
expectedResultFile: string, processor: PipelineElementInput) {
+        // public static testElement(testName: string, inputFile: string, 
expectedResultFile: string, processor: PipelineElementInput) {
         // Test
 
-        const inputFile = 'pipelineElement/' + pipelineElementTest.name + 
'/input.csv';
-        const expectedResultFile = 'pipelineElement/' + 
pipelineElementTest.name + '/expected.csv';
+        const inputFile = 'pipelineElement/' + pipelineElementTest.dir + '/' + 
pipelineElementTest.inputFile;
+        const expectedResultFile = 'pipelineElement/' + 
pipelineElementTest.dir + '/expected.csv';
+
+        let formatType;
+        pipelineElementTest.inputFile.endsWith('.csv') ? formatType = 'csv' : 
formatType = 'json_array_no_key';
 
         FileManagementUtils.addFile(inputFile);
 
@@ -42,27 +45,32 @@ export class ProcessingElementTestUtils {
         const adapterName = pipelineElementTest.name.toLowerCase();
 
         // Build adapter
-        const adapterInput = GenericAdapterBuilder
-            .create('File_Set')
-            .setName(adapterName)
-            .setTimestampProperty('timestamp')
-            .addProtocolInput('input', 'interval-key', '0')
-            .setFormat('csv')
-            .addFormatInput('input', 'delimiter', ';')
-            .addFormatInput('checkbox', 'header', 'check')
-            .build();
+        const adapterInputBuilder = GenericAdapterBuilder
+          .create('File_Set')
+          .setName(adapterName)
+          .setTimestampProperty('timestamp')
+          .addProtocolInput('input', 'interval-key', '0')
+          .setFormat(formatType);
+
+        if (formatType === 'csv') {
+            adapterInputBuilder
+              .addFormatInput('input', 'delimiter', ';')
+              .addFormatInput('checkbox', 'header', 'check');
+        }
+
+        const adapterInput = adapterInputBuilder.build();
 
         AdapterUtils.addGenericSetAdapter(adapterInput);
 
         // Build Pipeline
         const pipelineInput = PipelineBuilder.create(pipelineElementTest.name)
-            .addSource(adapterName)
-            .addProcessingElement(pipelineElementTest.processor)
-            .addSink(
-                PipelineElementBuilder.create('data_lake')
-                    .addInput('input', 'db_measurement', dataLakeIndex)
-                    .build())
-            .build();
+          .addSource(adapterName)
+          .addProcessingElement(pipelineElementTest.processor)
+          .addSink(
+            PipelineElementBuilder.create('data_lake')
+              .addInput('input', 'db_measurement', dataLakeIndex)
+              .build())
+          .build();
 
         PipelineUtils.addPipeline(pipelineInput);
 
diff --git 
a/ui/src/app/core-ui/static-properties/static-mapping-nary/static-mapping-nary.component.html
 
b/ui/src/app/core-ui/static-properties/static-mapping-nary/static-mapping-nary.component.html
index cf3e607..0da1f11 100644
--- 
a/ui/src/app/core-ui/static-properties/static-mapping-nary/static-mapping-nary.component.html
+++ 
b/ui/src/app/core-ui/static-properties/static-mapping-nary/static-mapping-nary.component.html
@@ -25,7 +25,9 @@
             none</button>
     </div>
     <div fxFlex="100" fxLayout="column" style="margin-top:10px;">
-                <mat-checkbox *ngFor="let property of availableProperties | 
displayRecommendedPipe: staticProperty.propertyScope: displayRecommended" 
[(ngModel)]="property['checked']"
+                <mat-checkbox *ngFor="let property of availableProperties | 
displayRecommendedPipe: staticProperty.propertyScope: displayRecommended"
+                              [attr.data-cy]="property.runtimeName"
+                              [(ngModel)]="property['checked']"
                               (change)="selectOption(property, $event)"
                               style="margin-left: 10px;">
                     {{property.runtimeName}}

Reply via email to