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/27 14:57:46 UTC
[incubator-streampipes] branch STREAMPIPES-483 updated: [STREAMPIPES-483] Refactor schema and value rule tests
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
The following commit(s) were added to refs/heads/STREAMPIPES-483 by this push:
new 712c644 [STREAMPIPES-483] Refactor schema and value rule tests
712c644 is described below
commit 712c6448a3ef098eafcb4ffd9683200fbd0d987f
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Mon Dec 27 15:57:37 2021 +0100
[STREAMPIPES-483] Refactor schema and value rule tests
---
.../support/utils/ConnectEventSchemaUtils.ts | 37 +++++++++++
ui/cypress/support/utils/ConnectUtils.ts | 42 ++++++++++++
ui/cypress/tests/adapter/schemaRules.smoke.ts | 32 +--------
ui/cypress/tests/adapter/valueRules.smoke.ts | 77 +++-------------------
4 files changed, 91 insertions(+), 97 deletions(-)
diff --git a/ui/cypress/support/utils/ConnectEventSchemaUtils.ts b/ui/cypress/support/utils/ConnectEventSchemaUtils.ts
index f055b43..c42b932 100644
--- a/ui/cypress/support/utils/ConnectEventSchemaUtils.ts
+++ b/ui/cypress/support/utils/ConnectEventSchemaUtils.ts
@@ -47,6 +47,43 @@ export class ConnectEventSchemaUtils {
this.eventSchemaNextBtnEnabled();
}
+ public static editTimestampProperty(propertyName: string, timestampRegex: string) {
+ cy.dataCy('edit-' + propertyName.toLowerCase(), { timeout: 10000 }).click();
+ cy.dataCy('sp-mark-as-timestamp').children().click();
+ cy.dataCy('connect-timestamp-converter').click().get('mat-option').contains('String').click();
+ cy.dataCy('connect-timestamp-string-regex').type(timestampRegex);
+
+ cy.dataCy('sp-save-edit-property').click();
+
+ cy.dataCy('edit-' + propertyName.toLowerCase(), { timeout: 10000 }).click({ force: true });
+ cy.dataCy('connect-timestamp-string-regex', { timeout: 10000 }).should('have.value', timestampRegex);
+ cy.dataCy('sp-save-edit-property').click();
+ }
+
+ public static numberTransformation(propertyName: string, value: string) {
+ cy.dataCy('edit-' + propertyName.toLowerCase(), { timeout: 10000 }).click();
+ cy.dataCy('connect-schema-correction-value').type(value);
+ cy.dataCy('connect-schema-correction-operator').click().get('mat-option').contains('Multiply').click();
+
+ cy.dataCy('sp-save-edit-property').click();
+ cy.dataCy('edit-' + propertyName.toLowerCase(), { timeout: 10000 }).click({ force: true });
+ cy.dataCy('connect-schema-correction-value', { timeout: 10000 }).should('have.value', value);
+ cy.dataCy('sp-save-edit-property').click();
+ }
+
+ public static unitTransformation(propertyName: string, fromUnit: string, toUnit: string) {
+ cy.dataCy('edit-' + propertyName.toLowerCase(), { timeout: 10000 }).click();
+ cy.dataCy('connect-schema-unit-from-dropdown').type(fromUnit);
+ cy.dataCy('connect-schema-unit-transform-btn').click();
+ cy.dataCy('connect-schema-unit-to-dropdown').click().get('mat-option').contains(toUnit).click();
+ cy.dataCy('sp-save-edit-property').click();
+
+ // TODO fix check when editing
+ // cy.dataCy('edit-' + propertyName.toLowerCase(), { timeout: 10000 }).click({ force: true });
+ // cy.dataCy('connect-schema-unit-from-input', { timeout: 10000 }).should('have.value', fromUnit);
+ // cy.dataCy('connect-schema-unit-to-dropdown', { timeout: 10000 }).should('have.value', toUnit);
+ // cy.dataCy('sp-save-edit-property').click();
+ }
public static addStaticProperty(propertyName: string, propertyValue: string) {
// Click add a static value to event
diff --git a/ui/cypress/support/utils/ConnectUtils.ts b/ui/cypress/support/utils/ConnectUtils.ts
index 95fa713..0f45e99 100644
--- a/ui/cypress/support/utils/ConnectUtils.ts
+++ b/ui/cypress/support/utils/ConnectUtils.ts
@@ -23,6 +23,8 @@ import { GenericAdapterInput } from '../model/GenericAdapterInput';
import { SpecificAdapterBuilder } from '../builder/SpecificAdapterBuilder';
import { AdapterInput } from '../model/AdapterInput';
import { ConnectEventSchemaUtils } from './ConnectEventSchemaUtils';
+import { GenericAdapterBuilder } from '../builder/GenericAdapterBuilder';
+import { DataLakeUtils } from './DataLakeUtils';
export class ConnectUtils {
@@ -177,4 +179,44 @@ export class ConnectUtils {
cy.dataCy('delete', { timeout: 20000 }).should('have.length', 0);
// });
}
+
+ public static setUpPreprocessingRuleTest(): AdapterInput {
+ const adapterConfiguration = GenericAdapterBuilder
+ .create('File_Set')
+ .setStoreInDataLake()
+ .setTimestampProperty('timestamp')
+ .setName('Adapter to test rules')
+ .setFormat('csv')
+ .addFormatInput('input', 'delimiter', ';')
+ .addFormatInput('checkbox', 'header', 'check')
+ .build();
+
+
+ ConnectUtils.goToConnect();
+ ConnectUtils.selectAdapter(adapterConfiguration.adapterType);
+ ConnectUtils.configureAdapter(adapterConfiguration.protocolConfiguration);
+ ConnectUtils.configureFormat(adapterConfiguration);
+
+ // wait till schema is shown
+ cy.dataCy('sp-connect-schema-editor', { timeout: 60000 }).should('be.visible');
+
+ return adapterConfiguration;
+ }
+
+ public static tearDownPreprocessingRuleTest(adapterConfiguration: AdapterInput,
+ expectedFile: string,
+ ignoreTime: boolean) {
+ ConnectEventSchemaUtils.finishEventSchemaConfiguration();
+
+ ConnectUtils.startSetAdapter(adapterConfiguration);
+
+ // Wait till data is stored
+ cy.wait(10000);
+
+ DataLakeUtils.checkResults(
+ 'adaptertotestrules',
+ expectedFile,
+ ignoreTime);
+ }
+
}
diff --git a/ui/cypress/tests/adapter/schemaRules.smoke.ts b/ui/cypress/tests/adapter/schemaRules.smoke.ts
index 81d3c9b..01418dc 100644
--- a/ui/cypress/tests/adapter/schemaRules.smoke.ts
+++ b/ui/cypress/tests/adapter/schemaRules.smoke.ts
@@ -18,9 +18,7 @@
import { ConnectUtils } from '../../support/utils/ConnectUtils';
import { FileManagementUtils } from '../../support/utils/FileManagementUtils';
-import { GenericAdapterBuilder } from '../../support/builder/GenericAdapterBuilder';
import { ConnectEventSchemaUtils } from '../../support/utils/ConnectEventSchemaUtils';
-import { DataLakeUtils } from '../../support/utils/DataLakeUtils';
describe('Connect schema rule transformations', () => {
beforeEach('Setup Test', () => {
@@ -30,24 +28,7 @@ describe('Connect schema rule transformations', () => {
it('Perform Test', () => {
- const adapterConfiguration = GenericAdapterBuilder
- .create('File_Set')
- .setStoreInDataLake()
- .setTimestampProperty('timestamp')
- .setName('Adapter to test schema rules')
- .setFormat('csv')
- .addFormatInput('input', 'delimiter', ';')
- .addFormatInput('checkbox', 'header', 'check')
- .build();
-
-
- ConnectUtils.goToConnect();
- ConnectUtils.selectAdapter(adapterConfiguration.adapterType);
- ConnectUtils.configureAdapter(adapterConfiguration.protocolConfiguration);
- ConnectUtils.configureFormat(adapterConfiguration);
-
- // wait till schema is shown
- cy.dataCy('sp-connect-schema-editor', { timeout: 60000 }).should('be.visible');
+ const adapterConfiguration = ConnectUtils.setUpPreprocessingRuleTest();
// Add static value to event
ConnectEventSchemaUtils.addStaticProperty('staticPropertyName', 'id1');
@@ -61,17 +42,10 @@ describe('Connect schema rule transformations', () => {
// Add a timestamp property
ConnectEventSchemaUtils.addTimestampProperty();
- ConnectEventSchemaUtils.finishEventSchemaConfiguration();
-
- ConnectUtils.startSetAdapter(adapterConfiguration);
-
- // Wait till data is stored
- cy.wait(10000);
-
- DataLakeUtils.checkResults(
- 'adaptertotestschemarules',
+ ConnectUtils.tearDownPreprocessingRuleTest(adapterConfiguration,
'cypress/fixtures/connect/schemaRules/expected.csv',
true);
+
});
});
diff --git a/ui/cypress/tests/adapter/valueRules.smoke.ts b/ui/cypress/tests/adapter/valueRules.smoke.ts
index 8aea013..c73b578 100644
--- a/ui/cypress/tests/adapter/valueRules.smoke.ts
+++ b/ui/cypress/tests/adapter/valueRules.smoke.ts
@@ -18,11 +18,9 @@
import { ConnectUtils } from '../../support/utils/ConnectUtils';
import { FileManagementUtils } from '../../support/utils/FileManagementUtils';
-import { GenericAdapterBuilder } from '../../support/builder/GenericAdapterBuilder';
import { ConnectEventSchemaUtils } from '../../support/utils/ConnectEventSchemaUtils';
-import { DataLakeUtils } from '../../support/utils/DataLakeUtils';
-describe('Connect schema rule transformations', () => {
+describe('Connect value rule transformations', () => {
beforeEach('Setup Test', () => {
cy.initStreamPipesTest();
FileManagementUtils.addFile('connect/valueRules/input.csv');
@@ -30,78 +28,21 @@ describe('Connect schema rule transformations', () => {
it('Perform Test', () => {
- const adapterConfiguration = GenericAdapterBuilder
- .create('File_Set')
- .setStoreInDataLake()
- .setTimestampProperty('timestamp')
- .setName('Adapter to test schema rules')
- .setFormat('csv')
- .addFormatInput('input', 'delimiter', ';')
- .addFormatInput('checkbox', 'header', 'check')
- .build();
-
-
- ConnectUtils.goToConnect();
- ConnectUtils.selectAdapter(adapterConfiguration.adapterType);
- ConnectUtils.configureAdapter(adapterConfiguration.protocolConfiguration);
- ConnectUtils.configureFormat(adapterConfiguration);
-
- // wait till schema is shown
- cy.dataCy('sp-connect-schema-editor', { timeout: 60000 }).should('be.visible');
+ const adapterConfiguration = ConnectUtils.setUpPreprocessingRuleTest();
// Edit timestamp property
- let propertyName = 'timestamp';
- const timestampRegex = 'yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'';
- cy.dataCy('edit-' + propertyName.toLowerCase(), { timeout: 10000 }).click();
- cy.dataCy('sp-mark-as-timestamp').children().click();
- cy.dataCy('connect-timestamp-converter').click().get('mat-option').contains('String').click();
- cy.dataCy('connect-timestamp-string-regex').type(timestampRegex);
-
- cy.dataCy('sp-save-edit-property').click();
-
- cy.dataCy('edit-' + propertyName.toLowerCase(), { timeout: 10000 }).click({ force: true });
- cy.dataCy('connect-timestamp-string-regex', { timeout: 10000 }).should('have.value', timestampRegex);
- cy.dataCy('sp-save-edit-property').click();
-
+ ConnectEventSchemaUtils.editTimestampProperty('timestamp',
+ 'yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'');
// Number transformation
- propertyName = 'value';
- const value = '10';
- cy.dataCy('edit-' + propertyName.toLowerCase(), { timeout: 10000 }).click();
- cy.dataCy('connect-schema-correction-value').type(value);
- cy.dataCy('connect-schema-correction-operator').click().get('mat-option').contains('Multiply').click();
-
- cy.dataCy('sp-save-edit-property').click();
- cy.dataCy('edit-' + propertyName.toLowerCase(), { timeout: 10000 }).click({ force: true });
- cy.dataCy('connect-schema-correction-value', { timeout: 10000 }).should('have.value', value);
- cy.dataCy('sp-save-edit-property').click();
+ ConnectEventSchemaUtils.numberTransformation('value', '10');
// Unit transformation
- propertyName = 'temperature';
- const fromUnit = '';
- const toUnit = '';
- cy.dataCy('edit-' + propertyName.toLowerCase(), { timeout: 10000 }).click();
- cy.dataCy('connect-schema-unit-from-dropdown').type('Degree Celsius');
- cy.dataCy('connect-schema-unit-transform-btn').click();
- cy.dataCy('connect-schema-unit-to-dropdown').click().get('mat-option').contains('Degree Fahrenheit').click();
- cy.dataCy('sp-save-edit-property').click();
-
- // TODO fix check when editing
- // cy.dataCy('edit-' + propertyName.toLowerCase(), { timeout: 10000 }).click({ force: true });
- // cy.dataCy('connect-schema-unit-from-input', { timeout: 10000 }).should('have.value', 'Degree Celsius');
- // cy.dataCy('connect-schema-unit-to-dropdown', { timeout: 10000 }).should('have.value', 'Degree Fahrenheit');
- // cy.dataCy('sp-save-edit-property').click();
-
-
- ConnectEventSchemaUtils.finishEventSchemaConfiguration();
-
- ConnectUtils.startSetAdapter(adapterConfiguration);
-
- // Wait till data is stored
- cy.wait(10000);
+ ConnectEventSchemaUtils.unitTransformation('temperature',
+ 'Degree Celsius',
+ 'Degree Fahrenheit');
- DataLakeUtils.checkResults(
- 'adaptertotestschemarules',
+ ConnectUtils.tearDownPreprocessingRuleTest(adapterConfiguration,
'cypress/fixtures/connect/valueRules/expected.csv',
false);
});