@Test public void testValidatePassZeroLength() { context.checking(new Expectations() { { allowing(actionContext).getParams(); will(returnValue(request)); oneOf(request).getGadgetUserPref(); will(returnValue("")); } }); sut.validate(actionContext); context.assertIsSatisfied(); }
@Override public void validate(final ActionContext inActionContext) throws ValidationException { GadgetUserPrefActionRequest currentRequest = (GadgetUserPrefActionRequest) inActionContext.getParams(); if (currentRequest.getGadgetUserPref().length() > 0) { try { JSONObject.fromObject(currentRequest.getGadgetUserPref()); } catch (JSONException jex) { throw new ValidationException("Gadget User Prefs must be valid JSON format."); } } }
UpdateGadgetUserPrefByIdValidation implements ValidationStrategy<ActionContext> { @Override public void validate(final ActionContext inActionContext) throws ValidationException { GadgetUserPrefActionRequest currentRequest = (GadgetUserPrefActionRequest) inActionContext.getParams(); if (currentRequest.getGadgetUserPref().length() > 0) { try { JSONObject.fromObject(currentRequest.getGadgetUserPref()); } catch (JSONException jex) { throw new ValidationException("Gadget User Prefs must be valid JSON format."); } } } }
UpdateGadgetUserPrefByIdValidation implements ValidationStrategy<ActionContext> { @Override public void validate(final ActionContext inActionContext) throws ValidationException { GadgetUserPrefActionRequest currentRequest = (GadgetUserPrefActionRequest) inActionContext.getParams(); if (currentRequest.getGadgetUserPref().length() > 0) { try { JSONObject.fromObject(currentRequest.getGadgetUserPref()); } catch (JSONException jex) { throw new ValidationException("Gadget User Prefs must be valid JSON format."); } } }  }
UpdateGadgetUserPrefByIdValidation implements ValidationStrategy<ActionContext> { @Override public void validate(final ActionContext inActionContext) throws ValidationException { GadgetUserPrefActionRequest currentRequest = (GadgetUserPrefActionRequest) inActionContext.getParams(); if (currentRequest.getGadgetUserPref().length() > 0) { try { JSONObject.fromObject(currentRequest.getGadgetUserPref()); } catch (JSONException jex) { throw new ValidationException("Gadget User Prefs must be valid JSON format."); } } }  @Override void validate(final ActionContext inActionContext); }
UpdateGadgetUserPrefByIdValidation implements ValidationStrategy<ActionContext> { @Override public void validate(final ActionContext inActionContext) throws ValidationException { GadgetUserPrefActionRequest currentRequest = (GadgetUserPrefActionRequest) inActionContext.getParams(); if (currentRequest.getGadgetUserPref().length() > 0) { try { JSONObject.fromObject(currentRequest.getGadgetUserPref()); } catch (JSONException jex) { throw new ValidationException("Gadget User Prefs must be valid JSON format."); } } }  @Override void validate(final ActionContext inActionContext);  }