use of org.apache.struts.action.ActionMessages in project sonarqube by SonarSource.
the class TestTagUtils method testGetActionErrors1e.
// ActionErrors (thrown Exception)
// TODO -- currently this does not hit the line for caught Exception
public void testGetActionErrors1e() {
ActionMessages actionErrors = new ActionMessages();
actionErrors.add("prop", new ActionMessage("key.key"));
request.setAttribute("errors", actionErrors);
try {
ActionMessages errors = tagutils.getActionMessages(pageContext, "does-not-exist");
assertNotNull("errors should not be null", errors);
assertNotNull("errors prop should not be null", errors.get("prop"));
for (Iterator iter = errors.get("prop"); iter.hasNext(); ) {
fail("Should not have any errors for does-not-exist");
}
} catch (JspException e) {
fail(e.getMessage());
}
}
use of org.apache.struts.action.ActionMessages in project sonarqube by SonarSource.
the class TestTagUtils method testActionMessages_getActionMessages_PageContext_String1.
// ------------------------------------------ getActionMessages()
// -- using ActionMessages
public void testActionMessages_getActionMessages_PageContext_String1() {
ActionMessages actionMessages = new ActionMessages();
actionMessages.add("prop", new ActionMessage("key.key"));
request.setAttribute("messages", actionMessages);
try {
ActionMessages messages = tagutils.getActionMessages(pageContext, "messages");
assertNotNull("messages should not be null", messages);
assertNotNull("messages prop should not be null", messages.get("prop"));
String val = null;
int i = 0;
for (Iterator iter = messages.get("prop"); iter.hasNext(); ) {
ActionMessage message = (ActionMessage) iter.next();
val = message.getKey();
i++;
}
assertEquals("only 1 message", i, 1);
assertEquals("messages prop should match", val, "key.key");
} catch (JspException e) {
fail(e.getMessage());
}
}
use of org.apache.struts.action.ActionMessages in project sonarqube by SonarSource.
the class TestTagUtils method testActionMessages_getActionMessages_PageContext_String2.
// -- using ActionErrors
public void testActionMessages_getActionMessages_PageContext_String2() {
ActionMessages actionMessages = new ActionMessages();
actionMessages.add("prop", new ActionMessage("key.key"));
request.setAttribute("messages", actionMessages);
try {
ActionMessages messages = tagutils.getActionMessages(pageContext, "messages");
assertNotNull("messages should not be null", messages);
assertNotNull("messages prop should not be null", messages.get("prop"));
String val = null;
int i = 0;
for (Iterator iter = messages.get("prop"); iter.hasNext(); ) {
ActionMessage message = (ActionMessage) iter.next();
val = message.getKey();
i++;
}
assertEquals("only 1 message", i, 1);
assertEquals("messages prop should match", val, "key.key");
} catch (JspException e) {
fail(e.getMessage());
}
}
use of org.apache.struts.action.ActionMessages in project sonarqube by SonarSource.
the class TestTagUtils method testActionMessages_getActionMessages_PageContext_String6.
// ActionMessages (thrown Exception)
// TODO -- currently this does not hit the line for caught Exception
public void testActionMessages_getActionMessages_PageContext_String6() {
ActionMessages actionMessages = new ActionMessages();
actionMessages.add("prop", new ActionMessage("key.key"));
request.setAttribute("messages", actionMessages);
try {
ActionMessages messages = tagutils.getActionMessages(pageContext, "does-not-exist");
assertNotNull("messages should not be null", messages);
assertNotNull("messages prop should not be null", messages.get("prop"));
for (Iterator iter = messages.get("prop"); iter.hasNext(); ) {
fail("Should not have any messages for does-not-exist");
}
} catch (JspException e) {
fail(e.getMessage());
}
}
use of org.apache.struts.action.ActionMessages in project head by mifos.
the class FeeAction method update.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
FeeActionForm feeActionForm = (FeeActionForm) form;
FeeStatus feeStatus = feeActionForm.getFeeStatusValue();
String forward = "";
Short feeStatusValue = null;
String whereToForward = "";
if (feeStatus != null) {
feeStatusValue = feeStatus.getValue();
}
FeeUpdateRequest feeUpdateRequest = new FeeUpdateRequest(Short.valueOf(feeActionForm.getFeeId()), feeActionForm.getCurrencyId(), feeActionForm.getAmount(), feeStatusValue, feeActionForm.getRateValue());
if (feeUpdateRequest.getFeeStatusValue() == 2) {
this.feeServiceFacade.updateFee(feeUpdateRequest);
try {
boolean remove = feeActionForm.isToRemove();
this.feeServiceFacade.removeFee(feeUpdateRequest, remove);
whereToForward = REMOVE_SUCCESS;
} catch (MifosRuntimeException e) {
ActionMessages messages = new ActionMessages();
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeCannotBeRemoved"));
saveMessages(request, messages);
whereToForward = UPDATE_SUCCESS;
}
} else if (feeActionForm.isToRemove() && feeUpdateRequest.getFeeStatusValue() == 1) {
ActionMessages errors = new ActionMessages();
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeCantBeRemove"));
saveErrors(request, errors);
whereToForward = UPDATE_FAILURE;
} else {
this.feeServiceFacade.updateFee(feeUpdateRequest);
whereToForward = UPDATE_SUCCESS;
}
if (whereToForward.equals(UPDATE_SUCCESS)) {
forward = ActionForwards.update_success.toString();
} else if (whereToForward.equals(UPDATE_FAILURE)) {
forward = ActionForwards.update_failure.toString();
} else if (whereToForward.equals(REMOVE_SUCCESS)) {
forward = ActionForwards.remove_fee_success.toString();
}
return mapping.findForward(forward);
}
Aggregations