-
Notifications
You must be signed in to change notification settings - Fork 329
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
Fixing problem: validation errors ignored on redirects. Closes #476 #725
Merged
Merged
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
cff51ec
Fixing problem: validation ignored on redirects.
renanigt c96221c
Importing the correct IllegalStateException.
renanigt f543fa9
Fixing indentation.
renanigt 07912a9
Checking for validator erros on method use from Result.
renanigt 64c3c07
Minor refactoring.
renanigt 7a2b82b
Adding classes that handles errors.
renanigt 7205e22
Minor.
renanigt c41ff72
Merge with branch master
renanigt 3a287f1
Merge branch 'master' into validationIgnoredOnRedirects
renanigt 117aac0
Removing unnecessary components since now we have Messages component.
renanigt b9614f9
Adding feature to handle errors.
renanigt f2af267
Undo changes on VRaptor.java
renanigt 274adc9
Minor fixing.
renanigt b89218e
Minor
renanigt c31c1b5
Improving based on Turini's suggestion.
renanigt cb49d2b
Fixing a typo.
renanigt fa16133
Adding hadnleErrors just in instanceFor method call
renanigt 7b7f243
Checking if Severity is ERROR
renanigt 9869b7c
Improvements based on Lucas's suggestions.
renanigt ae22e99
Improvements based on Lucas's suggestion.
renanigt bb4c60a
Improving tests.
renanigt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
import br.com.caelum.vraptor.interceptor.TypeNameExtractor; | ||
import br.com.caelum.vraptor.ioc.Container; | ||
import br.com.caelum.vraptor.proxy.WeldProxifier; | ||
import br.com.caelum.vraptor.validator.Messages; | ||
import br.com.caelum.vraptor.view.DefaultHttpResultTest.RandomController; | ||
import br.com.caelum.vraptor.view.LogicResult; | ||
import br.com.caelum.vraptor.view.PageResult; | ||
|
@@ -50,28 +51,30 @@ public class DefaultResultTest { | |
@Mock private HttpServletRequest request; | ||
@Mock private Container container; | ||
@Mock private TypeNameExtractor extractor; | ||
@Mock private Messages messages; | ||
|
||
private Result result; | ||
private WeldProxifier weldProxifier; | ||
|
||
@Before | ||
public void setup() { | ||
MockitoAnnotations.initMocks(this); | ||
result = new DefaultResult(request, container, null, extractor); | ||
result = new DefaultResult(request, container, null, extractor, messages); | ||
weldProxifier = new WeldProxifier(); | ||
} | ||
|
||
public static class MyView implements View { | ||
|
||
} | ||
|
||
@Test | ||
public void shouldUseContainerForNewView() { | ||
final MyView expectedView = new MyView(); | ||
when(container.instanceFor(MyView.class)).thenReturn(expectedView); | ||
|
||
MyView view = result.use(MyView.class); | ||
assertThat(view, is(expectedView)); | ||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
|
||
@Test | ||
|
@@ -90,6 +93,7 @@ public void shouldDelegateToPageResultOnForwardToURI() throws Exception { | |
result.forwardTo("/any/uri"); | ||
|
||
verify(pageResult).forwardTo("/any/uri"); | ||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
|
||
@Test | ||
|
@@ -100,6 +104,7 @@ public void shouldDelegateToPageResultOnRedirectToURI() throws Exception { | |
result.redirectTo("/any/uri"); | ||
|
||
verify(pageResult).redirectTo("/any/uri"); | ||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
|
||
private <T extends View> T mockResult(Class<T> view) { | ||
|
@@ -117,6 +122,7 @@ public void shouldDelegateToPageResultOnPageOf() throws Exception { | |
result.of(RandomController.class); | ||
|
||
verify(pageResult).of(RandomController.class); | ||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
@Test | ||
public void shouldDelegateToLogicResultOnForwardToLogic() throws Exception { | ||
|
@@ -136,7 +142,7 @@ public void shouldDelegateToLogicResultOnRedirectToLogic() throws Exception { | |
result.redirectTo(RandomController.class); | ||
|
||
verify(logicResult).redirectTo(RandomController.class); | ||
|
||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
@Test | ||
public void shouldDelegateToLogicResultOnRedirectToLogicWithInstance() throws Exception { | ||
|
@@ -146,7 +152,7 @@ public void shouldDelegateToLogicResultOnRedirectToLogicWithInstance() throws Ex | |
result.redirectTo(new RandomController()); | ||
|
||
verify(logicResult).redirectTo(RandomController.class); | ||
|
||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
|
||
@Test | ||
|
@@ -157,8 +163,9 @@ public void shouldDelegateToLogicResultOnForwardToLogicWithInstance() throws Exc | |
result.forwardTo(new RandomController()); | ||
|
||
verify(logicResult).forwardTo(RandomController.class); | ||
|
||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
|
||
@Test | ||
public void shouldDelegateToPageResultOnPageOfWithInstance() throws Exception { | ||
|
||
|
@@ -167,7 +174,7 @@ public void shouldDelegateToPageResultOnPageOfWithInstance() throws Exception { | |
result.of(new RandomController()); | ||
|
||
verify(pageResult).of(RandomController.class); | ||
|
||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
|
||
@Test | ||
|
@@ -177,6 +184,7 @@ public void shouldDelegateToLogicResultOnRedirectToLogicWithProxifiedTypeInstanc | |
assertThat(randomProxy, instanceOf(ProxyObject.class)); | ||
result.redirectTo(randomProxy); | ||
verify(logicResult).redirectTo(RandomController.class); | ||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
|
||
@Test | ||
|
@@ -186,6 +194,7 @@ public void shouldDelegateToLogicResultOnForwardToLogicWithProxifiedTypeInstance | |
assertThat(randomProxy, instanceOf(ProxyObject.class)); | ||
result.forwardTo(randomProxy); | ||
verify(logicResult).forwardTo(RandomController.class); | ||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
|
||
@Test | ||
|
@@ -195,6 +204,7 @@ public void shouldDelegateToPageResultOnPageOfWithProxifiedTypeInstance() throws | |
assertThat(randomProxy, instanceOf(ProxyObject.class)); | ||
result.of(randomProxy); | ||
verify(logicResult).of(RandomController.class); | ||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
|
||
@Test | ||
|
@@ -205,7 +215,7 @@ public void shouldDelegateToStatusOnNotFound() throws Exception { | |
result.notFound(); | ||
|
||
verify(status).notFound(); | ||
|
||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
|
||
@Test | ||
|
@@ -216,7 +226,7 @@ public void shouldDelegateToStatusOnPermanentlyRedirectToUri() throws Exception | |
result.permanentlyRedirectTo("url"); | ||
|
||
verify(status).movedPermanentlyTo("url"); | ||
|
||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
|
||
@Test | ||
|
@@ -227,7 +237,7 @@ public void shouldDelegateToStatusOnPermanentlyRedirectToControllerClass() throw | |
result.permanentlyRedirectTo(RandomController.class); | ||
|
||
verify(status).movedPermanentlyTo(RandomController.class); | ||
|
||
verify(messages).assertAbsenceOfErrors(); | ||
} | ||
|
||
@Test | ||
|
@@ -238,7 +248,7 @@ public void shouldDelegateToStatusOnPermanentlyRedirectToControllerInstance() th | |
result.permanentlyRedirectTo(new RandomController()); | ||
|
||
verify(status).movedPermanentlyTo(RandomController.class); | ||
|
||
verify(messages).assertAbsenceOfErrors(); | ||
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. leave this verify only for the method which is checking this behavior. No need to repeat it on all. |
||
} | ||
|
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
you don't need validator here.
you already have the errors (
getErrors()
), just use it.and remove validator dependency.
no more cyclic dependency ;)
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.
you can change this whole if on line 123 to:
slf4j already does the if internally.
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.
@lucascs what about
validator.onErrorUse(nothing());
?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.
True @lucascs, now I see your point. 😃
Thanks.
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.
it's from the time we didn't have
validator.getErrors()
method, so we had to catch the exception to be able to get the errors. VRaptor 3 inheritance ;)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.
Thanks a lot @lucascs. 😃