Feature/refactor can modify vote to validator service#334
Feature/refactor can modify vote to validator service#334szirbucz wants to merge 3 commits intoedemo:developfrom
Conversation
magwas
left a comment
There was a problem hiding this comment.
Again, comments are just on some representative places, and handling of test data should be figured out.
|
|
||
| private static final String NOT_SAME_USER_MESSAGE = | ||
| "The adminKey is \"user\" but the user is not same with that user who added the choice."; | ||
| private static final String CAN_ADDIN_IS_FALSE_MESSAGE = |
There was a problem hiding this comment.
Aren't those strings are constants in the production code?
There was a problem hiding this comment.
They are. If you mean, we should use constants of the production code, I suggest to forget it.
Let's imagine the situation, when someone accidentally removes some words from this string or an unlucky regex overwrites it. We wouldn't realize it, since we compare this constant to itself.
| voteAdminInfo, | ||
| choiceToDelete.getId() | ||
| ) | ||
| ).assertMessageIs("The adminKey is \"user\" but canAddin is false."); |
There was a problem hiding this comment.
Once a java constant, once an inline constant.
| assertThrows(() -> choiceService.deleteChoice(new VoteAdminInfo(vote.getId(), USER), | ||
| choiceToDelete.getId())).assertMessageIs("The adminKey is \"user\" but canAddin is false."); | ||
| final VoteAdminInfo voteAdminInfo = new VoteAdminInfo(vote.getId(), USER); | ||
| doThrow(new ReportedException(CAN_ADDIN_IS_FALSE_MESSAGE)) |
There was a problem hiding this comment.
Service stub, should be put into a stub provider.
| public class ChoiceModificationValidatorServiceTest | ||
| extends ChoiceValidatorBaseTest { | ||
|
|
||
| private static final String MODIFICATION = "modification"; |
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.mockito.Mockito.*; | ||
| import static org.mockito.Mockito.doThrow; |
There was a problem hiding this comment.
This is a sign that there are stubs which do not belong here.
| @RunWith(MockitoJUnitRunner.class) | ||
| public class ChoiceModifyValidationTest extends ChoiceTestBase { | ||
|
|
||
| private static final String DIFFERENT_USER_MESSAGE = |
| @Test | ||
| public void invalid_voteId_is_rejected() { | ||
| doThrow(new ReportedException("illegal voteId", invalidvoteId)).when(voteService) | ||
| doThrow(new ReportedException("illegal voteId", invalidvoteId)) |
No description provided.