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

Refactor stringassertion #393

Merged
merged 6 commits into from
Feb 19, 2024
Merged

Refactor stringassertion #393

merged 6 commits into from
Feb 19, 2024

Conversation

sbke-mms
Copy link
Collaborator

Description

The StringAssertion interface is no longer inheriting from QuantityAssertion instead both of those interfaces now inherit ObjectAssertion which inherits BinaryAssertion. Also StringAssertion is now restricted to the type String. This is a breaking change since StringAssertion previously was able to use the functions of QuantityAssertion. Since these only worked on numbers this didn't make sense and triggered this change.

These functions moved from QuantityAssertion to ObjectAssertion so StringAssertion can still use them:

  • `boolean is(Object expected)`
    
  • `boolean is(Object expected, String subject)`
    
  • `boolean isNot(Object expected)`
    
  • `boolean isNot(Object expected, String subject)`
    

Some changes regarding generic types to remove related warnings have been added as well.

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

This is a breaking change since the methods from QuantityAssertion are not available to StringAssertion anymore. An extra layer has been added with ObjectAssertion to capture methods that were used in both interfaces.
@@ -110,7 +111,7 @@ public BinaryAssertion<Boolean> hasWords(List<String> words) {
.collect(Collectors.joining("|"));
final Pattern wordsPattern = Pattern.compile(wordsList, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);

final String wordsListWithoutRegex = String.join("|", words);
final String wordsListWithoutRegex = java.lang.String.join("|", words);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why java.lang is used here?

@martingrossmann martingrossmann merged commit 69c794d into master Feb 19, 2024
@martingrossmann martingrossmann deleted the refactor-stringassertion branch February 19, 2024 08:54
@martingrossmann martingrossmann added this to the 2.8 milestone Feb 27, 2024
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