Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter multiplicity validation for service registration #1538

Merged
merged 2 commits into from
Oct 10, 2022

Conversation

irisyngao
Copy link
Contributor

@irisyngao irisyngao commented Oct 6, 2022

Summary

Add a parameter multiplicity validation when registering a service.
For MANY multiplicity, the allowed range is [0..*, .., ].
If users try to use [1..
] or others that have *, Studio will throw an error notification.

Fixes #1539
Depends on #1543

How did you test this change?

  • Test(s) added
  • Manual testing (please provide screenshots/recordings)
  • No testing (please provide an explanation)

@changeset-bot
Copy link

changeset-bot bot commented Oct 6, 2022

🦋 Changeset detected

Latest commit: efea3c6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
@finos/legend-graph Patch
@finos/legend-application-studio Patch
@finos/legend-application-query-bootstrap Patch
@finos/legend-application-query Patch
@finos/legend-application-studio-bootstrap Patch
@finos/legend-application-taxonomy-bootstrap Patch
@finos/legend-application-taxonomy Patch
@finos/legend-application Patch
@finos/legend-extension-dsl-data-space Patch
@finos/legend-extension-dsl-diagram Patch
@finos/legend-extension-dsl-mastery Patch
@finos/legend-extension-dsl-persistence-cloud Patch
@finos/legend-extension-dsl-persistence Patch
@finos/legend-extension-dsl-service Patch
@finos/legend-extension-dsl-text Patch
@finos/legend-extension-format-json-schema Patch
@finos/legend-extension-format-morphir Patch
@finos/legend-extension-store-flat-data Patch
@finos/legend-extension-store-relational Patch
@finos/legend-extension-store-service-store Patch
@finos/legend-manual-tests Patch
@finos/legend-query-builder Patch
@finos/legend-application-query-deployment Patch
@finos/legend-application-studio-deployment Patch
@finos/legend-application-taxonomy-deployment Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@finos-cla-bot finos-cla-bot bot added the cla-present CLA Signed label Oct 6, 2022
@irisyngao irisyngao self-assigned this Oct 6, 2022
@codecov
Copy link

codecov bot commented Oct 6, 2022

Codecov Report

Merging #1538 (6db2a1e) into master (a6830b4) will increase coverage by 0.01%.
The diff coverage is 71.42%.

❗ Current head 6db2a1e differs from pull request most recent head efea3c6. Consider uploading reports for the commit efea3c6 to get more accurate results

@@            Coverage Diff             @@
##           master    #1538      +/-   ##
==========================================
+ Coverage   40.57%   40.59%   +0.01%     
==========================================
  Files        1264     1264              
  Lines       56295    56284      -11     
  Branches    12718    12708      -10     
==========================================
+ Hits        22843    22847       +4     
+ Misses      33370    33355      -15     
  Partials       82       82              
Impacted Files Coverage Δ
...t-editor-state/service/ServiceRegistrationState.ts 78.22% <71.42%> (-0.41%) ⬇️
...nt-editor-state/mapping/MappingElementDecorator.ts 21.25% <0.00%> (-0.83%) ⬇️
...der/src/components/QueryBuilderParametersPanel.tsx 41.90% <0.00%> (ø)
...rc/components/editor/edit-panel/FunctionEditor.tsx 14.46% <0.00%> (ø)
...nents/editor/edit-panel/uml-editor/ClassEditor.tsx 51.07% <0.00%> (ø)
...editor/edit-panel/uml-editor/AssociationEditor.tsx 74.28% <0.00%> (ø)
...re/v1/V1_QueryBuilder_FunctionExpressionBuilder.ts 100.00% <0.00%> (ø)
...QueryBuilderProjectionValueSpecificationBuilder.ts 95.74% <0.00%> (ø)
.../pureGraph/to/helpers/V1_MilestoneBuilderHelper.ts 65.11% <0.00%> (ø)
...re/STO_ServiceStore_PureProtocolProcessorPlugin.ts 85.79% <0.00%> (ø)
... and 3 more

Copy link
Member

@MauricioUyaguari MauricioUyaguari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please confirm your test. Thanks

this.editorStore.applicationStore.notifyError(
`Multiplicy of ${params.map(
(p) => p.name,
)} is/are [1..*], which is not in the allowed range for MANY multiplicity. Please use [*], [0..*] instead.`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets confirm the list of accepted Multiplicies

@irisyngao irisyngao changed the title Add a parameter multiplicity validation for service registration Add parameter multiplicity validation for service registration Oct 6, 2022
Copy link
Member

@MauricioUyaguari MauricioUyaguari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please ensure error message prints expected message

@irisyngao irisyngao force-pushed the registration_validation branch 3 times, most recently from fd5e645 to 4eee71f Compare October 6, 2022 19:43
);
assertTrue(
invalidParams.length === 0,
`${invalidParams.map(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameters p1:[1..], p2:[1..] have unsupported multiplicities

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen Shot 2022-10-06 at 4 44 40 PM

)
.filter(filterByType(VariableExpression))
.filter(
(p) => !supportedServiceParamMultiplicties.includes(p.multiplicity),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think we can always assume multiplicity comes from the same graph and the multiplicity index. The most appropriate check here is to do the comparison by lower and upper bounds. The fact we cache multiplicities in the graph is just small optimization, we don't require other coders to have to know about it. I think it's best to create a comparator helper for multiplicity and use this. I almost guarantee this might cause a bug some day 🤷

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah in terms of bugs i think we could just use comparator. we should try to always use the getMultiplicity though so they are still the same object.
but in this casse if they happen to be different objects we should still not allow the ones with unsupported multiplicities.

@irisyngao irisyngao force-pushed the registration_validation branch from 62a625c to 8a435af Compare October 10, 2022 16:29
improve condition and error messages

improve error message

add a comparator for multiplicity
@irisyngao irisyngao force-pushed the registration_validation branch from 8a435af to cfe3a4c Compare October 10, 2022 16:30
@MauricioUyaguari MauricioUyaguari merged commit 34d6f9d into finos:master Oct 10, 2022
@irisyngao irisyngao deleted the registration_validation branch October 18, 2022 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-present CLA Signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Add service parameter multiplicity validation when registering a service
3 participants