@Test public void testExecute() throws Exception { HashMap<UserOptions, String> configMap = new HashMap<UserOptions, String>(); configMap.put(UserOptions.DisplayButtons, Boolean.toString(true)); configMap.put(UserOptions.EditorPageSize, Integer.toString(25)); configMap.put(UserOptions.EnterSavesApproved, Boolean.toString(true)); SaveOptionsAction action = new SaveOptionsAction(configMap); SaveOptionsResult result = handler.execute(action, null); assertThat(result.isSuccess(), Matchers.equalTo(true)); List<HAccountOption> accountOptions = getEm().createQuery("from HAccountOption").getResultList(); assertThat(accountOptions, Matchers.hasSize(configMap.size())); Map<String, HAccountOption> editorOptions = authenticatedAccount.getEditorOptions(); assertThat(editorOptions.values(), Matchers.containsInAnyOrder(accountOptions.toArray())); handler.execute(action, null); // save again should override previous // value accountOptions = getEm().createQuery("from HAccountOption").getResultList(); assertThat(accountOptions, Matchers.hasSize(configMap.size())); assertThat(editorOptions.values(), Matchers.containsInAnyOrder(accountOptions.toArray())); }
@Test public void testRollback() throws Exception { handler.rollback(null, null, null); }