-
Notifications
You must be signed in to change notification settings - Fork 332
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
Closes caelum/vraptor#581. Only instantiate objects with same type #355
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
import static org.hamcrest.Matchers.hasItem; | ||
import static org.hamcrest.Matchers.hasSize; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.not; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
import static org.hamcrest.Matchers.nullValue; | ||
import static org.hamcrest.Matchers.sameInstance; | ||
|
@@ -43,18 +44,22 @@ | |
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.junit.Test; | ||
|
||
import br.com.caelum.iogi.parameters.Parameter; | ||
import br.com.caelum.iogi.parameters.Parameters; | ||
import br.com.caelum.iogi.reflection.Target; | ||
import br.com.caelum.vraptor.Result; | ||
import br.com.caelum.vraptor.controller.ControllerMethod; | ||
import br.com.caelum.vraptor.controller.DefaultControllerMethod; | ||
import br.com.caelum.vraptor.http.ParametersProvider; | ||
import br.com.caelum.vraptor.http.ParametersProviderTest; | ||
import br.com.caelum.vraptor.validator.Message; | ||
|
||
public class IogiParametersProviderTest extends ParametersProviderTest { | ||
|
||
|
@@ -166,11 +171,28 @@ public void isCapableOfDealingWithSetsOfObjects() throws Exception { | |
assertThat(abc.iterator().next().getX(), is(1l)); | ||
} | ||
|
||
@Test | ||
public void shouldInjectOnlyAttributesWithSameType() throws Exception { | ||
Object result = mock(Result.class); | ||
when(request.getAttribute("result")).thenReturn(result); | ||
when(request.getParameter("result")).thenReturn("buggy"); | ||
|
||
ControllerMethod method = DefaultControllerMethod.instanceFor(OtherResource.class, | ||
OtherResource.class.getDeclaredMethod("logic", String.class)); | ||
|
||
List<Message> errors = new ArrayList<Message>(); | ||
Object[] out = provider.getParametersFor(method, errors); | ||
|
||
assertThat(out[0], not(is(result))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done by a7990e8 |
||
} | ||
|
||
//---------- | ||
|
||
class OtherResource { | ||
void logic(NeedsMyResource param) { | ||
} | ||
void logic(String result) { | ||
} | ||
} | ||
|
||
static class NeedsMyResource { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the test because I think that we need to check if IOGI got the right parameter too. @lucascs right?