Source:
<code>public void pollingFailure() throws Exception { UsernameUnavailablePasswordImpl credentials = new UsernameUnavailablePasswordImpl("pollingFailure", "test", "manchu"); systemStore.addCredentials(Domain.global(), credentials); FreeStyleProject project = r.createFreeStyleProject(); project.setQuietPeriod(0); r.buildAndAssertSuccess(project); project.setScm(new PasswordSCM("pollingFailure")); SCMTrigger trigger = new SCMTrigger("* * * * *"); project.addTrigger(trigger); trigger.start(project, true); GregorianCalendar cal = new GregorianCalendar(); cal.add(Calendar.MINUTE, 1); int number = project.getLastBuild().getNumber(); Trigger.checkTriggers(cal); r.waitUntilNoActivity(); <START> Collection<? extends Action> actions = trigger.getProjectActions(); <END> SCMTrigger.SCMAction action = (SCMTrigger.SCMAction)actions.iterator().next(); assertThat(action.getLog(), allOf( containsString("Checking remote revision as user: manchu"), containsString("Property 'password' is currently unavailable"))); assertThat("No new builds", project.getLastBuild().getNumber(), is(number)); cal.add(Calendar.MINUTE, 1); Trigger.checkTriggers(cal); r.waitUntilNoActivity(); actions = trigger.getProjectActions(); action = (SCMTrigger.SCMAction)actions.iterator().next(); assertThat(((SCMTrigger.SCMAction)actions.iterator().next()).getLog(), allOf( containsString("Checking remote revision as user: manchu"), containsString("Property 'password' is currently unavailable"))); assertThat("No new builds", project.getLastBuild().getNumber(), is(number)); systemStore.updateCredentials(Domain.global(), credentials, new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "pollingFailure", "working", "manchu", "secret")); Trigger.checkTriggers(cal); r.waitUntilNoActivity(); actions = trigger.getProjectActions(); action = (SCMTrigger.SCMAction)actions.iterator().next(); assertThat(action.getLog(), allOf( containsString("Checking remote revision as user: manchu"), not(containsString("Property 'password' is currently unavailable")), containsString("Checking remote revision with password: secret"))); assertThat("New build", project.getLastBuild().getNumber(), greaterThan(number)); }</code><technical_language>fragile assume action is this type</technical_language>

Target:
public void pollingFailure() throws Exception { UsernameUnavailablePasswordImpl credentials = new UsernameUnavailablePasswordImpl("pollingFailure", "test", "manchu"); systemStore.addCredentials(Domain.global(), credentials); FreeStyleProject project = r.createFreeStyleProject(); project.setQuietPeriod(0); r.buildAndAssertSuccess(project); project.setScm(new PasswordSCM("pollingFailure")); SCMTrigger trigger = new SCMTrigger("* * * * *"); project.addTrigger(trigger); trigger.start(project, true); GregorianCalendar cal = new GregorianCalendar(); cal.add(Calendar.MINUTE, 1); int number = project.getLastBuild().getNumber(); Trigger.checkTriggers(cal); r.waitUntilNoActivity(); SCMTrigger.SCMAction action = getScmAction(trigger); assertThat(action.getLog(), allOf( containsString("Checking remote revision as user: manchu"), containsString("Property 'password' is currently unavailable"))); assertThat("No new builds", project.getLastBuild().getNumber(), is(number)); cal.add(Calendar.MINUTE, 1); Trigger.checkTriggers(cal); r.waitUntilNoActivity(); action = getScmAction(trigger); assertThat(action.getLog(), allOf( containsString("Checking remote revision as user: manchu"), containsString("Property 'password' is currently unavailable"))); assertThat("No new builds", project.getLastBuild().getNumber(), is(number)); systemStore.updateCredentials(Domain.global(), credentials, new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "pollingFailure", "working", "manchu", "secret")); Trigger.checkTriggers(cal); r.waitUntilNoActivity(); action = getScmAction(trigger); assertThat(action.getLog(), allOf( containsString("Checking remote revision as user: manchu"), not(containsString("Property 'password' is currently unavailable")), containsString("Checking remote revision with password: secret"))); assertThat("New build", project.getLastBuild().getNumber(), greaterThan(number)); }