gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/spec/SpecGerritTriggerHudsonTest.java
/**
     * Tests to trigger a build with the same patch set twice. Expecting one build to be scheduled with one cause.
     *
     * @throws Exception if so.
     */
Tests to trigger a build with the same patch set twice. Expecting one build to be scheduled with one cause.
@throws Exception if so.
Tests to trigger a build with the same patch set twice . Expecting one build to be scheduled with one cause . @throws Exception if so .
@LocalData
    public void testDoubleTriggeredBuild() throws Exception {
        FreeStyleProject project = DuplicatesUtil.createGerritTriggeredJob(this, "projectX");
        server.waitForCommand(GERRIT_STREAM_EVENTS, 2000);
        PluginImpl.getInstance().triggerEvent(Setup.createPatchsetCreated());
        PluginImpl.getInstance().triggerEvent(Setup.createPatchsetCreated());
        RunList<FreeStyleBuild> builds = DuplicatesUtil.waitForBuilds(project, 1, 5000);
        FreeStyleBuild build = builds.get(0);
        assertSame(Result.SUCCESS, build.getResult());
        assertEquals(1, project.getBuilds().size());
        int count = 0;
        for (Cause cause : build.getCauses()) {
            if (cause instanceof GerritCause) {
                count++;
                assertNotNull(((GerritCause)cause).getContext());
                assertNotNull(((GerritCause)cause).getEvent());
            }
        }
        assertEquals(1, count);
    }
@ LocalData public void testDoubleTriggeredBuild ( ) throws Exception { FreeStyleProject project = DuplicatesUtil . createGerritTriggeredJob ( this , "projectX" ) ; server . waitForCommand ( GERRIT_STREAM_EVENTS , 2000 ) ; PluginImpl . getInstance ( ) . triggerEvent ( Setup . createPatchsetCreated ( ) ) ; PluginImpl . getInstance ( ) . triggerEvent ( Setup . createPatchsetCreated ( ) ) ; RunList < FreeStyleBuild > builds = DuplicatesUtil . waitForBuilds ( project , 1 , 5000 ) ; FreeStyleBuild build = builds . get ( 0 ) ; assertSame ( Result . SUCCESS , build . getResult ( ) ) ; assertEquals ( 1 , project . getBuilds ( ) . size ( ) ) ; int count = 0 ; for ( Cause cause : build . getCauses ( ) ) { if ( cause instanceof GerritCause ) { count ++ ; assertNotNull ( ( ( GerritCause ) cause ) . getContext ( ) ) ; assertNotNull ( ( ( GerritCause ) cause ) . getEvent ( ) ) ; } } assertEquals ( 1 , count ) ; }
Tests to trigger a build with the same patch set twice.
Tests to trigger a build with the same patch set twice .