SaveSetupAction { public String execute(DuracloudCredentialsForm credentials, SpaceForm spaceForm, DirectoryConfigs configs, AdvancedForm advancedForm, ModeForm modeForm) { syncConfigurationManager.persistDuracloudConfiguration(credentials.getUsername(), credentials.getPassword(), credentials.getHost(), credentials.getPort(), spaceForm.getSpaceId()); syncConfigurationManager.persistDirectoryConfigs(configs); syncConfigurationManager.setSyncDeletes(advancedForm.isSyncDeletes()); String up = advancedForm.getUpdatePolicy(); log.debug("setting update policy to {}", up); UpdatePolicyHelper.set(this.syncConfigurationManager, UpdatePolicy.valueOf(up)); syncConfigurationManager.setJumpStart(advancedForm.isJumpStart()); syncConfigurationManager.setMode(modeForm.getMode()); log.info("successfully saved setup."); return "success"; } @Autowired  SaveSetupAction(
        @Qualifier("syncConfigurationManager") SyncConfigurationManager syncConfigurationManager); String execute(DuracloudCredentialsForm credentials,
                          SpaceForm spaceForm,
                          DirectoryConfigs configs,
                          AdvancedForm advancedForm,
                          ModeForm modeForm);  }
@Test public void testExecute() throws Exception { DirectoryConfigs configs = new DirectoryConfigs(); configs.add(new DirectoryConfig("/test")); SpaceForm space = new SpaceForm(); SyncConfigurationManager scm = createMock(SyncConfigurationManager.class); String username = "username"; String password = "password"; String host = "host"; String spaceId = "spaceId"; DuracloudCredentialsForm cred = new DuracloudCredentialsForm(); cred.setUsername(username); cred.setPassword(password); cred.setHost(host); space.setSpaceId(spaceId); scm.persistDuracloudConfiguration(username, password, host, cred.getPort(), spaceId); EasyMock.expectLastCall().once(); scm.persistDirectoryConfigs(configs); AdvancedForm advanced = new AdvancedForm(); advanced.setSyncDeletes(false); scm.setSyncDeletes(advanced.isSyncDeletes()); EasyMock.expectLastCall().once(); advanced.setJumpStart(false); scm.setJumpStart(advanced.isJumpStart()); EasyMock.expectLastCall().once(); advanced.setUpdatePolicy(UpdatePolicy.OVERWRITE.name()); scm.setSyncUpdates(true); EasyMock.expectLastCall().once(); scm.setRenameUpdates(false); EasyMock.expectLastCall().once(); ModeForm modeForm = new ModeForm(); modeForm.setMode(RunMode.SINGLE_PASS); scm.setMode(RunMode.SINGLE_PASS); EasyMock.expectLastCall().once(); SaveSetupAction sc = new SaveSetupAction(scm); replay(); String result = sc.execute(cred, space, configs, advanced, modeForm); Assert.assertEquals("success", result); }