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

removing final to enable mocking this class #250

Merged
merged 1 commit into from
Nov 6, 2013
Merged

Conversation

csokol
Copy link
Contributor

@csokol csokol commented Nov 6, 2013

Since this class its hard to instantiate, it should not be final so that we can mock it for testing.

I'm trying to update vraptor-plugin-hibernate4 and we need to mock Parameter class in its tests.

btw, we have two repositories for vraptor-plugin-hibernate4, the one in @garcia-jj and in @caelum, I'm developing in the caelum repo...

@@ -13,7 +13,7 @@
*
* @author Otávio Scherer Garcia
*/
public final class Parameter implements AnnotatedElement {
public class Parameter implements AnnotatedElement {
Copy link
Member

Choose a reason for hiding this comment

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

The problem is that Parameter from Java 8 is final, and the proposal for this is to be closer to Java 8. Changing this the tests will break in Java 8 environments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well... any ideas on how to intantiate this class for testing? I don't want
to provide a real AccessibleObject instance or to mock full Constructor or
Method methods...

Chico Sokol

On Wed, Nov 6, 2013 at 11:05 AM, Otávio Garcia notifications@gitpro.ttaallkk.topwrote:

In vraptor-core/src/main/java/br/com/caelum/vraptor/http/Parameter.java:

@@ -13,7 +13,7 @@
*

  • @author Otávio Scherer Garcia
    */
    -public final class Parameter implements AnnotatedElement {
    +public class Parameter implements AnnotatedElement {

The problem is that Parameter from Java 8 is final, and the proposal for
this is to be closer to Java 8. Changing this the tests will break in Java
8 environments.


Reply to this email directly or view it on GitHubhttps://github.com//pull/250/files#r7462564
.

Copy link
Member

Choose a reason for hiding this comment

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

I think better... we can change this removing final. Java 8 allow us to use Method.getParameters without using ParameterNameProvider, so these classes will be removed.

Ship this :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

\o/

Chico Sokol

On Wed, Nov 6, 2013 at 11:26 AM, Otávio Garcia notifications@gitpro.ttaallkk.topwrote:

In vraptor-core/src/main/java/br/com/caelum/vraptor/http/Parameter.java:

@@ -13,7 +13,7 @@
*

  • @author Otávio Scherer Garcia
    */
    -public final class Parameter implements AnnotatedElement {
    +public class Parameter implements AnnotatedElement {

I think better... we can change this removing final. Java 8 allow us to
use Method.getParameters without using ParameterNameProvider, so these
classes will be removed.

Ship this :)


Reply to this email directly or view it on GitHubhttps://github.com//pull/250/files#r7462938
.

csokol added a commit that referenced this pull request Nov 6, 2013
removing final to enable mocking this class
@csokol csokol merged commit 7676cef into master Nov 6, 2013
@lucascs lucascs deleted the parameterClassNotFinal branch November 6, 2013 17:10
@Turini Turini added this to the 4.0.0-beta-3 milestone Mar 6, 2014
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