Source:
public void testMultiFieldsSourceWith2N() throws Exception { String mockSource = "Multiple"; String multiFieldData = "MultipleFields"; ETLBatchConfig etlConfig = buildETLBatchConfig(mockSource, multiFieldData, "2"); AppRequest<ETLBatchConfig> appRequest = new AppRequest<>(DATAPIPELINE_ARTIFACT, etlConfig); ApplicationId appId = NamespaceId.DEFAULT.app(APP_NAME); ApplicationManager appManager = deployApplication(appId.toId(), appRequest); DataSetManager<Table> inputManager = getDataset(mockSource); List<StructuredRecord> input = ImmutableList.of( StructuredRecord.builder(SOURCE_SCHEMA_MULTIPLE).set(FIELD_TO_BE_TRANSFORMED, DATA_TO_BE_TRANSFORMED1) .set(ADDITIONAL_FIELD, "CDAP1").build(), StructuredRecord.builder(SOURCE_SCHEMA_MULTIPLE).set(FIELD_TO_BE_TRANSFORMED, DATA_TO_BE_TRANSFORMED2) .set(ADDITIONAL_FIELD, "CDAP2").build() ); MockSource.writeInput(inputManager, input); WorkflowManager workflowManager = appManager.getWorkflowManager(SmartWorkflow.NAME); workflowManager.start(); workflowManager.waitForFinish(5, TimeUnit.MINUTES); DataSetManager<Table> nGrams = getDataset(multiFieldData); List<StructuredRecord> output = MockSink.readOutput(nGrams); Set<List> results = new HashSet<>(); for (StructuredRecord structuredRecord : output) { results.add((ArrayList) structuredRecord.get(OUTPUT_FIELD)); } StructuredRecord row = output.get(0); Assert.assertEquals(2, output.size()); Assert.assertEquals(getExpectedData(), results); Assert.assertTrue(getExpectedData().containsAll(results)); Assert.assertEquals(1, row.getSchema().getFields().size()); Assert.assertEquals("ARRAY", row.getSchema().getField(OUTPUT_FIELD).getSchema().getType().toString()); }

Target:
public void testMultiFieldsSourceWith2N() throws Exception { String mockSource = "Multiple"; String multiFieldData = "MultipleFields"; ETLBatchConfig etlConfig = buildETLBatchConfig(mockSource, multiFieldData, "2"); AppRequest<ETLBatchConfig> appRequest = new AppRequest<>(DATAPIPELINE_ARTIFACT, etlConfig); ApplicationId appId = NamespaceId.DEFAULT.app(APP_NAME); ApplicationManager appManager = deployApplication(appId.toId(), appRequest); DataSetManager<Table> inputManager = getDataset(mockSource); List<StructuredRecord> input = ImmutableList.of( StructuredRecord.builder(SOURCE_SCHEMA_MULTIPLE).set(FIELD_TO_BE_TRANSFORMED, DATA_TO_BE_TRANSFORMED1) .set(ADDITIONAL_FIELD, "CDAP1").build(), StructuredRecord.builder(SOURCE_SCHEMA_MULTIPLE).set(FIELD_TO_BE_TRANSFORMED, DATA_TO_BE_TRANSFORMED2) .set(ADDITIONAL_FIELD, "CDAP2").build() ); MockSource.writeInput(inputManager, input); WorkflowManager workflowManager = appManager.getWorkflowManager(SmartWorkflow.NAME); workflowManager.start(); workflowManager.waitForFinish(5, TimeUnit.MINUTES); DataSetManager<Table> nGrams = getDataset(multiFieldData); List<StructuredRecord> output = MockSink.readOutput(nGrams); Set<List> results = new HashSet<>(); for (StructuredRecord structuredRecord : output) { results.add((ArrayList) structuredRecord.get(OUTPUT_FIELD)); } Assert.assertEquals(2, output.size()); Assert.assertEquals(getExpectedData(), results); StructuredRecord row = output.get(0); Assert.assertEquals(1, row.getSchema().getFields().size()); Assert.assertEquals("ARRAY", row.getSchema().getField(OUTPUT_FIELD).getSchema().getType().toString()); }