package org.apache.beam.runners.spark.structuredstreaming.utils;

import java.util.ArrayList;
import java.util.List;
import org.apache.beam.runners.spark.structuredstreaming.translation.helpers.EncoderHelpers;
import org.apache.beam.sdk.coders.Coder;
import org.apache.beam.sdk.coders.VarIntCoder;
import org.apache.spark.sql.SparkSession;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
/**
 * Test of the wrapping of Beam Coders as Spark ExpressionEncoders.
 */
public class EncodersTest {

  @Test
  public void beamCoderToSparkEncoderTest() {
    SparkSession sparkSession = SparkSession.builder().appName("beamCoderToSparkEncoderTest")
        .master("local[4]").getOrCreate();
    List<Integer> data = new ArrayList<>();
    data.add(1);
    data.add(2);
    data.add(3);
    sparkSession.createDataset(data, EncoderHelpers.fromBeamCoder(VarIntCoder.of()));
//    sparkSession.createDataset(data, EncoderHelpers.genericEncoder());
  }
}

@@ -59,16 +59,62 @@
 utils;%0A%0A
+import static org.junit.Assert.assertEquals;%0A%0A
 import j
@@ -283,16 +283,22 @@
 .coders.
+VarInt
 Coder;%0Ai
@@ -318,35 +318,25 @@
 che.
-beam.sdk.coders.VarIntCoder
+spark.sql.Dataset
 ;%0Aim
@@ -882,16 +882,43 @@
 (3);%0A   
+ Dataset%3CInteger%3E dataset =
  sparkSe
@@ -914,32 +914,41 @@
 t = sparkSession
+%0A        
 .createDataset(d
@@ -1005,78 +1005,91 @@
 ));%0A
-//
     
-sparkSession.createDataset(data, EncoderHelpers.genericEncoder()
+List%3CInteger%3E results = dataset.collectAsList();%0A    assertEquals(data, results
 );%0A 

Add an assert of equality in the encoders test