why does Apache Flink skipps the event from datastream?

In the following unit test case, some event specified by numberOfElements is generated and fed as a data stream. This unit cases randomly fails at the line.

assertEquals(numberOfElements, CollectSink.values.size());

Any explanation why Apache Flink is skipping the events.

public class FlinkTest {

StreamExecutionEnvironment env;

public void setup(){
     env = StreamExecutionEnvironment.createLocalEnvironment();

public void testStream() throws Exception {

    final int numberOfElements = 50;

    DataStream<Tuple2<String, Integer>> tupleStream = env.fromCollection(getCollectionOfBucketImps(numberOfElements));
    tupleStream.addSink(new CollectSink());

    assertEquals(numberOfElements, getCollectionOfBucketImps(numberOfElements).size());
    assertEquals(numberOfElements, CollectSink.values.size());

public static List<Tuple2<String, Integer>> getCollectionOfBucketImps(int numberOfElements) throws InterruptedException {
    List<Tuple2<String, Integer>> records = new ArrayList<>();
    for (int i = 0; i < numberOfElements ; i++) {
        records.add(new Tuple2<>(Integer.toString(i%10), i));
    return records;

// create a testing sink
private static class CollectSink implements SinkFunction<Tuple2<String, Integer>> {

    public static final List<Tuple2<String, Integer>> values = new ArrayList<>();

    public void invoke(Tuple2<String, Integer> value, Context context) throws Exception {