You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2021/12/13 07:05:24 UTC

[incubator-streampipes] branch STREAMPIPES-483 created (now 560fca8)

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

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


      at 560fca8  [STREAMPIPES-483] Provide E2E tests for preprocessing rules within the adapter

This branch includes the following new commits:

     new 560fca8  [STREAMPIPES-483] Provide E2E tests for preprocessing rules within the adapter

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[incubator-streampipes] 01/01: [STREAMPIPES-483] Provide E2E tests for preprocessing rules within the adapter

Posted by ze...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 560fca8120a5498f7e31183a16a4a497054bb746
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Mon Dec 13 08:04:59 2021 +0100

    [STREAMPIPES-483] Provide E2E tests for preprocessing rules within the adapter
---
 ui/cypress/support/utils/AdapterUtils.ts           | 10 +--
 .../adapter/machineDataSimulator.smoke.spec.ts     |  9 ++-
 ui/cypress/tests/adapter/schemaRules.smoke.ts      | 76 ++++++++++++++++++++++
 ui/package.json                                    |  4 +-
 .../event-schema/event-schema.component.html       | 11 +++-
 .../schema-editor-header.component.html            | 17 +++--
 .../edit-event-property-primitive.component.html   |  8 ++-
 .../edit-event-property-primitive.component.ts     | 10 ++-
 .../edit-event-property.component.html             |  6 +-
 9 files changed, 124 insertions(+), 27 deletions(-)

diff --git a/ui/cypress/support/utils/AdapterUtils.ts b/ui/cypress/support/utils/AdapterUtils.ts
index ec84372..7eaadff 100644
--- a/ui/cypress/support/utils/AdapterUtils.ts
+++ b/ui/cypress/support/utils/AdapterUtils.ts
@@ -107,12 +107,12 @@ export class AdapterUtils {
     cy.visit('#/connect');
   }
 
-  private static selectAdapter(name) {
+  public static selectAdapter(name) {
     // Select adapter
     cy.get('#' + name).click();
   }
 
-  private static configureAdapter(configs: UserInput[]) {
+  public static configureAdapter(configs: UserInput[]) {
 
     StaticPropertyUtils.input(configs);
 
@@ -157,13 +157,13 @@ export class AdapterUtils {
     cy.get('#event-schema-next-button').parent().should('not.be.disabled');
   }
 
-  private static finishEventSchemaConfiguration() {
+  public static finishEventSchemaConfiguration() {
     // Click next
     cy.dataCy('sp-connect-schema-editor', { timeout: 10000 }).should('be.visible');
     cy.get('#event-schema-next-button').click();
   }
 
-  private static startStreamAdapter(adapterInput: AdapterInput) {
+  public static startStreamAdapter(adapterInput: AdapterInput) {
     AdapterUtils.startAdapter(adapterInput, 'sp-connect-adapter-live-preview');
   }
 
@@ -171,7 +171,7 @@ export class AdapterUtils {
     AdapterUtils.startAdapter(adapterInput, 'sp-connect-adapter-set-success');
   }
 
-  private static startAdapter(adapterInput: AdapterInput, successElement) {
+  public static startAdapter(adapterInput: AdapterInput, successElement) {
     // Set adapter name
     cy.dataCy('sp-adapter-name').type(adapterInput.adapterName);
 
diff --git a/ui/cypress/tests/adapter/machineDataSimulator.smoke.spec.ts b/ui/cypress/tests/adapter/machineDataSimulator.smoke.spec.ts
index bd70350..9353cc3 100644
--- a/ui/cypress/tests/adapter/machineDataSimulator.smoke.spec.ts
+++ b/ui/cypress/tests/adapter/machineDataSimulator.smoke.spec.ts
@@ -26,16 +26,15 @@ describe('Test Random Data Simulator Stream Adapter', () => {
 
   it('Perform Test', () => {
     const adapterInput = SpecificAdapterBuilder
-      .create('Machine_Data_Simulator')
-      .setName('Machine Data Simulator Test')
-      .addInput('input', 'wait-time-ms', '1000')
-      .build();
+        .create('Machine_Data_Simulator')
+        .setName('Machine Data Simulator Test')
+        .addInput('input', 'wait-time-ms', '1000')
+        .build();
 
 
     cy.visit('#/connect');
     AdapterUtils.testSpecificStreamAdapter(adapterInput);
     AdapterUtils.deleteAdapter();
-
   });
 
 });
diff --git a/ui/cypress/tests/adapter/schemaRules.smoke.ts b/ui/cypress/tests/adapter/schemaRules.smoke.ts
new file mode 100644
index 0000000..a922e73
--- /dev/null
+++ b/ui/cypress/tests/adapter/schemaRules.smoke.ts
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ *
+ */
+
+import { AdapterUtils } from '../../support/utils/AdapterUtils';
+import { SpecificAdapterBuilder } from '../../support/builder/SpecificAdapterBuilder';
+
+describe('Test Random Data Simulator Stream Adapter', () => {
+    beforeEach('Setup Test', () => {
+        cy.initStreamPipesTest();
+    });
+
+    it('Perform Test', () => {
+
+        const adapterConfiguration = SpecificAdapterBuilder
+            .create('Machine_Data_Simulator')
+            .setName('Machine Data Simulator Test')
+            .addInput('input', 'wait-time-ms', '1000')
+            .build();
+
+
+        AdapterUtils.goToConnect();
+
+        AdapterUtils.selectAdapter(adapterConfiguration.adapterType);
+
+        AdapterUtils.configureAdapter(adapterConfiguration.adapterConfiguration);
+
+        // wait till schema is shown
+
+       cy.dataCy('sp-connect-schema-editor', { timeout: 60000 }).should('be.visible');
+
+        // Add fixed property
+
+        // Click add a static value to event
+        cy.dataCy('connect-add-static-property', { timeout: 10000 }).click();
+
+        // Edit new property
+        const propertyName = 'staticPropertyName';
+        const propertyValue = 'id1';
+        cy.dataCy('edit-key_0', { timeout: 10000 }).click();
+
+        cy.dataCy('connect-edit-field-runtime-name', { timeout: 10000 })
+            .type('{backspace}{backspace}{backspace}{backspace}{backspace}' + propertyName);
+        cy.dataCy('connect-edit-field-static-value', { timeout: 10000 }).type(propertyValue);
+
+        cy.dataCy('sp-save-edit-property').click();
+
+        // validate that static value is persisted
+        cy.dataCy('edit-' + propertyName, { timeout: 10000 }).click();
+        cy.dataCy('connect-edit-field-static-value', { timeout: 10000 }).should('have.value', propertyValue);
+        cy.dataCy('sp-save-edit-property').click();
+
+        AdapterUtils.finishEventSchemaConfiguration();
+
+        AdapterUtils.startAdapter(adapterConfiguration, 'sp-connect-adapter-live-preview');
+
+        // Add timestamp
+        // Delete
+        // Change data type
+    });
+
+});
diff --git a/ui/package.json b/ui/package.json
index 640862b..1063438 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -111,8 +111,8 @@
     "copy-webpack-plugin": "^5.1.2",
     "css-loader": "^0.28.11",
     "csv-string": "4.0.1",
-    "cypress": "^7.7.0",
-    "cypress-file-upload": "5.0.7",
+    "cypress": "^9.1.1",
+    "cypress-file-upload": "^5.0.8",
     "extract-text-webpack-plugin": "^3.0.2",
     "file-loader": "^1.1.6",
     "html-webpack-plugin": "^3.2.0",
diff --git a/ui/src/app/connect/components/schema-editor/event-schema/event-schema.component.html b/ui/src/app/connect/components/schema-editor/event-schema/event-schema.component.html
index d422367..3077edf 100644
--- a/ui/src/app/connect/components/schema-editor/event-schema/event-schema.component.html
+++ b/ui/src/app/connect/components/schema-editor/event-schema/event-schema.component.html
@@ -43,8 +43,15 @@
                     *ngIf="isError">
             </sp-error-message>
 
-            <div *ngIf="!isError && !isLoading" fxLayout="column" fxLayoutAlign="space-evenly stretched" class="drag-drop-tree" data-cy="sp-connect-schema-editor">
-                <tree-root #tree [nodes]="nodes" [options]="options" (updateData)="onUpdateData(tree)">
+            <div *ngIf="!isError && !isLoading"
+                 fxLayout="column"
+                 fxLayoutAlign="space-evenly stretched"
+                 class="drag-drop-tree"
+                 data-cy="sp-connect-schema-editor">
+                <tree-root #tree
+                           [nodes]="nodes"
+                           [options]="options"
+                           (updateData)="onUpdateData(tree)">
                     <ng-template #treeNodeTemplate let-node let-index="index">
                         <event-property-row
                                 [node]="node"
diff --git a/ui/src/app/connect/components/schema-editor/schema-editor-header/schema-editor-header.component.html b/ui/src/app/connect/components/schema-editor/schema-editor-header/schema-editor-header.component.html
index bd19b4d..b3cae9a 100644
--- a/ui/src/app/connect/components/schema-editor/schema-editor-header/schema-editor-header.component.html
+++ b/ui/src/app/connect/components/schema-editor/schema-editor-header/schema-editor-header.component.html
@@ -19,18 +19,27 @@
 <div fxLayout="row">
     <div fxLayoutAlign="space-between center" class="add-schema" fxFlex="0 1 100%">
         <div>
-            <button color="primary" mat-button (click)=addNestedProperty()>
+            <button color="primary"
+                    mat-button
+                    data-cy="connect-add-nested-property"
+                    (click)=addNestedProperty()>
                 <mat-icon matTooltip="Add a Nested Property">queue</mat-icon>
             </button>
-            <button color="primary" mat-button
+            <button color="primary"
+                    mat-button
+                    data-cy="connect-add-static-property"
                     (click)="addStaticValueProperty()">
                 <mat-icon matTooltip="Add a static value to event">add</mat-icon>
             </button>
-            <button color="primary" mat-button
+            <button color="primary"
+                    mat-button
+                    data-cy="connect-add-timestamp-property"
                     (click)=addTimestampProperty()>
                 <mat-icon matTooltip="Add timestamp to event schema">access_time</mat-icon>
             </button>
-            <button color="primary" mat-button (click)=guessSchema()>
+            <button color="primary"
+                    mat-button
+                    (click)=guessSchema()>
                 <mat-icon matTooltip="Refresh Schema">refresh</mat-icon>
             </button>
             <!--            <button color="primary" mat-button (click)=togglePreview()>-->
diff --git a/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.html b/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.html
index 533dc0d..def4039 100644
--- a/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.html
+++ b/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.html
@@ -37,9 +37,13 @@
 
     <div fxLayout="row" fxLayoutAlign="start" *ngIf="addedByUser">
         <mat-form-field  class="doubleWidth">
-            <input matInput placeholder="Static Value" name="static_value" id="static_value"
+            <input matInput
+                   placeholder="Static Value"
+                   name="static_value"
+                   id="static_value"
+                   data-cy="connect-edit-field-static-value"
                 [(ngModel)]="cachedProperty.staticValue">
         </mat-form-field>
     </div>
 
-</div>
\ No newline at end of file
+</div>
diff --git a/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.ts b/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.ts
index d9388ae..7f50bb7 100644
--- a/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.ts
+++ b/ui/src/app/connect/dialog/edit-event-property/components/edit-event-property-primitive/edit-event-property-primitive.component.ts
@@ -41,7 +41,9 @@ export class EditEventPropertyPrimitiveComponent implements OnInit {
   ngOnInit(): void {
     this.setShowUnitTransformation();
     this.addedByUser = this.staticValueAddedByUser();
-    this.cachedProperty.staticValue = '';
+    if (!this.cachedProperty.staticValue) {
+      this.cachedProperty.staticValue = '';
+    }
   }
 
   setShowUnitTransformation() {
@@ -56,11 +58,7 @@ export class EditEventPropertyPrimitiveComponent implements OnInit {
   }
 
   staticValueAddedByUser() {
-    if (this.cachedProperty.elementId.startsWith('http://eventProperty.de/staticValue/')) {
-      return true;
-    } else {
-      return false;
-    }
+    return this.cachedProperty.elementId.startsWith('http://eventProperty.de/staticValue/');
   }
 
 }
diff --git a/ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.html b/ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.html
index f7f278d..5168be5 100644
--- a/ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.html
+++ b/ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.html
@@ -27,7 +27,11 @@
       </div>
       <div attr.id="input-runtime-name-{{cachedProperty.label}}" class="form-group" fxFlexAlign="center">
         <mat-form-field class="example-full-width" color="accent">
-          <input matInput placeholder="RuntimeName" name="runtimename" id="runtimename"
+          <input matInput
+                 placeholder="RuntimeName"
+                 name="runtimename"
+                 id="runtimename"
+                 data-cy="connect-edit-field-runtime-name"
             [(ngModel)]="cachedProperty.runtimeName">
         </mat-form-field>
       </div>