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

New methods copyValueOf, is(Not)Empty and capitalise #323

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jtenkate
Copy link

No description provided.

@jtenkate jtenkate closed this May 27, 2020
@jtenkate jtenkate reopened this May 27, 2020
Copy link
Owner

@fhoeben fhoeben left a comment

Choose a reason for hiding this comment

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

Can you also add the new methods to the documentation/examples?

jtenkate and others added 4 commits October 2, 2020 12:19
Update to latest master
main/java:
-renamed copyValueOf to getValueOf
-new methods for checking undefined symbols: isUndefined, isEmptyOrUndefined
-updated methods: isEmpty, isNotEmpty, capitalise
-additional method setNullValue.
test/java:
-reverted import wildcard
-updated unit tests
-added unit tests for new methods
wiki:
-added examples for usage of new methods.
-new example without regex for replaceAllInWith
@jtenkate
Copy link
Author

jtenkate commented Oct 9, 2020

Hi Fried, I've made quite a lot of changes and added a couple of new methods for checking undefined symbols (based on the symbol name definition). Let me know if further changes are needed.
Cheers Jeroen

* @param value value to capitalise.
* @return capitalised value.
*/
public String capitalise (String value) {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
public String capitalise (String value) {
public String capitalise(String value) {

*
* @return null value.
*/
public String setNullValue() { return null;}
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
public String setNullValue() { return null;}
public String setNullValue() {
return null;
}

Copy link
Owner

Choose a reason for hiding this comment

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

How do you use this method in your tests? Is there added value (over just assigning an empty string)?

* @param value value to check.
* @return {@code true} if undefined (value is symbol name-like), {@code false} otherwise.
*/
public boolean isUndefined(String value) {
Copy link
Owner

Choose a reason for hiding this comment

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

This seems like an unreliable way to check for an undefined symbol. It will also match a string that happens to conform to the regular expression. Is there a better way to check whether a symbol is known in Slim? Maybe it can be checked by having a special Slim table...

If this is a really important thing to check in your tests you could just check this regular expression using standard Slim regex matching and valueOf or getValueOf wrapped in a scenario...

Copy link
Owner

Choose a reason for hiding this comment

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

Having a symbol in your tests that may or may not be assigned a value sounds like a code smell of your tests.

If you worry a symbol may have been assigned a value in a previous test in a suite, just ensure you assign a known (empty, or otherwise not occurring value) in your SetUp.

* @param value value to check.
* @return {@code true} if empty, or {@code false} otherwise.
*/
public boolean isEmpty(String value) { return StringUtils.isEmpty(value); }
Copy link
Owner

Choose a reason for hiding this comment

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

Does this really add value on top of a regular Slim regex check (possibly wrapped in a scenario)?

* @param value value to check.
* @return {@code true} if filled (not empty), {@code false} otherwise.
*/
public boolean isNotEmpty(String value) { return !isEmpty(value); }
Copy link
Owner

Choose a reason for hiding this comment

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

idem

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.

3 participants