public void testExecute() throws Exception {
// Given: we want to add comment to trans unit id 2 and locale id DE
String commentContent = "new comment";
TransUnitId transUnitId = new TransUnitId(2L);
HLocale hLocale = new HLocale(LocaleId.DE);
AddReviewCommentAction action =
new AddReviewCommentAction(transUnitId, commentContent,
documentId);
action.setWorkspaceId(TestFixture.workspaceId(LocaleId.DE));
when(authenticatedAccount.getPerson()).thenReturn(hPerson);
when(securityServiceImpl.checkWorkspaceStatus(action.getWorkspaceId()))
.thenReturn(hProject);
when(
translationWorkspaceManager.getOrRegisterWorkspace(action
.getWorkspaceId())).thenReturn(workspace);
when(localeService.getByLocaleId(action.getWorkspaceId().getLocaleId()))
.thenReturn(hLocale);
when(
textFlowTargetDAO.getTextFlowTarget(transUnitId.getValue(),
hLocale.getLocaleId())).thenReturn(hTextFlowTarget);
when(hTextFlowTarget.getState()).thenReturn(ContentState.Rejected);
when(hTextFlowTarget.getTextFlow()).thenReturn(hTextFlow);
when(hTextFlowTarget.addReviewComment(commentContent, hPerson))
.thenReturn(hReviewComment);
when(hReviewComment.getId()).thenReturn(1L);
// When:
AddReviewCommentResult result = handler.execute(action, null);
// Then:
InOrder inOrder =
Mockito.inOrder(textFlowTargetDAO,
textFlowTargetReviewCommentsDAO,
hTextFlowTarget, workspace,
securityServiceImpl, identity);
inOrder.verify(securityServiceImpl).checkWorkspaceStatus(
action.getWorkspaceId());
inOrder.verify(textFlowTargetDAO).getTextFlowTarget(
transUnitId.getValue(), hLocale.getLocaleId());
inOrder.verify(identity).checkPermission("review-comment", hLocale,
hProject);
inOrder.verify(hTextFlowTarget).addReviewComment(commentContent,