@Test
public void failOnMultipleProgramInstance()
{

    // Data preparation
    Program programNoReg = createProgram( 'P' );
    programNoReg.setProgramType( ProgramType.WITHOUT_REGISTRATION );
    Map<String, Program> programMap = new HashMap<>();
    programMap.put( programNoReg.getUid(), programNoReg );
    when( workContext.getProgramsMap() ).thenReturn( programMap );
    //
    // Program Instance
    //
    when( workContext.getProgramInstanceMap() ).thenReturn( new HashMap<>() );
    //
    // Tracked Entity Instance
    //
    TrackedEntityInstance tei = createTrackedEntityInstance( createOrganisationUnit( 'A' ) );
    Map<String, Pair<TrackedEntityInstance, Boolean>> teiMap = new HashMap<>();
    teiMap.put( event.getUid(), Pair.of( tei, true ) );
    when( workContext.getTrackedEntityInstanceMap() ).thenReturn( teiMap );
    ProgramInstance programInstance1 = new ProgramInstance();
    ProgramInstance programInstance2 = new ProgramInstance();
    when( this.programInstanceStore.get( programNoReg, ProgramStatus.ACTIVE ) )
            .thenReturn( Lists.newArrayList( programInstance1, programInstance2 ) );
    event.setProgram( programNoReg.getUid() );
    //
    // Method under test
    //
    ImportSummary summary = rule.check( new ImmutableEvent( event ), workContext );
    assertHasError( summary, event,
            "Multiple active program instances exists for program: " + programNoReg.getUid() );
}