This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch
3506-connect-static-property-type-cannot-be-changed-to-numeric-value
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to
refs/heads/3506-connect-static-property-type-cannot-be-changed-to-numeric-value
by this push:
new 9d6beaab9c fix(#3506): Fix edit adapter with add static and change
data type rule
9d6beaab9c is described below
commit 9d6beaab9c73fed694be16a2f700c8e36ce67331
Author: Philipp Zehnder <[email protected]>
AuthorDate: Wed Feb 26 11:27:28 2025 +0100
fix(#3506): Fix edit adapter with add static and change data type rule
---
.../convert/ToTransformedSchemaConverter.java | 6 ++++++
.../connect/rules/addNumericalStaticValue.spec.ts | 25 +++++++++++++++++++++-
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git
a/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/convert/ToTransformedSchemaConverter.java
b/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/convert/ToTransformedSchemaConverter.java
index 00dcd7cc43..2a677fb89f 100644
---
a/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/convert/ToTransformedSchemaConverter.java
+++
b/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/convert/ToTransformedSchemaConverter.java
@@ -122,6 +122,10 @@ public class ToTransformedSchemaConverter implements
ITransformationRuleVisitor,
public void visit(AddValueTransformationRuleDescription rule) {
var property = new EventPropertyPrimitive();
property.setElementId(STATIC_VALUE_ID_PREFIX + rule.getStaticValue());
+ var uniqueId = UUIDGenerator.generateUuid().substring(0, 10);
+
+ property.setElementId(STATIC_VALUE_ID_PREFIX + uniqueId + ":" +
rule.getStaticValue());
+
property.setRuntimeName(rule.getRuntimeKey());
property.setRuntimeType(rule.getDatatype());
property.setLabel(rule.getLabel());
@@ -137,6 +141,8 @@ public class ToTransformedSchemaConverter implements
ITransformationRuleVisitor,
this.properties.add(property);
}
+
+
@Override
public void visit(ChangeDatatypeTransformationRuleDescription rule) {
var property = findPrimitiveProperty(properties, rule.getRuntimeKey());
diff --git a/ui/cypress/tests/connect/rules/addNumericalStaticValue.spec.ts
b/ui/cypress/tests/connect/rules/addNumericalStaticValue.spec.ts
index 7dc03598a5..0745e6e247 100644
--- a/ui/cypress/tests/connect/rules/addNumericalStaticValue.spec.ts
+++ b/ui/cypress/tests/connect/rules/addNumericalStaticValue.spec.ts
@@ -20,6 +20,7 @@ import { ConnectUtils } from
'../../../support/utils/connect/ConnectUtils';
import { FileManagementUtils } from
'../../../support/utils/FileManagementUtils';
import { ConnectEventSchemaUtils } from
'../../../support/utils/connect/ConnectEventSchemaUtils';
import { DataLakeUtils } from '../../../support/utils/datalake/DataLakeUtils';
+import { ConnectBtns } from '../../../support/utils/connect/ConnectBtns';
describe('Connect schema rule transformations', () => {
beforeEach('Setup Test', () => {
@@ -31,7 +32,7 @@ describe('Connect schema rule transformations', () => {
'connect/addNumericalStaticValue/input.csv',
);
const adapterConfiguration =
- ConnectUtils.setUpPreprocessingRuleTest(true);
+ ConnectUtils.setUpPreprocessingRuleTest(false);
const newValueOne = 'newValueOne';
const newValueTwo = 'newValueTwo';
@@ -58,5 +59,27 @@ describe('Connect schema rule transformations', () => {
'cypress/fixtures/connect/addNumericalStaticValue/expected.json',
true,
);
+
+ ConnectUtils.goToConnect();
+ ConnectBtns.editAdapter().click();
+ // This waiting time is required to ensure that the file is loaded
correctly before the next button is clicked
+ cy.wait(1000);
+ ConnectBtns.nextBtn().click();
+
+ // Validate that the preview is correct
+
+ const expectedJsonPreview = {
+ newValueTwo: 2,
+ count: 122,
+ timestamp: 1720018277000,
+ newValueOne: 1,
+ };
+ ConnectEventSchemaUtils.schemaPreviewResultEvent().then($el => {
+ let jsonPreview = $el.text();
+ jsonPreview = jsonPreview.replace(/\s+/g, '');
+
+ const actualJson = JSON.parse(jsonPreview);
+ expect(actualJson).to.deep.equal(expectedJsonPreview);
+ });
});
});