Skip to content

Conversation

@Nava2
Copy link
Contributor

@Nava2 Nava2 commented May 30, 2017

Backport of 3de4c3b.

  • Added findGetterDescriptionForField(FieldDescription base) to check against all known prefixes for methods that clash
  • Extended test case for FieldPropertyClash to include predicate case

Fun fact: The current master branch fails on windows, I had to use a vagrant machine to test this. 😢

Fixes #105.

* Added `findGetterDescriptionForField(FieldDescription base)` to
  check against all known prefixes for methods that clash
* Extended test case for FieldPropertyClash to include predicate
  case
@joel-costigliola
Copy link
Member

is that because of line endings ? I use linux, that kind of errors are not easy to detect.

@Nava2
Copy link
Contributor Author

Nava2 commented May 30, 2017

Some are, AssertionsEntryPointGeneratorTest#should_generate_correctly_standard_assertions_entry_point_class_for_classes_with_same_name() definitely is.

AssertionGeneratorTest#should_generate_assertion_for_property_with_exception(Class) fails for some reason I can't reason by looking at it. I fixed all of these in #101 though as I use both Windows and OSX when working (and vagrant Ubuntu boxes on Windows as needed!).

this.superType = superType;
}

public GetterDescription findGetterDescriptionForField(FieldDescription base) {
Copy link
Member

Choose a reason for hiding this comment

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

can you add unit tests for this in FieldDescriptionTest ?

Copy link
Contributor Author

@Nava2 Nava2 Jun 1, 2017

Choose a reason for hiding this comment

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

Wouldn't it make more sense in ClassDescriptionTest?

Edit: It would, but that class doesn't exist... 😅

field.getTypeDescription(),
Collections.<TypeName> emptyList()))) {

if (classDescription.findGetterDescriptionForField(field) != null) {
Copy link
Member

@joel-costigliola joel-costigliola Jun 1, 2017

Choose a reason for hiding this comment

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

rename findGetterDescriptionForField to hasGetterForField and simply return a boolean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with the name. For return type, I think it could be useful later to have it returning the value. If we were on Java 8 I'd rather return an Optional<>, though. Thought?s

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Additionally, I've realized that there is a very real possibility of multiple. So either:

  1. return a Set<> of Getters
  2. Boolean on first found

I'm okay with either.

return getterDesc;
}
}
} else {
Copy link
Member

@joel-costigliola joel-costigliola Jun 1, 2017

Choose a reason for hiding this comment

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

I think the else can be removed and replaced by this one line (assuming we return a boolean):

return fieldMap.containsKey("get" + capName)

@joel-costigliola
Copy link
Member

@Nava2 can you address my comments on top of 3de4c3b ? I will cherry pick the commits once done.

@joel-costigliola joel-costigliola added this to the 2.1.0 milestone Jun 1, 2017
@Nava2
Copy link
Contributor Author

Nava2 commented Jun 1, 2017

Sure thing, I'll get to it later today!

Nava2 added a commit to Nava2/assertj-assertions-generator that referenced this pull request Jun 1, 2017
* Addresses comments from @joel-costigliola in assertj#106
* Broke method into two: one for presence, one for getting the values
* Added many more tests
@Nava2 Nava2 closed this Jun 1, 2017
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.

If field and getter predicates share property name, colliding signatures are generated

2 participants