@Test public void testPerformAction() throws Exception { final String userPrefsJson = "{'userPref1':'value1','userPref2':'value2'}"; final GadgetUserPrefDTO testPrefs1 = context.mock(GadgetUserPrefDTO.class); final GadgetUserPrefActionRequest requestParam = new GadgetUserPrefActionRequest(new Long(1L), userPrefsJson); context.checking(new Expectations() { { oneOf(mapper).execute(with(any(GadgetUserPrefRequest.class))); will(returnValue(testPrefs1)); oneOf(testPrefs1).getJsonUserPref(); will(returnValue(userPrefsJson)); } }); sut.execute(new ActionContext() { private static final long serialVersionUID = 1846377112179005545L; @Override public Serializable getParams() { return requestParam; } @Override public Map<String, Object> getState() { return null; } @Override public String getActionId() { return null; } @Override public void setActionId(final String inActionId) { } }); context.assertIsSatisfied(); }
@Override public Serializable execute(final ActionContext inActionContext) { GadgetUserPrefActionRequest request = (GadgetUserPrefActionRequest) inActionContext.getParams(); String userPrefs; try { GadgetUserPrefDTO currentPrefs = mapper.execute(new GadgetUserPrefRequest(request.getGadgetId(), request .getGadgetUserPref())); userPrefs = currentPrefs.getJsonUserPref(); } catch (NoResultException nex) { userPrefs = DEFAULT_USER_PREFS; } return userPrefs; }
GetGadgetUserPrefByIdExecutionStrategy implements ExecutionStrategy<ActionContext> { @Override public Serializable execute(final ActionContext inActionContext) { GadgetUserPrefActionRequest request = (GadgetUserPrefActionRequest) inActionContext.getParams(); String userPrefs; try { GadgetUserPrefDTO currentPrefs = mapper.execute(new GadgetUserPrefRequest(request.getGadgetId(), request .getGadgetUserPref())); userPrefs = currentPrefs.getJsonUserPref(); } catch (NoResultException nex) { userPrefs = DEFAULT_USER_PREFS; } return userPrefs; } }
GetGadgetUserPrefByIdExecutionStrategy implements ExecutionStrategy<ActionContext> { @Override public Serializable execute(final ActionContext inActionContext) { GadgetUserPrefActionRequest request = (GadgetUserPrefActionRequest) inActionContext.getParams(); String userPrefs; try { GadgetUserPrefDTO currentPrefs = mapper.execute(new GadgetUserPrefRequest(request.getGadgetId(), request .getGadgetUserPref())); userPrefs = currentPrefs.getJsonUserPref(); } catch (NoResultException nex) { userPrefs = DEFAULT_USER_PREFS; } return userPrefs; } GetGadgetUserPrefByIdExecutionStrategy(final GetGadgetUserPrefMapper inMapper); }
GetGadgetUserPrefByIdExecutionStrategy implements ExecutionStrategy<ActionContext> { @Override public Serializable execute(final ActionContext inActionContext) { GadgetUserPrefActionRequest request = (GadgetUserPrefActionRequest) inActionContext.getParams(); String userPrefs; try { GadgetUserPrefDTO currentPrefs = mapper.execute(new GadgetUserPrefRequest(request.getGadgetId(), request .getGadgetUserPref())); userPrefs = currentPrefs.getJsonUserPref(); } catch (NoResultException nex) { userPrefs = DEFAULT_USER_PREFS; } return userPrefs; } GetGadgetUserPrefByIdExecutionStrategy(final GetGadgetUserPrefMapper inMapper); @Override Serializable execute(final ActionContext inActionContext); }
GetGadgetUserPrefByIdExecutionStrategy implements ExecutionStrategy<ActionContext> { @Override public Serializable execute(final ActionContext inActionContext) { GadgetUserPrefActionRequest request = (GadgetUserPrefActionRequest) inActionContext.getParams(); String userPrefs; try { GadgetUserPrefDTO currentPrefs = mapper.execute(new GadgetUserPrefRequest(request.getGadgetId(), request .getGadgetUserPref())); userPrefs = currentPrefs.getJsonUserPref(); } catch (NoResultException nex) { userPrefs = DEFAULT_USER_PREFS; } return userPrefs; } GetGadgetUserPrefByIdExecutionStrategy(final GetGadgetUserPrefMapper inMapper); @Override Serializable execute(final ActionContext inActionContext);  }