Skip to content

Assert the value descriptor schema hash in AssetModelTest - #3586

Open
costajohnt wants to merge 1 commit into
openremote:mainfrom
costajohnt:fix-asset-model-hash-assertion
Open

costajohnt wants to merge 1 commit into
openremote:mainfrom
costajohnt:fix-asset-model-hash-assertion

Conversation

@costajohnt

Copy link
Copy Markdown

Description

In AssetModelTest ("Get valueDescriptor schema and hash for #name"), the hash comparison sat inside an if (!hash.empty) { ... } block. Spock doesn't treat expressions nested in an if as conditions, so a wrong hash in the where: table could never fail the test. This makes it a top-level condition, hash.empty || result.hash() == hash, which still skips the rows whose expected hash is left empty.

I checked the three non-empty hashes (text, text[], text[][]) by computing new ValueUtil.SchemaResult(ValueUtil.getSchema(clazz).toString()).hash() in a scratch model spec. All three match, and a row with a wrong hash fails the new condition. I didn't run this spec end to end because it needs the manager container with PostgreSQL and Keycloak. spotlessGroovyCheck passes.

Checklist

  • 1. Acceptance criteria of the linked issue(s) are met
  • 2. Tests are written and all tests pass
  • 3. Changes are manually tested by you and the reviewer
  • 4. Documentation is written or updated

Found with groovyfmt, a Groovy formatter and linter.

The hash comparison sat inside an if block, which Spock does not treat as a condition, so a wrong hash never failed the test. Make it a top-level condition that still skips rows with an empty expected hash.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants