@finos/legend-application-studio 26.1.8 → 26.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js +2 -2
- package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js.map +1 -1
- package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.d.ts +15 -2
- package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.js +46 -5
- package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.js.map +1 -1
- package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.js +18 -3
- package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.js.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_NewSchemaSetDriver.d.ts.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_NewSchemaSetDriver.js +2 -2
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_NewSchemaSetDriver.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingEditor.js +0 -3
- package/lib/components/editor/editor-group/mapping-editor/MappingEditor.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js +36 -72
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js.map +1 -1
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestDataEditor.d.ts +5 -0
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestDataEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestDataEditor.js +53 -8
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestDataEditor.js.map +1 -1
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestableEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestableEditor.js +3 -1
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestableEditor.js.map +1 -1
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.js +7 -3
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.js.map +1 -1
- package/lib/components/editor/editor-group/testable/TestableSharedComponents.js +1 -1
- package/lib/components/editor/editor-group/testable/TestableSharedComponents.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +3 -3
- package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.d.ts +22 -1
- package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.js +56 -5
- package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts +12 -12
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js +113 -61
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.d.ts +4 -2
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js +23 -9
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts +5 -2
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.js +23 -16
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.d.ts +3 -2
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js +11 -7
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.d.ts +3 -2
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js +29 -8
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.d.ts +2 -2
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.js +8 -6
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.d.ts +14 -2
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js +75 -5
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js.map +1 -1
- package/lib/stores/editor/utils/MockDataUtils.d.ts +4 -1
- package/lib/stores/editor/utils/MockDataUtils.d.ts.map +1 -1
- package/lib/stores/editor/utils/MockDataUtils.js +70 -2
- package/lib/stores/editor/utils/MockDataUtils.js.map +1 -1
- package/lib/stores/editor/utils/TestableUtils.d.ts +1 -2
- package/lib/stores/editor/utils/TestableUtils.d.ts.map +1 -1
- package/lib/stores/editor/utils/TestableUtils.js +4 -13
- package/lib/stores/editor/utils/TestableUtils.js.map +1 -1
- package/lib/stores/graph-modifier/DSL_Data_GraphModifierHelper.d.ts +6 -2
- package/lib/stores/graph-modifier/DSL_Data_GraphModifierHelper.d.ts.map +1 -1
- package/lib/stores/graph-modifier/DSL_Data_GraphModifierHelper.js +23 -4
- package/lib/stores/graph-modifier/DSL_Data_GraphModifierHelper.js.map +1 -1
- package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.js +1 -1
- package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.js.map +1 -1
- package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.d.ts +1 -0
- package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.d.ts.map +1 -1
- package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.js +3 -0
- package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.js.map +1 -1
- package/package.json +13 -13
- package/src/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.tsx +13 -0
- package/src/components/editor/editor-group/data-editor/EmbeddedDataEditor.tsx +129 -3
- package/src/components/editor/editor-group/data-editor/RelationalCSVDataEditor.tsx +65 -0
- package/src/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_NewSchemaSetDriver.tsx +6 -3
- package/src/components/editor/editor-group/mapping-editor/MappingEditor.tsx +0 -6
- package/src/components/editor/editor-group/mapping-editor/MappingTestableEditor.tsx +159 -366
- package/src/components/editor/editor-group/service-editor/testable/ServiceTestDataEditor.tsx +187 -61
- package/src/components/editor/editor-group/service-editor/testable/ServiceTestableEditor.tsx +26 -18
- package/src/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.tsx +85 -83
- package/src/components/editor/editor-group/testable/TestableSharedComponents.tsx +2 -2
- package/src/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.ts +75 -4
- package/src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.ts +157 -69
- package/src/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.ts +45 -10
- package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.ts +37 -15
- package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.ts +15 -8
- package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.ts +57 -6
- package/src/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.ts +10 -6
- package/src/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.ts +92 -3
- package/src/stores/editor/utils/MockDataUtils.ts +109 -1
- package/src/stores/editor/utils/TestableUtils.ts +4 -19
- package/src/stores/graph-modifier/DSL_Data_GraphModifierHelper.ts +45 -6
- package/src/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.ts +1 -1
- package/src/stores/graph-modifier/STO_Relational_GraphModifierHelper.ts +6 -0
@@ -20,6 +20,7 @@ import {
|
|
20
20
|
type PlainObject,
|
21
21
|
assertErrorThrown,
|
22
22
|
guaranteeType,
|
23
|
+
returnUndefOnError,
|
23
24
|
} from '@finos/legend-shared';
|
24
25
|
import type { EditorStore } from '../../../EditorStore.js';
|
25
26
|
import {
|
@@ -33,16 +34,19 @@ import { ServiceRegistrationState } from '../../../editor-state/element-editor-s
|
|
33
34
|
import { ElementEditorState } from '../../../editor-state/element-editor-state/ElementEditorState.js';
|
34
35
|
import {
|
35
36
|
type PackageableElement,
|
36
|
-
type
|
37
|
+
type ValueSpecification,
|
37
38
|
Service,
|
38
39
|
PureSingleExecution,
|
39
40
|
PureMultiExecution,
|
40
|
-
PureExecution,
|
41
41
|
isStubbed_RawLambda,
|
42
|
+
getValueSpecificationReturnType,
|
43
|
+
type Type,
|
44
|
+
resolveServiceQueryRawLambda,
|
42
45
|
} from '@finos/legend-graph';
|
43
46
|
import { ServiceTestableState } from './testable/ServiceTestableState.js';
|
44
47
|
import { User } from '@finos/legend-server-sdlc';
|
45
48
|
import { ServicePostValidationsState } from './ServicePostValidationState.js';
|
49
|
+
import { valueSpecReturnTDS } from '@finos/legend-query-builder';
|
46
50
|
|
47
51
|
export enum SERVICE_TAB {
|
48
52
|
GENERAL = 'GENERAL',
|
@@ -52,6 +56,45 @@ export enum SERVICE_TAB {
|
|
52
56
|
POST_VALIDATION = 'POST_VALIDATION',
|
53
57
|
}
|
54
58
|
|
59
|
+
export const resolveServiceQueryValueSpec = (
|
60
|
+
service: Service,
|
61
|
+
editorStore: EditorStore,
|
62
|
+
): ValueSpecification | undefined => {
|
63
|
+
const rawLambda = resolveServiceQueryRawLambda(service);
|
64
|
+
if (rawLambda) {
|
65
|
+
return editorStore.graphManagerState.graphManager.buildValueSpecification(
|
66
|
+
editorStore.graphManagerState.graphManager.serializeRawValueSpecification(
|
67
|
+
rawLambda,
|
68
|
+
),
|
69
|
+
editorStore.graphManagerState.graph,
|
70
|
+
);
|
71
|
+
}
|
72
|
+
return undefined;
|
73
|
+
};
|
74
|
+
|
75
|
+
export const resolveServiceQueryReturnType = (
|
76
|
+
service: Service,
|
77
|
+
editorStore: EditorStore,
|
78
|
+
): Type | undefined => {
|
79
|
+
const valueSpec = resolveServiceQueryValueSpec(service, editorStore);
|
80
|
+
if (valueSpec) {
|
81
|
+
return returnUndefOnError(() => getValueSpecificationReturnType(valueSpec));
|
82
|
+
}
|
83
|
+
return undefined;
|
84
|
+
};
|
85
|
+
|
86
|
+
export const isServiceQueryTDS = (
|
87
|
+
service: Service,
|
88
|
+
editorStore: EditorStore,
|
89
|
+
): boolean => {
|
90
|
+
const valueSpec = resolveServiceQueryValueSpec(service, editorStore);
|
91
|
+
return Boolean(
|
92
|
+
valueSpec
|
93
|
+
? valueSpecReturnTDS(valueSpec, editorStore.graphManagerState.graph)
|
94
|
+
: undefined,
|
95
|
+
);
|
96
|
+
};
|
97
|
+
|
55
98
|
export const MINIMUM_SERVICE_OWNERS = 2;
|
56
99
|
export class ServiceEditorState extends ElementEditorState {
|
57
100
|
executionState: ServiceExecutionState;
|
@@ -146,14 +189,6 @@ export class ServiceEditorState extends ElementEditorState {
|
|
146
189
|
);
|
147
190
|
}
|
148
191
|
|
149
|
-
get serviceQuery(): RawLambda | undefined {
|
150
|
-
const execution = this.service.execution;
|
151
|
-
if (execution instanceof PureExecution) {
|
152
|
-
return execution.func;
|
153
|
-
}
|
154
|
-
return undefined;
|
155
|
-
}
|
156
|
-
|
157
192
|
*searchUsers(name: string): GeneratorFn<User[]> {
|
158
193
|
try {
|
159
194
|
return (
|
package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.ts
CHANGED
@@ -34,6 +34,8 @@ import {
|
|
34
34
|
ConnectionPointer,
|
35
35
|
reportGraphAnalytics,
|
36
36
|
observe_ValueSpecification,
|
37
|
+
getAllIdentifiedConnectionsFromRuntime,
|
38
|
+
getAllIdentifiedServiceConnections,
|
37
39
|
} from '@finos/legend-graph';
|
38
40
|
import {
|
39
41
|
type GeneratorFn,
|
@@ -44,7 +46,6 @@ import {
|
|
44
46
|
guaranteeNonNullable,
|
45
47
|
returnUndefOnError,
|
46
48
|
getNullableFirstEntry,
|
47
|
-
uniq,
|
48
49
|
} from '@finos/legend-shared';
|
49
50
|
import { action, flow, flowResult, makeObservable, observable } from 'mobx';
|
50
51
|
import type { EditorStore } from '../../../../EditorStore.js';
|
@@ -55,7 +56,6 @@ import {
|
|
55
56
|
import {
|
56
57
|
TEMPORARY__createRelationalDataFromCSV,
|
57
58
|
EmbeddedDataConnectionTypeVisitor,
|
58
|
-
getAllIdentifiedConnectionsFromRuntime,
|
59
59
|
TEMPORARY__EmbeddedDataConnectionVisitor,
|
60
60
|
} from '../../../../utils/TestableUtils.js';
|
61
61
|
import { EmbeddedDataType } from '../../../ExternalFormatState.js';
|
@@ -74,6 +74,18 @@ import {
|
|
74
74
|
getExecutionQueryFromRawLambda,
|
75
75
|
} from '@finos/legend-query-builder';
|
76
76
|
|
77
|
+
export const createConnectionTestData = (
|
78
|
+
val: IdentifiedConnection,
|
79
|
+
embeddedDataType: string,
|
80
|
+
editorStore: EditorStore,
|
81
|
+
): ConnectionTestData => {
|
82
|
+
const connectionTestData = new ConnectionTestData();
|
83
|
+
connectionTestData.connectionId = val.id;
|
84
|
+
const testData = createEmbeddedData(embeddedDataType, editorStore);
|
85
|
+
connectionTestData.testData = testData;
|
86
|
+
return connectionTestData;
|
87
|
+
};
|
88
|
+
|
77
89
|
export class ServiceTestDataParametersState extends LambdaParametersState {
|
78
90
|
connectionTestDataState: ConnectionTestDataState;
|
79
91
|
|
@@ -140,6 +152,7 @@ export class ConnectionTestDataState {
|
|
140
152
|
readonly connectionData: ConnectionTestData;
|
141
153
|
readonly parametersState: ServiceTestDataParametersState;
|
142
154
|
readonly generatingTestDataState = ActionState.create();
|
155
|
+
useSharedModal = false;
|
143
156
|
|
144
157
|
embeddedEditorState: EmbeddedDataEditorState;
|
145
158
|
anonymizeGeneratedData = true;
|
@@ -151,8 +164,10 @@ export class ConnectionTestDataState {
|
|
151
164
|
makeObservable(this, {
|
152
165
|
generatingTestDataState: observable,
|
153
166
|
embeddedEditorState: observable,
|
167
|
+
useSharedModal: observable,
|
154
168
|
anonymizeGeneratedData: observable,
|
155
169
|
setAnonymizeGeneratedData: action,
|
170
|
+
changeEmbeddedData: action,
|
156
171
|
generateTestData: flow,
|
157
172
|
generateTestDataForDatabaseConnection: flow,
|
158
173
|
});
|
@@ -171,6 +186,10 @@ export class ConnectionTestDataState {
|
|
171
186
|
);
|
172
187
|
}
|
173
188
|
|
189
|
+
setUseSharedModal(val: boolean): void {
|
190
|
+
this.useSharedModal = val;
|
191
|
+
}
|
192
|
+
|
174
193
|
setAnonymizeGeneratedData(val: boolean): void {
|
175
194
|
this.anonymizeGeneratedData = val;
|
176
195
|
}
|
@@ -290,6 +309,18 @@ export class ConnectionTestDataState {
|
|
290
309
|
}
|
291
310
|
}
|
292
311
|
|
312
|
+
changeEmbeddedData(val: EmbeddedData): void {
|
313
|
+
service_setConnectionTestDataEmbeddedData(
|
314
|
+
this.connectionData,
|
315
|
+
val,
|
316
|
+
this.editorStore.changeDetectionState.observerContext,
|
317
|
+
);
|
318
|
+
this.embeddedEditorState = new EmbeddedDataEditorState(
|
319
|
+
this.testDataState.editorStore,
|
320
|
+
this.connectionData.testData,
|
321
|
+
);
|
322
|
+
}
|
323
|
+
|
293
324
|
resolveConnectionValue(id: string): Connection | undefined {
|
294
325
|
const connection = this.getAllIdentifiedConnections().find(
|
295
326
|
(c) => c.id === id,
|
@@ -358,7 +389,10 @@ export class NewConnectionDataState {
|
|
358
389
|
|
359
390
|
openModal(): void {
|
360
391
|
this.setModal(true);
|
361
|
-
|
392
|
+
const service =
|
393
|
+
this.testSuiteState.testSuiteState.testableState.serviceEditorState
|
394
|
+
.service;
|
395
|
+
this.connection = getAllIdentifiedServiceConnections(service)[0];
|
362
396
|
if (this.connection) {
|
363
397
|
this.handleConnectionChange(this.connection);
|
364
398
|
}
|
@@ -469,16 +503,4 @@ export class ServiceTestDataState {
|
|
469
503
|
this.setSelectedDataState(new ConnectionTestDataState(this, val));
|
470
504
|
}
|
471
505
|
}
|
472
|
-
get allIdentifiedConnections(): IdentifiedConnection[] {
|
473
|
-
const service =
|
474
|
-
this.testSuiteState.testableState.serviceEditorState.service;
|
475
|
-
const execution = service.execution;
|
476
|
-
let runtimes: Runtime[] = [];
|
477
|
-
if (execution instanceof PureSingleExecution && execution.runtime) {
|
478
|
-
runtimes = [execution.runtime];
|
479
|
-
} else if (execution instanceof PureMultiExecution) {
|
480
|
-
runtimes = execution.executionParameters.map((t) => t.runtime);
|
481
|
-
}
|
482
|
-
return uniq(runtimes.flatMap(getAllIdentifiedConnectionsFromRuntime));
|
483
|
-
}
|
484
506
|
}
|
@@ -31,9 +31,13 @@ import {
|
|
31
31
|
LambdaFunctionInstanceValue,
|
32
32
|
SimpleFunctionExpression,
|
33
33
|
CollectionInstanceValue,
|
34
|
+
resolveServiceQueryRawLambda,
|
34
35
|
} from '@finos/legend-graph';
|
35
36
|
import { action, flow, makeObservable, observable } from 'mobx';
|
36
|
-
import {
|
37
|
+
import {
|
38
|
+
TESTABLE_TEST_TAB,
|
39
|
+
TestableTestEditorState,
|
40
|
+
} from '../../testable/TestableEditorState.js';
|
37
41
|
import type { ServiceTestSuiteState } from './ServiceTestableState.js';
|
38
42
|
import {
|
39
43
|
service_addAssertKeyForTest,
|
@@ -70,9 +74,9 @@ export enum SERIALIZATION_FORMAT {
|
|
70
74
|
}
|
71
75
|
|
72
76
|
export enum SERIALIZATION_FORMAT_LABEL {
|
73
|
-
DEFAULT = 'DEFAULT',
|
74
77
|
PURE = 'PURE',
|
75
|
-
|
78
|
+
TABULAR_DATA = 'TABULAR DATA',
|
79
|
+
DEFAULT = 'DEFAULT',
|
76
80
|
}
|
77
81
|
|
78
82
|
const getSerializationFormatLabel = (val: string): string => {
|
@@ -82,7 +86,7 @@ const getSerializationFormatLabel = (val: string): string => {
|
|
82
86
|
case SERIALIZATION_FORMAT.PURE:
|
83
87
|
return SERIALIZATION_FORMAT.PURE;
|
84
88
|
case SERIALIZATION_FORMAT.PURE_TDSOBJECT:
|
85
|
-
return SERIALIZATION_FORMAT_LABEL.
|
89
|
+
return SERIALIZATION_FORMAT_LABEL.TABULAR_DATA;
|
86
90
|
default:
|
87
91
|
return val;
|
88
92
|
}
|
@@ -200,8 +204,7 @@ export class ServiceTestSetupState {
|
|
200
204
|
}
|
201
205
|
|
202
206
|
get queryVariableExpressions(): VariableExpression[] {
|
203
|
-
const query =
|
204
|
-
this.testState.suiteState.testableState.serviceEditorState.serviceQuery;
|
207
|
+
const query = resolveServiceQueryRawLambda(this.testState.service);
|
205
208
|
return query
|
206
209
|
? buildLambdaVariableExpressions(
|
207
210
|
query,
|
@@ -240,8 +243,7 @@ export class ServiceTestSetupState {
|
|
240
243
|
binding: Binding;
|
241
244
|
param: string;
|
242
245
|
}[] {
|
243
|
-
const query =
|
244
|
-
this.testState.suiteState.testableState.serviceEditorState.serviceQuery;
|
246
|
+
const query = resolveServiceQueryRawLambda(this.testState.service);
|
245
247
|
if (query && !isStubbed_RawLambda(query)) {
|
246
248
|
// safely pass unsupported funtions when building ValueSpecification from Rawlambda
|
247
249
|
try {
|
@@ -560,5 +562,10 @@ export class ServiceTestState extends TestableTestEditorState {
|
|
560
562
|
this.suiteState = suiteState;
|
561
563
|
this.testable = suiteState.testableState.serviceEditorState.service;
|
562
564
|
this.setupState = new ServiceTestSetupState(this);
|
565
|
+
this.selectedTab = TESTABLE_TEST_TAB.SETUP;
|
566
|
+
}
|
567
|
+
|
568
|
+
get service(): Service {
|
569
|
+
return this.suiteState.testableState.service;
|
563
570
|
}
|
564
571
|
}
|
package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.ts
CHANGED
@@ -28,6 +28,7 @@ import {
|
|
28
28
|
TestError,
|
29
29
|
MultiExecutionServiceTestResult,
|
30
30
|
TestExecutionStatus,
|
31
|
+
getAllIdentifiedServiceConnections,
|
31
32
|
} from '@finos/legend-graph';
|
32
33
|
import {
|
33
34
|
type GeneratorFn,
|
@@ -39,31 +40,77 @@ import {
|
|
39
40
|
isNonNullable,
|
40
41
|
generateEnumerableNameFromToken,
|
41
42
|
getNullableFirstEntry,
|
43
|
+
guaranteeNonNullable,
|
44
|
+
returnUndefOnError,
|
42
45
|
} from '@finos/legend-shared';
|
43
46
|
import { action, flow, makeObservable, observable } from 'mobx';
|
44
47
|
import type { EditorStore } from '../../../../EditorStore.js';
|
45
48
|
import {
|
49
|
+
service_addConnectionTestData,
|
46
50
|
service_addTest,
|
47
51
|
service_addTestSuite,
|
48
52
|
service_deleteTestSuite,
|
49
53
|
} from '../../../../../graph-modifier/DSL_Service_GraphModifierHelper.js';
|
50
|
-
import {
|
51
|
-
|
52
|
-
|
54
|
+
import {
|
55
|
+
EmbeddedDataConnectionTypeVisitor,
|
56
|
+
createEmptyEqualToJsonAssertion,
|
57
|
+
} from '../../../../utils/TestableUtils.js';
|
58
|
+
import {
|
59
|
+
isServiceQueryTDS,
|
60
|
+
type ServiceEditorState,
|
61
|
+
} from '../ServiceEditorState.js';
|
62
|
+
import {
|
63
|
+
ServiceTestDataState,
|
64
|
+
createConnectionTestData,
|
65
|
+
} from './ServiceTestDataState.js';
|
53
66
|
import {
|
54
67
|
SERIALIZATION_FORMAT,
|
55
68
|
ServiceTestState,
|
56
69
|
} from './ServiceTestEditorState.js';
|
57
70
|
|
58
|
-
const createEmptyServiceTestSuite = (
|
71
|
+
const createEmptyServiceTestSuite = (
|
72
|
+
serviceTestableState: ServiceTestableState,
|
73
|
+
): ServiceTestSuite => {
|
74
|
+
// setup
|
75
|
+
const serviceEditorState = serviceTestableState.serviceEditorState;
|
76
|
+
const service = serviceEditorState.service;
|
59
77
|
const suite = new ServiceTestSuite();
|
60
78
|
suite.id = generateEnumerableNameFromToken(
|
61
79
|
service.tests.map((s) => s.id),
|
62
80
|
DEFAULT_TEST_SUITE_PREFIX,
|
63
81
|
);
|
82
|
+
// data
|
64
83
|
suite.testData = new TestData();
|
84
|
+
const connections = getAllIdentifiedServiceConnections(service);
|
85
|
+
if (connections.length === 1) {
|
86
|
+
const iVal = guaranteeNonNullable(connections[0]);
|
87
|
+
const connectionValue = iVal.connection;
|
88
|
+
const type = returnUndefOnError(() =>
|
89
|
+
connectionValue.accept_ConnectionVisitor(
|
90
|
+
new EmbeddedDataConnectionTypeVisitor(serviceEditorState.editorStore),
|
91
|
+
),
|
92
|
+
);
|
93
|
+
if (type) {
|
94
|
+
const testData = createConnectionTestData(
|
95
|
+
iVal,
|
96
|
+
type,
|
97
|
+
serviceEditorState.editorStore,
|
98
|
+
);
|
99
|
+
service_addConnectionTestData(
|
100
|
+
suite,
|
101
|
+
testData,
|
102
|
+
serviceEditorState.editorStore.changeDetectionState.observerContext,
|
103
|
+
);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
//
|
65
107
|
const test = new ServiceTest();
|
66
|
-
test.serializationFormat =
|
108
|
+
test.serializationFormat = isServiceQueryTDS(
|
109
|
+
serviceEditorState.service,
|
110
|
+
serviceEditorState.editorStore,
|
111
|
+
)
|
112
|
+
? SERIALIZATION_FORMAT.PURE_TDSOBJECT
|
113
|
+
: SERIALIZATION_FORMAT.PURE;
|
67
114
|
test.id = generateEnumerableNameFromToken([], DEFAULT_TEST_PREFIX);
|
68
115
|
test.__parent = suite;
|
69
116
|
suite.tests = [test];
|
@@ -258,6 +305,10 @@ export class ServiceTestableState {
|
|
258
305
|
this.initSuites();
|
259
306
|
}
|
260
307
|
|
308
|
+
get service(): Service {
|
309
|
+
return this.serviceEditorState.service;
|
310
|
+
}
|
311
|
+
|
261
312
|
setSuiteToRename(testSuite: ServiceTestSuite | undefined): void {
|
262
313
|
this.suiteToRename = testSuite;
|
263
314
|
}
|
@@ -290,7 +341,7 @@ export class ServiceTestableState {
|
|
290
341
|
}
|
291
342
|
|
292
343
|
addTestSuite(): void {
|
293
|
-
const suite = createEmptyServiceTestSuite(this
|
344
|
+
const suite = createEmptyServiceTestSuite(this);
|
294
345
|
service_addTestSuite(
|
295
346
|
this.serviceEditorState.service,
|
296
347
|
suite,
|
@@ -45,8 +45,8 @@ import {
|
|
45
45
|
import type { TestableTestEditorState } from './TestableEditorState.js';
|
46
46
|
|
47
47
|
export enum TEST_ASSERTION_TAB {
|
48
|
-
|
49
|
-
|
48
|
+
SETUP = 'SETUP',
|
49
|
+
RESULT = 'RESULT',
|
50
50
|
}
|
51
51
|
|
52
52
|
export abstract class TestAssertionStatusState {
|
@@ -273,7 +273,7 @@ export class TestAssertionEditorState {
|
|
273
273
|
assertionState: TestAssertionState;
|
274
274
|
assertionResultState: TestAssertionResultState;
|
275
275
|
assertion: TestAssertion;
|
276
|
-
selectedTab = TEST_ASSERTION_TAB.
|
276
|
+
selectedTab = TEST_ASSERTION_TAB.SETUP;
|
277
277
|
generatingExpectedAction = ActionState.create();
|
278
278
|
constructor(
|
279
279
|
editorStore: EditorStore,
|
@@ -302,7 +302,7 @@ export class TestAssertionEditorState {
|
|
302
302
|
this.generatingExpectedAction.inProgress();
|
303
303
|
const bare = this.assertionState.generateBare();
|
304
304
|
bare.parentTest = this.assertion.parentTest;
|
305
|
-
const
|
305
|
+
const assertFail =
|
306
306
|
(yield this.editorStore.graphManagerState.graphManager.generateExpectedResult(
|
307
307
|
this.testState.testable,
|
308
308
|
this.testState.test,
|
@@ -310,13 +310,17 @@ export class TestAssertionEditorState {
|
|
310
310
|
bare,
|
311
311
|
this.editorStore.graphManagerState.graph,
|
312
312
|
)) as AssertFail;
|
313
|
-
this.assertionState.generateExpected(
|
313
|
+
this.assertionState.generateExpected(assertFail);
|
314
314
|
this.generatingExpectedAction.complete();
|
315
|
+
this.editorStore.applicationStore.notificationService.notifySuccess(
|
316
|
+
`Expected results generated!`,
|
317
|
+
);
|
315
318
|
} catch (error) {
|
316
319
|
assertErrorThrown(error);
|
317
320
|
this.editorStore.applicationStore.notificationService.notifyError(
|
318
|
-
`Error generating expected result: ${error.message}
|
321
|
+
`Error generating expected result, please check data input: ${error.message}.`,
|
319
322
|
);
|
323
|
+
this.setSelectedTab(TEST_ASSERTION_TAB.SETUP);
|
320
324
|
this.generatingExpectedAction.fail();
|
321
325
|
}
|
322
326
|
}
|
@@ -24,6 +24,7 @@ import {
|
|
24
24
|
RunTestsTestableInput,
|
25
25
|
TestSuite,
|
26
26
|
TestExecutionStatus,
|
27
|
+
TestError,
|
27
28
|
} from '@finos/legend-graph';
|
28
29
|
import {
|
29
30
|
type GeneratorFn,
|
@@ -33,6 +34,7 @@ import {
|
|
33
34
|
ActionState,
|
34
35
|
addUniqueEntry,
|
35
36
|
deleteEntry,
|
37
|
+
isNonNullable,
|
36
38
|
} from '@finos/legend-shared';
|
37
39
|
import { action, makeObservable, observable } from 'mobx';
|
38
40
|
import type { EditorStore } from '../../../EditorStore.js';
|
@@ -66,7 +68,7 @@ export class TestableTestResultState {
|
|
66
68
|
|
67
69
|
export enum TESTABLE_TEST_TAB {
|
68
70
|
SETUP = 'SETUP',
|
69
|
-
|
71
|
+
ASSERTION = 'ASSERTION',
|
70
72
|
}
|
71
73
|
|
72
74
|
export class TestableTestEditorState {
|
@@ -75,7 +77,7 @@ export class TestableTestEditorState {
|
|
75
77
|
test: AtomicTest;
|
76
78
|
selectedAsertionState: TestAssertionEditorState | undefined;
|
77
79
|
assertionEditorStates: TestAssertionEditorState[] = [];
|
78
|
-
selectedTab = TESTABLE_TEST_TAB.
|
80
|
+
selectedTab = TESTABLE_TEST_TAB.ASSERTION;
|
79
81
|
assertionToRename: TestAssertion | undefined;
|
80
82
|
runningTestAction = ActionState.create();
|
81
83
|
testResultState: TestableTestResultState;
|
@@ -177,7 +179,7 @@ export class TestableTestEditorState {
|
|
177
179
|
this.testResultState.setResult(testResult);
|
178
180
|
this.assertionEditorStates.forEach((assertionState) => {
|
179
181
|
assertionState.assertionResultState.setTestResult(testResult);
|
180
|
-
assertionState.setSelectedTab(TEST_ASSERTION_TAB.
|
182
|
+
assertionState.setSelectedTab(TEST_ASSERTION_TAB.RESULT);
|
181
183
|
});
|
182
184
|
}
|
183
185
|
|
@@ -211,3 +213,90 @@ export class TestableTestEditorState {
|
|
211
213
|
).length;
|
212
214
|
}
|
213
215
|
}
|
216
|
+
|
217
|
+
export class TestableTestSuiteEditorState {
|
218
|
+
readonly editorStore: EditorStore;
|
219
|
+
testable: Testable;
|
220
|
+
suite: TestSuite;
|
221
|
+
isReadOnly: boolean;
|
222
|
+
testStates: TestableTestEditorState[] = [];
|
223
|
+
isRunningTest = ActionState.create();
|
224
|
+
selectTestState: TestableTestEditorState | undefined;
|
225
|
+
|
226
|
+
constructor(
|
227
|
+
testable: Testable,
|
228
|
+
suite: TestSuite,
|
229
|
+
isReadOnly: boolean,
|
230
|
+
editorStore: EditorStore,
|
231
|
+
) {
|
232
|
+
this.testable = testable;
|
233
|
+
this.suite = suite;
|
234
|
+
this.isReadOnly = isReadOnly;
|
235
|
+
this.editorStore = editorStore;
|
236
|
+
}
|
237
|
+
|
238
|
+
*runSuite(): GeneratorFn<void> {
|
239
|
+
try {
|
240
|
+
this.isRunningTest.inProgress();
|
241
|
+
this.testStates.forEach((t) => t.resetResult());
|
242
|
+
this.testStates.forEach((t) => t.runningTestAction.inProgress());
|
243
|
+
const input = new RunTestsTestableInput(this.testable);
|
244
|
+
input.unitTestIds = this.suite.tests.map(
|
245
|
+
(t) => new UniqueTestId(this.suite, t),
|
246
|
+
);
|
247
|
+
const testResults =
|
248
|
+
(yield this.editorStore.graphManagerState.graphManager.runTests(
|
249
|
+
[input],
|
250
|
+
this.editorStore.graphManagerState.graph,
|
251
|
+
)) as TestResult[];
|
252
|
+
testResults.forEach((result) => {
|
253
|
+
const state = this.testStates.find((t) => t.test === result.atomicTest);
|
254
|
+
state?.handleTestResult(result);
|
255
|
+
});
|
256
|
+
this.isRunningTest.complete();
|
257
|
+
} catch (error) {
|
258
|
+
assertErrorThrown(error);
|
259
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
260
|
+
this.isRunningTest.fail();
|
261
|
+
} finally {
|
262
|
+
this.testStates.forEach((t) => t.runningTestAction.complete());
|
263
|
+
}
|
264
|
+
}
|
265
|
+
|
266
|
+
*runFailingTests(): GeneratorFn<void> {
|
267
|
+
try {
|
268
|
+
this.isRunningTest.inProgress();
|
269
|
+
const input = new RunTestsTestableInput(this.testable);
|
270
|
+
input.unitTestIds = this.testStates
|
271
|
+
.map((testState) => {
|
272
|
+
const result = testState.testResultState.result;
|
273
|
+
if (
|
274
|
+
(result instanceof TestExecuted &&
|
275
|
+
result.testExecutionStatus === TestExecutionStatus.FAIL) ||
|
276
|
+
result instanceof TestError
|
277
|
+
) {
|
278
|
+
testState.runningTestAction.inProgress();
|
279
|
+
return new UniqueTestId(this.suite, testState.test);
|
280
|
+
}
|
281
|
+
return undefined;
|
282
|
+
})
|
283
|
+
.filter(isNonNullable);
|
284
|
+
const testResults =
|
285
|
+
(yield this.editorStore.graphManagerState.graphManager.runTests(
|
286
|
+
[input],
|
287
|
+
this.editorStore.graphManagerState.graph,
|
288
|
+
)) as TestResult[];
|
289
|
+
testResults.forEach((result) => {
|
290
|
+
const state = this.testStates.find((t) => t.test === result.atomicTest);
|
291
|
+
state?.handleTestResult(result);
|
292
|
+
});
|
293
|
+
this.isRunningTest.complete();
|
294
|
+
} catch (error) {
|
295
|
+
assertErrorThrown(error);
|
296
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
297
|
+
this.isRunningTest.fail();
|
298
|
+
} finally {
|
299
|
+
this.testStates.forEach((t) => t.runningTestAction.complete());
|
300
|
+
}
|
301
|
+
}
|
302
|
+
}
|
@@ -21,10 +21,12 @@ import {
|
|
21
21
|
Randomizer,
|
22
22
|
UnsupportedOperationError,
|
23
23
|
type PlainObject,
|
24
|
+
isNonNullable,
|
25
|
+
filterByType,
|
24
26
|
} from '@finos/legend-shared';
|
25
27
|
import type { EditorStore } from '../EditorStore.js';
|
26
28
|
import {
|
27
|
-
|
29
|
+
PrimitiveType,
|
28
30
|
type Enumeration,
|
29
31
|
PRIMITIVE_TYPE,
|
30
32
|
Class,
|
@@ -32,6 +34,28 @@ import {
|
|
32
34
|
DATE_FORMAT,
|
33
35
|
DATE_TIME_FORMAT,
|
34
36
|
classHasCycle,
|
37
|
+
TableAlias,
|
38
|
+
Table,
|
39
|
+
Column,
|
40
|
+
VarChar,
|
41
|
+
type RelationalDataType,
|
42
|
+
Char,
|
43
|
+
VarBinary,
|
44
|
+
TinyInt,
|
45
|
+
Float,
|
46
|
+
Timestamp,
|
47
|
+
Binary,
|
48
|
+
Bit,
|
49
|
+
Other,
|
50
|
+
Numeric,
|
51
|
+
Decimal,
|
52
|
+
Double,
|
53
|
+
Integer,
|
54
|
+
Real,
|
55
|
+
SmallInt,
|
56
|
+
Date as ColumnDate,
|
57
|
+
SemiStructured,
|
58
|
+
Json,
|
35
59
|
} from '@finos/legend-graph';
|
36
60
|
import {
|
37
61
|
CLASS_PROPERTY_TYPE,
|
@@ -182,6 +206,85 @@ export const createMockDataForClassWithFormat = (
|
|
182
206
|
}
|
183
207
|
};
|
184
208
|
|
209
|
+
export const getPrimitiveTypeFromRelationalType = (
|
210
|
+
type: RelationalDataType,
|
211
|
+
): PrimitiveType | undefined => {
|
212
|
+
if (
|
213
|
+
type instanceof VarChar ||
|
214
|
+
type instanceof Char ||
|
215
|
+
type instanceof VarBinary ||
|
216
|
+
type instanceof Binary ||
|
217
|
+
type instanceof Bit ||
|
218
|
+
type instanceof Other
|
219
|
+
) {
|
220
|
+
return PrimitiveType.STRING;
|
221
|
+
} else if (type instanceof Numeric) {
|
222
|
+
return PrimitiveType.NUMBER;
|
223
|
+
} else if (type instanceof Decimal) {
|
224
|
+
return PrimitiveType.DECIMAL;
|
225
|
+
} else if (
|
226
|
+
type instanceof Double ||
|
227
|
+
type instanceof Integer ||
|
228
|
+
type instanceof Real ||
|
229
|
+
type instanceof SmallInt ||
|
230
|
+
type instanceof TinyInt
|
231
|
+
) {
|
232
|
+
return PrimitiveType.INTEGER;
|
233
|
+
} else if (type instanceof Float) {
|
234
|
+
return PrimitiveType.FLOAT;
|
235
|
+
} else if (type instanceof ColumnDate) {
|
236
|
+
return PrimitiveType.DATE;
|
237
|
+
} else if (type instanceof Timestamp) {
|
238
|
+
return PrimitiveType.DATETIME;
|
239
|
+
}
|
240
|
+
return undefined;
|
241
|
+
};
|
242
|
+
export const createMockDataForColumn = (
|
243
|
+
col: Column,
|
244
|
+
isPrimaryKey: boolean,
|
245
|
+
idx?: number | number,
|
246
|
+
): string | undefined => {
|
247
|
+
const type = col.type;
|
248
|
+
|
249
|
+
if (
|
250
|
+
(type instanceof Double ||
|
251
|
+
type instanceof Integer ||
|
252
|
+
type instanceof Real ||
|
253
|
+
type instanceof SmallInt ||
|
254
|
+
type instanceof TinyInt) &&
|
255
|
+
isPrimaryKey &&
|
256
|
+
idx
|
257
|
+
) {
|
258
|
+
return idx.toString();
|
259
|
+
}
|
260
|
+
const primitive = getPrimitiveTypeFromRelationalType(type);
|
261
|
+
if (primitive) {
|
262
|
+
return createMockPrimitiveProperty(primitive, col.name).toString();
|
263
|
+
} else if (type instanceof Json || type instanceof SemiStructured) {
|
264
|
+
return '{}';
|
265
|
+
}
|
266
|
+
return undefined;
|
267
|
+
};
|
268
|
+
|
269
|
+
export const createMockDataForTable = (
|
270
|
+
table: Table,
|
271
|
+
ITERATIONS = 1,
|
272
|
+
): string => {
|
273
|
+
const targetedCols = table.columns.filter(filterByType(Column));
|
274
|
+
const colNames = targetedCols.map((e) => e.name).join(',');
|
275
|
+
const vals = Array.from(Array(ITERATIONS).keys())
|
276
|
+
.map((idx) =>
|
277
|
+
targetedCols
|
278
|
+
.map((col) =>
|
279
|
+
createMockDataForColumn(col, table.primaryKey.includes(col), idx),
|
280
|
+
)
|
281
|
+
.filter(isNonNullable)
|
282
|
+
.join(','),
|
283
|
+
)
|
284
|
+
.join('\n');
|
285
|
+
return `${colNames}\n${vals}`;
|
286
|
+
};
|
287
|
+
|
185
288
|
export const createMockDataForMappingElementSource = (
|
186
289
|
srcElement: MappingElementSource,
|
187
290
|
editorStore: EditorStore,
|
@@ -200,6 +303,11 @@ export const createMockDataForMappingElementSource = (
|
|
200
303
|
);
|
201
304
|
return '';
|
202
305
|
}
|
306
|
+
} else if (
|
307
|
+
srcElement instanceof TableAlias &&
|
308
|
+
srcElement.relation instanceof Table
|
309
|
+
) {
|
310
|
+
return createMockDataForTable(srcElement.relation);
|
203
311
|
}
|
204
312
|
editorStore.applicationStore.notificationService.notifyWarning(
|
205
313
|
new UnsupportedOperationError(
|