@Test
public void testNotLinkedDataElementsAreRemovedFromEvent()
{

    WorkContext ctx = WorkContext.builder()
        .importOptions( ImportOptions.getDefaultImportOptions() )
        .programsMap( getProgramMap() )
        .build();
    Event event = new Event();
    event.setProgramStage( PROGRAMSTAGE );
    HashSet<DataValue> dataValues = Sets.newHashSet(
        new DataValue( DATA_ELEMENT_1, "whatever" ),
        new DataValue( DATA_ELEMENT_2, "another value" ) );
    event.setDataValues( dataValues );
    preProcessor.process( event, ctx );
    Set<String> allowedDataValues = ctx
        .getProgramStage( ctx.getImportOptions().getIdSchemes().getProgramStageIdScheme(), PROGRAMSTAGE )
        .getDataElements().stream()
        .map( BaseIdentifiableObject::getUid )
        .collect( Collectors.toSet() );
    Set<String> filteredEventDataValues = event.getDataValues().stream()
        .map( DataValue::getDataElement )
        .collect( Collectors.toSet() );
    assertTrue( allowedDataValues.containsAll( filteredEventDataValues ) );
}