Skip to content

Conversation

nastra
Copy link
Collaborator

@nastra nastra commented Jul 2, 2024

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

The assert keyboard in Java needs to be explicitly enabled (via -ea), otherwise it doesn't do anything and gets optimized away. There are also a few assert usages in web service code and those should be replaced either with Preconditions.checkNotNull or with a Validation API

@@ -11,6 +11,7 @@

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.*;
Copy link
Contributor

@tdas tdas Jul 2, 2024

Choose a reason for hiding this comment

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

do we need these imports any more?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah those are still used across tests until Junit4 assertions are switched to AssertJ assertions

assertThat(resp.getNextPageToken()).isNotNull();
assertThat(resp.getTables()).hasSize(1)
.first()
.usingRecursiveComparison()
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems to be a change in the test logic. @ravivj-db could you double check this?

Copy link
Collaborator Author

@nastra nastra Jul 2, 2024

Choose a reason for hiding this comment

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

this is because previously the assert wasn't executed and the condition was actually never met (the single element in the list was never equal to the expectation due to tiny differences in the fields that were excluded here)

@tdas tdas requested a review from ravivj-db July 2, 2024 14:28
@tdas
Copy link
Contributor

tdas commented Jul 4, 2024

@nastra Thank you very much for the fixes and improvements!

@tdas tdas merged commit ca580fa into unitycatalog:main Jul 4, 2024
@nastra nastra deleted the replace-assert branch July 5, 2024 06:53
ravivj-db pushed a commit to ravivj-db/unitycatalog that referenced this pull request Jul 5, 2024
**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [ ] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated

**Description of changes**

The `assert` keyboard in Java needs to be explicitly enabled (via
`-ea`), otherwise it doesn't do anything and gets optimized away. There
are also a few `assert` usages in web service code and those should be
replaced either with `Preconditions.checkNotNull` or with a Validation
API
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