@finos/legend-application-studio 27.0.0 → 27.1.1
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/__lib__/LegendStudioApplicationNavigationContext.d.ts +9 -1
- package/lib/__lib__/LegendStudioApplicationNavigationContext.d.ts.map +1 -1
- package/lib/__lib__/LegendStudioApplicationNavigationContext.js +11 -1
- package/lib/__lib__/LegendStudioApplicationNavigationContext.js.map +1 -1
- package/lib/__lib__/LegendStudioEvent.d.ts +1 -0
- package/lib/__lib__/LegendStudioEvent.d.ts.map +1 -1
- package/lib/__lib__/LegendStudioEvent.js +1 -0
- package/lib/__lib__/LegendStudioEvent.js.map +1 -1
- package/lib/application/LegendStudioApplicationConfig.d.ts +6 -0
- package/lib/application/LegendStudioApplicationConfig.d.ts.map +1 -1
- package/lib/application/LegendStudioApplicationConfig.js +7 -0
- package/lib/application/LegendStudioApplicationConfig.js.map +1 -1
- package/lib/components/ElementIconUtils.d.ts.map +1 -1
- package/lib/components/ElementIconUtils.js +3 -1
- package/lib/components/ElementIconUtils.js.map +1 -1
- package/lib/components/editor/editor-group/ModelImporter.d.ts.map +1 -1
- package/lib/components/editor/editor-group/ModelImporter.js +1 -0
- package/lib/components/editor/editor-group/ModelImporter.js.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.d.ts.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js +8 -10
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js.map +1 -1
- package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.js +10 -4
- 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 +65 -12
- package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.js.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js +3 -0
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetElementEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetElementEditor.js +3 -0
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetElementEditor.js.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.js +3 -0
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.d.ts +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 +101 -137
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/NewMappingElementModal.js +1 -2
- package/lib/components/editor/editor-group/mapping-editor/NewMappingElementModal.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 +9 -4
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.js.map +1 -1
- package/lib/components/editor/editor-group/testable/TestableSharedComponents.d.ts +11 -0
- package/lib/components/editor/editor-group/testable/TestableSharedComponents.d.ts.map +1 -1
- package/lib/components/editor/editor-group/testable/TestableSharedComponents.js +27 -2
- package/lib/components/editor/editor-group/testable/TestableSharedComponents.js.map +1 -1
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.d.ts.map +1 -1
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.js +38 -6
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.js.map +1 -1
- package/lib/components/editor/side-bar/CreateNewElementModal.d.ts +3 -0
- package/lib/components/editor/side-bar/CreateNewElementModal.d.ts.map +1 -1
- package/lib/components/editor/side-bar/CreateNewElementModal.js +43 -1
- package/lib/components/editor/side-bar/CreateNewElementModal.js.map +1 -1
- package/lib/components/extensions/Core_LegendStudioApplicationPlugin.d.ts.map +1 -1
- package/lib/components/extensions/Core_LegendStudioApplicationPlugin.js +10 -0
- package/lib/components/extensions/Core_LegendStudioApplicationPlugin.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/editor/EditorGraphState.js +1 -1
- package/lib/stores/editor/EditorGraphState.js.map +1 -1
- package/lib/stores/editor/EditorStore.d.ts.map +1 -1
- package/lib/stores/editor/EditorStore.js +10 -2
- package/lib/stores/editor/EditorStore.js.map +1 -1
- package/lib/stores/editor/NewElementState.d.ts +0 -1
- package/lib/stores/editor/NewElementState.d.ts.map +1 -1
- package/lib/stores/editor/NewElementState.js +43 -10
- package/lib/stores/editor/NewElementState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts +0 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js +26 -30
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.d.ts +2 -2
- package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.js +2 -2
- package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.d.ts +14 -19
- 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 +30 -65
- 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/MappingEditorState.d.ts +4 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.js +5 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts +56 -78
- 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 +285 -384
- 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/mapping/testable/MappingTestingHelper.d.ts +23 -0
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.d.ts.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.js +129 -0
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.js.map +1 -0
- 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 +2 -2
- 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 +1 -0
- 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 +12 -2
- 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/ServiceTestableState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js +15 -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 +7 -4
- 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 +53 -10
- 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 +2 -1
- 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 +20 -16
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js.map +1 -1
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts +9 -0
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts.map +1 -1
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js +149 -3
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js.map +1 -1
- package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.d.ts +1 -1
- package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.d.ts.map +1 -1
- package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.js +3 -0
- package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.js.map +1 -1
- package/lib/stores/editor/utils/MockDataUtils.d.ts.map +1 -1
- package/lib/stores/editor/utils/MockDataUtils.js +3 -0
- package/lib/stores/editor/utils/MockDataUtils.js.map +1 -1
- package/lib/stores/editor/utils/ModelClassifierUtils.d.ts +2 -5
- package/lib/stores/editor/utils/ModelClassifierUtils.d.ts.map +1 -1
- package/lib/stores/editor/utils/ModelClassifierUtils.js +2 -6
- package/lib/stores/editor/utils/ModelClassifierUtils.js.map +1 -1
- package/lib/stores/editor/utils/TestableUtils.d.ts +11 -1
- package/lib/stores/editor/utils/TestableUtils.d.ts.map +1 -1
- package/lib/stores/editor/utils/TestableUtils.js +50 -1
- package/lib/stores/editor/utils/TestableUtils.js.map +1 -1
- package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.d.ts +5 -4
- package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.d.ts.map +1 -1
- package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.js +4 -1
- package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.js.map +1 -1
- package/package.json +6 -6
- package/src/__lib__/LegendStudioApplicationNavigationContext.ts +12 -1
- package/src/__lib__/LegendStudioEvent.ts +1 -1
- package/src/application/LegendStudioApplicationConfig.ts +8 -0
- package/src/components/ElementIconUtils.tsx +3 -0
- package/src/components/editor/editor-group/ModelImporter.tsx +4 -0
- package/src/components/editor/editor-group/connection-editor/DatabaseBuilder.tsx +12 -13
- package/src/components/editor/editor-group/data-editor/EmbeddedDataEditor.tsx +45 -38
- package/src/components/editor/editor-group/data-editor/RelationalCSVDataEditor.tsx +140 -31
- package/src/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.tsx +7 -0
- package/src/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetElementEditor.tsx +6 -0
- package/src/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.tsx +6 -0
- package/src/components/editor/editor-group/mapping-editor/MappingTestableEditor.tsx +296 -414
- package/src/components/editor/editor-group/mapping-editor/NewMappingElementModal.tsx +1 -1
- package/src/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.tsx +12 -7
- package/src/components/editor/editor-group/testable/TestableSharedComponents.tsx +88 -3
- package/src/components/editor/panel-group/SQLPlaygroundPanel.tsx +104 -18
- package/src/components/editor/side-bar/CreateNewElementModal.tsx +111 -1
- package/src/components/extensions/Core_LegendStudioApplicationPlugin.tsx +10 -0
- package/src/stores/editor/EditorGraphState.ts +1 -1
- package/src/stores/editor/EditorStore.ts +29 -17
- package/src/stores/editor/NewElementState.ts +109 -21
- package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.ts +33 -40
- package/src/stores/editor/editor-state/element-editor-state/data/DataEditorState.ts +7 -1
- package/src/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.ts +48 -77
- package/src/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.ts +5 -1
- package/src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.ts +407 -617
- package/src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.ts +243 -0
- package/src/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.ts +6 -2
- package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.ts +18 -1
- package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.ts +20 -12
- package/src/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.ts +76 -18
- package/src/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.ts +29 -24
- package/src/stores/editor/panel-group/SQLPlaygroundPanelState.ts +224 -1
- package/src/stores/editor/sidebar-state/testable/GlobalTestRunnerState.ts +4 -1
- package/src/stores/editor/utils/MockDataUtils.ts +2 -0
- package/src/stores/editor/utils/ModelClassifierUtils.ts +2 -6
- package/src/stores/editor/utils/TestableUtils.ts +73 -0
- package/src/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.ts +15 -12
- package/tsconfig.json +1 -0
package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js
CHANGED
@@ -13,152 +13,48 @@
|
|
13
13
|
* See the License for the specific language governing permissions and
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
|
-
import { LAMBDA_PIPE, buildSourceInformationSourceId, isStubbed_RawLambda, GRAPH_MANAGER_EVENT,
|
16
|
+
import { MappingTestSuite, MappingTest, LAMBDA_PIPE, buildSourceInformationSourceId, isStubbed_RawLambda, GRAPH_MANAGER_EVENT, PackageableElementExplicitReference, StoreTestData, getRootSetImplementation, DataElementReference, RelationalCSVData, RunTestsTestableInput, UniqueTestId, } from '@finos/legend-graph';
|
17
17
|
import { action, flow, flowResult, makeObservable, observable } from 'mobx';
|
18
|
-
import { ActionState, assertErrorThrown,
|
19
|
-
import { LambdaEditorState
|
20
|
-
import {
|
21
|
-
import { mappingTestable_addStoreTestData, mappingTestable_deleteStoreTestData, mappingTestable_setQuery, mapping_addTestSuite, mapping_deleteTestSuite, } from '../../../../../graph-modifier/DSL_Mapping_GraphModifierHelper.js';
|
22
|
-
import {
|
18
|
+
import { ActionState, assertErrorThrown, isNonNullable, UnsupportedOperationError, LogEvent, uuid, filterByType, } from '@finos/legend-shared';
|
19
|
+
import { LambdaEditorState } from '@finos/legend-query-builder';
|
20
|
+
import {} from '../MappingEditorState.js';
|
21
|
+
import { mappingTestable_addStoreTestData, mappingTestable_deleteStoreTestData, mappingTestable_setEmbeddedData, mappingTestable_setQuery, mapping_addTestSuite, mapping_deleteTestSuite, } from '../../../../../graph-modifier/DSL_Mapping_GraphModifierHelper.js';
|
22
|
+
import { EmbeddedDataCreatorFromEmbeddedData, createBareExternalFormat, isTestPassing, } from '../../../../utils/TestableUtils.js';
|
23
23
|
import { TESTABLE_TEST_TAB, TestableTestEditorState, TestableTestSuiteEditorState, } from '../../testable/TestableEditorState.js';
|
24
24
|
import { EmbeddedDataEditorState } from '../../data/DataEditorState.js';
|
25
25
|
import { testSuite_addTest, testSuite_deleteTest, testable_setId, } from '../../../../../graph-modifier/Testable_GraphModifierHelper.js';
|
26
26
|
import { EmbeddedDataType } from '../../../ExternalFormatState.js';
|
27
|
-
import {
|
28
|
-
|
29
|
-
(function (MAPPING_TEST_SUITE_TYPE) {
|
30
|
-
MAPPING_TEST_SUITE_TYPE["DATA"] = "DATA";
|
31
|
-
MAPPING_TEST_SUITE_TYPE["QUERY"] = "QUERY";
|
32
|
-
})(MAPPING_TEST_SUITE_TYPE || (MAPPING_TEST_SUITE_TYPE = {}));
|
33
|
-
const createGraphFetchLambda = (mainClass, graphManagerState, root) => {
|
34
|
-
const lambdaFunction = new LambdaFunction(new FunctionType(PackageableElementExplicitReference.create(graphManagerState.graph.getType(CORE_PURE_PATH.ANY)), Multiplicity.ONE));
|
35
|
-
const getAllFunction = buildGetAllFunction(mainClass, Multiplicity.ONE);
|
36
|
-
const serialize = buildSerialzieFunctionWithGraphFetch(root, false, getAllFunction, undefined);
|
37
|
-
lambdaFunction.expressionSequence = [serialize];
|
38
|
-
return buildRawLambdaFromLambdaFunction(lambdaFunction, graphManagerState);
|
39
|
-
};
|
40
|
-
const createBareModelStoreData = (_class, editorStore) => {
|
41
|
-
const embeddedData = createEmbeddedDataFromClass(_class, editorStore);
|
42
|
-
const testData = new StoreTestData();
|
43
|
-
const modelStoreData = new ModelStoreData();
|
44
|
-
const modelData = new ModelEmbeddedData();
|
45
|
-
modelData.data = embeddedData;
|
46
|
-
modelData.model = PackageableElementExplicitReference.create(_class);
|
47
|
-
modelStoreData.modelData = [modelData];
|
48
|
-
testData.data = modelStoreData;
|
49
|
-
testData.store = PackageableElementExplicitReference.create(ModelStore.INSTANCE);
|
50
|
-
return testData;
|
51
|
-
};
|
52
|
-
const createBareMappingDataTest = (id, storeTestData, suite) => {
|
53
|
-
const dataTest = new MappingDataTest();
|
54
|
-
dataTest.id = id;
|
55
|
-
dataTest.storeTestData = storeTestData ? [storeTestData] : [];
|
56
|
-
dataTest.assertions = [
|
57
|
-
createDefaultEqualToJSONTestAssertion(DEFAULT_TEST_ASSERTION_ID),
|
58
|
-
];
|
59
|
-
if (suite) {
|
60
|
-
dataTest.__parent = suite;
|
61
|
-
suite.tests.push(dataTest);
|
62
|
-
}
|
63
|
-
return dataTest;
|
64
|
-
};
|
65
|
-
const createBareMappingQueryTest = (id, query, suite) => {
|
66
|
-
const dataTest = new MappingQueryTest();
|
67
|
-
dataTest.id = id;
|
68
|
-
dataTest.func = query;
|
69
|
-
dataTest.assertions = [
|
70
|
-
createDefaultEqualToJSONTestAssertion(DEFAULT_TEST_ASSERTION_ID),
|
71
|
-
];
|
72
|
-
if (suite) {
|
73
|
-
dataTest.__parent = suite;
|
74
|
-
suite.tests.push(dataTest);
|
75
|
-
}
|
76
|
-
return dataTest;
|
77
|
-
};
|
78
|
-
export class MappingTestableQueryState extends LambdaEditorState {
|
79
|
-
editorStore;
|
80
|
-
parent;
|
81
|
-
isInitializingLambda = false;
|
82
|
-
query;
|
83
|
-
constructor(editorStore, parent, query) {
|
84
|
-
super('', LAMBDA_PIPE);
|
85
|
-
makeObservable(this, {
|
86
|
-
query: observable,
|
87
|
-
isInitializingLambda: observable,
|
88
|
-
setIsInitializingLambda: action,
|
89
|
-
updateLamba: flow,
|
90
|
-
});
|
91
|
-
this.parent = parent;
|
92
|
-
this.editorStore = editorStore;
|
93
|
-
this.query = query;
|
94
|
-
}
|
95
|
-
get lambdaId() {
|
96
|
-
return buildSourceInformationSourceId([this.uuid]);
|
97
|
-
}
|
98
|
-
setIsInitializingLambda(val) {
|
99
|
-
this.isInitializingLambda = val;
|
100
|
-
}
|
101
|
-
*updateLamba(val) {
|
102
|
-
this.query = val;
|
103
|
-
mappingTestable_setQuery(this.parent, val);
|
104
|
-
yield flowResult(this.convertLambdaObjectToGrammarString(true));
|
105
|
-
}
|
106
|
-
*convertLambdaObjectToGrammarString(pretty) {
|
107
|
-
if (!isStubbed_RawLambda(this.query)) {
|
108
|
-
try {
|
109
|
-
const lambdas = new Map();
|
110
|
-
lambdas.set(this.lambdaId, this.query);
|
111
|
-
const isolatedLambdas = (yield this.editorStore.graphManagerState.graphManager.lambdasToPureCode(lambdas, pretty));
|
112
|
-
const grammarText = isolatedLambdas.get(this.lambdaId);
|
113
|
-
this.setLambdaString(grammarText !== undefined
|
114
|
-
? this.extractLambdaString(grammarText)
|
115
|
-
: '');
|
116
|
-
this.clearErrors();
|
117
|
-
}
|
118
|
-
catch (error) {
|
119
|
-
assertErrorThrown(error);
|
120
|
-
this.editorStore.applicationStore.logService.error(LogEvent.create(GRAPH_MANAGER_EVENT.PARSING_FAILURE), error);
|
121
|
-
}
|
122
|
-
}
|
123
|
-
else {
|
124
|
-
this.clearErrors();
|
125
|
-
this.setLambdaString('');
|
126
|
-
}
|
127
|
-
}
|
128
|
-
// NOTE: since we don't allow edition in text mode, we don't need to implement this
|
129
|
-
*convertLambdaGrammarStringToObject() {
|
130
|
-
throw new UnsupportedOperationError();
|
131
|
-
}
|
132
|
-
}
|
133
|
-
export class MappingTestState extends TestableTestEditorState {
|
134
|
-
mappingTestableState;
|
135
|
-
uuid = uuid();
|
136
|
-
test;
|
137
|
-
constructor(editorStore, mappingTestableState, test) {
|
138
|
-
super(mappingTestableState.mapping, test, mappingTestableState.mappingEditorState.isReadOnly, editorStore);
|
139
|
-
this.mappingTestableState = mappingTestableState;
|
140
|
-
this.test = test;
|
141
|
-
this.selectedTab = this.defaultTab();
|
142
|
-
}
|
143
|
-
}
|
27
|
+
import { createBareMappingTest, createGraphFetchQueryFromMappingAnalysis, generateStoreTestDataFromSetImpl, } from './MappingTestingHelper.js';
|
28
|
+
import { LEGEND_STUDIO_APP_EVENT } from '../../../../../../__lib__/LegendStudioEvent.js';
|
144
29
|
export class StoreTestDataState {
|
145
30
|
editorStore;
|
146
31
|
testDataState;
|
147
32
|
storeTestData;
|
148
|
-
generatingTestDataSate = ActionState.create();
|
149
33
|
embeddedEditorState;
|
34
|
+
dataElementModal = false;
|
150
35
|
constructor(editorStore, testDataState, value) {
|
151
36
|
makeObservable(this, {
|
152
37
|
storeTestData: observable,
|
153
|
-
|
38
|
+
dataElementModal: observable,
|
39
|
+
setDataElementModal: action,
|
40
|
+
changeEmbeddedData: action,
|
154
41
|
});
|
155
42
|
this.editorStore = editorStore;
|
156
43
|
this.testDataState = testDataState;
|
157
44
|
this.storeTestData = value;
|
45
|
+
this.embeddedEditorState = new EmbeddedDataEditorState(this.testDataState.editorStore, this.storeTestData.data, {
|
46
|
+
hideSource: true,
|
47
|
+
});
|
48
|
+
}
|
49
|
+
setDataElementModal(val) {
|
50
|
+
this.dataElementModal = val;
|
51
|
+
}
|
52
|
+
changeEmbeddedData(val) {
|
53
|
+
mappingTestable_setEmbeddedData(this.storeTestData, val, this.editorStore.changeDetectionState.observerContext);
|
158
54
|
this.embeddedEditorState = new EmbeddedDataEditorState(this.testDataState.editorStore, this.storeTestData.data);
|
159
55
|
}
|
160
56
|
}
|
161
|
-
export class
|
57
|
+
export class MappingTestDataState {
|
162
58
|
editorStore;
|
163
59
|
mappingTestableState;
|
164
60
|
selectedDataState;
|
@@ -217,64 +113,91 @@ export class MappingTestableDataState {
|
|
217
113
|
this.openStoreTestData(_storeData);
|
218
114
|
}
|
219
115
|
}
|
220
|
-
export class
|
116
|
+
export class MappingTestState extends TestableTestEditorState {
|
117
|
+
parentState;
|
118
|
+
mappingTestableState;
|
119
|
+
uuid = uuid();
|
221
120
|
test;
|
222
|
-
|
223
|
-
constructor(editorStore,
|
224
|
-
super(
|
121
|
+
dataState;
|
122
|
+
constructor(editorStore, parentSuiteState, test) {
|
123
|
+
super(parentSuiteState.mappingTestableState.mapping, test, parentSuiteState.mappingTestableState.mappingEditorState.isReadOnly, editorStore);
|
225
124
|
makeObservable(this, {
|
226
|
-
defaultTab: observable,
|
227
125
|
selectedAsertionState: observable,
|
228
126
|
selectedTab: observable,
|
229
127
|
assertionToRename: observable,
|
230
128
|
assertionEditorStates: observable,
|
231
129
|
testResultState: observable,
|
232
130
|
runningTestAction: observable,
|
131
|
+
dataState: observable,
|
233
132
|
addAssertion: action,
|
234
133
|
setAssertionToRename: action,
|
235
134
|
handleTestResult: action,
|
236
|
-
buildQueryState: action,
|
237
135
|
setSelectedTab: action,
|
238
136
|
runTest: flow,
|
239
|
-
test: observable,
|
240
137
|
});
|
138
|
+
this.parentState = parentSuiteState;
|
139
|
+
this.mappingTestableState = parentSuiteState.mappingTestableState;
|
241
140
|
this.test = test;
|
242
|
-
this.
|
141
|
+
this.selectedTab = this.defaultTab();
|
142
|
+
this.dataState = new MappingTestDataState(this.editorStore, parentSuiteState.mappingTestableState, test);
|
243
143
|
}
|
244
144
|
defaultTab() {
|
245
145
|
return TESTABLE_TEST_TAB.SETUP;
|
246
146
|
}
|
247
|
-
buildQueryState() {
|
248
|
-
const queryState = new MappingTestableQueryState(this.editorStore, this.test, this.test.func);
|
249
|
-
flowResult(queryState.updateLamba(this.test.func)).catch(this.editorStore.applicationStore.alertUnhandledError);
|
250
|
-
return queryState;
|
251
|
-
}
|
252
147
|
}
|
253
|
-
export class
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
148
|
+
export class MappingTestSuiteQueryState extends LambdaEditorState {
|
149
|
+
editorStore;
|
150
|
+
parent;
|
151
|
+
isInitializingLambda = false;
|
152
|
+
query;
|
153
|
+
constructor(editorStore, parent, query) {
|
154
|
+
super('', LAMBDA_PIPE);
|
258
155
|
makeObservable(this, {
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
assertionEditorStates: observable,
|
264
|
-
testResultState: observable,
|
265
|
-
runningTestAction: observable,
|
266
|
-
addAssertion: action,
|
267
|
-
setAssertionToRename: action,
|
268
|
-
handleTestResult: action,
|
269
|
-
setSelectedTab: action,
|
270
|
-
runTest: flow,
|
271
|
-
test: observable,
|
156
|
+
query: observable,
|
157
|
+
isInitializingLambda: observable,
|
158
|
+
setIsInitializingLambda: action,
|
159
|
+
updateLamba: flow,
|
272
160
|
});
|
273
|
-
this.
|
274
|
-
this.
|
161
|
+
this.parent = parent;
|
162
|
+
this.editorStore = editorStore;
|
163
|
+
this.query = query;
|
275
164
|
}
|
276
|
-
|
277
|
-
return
|
165
|
+
get lambdaId() {
|
166
|
+
return buildSourceInformationSourceId([this.uuid]);
|
167
|
+
}
|
168
|
+
setIsInitializingLambda(val) {
|
169
|
+
this.isInitializingLambda = val;
|
170
|
+
}
|
171
|
+
*updateLamba(val) {
|
172
|
+
this.query = val;
|
173
|
+
mappingTestable_setQuery(this.parent, val);
|
174
|
+
yield flowResult(this.convertLambdaObjectToGrammarString(true));
|
175
|
+
}
|
176
|
+
*convertLambdaObjectToGrammarString(pretty) {
|
177
|
+
if (!isStubbed_RawLambda(this.query)) {
|
178
|
+
try {
|
179
|
+
const lambdas = new Map();
|
180
|
+
lambdas.set(this.lambdaId, this.query);
|
181
|
+
const isolatedLambdas = (yield this.editorStore.graphManagerState.graphManager.lambdasToPureCode(lambdas, pretty));
|
182
|
+
const grammarText = isolatedLambdas.get(this.lambdaId);
|
183
|
+
this.setLambdaString(grammarText !== undefined
|
184
|
+
? this.extractLambdaString(grammarText)
|
185
|
+
: '');
|
186
|
+
this.clearErrors();
|
187
|
+
}
|
188
|
+
catch (error) {
|
189
|
+
assertErrorThrown(error);
|
190
|
+
this.editorStore.applicationStore.logService.error(LogEvent.create(GRAPH_MANAGER_EVENT.PARSING_FAILURE), error);
|
191
|
+
}
|
192
|
+
}
|
193
|
+
else {
|
194
|
+
this.clearErrors();
|
195
|
+
this.setLambdaString('');
|
196
|
+
}
|
197
|
+
}
|
198
|
+
// NOTE: since we don't allow edition in text mode, we don't need to implement this
|
199
|
+
*convertLambdaGrammarStringToObject() {
|
200
|
+
throw new UnsupportedOperationError();
|
278
201
|
}
|
279
202
|
}
|
280
203
|
export class MappingTestSuiteState extends TestableTestSuiteEditorState {
|
@@ -283,20 +206,65 @@ export class MappingTestSuiteState extends TestableTestSuiteEditorState {
|
|
283
206
|
testStates = [];
|
284
207
|
selectTestState;
|
285
208
|
showCreateModal = false;
|
209
|
+
queryState;
|
286
210
|
constructor(editorStore, mappingTestableState, suite) {
|
287
211
|
super(mappingTestableState.mapping, suite, mappingTestableState.mappingEditorState.isReadOnly, editorStore);
|
212
|
+
makeObservable(this, {
|
213
|
+
queryState: observable,
|
214
|
+
showCreateModal: observable,
|
215
|
+
selectTestState: observable,
|
216
|
+
runningSuiteState: observable,
|
217
|
+
setShowModal: action,
|
218
|
+
changeTest: action,
|
219
|
+
addNewTest: action,
|
220
|
+
deleteTest: action,
|
221
|
+
buildQueryState: action,
|
222
|
+
buildTestState: action,
|
223
|
+
createStoreTestData: action,
|
224
|
+
runSuite: flow,
|
225
|
+
runFailingTests: flow,
|
226
|
+
});
|
288
227
|
this.mappingTestableState = mappingTestableState;
|
289
228
|
this.suite = suite;
|
290
229
|
this.testStates = this.buildTestStates();
|
291
230
|
this.selectTestState = this.testStates[0];
|
231
|
+
this.queryState = this.buildQueryState();
|
292
232
|
}
|
293
233
|
buildTestStates() {
|
294
234
|
return this.suite.tests
|
295
235
|
.map((t) => this.buildTestState(t))
|
296
236
|
.filter(isNonNullable);
|
297
237
|
}
|
238
|
+
buildTestState(val) {
|
239
|
+
if (val instanceof MappingTest) {
|
240
|
+
return new MappingTestState(this.editorStore, this, val);
|
241
|
+
}
|
242
|
+
return undefined;
|
243
|
+
}
|
244
|
+
buildQueryState() {
|
245
|
+
const queryState = new MappingTestSuiteQueryState(this.editorStore, this.suite, this.suite.func);
|
246
|
+
flowResult(queryState.updateLamba(this.suite.func)).catch(this.editorStore.applicationStore.alertUnhandledError);
|
247
|
+
return queryState;
|
248
|
+
}
|
249
|
+
createStoreTestData(targetClass) {
|
250
|
+
const firstData = this.suite.tests.filter(filterByType(MappingTest))[0]
|
251
|
+
?.storeTestData[0];
|
252
|
+
if (firstData) {
|
253
|
+
const storeTestData = new StoreTestData();
|
254
|
+
storeTestData.store = PackageableElementExplicitReference.create(firstData.store.value);
|
255
|
+
storeTestData.data = firstData.data.accept_EmbeddedDataVisitor(new EmbeddedDataCreatorFromEmbeddedData());
|
256
|
+
return storeTestData;
|
257
|
+
}
|
258
|
+
else if (targetClass) {
|
259
|
+
const rootSetImpl = getRootSetImplementation(this.mappingTestableState.mapping, targetClass);
|
260
|
+
return rootSetImpl
|
261
|
+
? generateStoreTestDataFromSetImpl(rootSetImpl, this.editorStore)
|
262
|
+
: undefined;
|
263
|
+
}
|
264
|
+
return undefined;
|
265
|
+
}
|
298
266
|
addNewTest(id, _class) {
|
299
|
-
const test =
|
267
|
+
const test = createBareMappingTest(id, this.createStoreTestData(_class), this.suite);
|
300
268
|
testSuite_addTest(this.suite, test, this.mappingTestableState.editorStore.changeDetectionState
|
301
269
|
.observerContext);
|
302
270
|
const testState = this.buildTestState(test);
|
@@ -324,94 +292,6 @@ export class MappingTestSuiteState extends TestableTestSuiteEditorState {
|
|
324
292
|
this.testStates = this.testStates.filter((e) => e.test !== val);
|
325
293
|
}
|
326
294
|
}
|
327
|
-
export class MappingDataTestSuiteState extends MappingTestSuiteState {
|
328
|
-
suite;
|
329
|
-
dataState;
|
330
|
-
constructor(editorStore, mappingTestableState, suite) {
|
331
|
-
super(editorStore, mappingTestableState, suite);
|
332
|
-
makeObservable(this, {
|
333
|
-
testStates: observable,
|
334
|
-
selectTestState: observable,
|
335
|
-
showCreateModal: observable,
|
336
|
-
buildTestStates: action,
|
337
|
-
changeTest: action,
|
338
|
-
deleteTest: action,
|
339
|
-
removeTestState: action,
|
340
|
-
addNewTest: action,
|
341
|
-
setShowModal: action,
|
342
|
-
runFailingTests: flow,
|
343
|
-
runSuite: flow,
|
344
|
-
});
|
345
|
-
this.suite = suite;
|
346
|
-
this.dataState = new MappingTestableDataState(this.editorStore, mappingTestableState, suite);
|
347
|
-
}
|
348
|
-
buildTestState(val) {
|
349
|
-
if (val instanceof MappingQueryTest) {
|
350
|
-
return new MappingQueryTestState(this.editorStore, this.mappingTestableState, val);
|
351
|
-
}
|
352
|
-
return undefined;
|
353
|
-
}
|
354
|
-
createNewTest(id, _class) {
|
355
|
-
const query = _class
|
356
|
-
? this.mappingTestableState.createSuiteState.createDefaultQuery(_class)
|
357
|
-
: stub_RawLambda();
|
358
|
-
return createBareMappingQueryTest(id, query, this.suite);
|
359
|
-
}
|
360
|
-
getDefaultClass() {
|
361
|
-
return getMappingCompatibleClasses(this.dataState.mappingTestableState.mapping, this.dataState.mappingTestableState.editorStore.graphManagerState
|
362
|
-
.usableClasses)[0];
|
363
|
-
}
|
364
|
-
}
|
365
|
-
export class MappingQueryTestSuiteState extends MappingTestSuiteState {
|
366
|
-
suite;
|
367
|
-
queryState;
|
368
|
-
constructor(editorStore, mappingTestableState, suite) {
|
369
|
-
super(editorStore, mappingTestableState, suite);
|
370
|
-
makeObservable(this, {
|
371
|
-
queryState: observable,
|
372
|
-
testStates: observable,
|
373
|
-
selectTestState: observable,
|
374
|
-
showCreateModal: observable,
|
375
|
-
deleteTest: action,
|
376
|
-
buildTestStates: action,
|
377
|
-
buildQueryState: action,
|
378
|
-
addNewTest: action,
|
379
|
-
changeTest: action,
|
380
|
-
setShowModal: action,
|
381
|
-
runFailingTests: flow,
|
382
|
-
runSuite: flow,
|
383
|
-
});
|
384
|
-
this.suite = suite;
|
385
|
-
this.queryState = this.buildQueryState();
|
386
|
-
}
|
387
|
-
buildTestState(val) {
|
388
|
-
if (val instanceof MappingDataTest) {
|
389
|
-
return new MappingDataTestState(this.editorStore, this.mappingTestableState, val);
|
390
|
-
}
|
391
|
-
return undefined;
|
392
|
-
}
|
393
|
-
createNewTest(id, _class) {
|
394
|
-
const data = _class
|
395
|
-
? createBareModelStoreData(_class, this.mappingTestableState.editorStore)
|
396
|
-
: undefined;
|
397
|
-
return createBareMappingDataTest(id, data, this.suite);
|
398
|
-
}
|
399
|
-
buildQueryState() {
|
400
|
-
const queryState = new MappingTestableQueryState(this.editorStore, this.suite, this.suite.func);
|
401
|
-
flowResult(queryState.updateLamba(this.suite.func)).catch(this.editorStore.applicationStore.alertUnhandledError);
|
402
|
-
return queryState;
|
403
|
-
}
|
404
|
-
getDefaultClass() {
|
405
|
-
const dataTest = this.suite.tests.filter(filterByType(MappingDataTest))[0];
|
406
|
-
if (dataTest) {
|
407
|
-
const storeTestData = dataTest.storeTestData[0]?.data;
|
408
|
-
if (storeTestData instanceof ModelStoreData) {
|
409
|
-
return storeTestData.modelData?.[0]?.model.value;
|
410
|
-
}
|
411
|
-
}
|
412
|
-
return undefined;
|
413
|
-
}
|
414
|
-
}
|
415
295
|
export class CreateSuiteState {
|
416
296
|
editorStore;
|
417
297
|
mappingTestableState;
|
@@ -422,61 +302,34 @@ export class CreateSuiteState {
|
|
422
302
|
this.mappingTestableState = mappingTestableState;
|
423
303
|
makeObservable(this, {
|
424
304
|
showModal: observable,
|
425
|
-
setShowModal: action,
|
426
305
|
createAndAddTestSuite: flow,
|
427
306
|
isCreatingSuiteState: observable,
|
428
307
|
});
|
429
308
|
}
|
430
|
-
|
431
|
-
this.showModal = val;
|
432
|
-
}
|
433
|
-
*createAndAddTestSuite(_class, type, name, testName) {
|
434
|
-
// type
|
309
|
+
*createAndAddTestSuite(_class, suiteName, testName) {
|
435
310
|
try {
|
436
311
|
this.isCreatingSuiteState.inProgress();
|
437
312
|
const mappingTestableState = this.mappingTestableState;
|
313
|
+
const mappingTestSuite = new MappingTestSuite();
|
314
|
+
mappingTestSuite.id = suiteName;
|
315
|
+
// mapping anaylsis
|
438
316
|
if (!mappingTestableState.mappingModelCoverageAnalysisResult) {
|
439
317
|
this.isCreatingSuiteState.setMessage('Analyzing mapping to generate test query...');
|
440
318
|
yield flowResult(mappingTestableState.analyzeMappingModelCoverage());
|
441
319
|
}
|
442
320
|
this.isCreatingSuiteState.setMessage('Creating test query...');
|
443
|
-
|
444
|
-
|
321
|
+
// add query
|
322
|
+
mappingTestSuite.func = createGraphFetchQueryFromMappingAnalysis(_class, mappingTestableState.editorStore.graphManagerState, mappingTestableState.mappingModelCoverageAnalysisResult);
|
323
|
+
// add first test
|
324
|
+
const rootSetImpl = getRootSetImplementation(mappingTestableState.mapping, _class);
|
445
325
|
const storeTestData = rootSetImpl
|
446
|
-
?
|
326
|
+
? generateStoreTestDataFromSetImpl(rootSetImpl, this.editorStore)
|
447
327
|
: undefined;
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
test.__parent = dataSuite;
|
454
|
-
dataSuite.tests = [test];
|
455
|
-
const _assertion = createDefaultEqualToJSONTestAssertion(`${testName}_assertion1`);
|
456
|
-
test.assertions = [_assertion];
|
457
|
-
_assertion.parentTest = test;
|
458
|
-
testSuite = dataSuite;
|
459
|
-
}
|
460
|
-
else {
|
461
|
-
const querySuite = new MappingQueryTestSuite();
|
462
|
-
querySuite.func = query;
|
463
|
-
// add test
|
464
|
-
const _test = createBareMappingDataTest(testName, storeTestData, querySuite);
|
465
|
-
const _assertion = createDefaultEqualToJSONTestAssertion(`${testName}_assertion1`);
|
466
|
-
_test.assertions = [_assertion];
|
467
|
-
_assertion.parentTest = _test;
|
468
|
-
testSuite = querySuite;
|
469
|
-
}
|
470
|
-
testSuite.id = name;
|
471
|
-
mapping_addTestSuite(this.mappingTestableState.mapping, testSuite, this.editorStore.changeDetectionState.observerContext);
|
472
|
-
this.mappingTestableState.changeSuite(testSuite);
|
473
|
-
const selectTestState = this.mappingTestableState.selectedTestSuite?.selectTestState;
|
474
|
-
const selectedAsertionState = selectTestState?.selectedAsertionState;
|
475
|
-
if (selectTestState && selectedAsertionState) {
|
476
|
-
this.isCreatingSuiteState.setMessage('Attempting to generate expected result...');
|
477
|
-
yield flowResult(selectedAsertionState.generateExpected());
|
478
|
-
}
|
479
|
-
this.setShowModal(false);
|
328
|
+
createBareMappingTest(testName, storeTestData, mappingTestSuite);
|
329
|
+
// set test suite
|
330
|
+
mapping_addTestSuite(this.mappingTestableState.mapping, mappingTestSuite, this.editorStore.changeDetectionState.observerContext);
|
331
|
+
this.mappingTestableState.changeSuite(mappingTestSuite);
|
332
|
+
this.mappingTestableState.closeCreateModal();
|
480
333
|
}
|
481
334
|
catch (error) {
|
482
335
|
assertErrorThrown(error);
|
@@ -487,81 +340,19 @@ export class CreateSuiteState {
|
|
487
340
|
this.isCreatingSuiteState.setMessage(undefined);
|
488
341
|
}
|
489
342
|
}
|
490
|
-
createDefaultQuery(_class) {
|
491
|
-
try {
|
492
|
-
const mappingTestableState = this.mappingTestableState;
|
493
|
-
const anaylsis = guaranteeNonNullable(mappingTestableState.mappingModelCoverageAnalysisResult);
|
494
|
-
const mappedEntity = guaranteeNonNullable(anaylsis.mappedEntities.find((e) => e.path === _class.path));
|
495
|
-
const rootTree = new RootGraphFetchTree(PackageableElementExplicitReference.create(_class));
|
496
|
-
// TODO: allow complex properties
|
497
|
-
mappedEntity.properties.forEach((e) => {
|
498
|
-
if (!(e instanceof EntityMappedProperty)) {
|
499
|
-
const name = e.name;
|
500
|
-
const property = getAllClassProperties(_class)
|
501
|
-
.concat(
|
502
|
-
// we fetch mapped derived properties without parameters
|
503
|
-
getAllClassDerivedProperties(_class).filter((p) => !p.parameters || !p.parameters.length))
|
504
|
-
.find((prop) => prop.name === name);
|
505
|
-
if (property) {
|
506
|
-
const subTree = new PropertyGraphFetchTree(PropertyExplicitReference.create(property), undefined);
|
507
|
-
rootTree.subTrees.push(subTree);
|
508
|
-
}
|
509
|
-
}
|
510
|
-
});
|
511
|
-
assertTrue(!rootTree.isEmpty);
|
512
|
-
return createGraphFetchLambda(_class, this.editorStore.graphManagerState, rootTree);
|
513
|
-
}
|
514
|
-
catch (error) {
|
515
|
-
assertErrorThrown(error);
|
516
|
-
const lambdaFunction = new LambdaFunction(new FunctionType(PackageableElementExplicitReference.create(this.editorStore.graphManagerState.graph.getType(CORE_PURE_PATH.ANY)), Multiplicity.ONE));
|
517
|
-
lambdaFunction.expressionSequence = [
|
518
|
-
buildGetAllFunction(_class, Multiplicity.ONE),
|
519
|
-
];
|
520
|
-
return buildRawLambdaFromLambdaFunction(lambdaFunction, this.editorStore.graphManagerState);
|
521
|
-
}
|
522
|
-
}
|
523
|
-
// change to use api call for relational
|
524
|
-
attemptToGenerateTestData(setImpl, editorStore) {
|
525
|
-
if (setImpl instanceof RelationalInstanceSetImplementation ||
|
526
|
-
setImpl instanceof EmbeddedRelationalInstanceSetImplementation ||
|
527
|
-
setImpl instanceof EmbeddedRelationalInstanceSetImplementation) {
|
528
|
-
const _table = getMappingElementSource(setImpl, editorStore.pluginManager.getApplicationPlugins());
|
529
|
-
if (_table instanceof TableAlias) {
|
530
|
-
const relation = _table.relation.value;
|
531
|
-
const owner = relation.schema._OWNER;
|
532
|
-
const val = new RelationalCSVData();
|
533
|
-
if (relation instanceof Table) {
|
534
|
-
const mockTable = new RelationalCSVDataTable();
|
535
|
-
const values = createMockDataForTable(relation);
|
536
|
-
mockTable.table = relation.name;
|
537
|
-
mockTable.schema = relation.schema.name;
|
538
|
-
mockTable.values = values;
|
539
|
-
val.tables.push(mockTable);
|
540
|
-
}
|
541
|
-
const testData = new StoreTestData();
|
542
|
-
testData.data = val;
|
543
|
-
testData.store = PackageableElementExplicitReference.create(owner);
|
544
|
-
return testData;
|
545
|
-
}
|
546
|
-
}
|
547
|
-
else if (setImpl instanceof PureInstanceSetImplementation) {
|
548
|
-
const srcClass = setImpl.srcClass;
|
549
|
-
if (srcClass) {
|
550
|
-
return createBareModelStoreData(srcClass.value, this.mappingTestableState.editorStore);
|
551
|
-
}
|
552
|
-
}
|
553
|
-
return undefined;
|
554
|
-
}
|
555
343
|
}
|
556
344
|
export class MappingTestableState {
|
557
345
|
editorStore;
|
558
346
|
mappingEditorState;
|
559
|
-
selectedTestSuite;
|
560
|
-
testableComponentToRename;
|
561
|
-
// state
|
562
|
-
createSuiteState;
|
563
347
|
mappingModelCoverageAnalysisState = ActionState.create();
|
564
348
|
mappingModelCoverageAnalysisResult;
|
349
|
+
testableComponentToRename;
|
350
|
+
createSuiteState;
|
351
|
+
isRunningTestableSuitesState = ActionState.create();
|
352
|
+
isRunningFailingSuitesState = ActionState.create();
|
353
|
+
selectedTestSuite;
|
354
|
+
testableResults;
|
355
|
+
runningSuite;
|
565
356
|
constructor(editorStore, mappingEditorState) {
|
566
357
|
makeObservable(this, {
|
567
358
|
mappingModelCoverageAnalysisResult: observable,
|
@@ -569,33 +360,82 @@ export class MappingTestableState {
|
|
569
360
|
selectedTestSuite: observable,
|
570
361
|
testableComponentToRename: observable,
|
571
362
|
renameTestableComponent: observable,
|
363
|
+
testableResults: observable,
|
364
|
+
createSuiteState: observable,
|
572
365
|
changeSuite: action,
|
366
|
+
closeCreateModal: action,
|
367
|
+
openCreateModal: action,
|
573
368
|
init: action,
|
574
369
|
deleteTestSuite: action,
|
575
370
|
analyzeMappingModelCoverage: flow,
|
576
371
|
setRenameComponent: action,
|
372
|
+
handleNewResults: action,
|
373
|
+
runTestable: flow,
|
374
|
+
runSuite: flow,
|
375
|
+
runAllFailingSuites: flow,
|
577
376
|
});
|
578
377
|
this.editorStore = editorStore;
|
579
378
|
this.mappingEditorState = mappingEditorState;
|
580
|
-
this.createSuiteState = new CreateSuiteState(this.editorStore, this);
|
581
379
|
this.init();
|
582
380
|
}
|
583
381
|
get mapping() {
|
584
382
|
return this.mappingEditorState.mapping;
|
585
383
|
}
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
384
|
+
get suiteCount() {
|
385
|
+
return this.mapping.tests.length;
|
386
|
+
}
|
387
|
+
get passingSuites() {
|
388
|
+
const results = this.testableResults;
|
389
|
+
if (results?.length) {
|
390
|
+
return this.mapping.tests.filter((suite) => results
|
391
|
+
.filter((res) => res.parentSuite?.id === suite.id)
|
392
|
+
.every((e) => isTestPassing(e)));
|
590
393
|
}
|
394
|
+
return [];
|
395
|
+
}
|
396
|
+
get failingSuites() {
|
397
|
+
const results = this.testableResults;
|
398
|
+
if (results?.length) {
|
399
|
+
return this.mapping.tests.filter((suite) => results
|
400
|
+
.filter((res) => res.parentSuite?.id === suite.id)
|
401
|
+
.some((e) => !isTestPassing(e)));
|
402
|
+
}
|
403
|
+
return [];
|
404
|
+
}
|
405
|
+
get staticSuites() {
|
406
|
+
const results = this.testableResults;
|
407
|
+
if (results?.length) {
|
408
|
+
return this.mapping.tests.filter((suite) => results.every((res) => res.parentSuite?.id !== suite.id));
|
409
|
+
}
|
410
|
+
return this.mapping.tests;
|
411
|
+
}
|
412
|
+
resolveSuiteResults(suite) {
|
413
|
+
return this.testableResults?.filter((t) => t.parentSuite?.id === suite.id);
|
414
|
+
}
|
415
|
+
clearTestResultsForSuite(suite) {
|
416
|
+
this.testableResults = this.testableResults?.filter((t) => !(this.resolveSuiteResults(suite) ?? []).includes(t));
|
417
|
+
}
|
418
|
+
setTestableResults(val) {
|
419
|
+
this.testableResults = val;
|
591
420
|
}
|
592
421
|
init() {
|
593
|
-
// TODO: ? should we add a test suite here by default if certain things
|
594
422
|
const suite = this.mapping.tests[0];
|
595
423
|
this.selectedTestSuite = suite
|
596
424
|
? this.buildTestSuiteState(suite)
|
597
425
|
: undefined;
|
598
426
|
}
|
427
|
+
openCreateModal() {
|
428
|
+
this.createSuiteState = new CreateSuiteState(this.editorStore, this);
|
429
|
+
}
|
430
|
+
closeCreateModal() {
|
431
|
+
this.createSuiteState = undefined;
|
432
|
+
}
|
433
|
+
renameTestableComponent(val) {
|
434
|
+
const _component = this.testableComponentToRename;
|
435
|
+
if (_component) {
|
436
|
+
testable_setId(_component, val ?? '');
|
437
|
+
}
|
438
|
+
}
|
599
439
|
changeSuite(suite) {
|
600
440
|
if (this.selectedTestSuite?.suite !== suite) {
|
601
441
|
this.selectedTestSuite = this.buildTestSuiteState(suite);
|
@@ -610,22 +450,11 @@ export class MappingTestableState {
|
|
610
450
|
this.init();
|
611
451
|
}
|
612
452
|
}
|
613
|
-
buildTestSuiteStates() {
|
614
|
-
return this.mapping.tests
|
615
|
-
.map((suite) => this.buildTestSuiteState(suite))
|
616
|
-
.filter(isNonNullable);
|
617
|
-
}
|
618
453
|
buildTestSuiteState(val) {
|
619
|
-
|
620
|
-
return new MappingQueryTestSuiteState(this.editorStore, this, val);
|
621
|
-
}
|
622
|
-
else if (val instanceof MappingDataTestSuite) {
|
623
|
-
return new MappingDataTestSuiteState(this.editorStore, this, val);
|
624
|
-
}
|
625
|
-
return undefined;
|
454
|
+
return new MappingTestSuiteState(this.editorStore, this, val);
|
626
455
|
}
|
627
|
-
// check to only anaylsis when mapping has changed
|
628
456
|
*analyzeMappingModelCoverage() {
|
457
|
+
this.mappingModelCoverageAnalysisResult = undefined;
|
629
458
|
this.mappingModelCoverageAnalysisState.inProgress();
|
630
459
|
this.mappingModelCoverageAnalysisState.setMessage('Analyzing Mapping...');
|
631
460
|
try {
|
@@ -633,17 +462,89 @@ export class MappingTestableState {
|
|
633
462
|
}
|
634
463
|
catch (error) {
|
635
464
|
assertErrorThrown(error);
|
636
|
-
this.editorStore.applicationStore.
|
465
|
+
this.editorStore.applicationStore.logService.error(LogEvent.create(LEGEND_STUDIO_APP_EVENT.MAPPING_TEST_FAILURE), error);
|
637
466
|
}
|
638
467
|
finally {
|
639
468
|
this.mappingModelCoverageAnalysisState.complete();
|
640
469
|
}
|
641
470
|
}
|
642
|
-
|
643
|
-
|
471
|
+
*runSuite(suite) {
|
472
|
+
try {
|
473
|
+
this.runningSuite = suite;
|
474
|
+
this.clearTestResultsForSuite(suite);
|
475
|
+
this.selectedTestSuite?.testStates.forEach((t) => t.resetResult());
|
476
|
+
this.selectedTestSuite?.testStates.forEach((t) => t.runningTestAction.inProgress());
|
477
|
+
const input = new RunTestsTestableInput(this.mapping);
|
478
|
+
suite.tests.forEach((t) => input.unitTestIds.push(new UniqueTestId(suite, t)));
|
479
|
+
const testResults = (yield this.editorStore.graphManagerState.graphManager.runTests([input], this.editorStore.graphManagerState.graph));
|
480
|
+
this.handleNewResults(testResults);
|
481
|
+
}
|
482
|
+
catch (error) {
|
483
|
+
assertErrorThrown(error);
|
484
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
485
|
+
this.isRunningTestableSuitesState.fail();
|
486
|
+
}
|
487
|
+
finally {
|
488
|
+
this.selectedTestSuite?.testStates.forEach((t) => t.runningTestAction.complete());
|
489
|
+
this.runningSuite = undefined;
|
490
|
+
}
|
644
491
|
}
|
645
|
-
|
646
|
-
|
492
|
+
*runTestable() {
|
493
|
+
try {
|
494
|
+
this.setTestableResults(undefined);
|
495
|
+
this.isRunningTestableSuitesState.inProgress();
|
496
|
+
this.selectedTestSuite?.testStates.forEach((t) => t.resetResult());
|
497
|
+
this.selectedTestSuite?.testStates.forEach((t) => t.runningTestAction.inProgress());
|
498
|
+
const input = new RunTestsTestableInput(this.mapping);
|
499
|
+
const testResults = (yield this.editorStore.graphManagerState.graphManager.runTests([input], this.editorStore.graphManagerState.graph));
|
500
|
+
this.handleNewResults(testResults);
|
501
|
+
this.isRunningTestableSuitesState.complete();
|
502
|
+
}
|
503
|
+
catch (error) {
|
504
|
+
assertErrorThrown(error);
|
505
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
506
|
+
this.isRunningTestableSuitesState.fail();
|
507
|
+
}
|
508
|
+
finally {
|
509
|
+
this.selectedTestSuite?.testStates.forEach((t) => t.runningTestAction.complete());
|
510
|
+
}
|
511
|
+
}
|
512
|
+
*runAllFailingSuites() {
|
513
|
+
try {
|
514
|
+
this.isRunningFailingSuitesState.inProgress();
|
515
|
+
const input = new RunTestsTestableInput(this.mapping);
|
516
|
+
this.failingSuites.forEach((s) => {
|
517
|
+
s.tests.forEach((t) => input.unitTestIds.push(new UniqueTestId(s, t)));
|
518
|
+
});
|
519
|
+
const testResults = (yield this.editorStore.graphManagerState.graphManager.runTests([input], this.editorStore.graphManagerState.graph));
|
520
|
+
this.handleNewResults(testResults);
|
521
|
+
this.isRunningFailingSuitesState.complete();
|
522
|
+
}
|
523
|
+
catch (error) {
|
524
|
+
assertErrorThrown(error);
|
525
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
526
|
+
this.isRunningFailingSuitesState.fail();
|
527
|
+
}
|
528
|
+
finally {
|
529
|
+
this.selectedTestSuite?.testStates.forEach((t) => t.runningTestAction.complete());
|
530
|
+
}
|
531
|
+
}
|
532
|
+
handleNewResults(results) {
|
533
|
+
if (this.testableResults?.length) {
|
534
|
+
const newSuitesResults = results
|
535
|
+
.map((e) => e.parentSuite?.id)
|
536
|
+
.filter(isNonNullable);
|
537
|
+
const reducedFilters = this.testableResults.filter((res) => !newSuitesResults.includes(res.parentSuite?.id ?? ''));
|
538
|
+
this.setTestableResults([...reducedFilters, ...results]);
|
539
|
+
}
|
540
|
+
else {
|
541
|
+
this.setTestableResults(results);
|
542
|
+
}
|
543
|
+
this.testableResults?.forEach((result) => {
|
544
|
+
const state = this.selectedTestSuite?.testStates.find((t) => t.test.id === result.atomicTest.id &&
|
545
|
+
t.parentState.suite.id === result.parentSuite?.id);
|
546
|
+
state?.handleTestResult(result);
|
547
|
+
});
|
647
548
|
}
|
648
549
|
}
|
649
550
|
//# sourceMappingURL=MappingTestableState.js.map
|