Program: 125908
Project: 125908
Buggy source:
/** 
 * Unit tests for   {@link org.talend.core.model.metadata.MetadataToolHelper#convertToAvro(IMetadataTable)}Test a simple MetadataTable.
 */
@Test public void testConvertToAvro_Basic(){
  MetadataTable table=ConnectionFactory.eINSTANCE.createMetadataTable();
  table.setLabel("String_Node_Str");
  table.setComment("String_Node_Str");
  ArrayList<org.talend.core.model.metadata.builder.connection.MetadataColumn> columns=new ArrayList<>();
{
    org.talend.core.model.metadata.builder.connection.MetadataColumn column=ConnectionFactory.eINSTANCE.createMetadataColumn();
    column.setLabel("String_Node_Str");
    column.setTalendType(JavaTypesManager.INTEGER.getId());
    column.setNullable(true);
    columns.add(column);
  }
{
    org.talend.core.model.metadata.builder.connection.MetadataColumn column=ConnectionFactory.eINSTANCE.createMetadataColumn();
    column.setLabel("String_Node_Str");
    column.setTalendType(JavaTypesManager.STRING.getId());
    column.setNullable(false);
    columns.add(column);
  }
{
    org.talend.core.model.metadata.builder.connection.MetadataColumn column=ConnectionFactory.eINSTANCE.createMetadataColumn();
    column.setLabel("String_Node_Str");
    column.setTalendType(JavaTypesManager.BOOLEAN.getId());
    column.setNullable(false);
    columns.add(column);
  }
{
    org.talend.core.model.metadata.builder.connection.MetadataColumn column=ConnectionFactory.eINSTANCE.createMetadataColumn();
    column.setLabel("String_Node_Str");
    column.setTalendType("String_Node_Str");
    column.setNullable(false);
    columns.add(column);
  }
  table.getColumns().addAll(columns);
  Schema s=MetadataToolAvroHelper.convertToAvro(table);
  assertThat(s.getType(),is(Schema.Type.RECORD));
  assertThat(s.getName(),is("String_Node_Str"));
  assertThat(s.getFields(),hasSize(4));
  assertThat(s.getProp(Talend6SchemaConstants.TALEND6_LABEL),is("String_Node_Str"));
  assertThat(s.getProp(Talend6SchemaConstants.TALEND6_COMMENT),is("String_Node_Str"));
  Schema.Field f=s.getFields().get(0);
  assertTrue(AvroUtils.isNullable(f.schema()));
  assertThat(AvroUtils.unwrapIfNullable(f.schema()).getType(),is(Schema.Type.INT));
  assertThat(f.name(),is("String_Node_Str"));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_LABEL),is("String_Node_Str"));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_COLUMN_TALEND_TYPE),is("String_Node_Str"));
  f=s.getFields().get(1);
  assertThat(f.schema().getType(),is(Schema.Type.STRING));
  assertThat(f.name(),is("String_Node_Str"));
  assertFalse(AvroUtils.isNullable(f.schema()));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_LABEL),is("String_Node_Str"));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_COLUMN_TALEND_TYPE),is("String_Node_Str"));
  f=s.getFields().get(2);
  assertThat(f.schema().getType(),is(Schema.Type.BOOLEAN));
  assertThat(f.name(),is("String_Node_Str"));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_LABEL),is("String_Node_Str"));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_COLUMN_TALEND_TYPE),is("String_Node_Str"));
  f=s.getFields().get(3);
  assertThat(f.schema().getType(),is(Schema.Type.BYTES));
  assertThat(f.name(),is("String_Node_Str"));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_LABEL),is("String_Node_Str"));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_COLUMN_TALEND_TYPE),is("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Unit tests for   {@link org.talend.core.model.metadata.MetadataToolHelper#convertToAvro(IMetadataTable)}Test a simple MetadataTable.
 */
@Test public void testConvertToAvro_Basic(){
  MetadataTable table=ConnectionFactory.eINSTANCE.createMetadataTable();
  table.setLabel("String_Node_Str");
  table.setComment("String_Node_Str");
  ArrayList<org.talend.core.model.metadata.builder.connection.MetadataColumn> columns=new ArrayList<>();
{
    org.talend.core.model.metadata.builder.connection.MetadataColumn column=ConnectionFactory.eINSTANCE.createMetadataColumn();
    column.setLabel("String_Node_Str");
    column.setTalendType(JavaTypesManager.INTEGER.getId());
    column.setNullable(true);
    columns.add(column);
  }
{
    org.talend.core.model.metadata.builder.connection.MetadataColumn column=ConnectionFactory.eINSTANCE.createMetadataColumn();
    column.setLabel("String_Node_Str");
    column.setTalendType(JavaTypesManager.STRING.getId());
    column.setNullable(false);
    columns.add(column);
  }
{
    org.talend.core.model.metadata.builder.connection.MetadataColumn column=ConnectionFactory.eINSTANCE.createMetadataColumn();
    column.setLabel("String_Node_Str");
    column.setTalendType(JavaTypesManager.BOOLEAN.getId());
    column.setNullable(false);
    columns.add(column);
  }
{
    org.talend.core.model.metadata.builder.connection.MetadataColumn column=ConnectionFactory.eINSTANCE.createMetadataColumn();
    column.setLabel("String_Node_Str");
    column.setTalendType("String_Node_Str");
    column.setNullable(false);
    columns.add(column);
  }
  table.getColumns().addAll(columns);
  Schema s=MetadataToolAvroHelper.convertToAvro(table);
  assertThat(s.getType(),is(Schema.Type.RECORD));
  assertThat(s.getName(),is("String_Node_Str"));
  assertThat(s.getFields(),hasSize(3));
  assertThat(s.getProp(Talend6SchemaConstants.TALEND6_LABEL),is("String_Node_Str"));
  assertThat(s.getProp(Talend6SchemaConstants.TALEND6_COMMENT),is("String_Node_Str"));
  Schema.Field f=s.getFields().get(0);
  assertTrue(AvroUtils.isNullable(f.schema()));
  assertThat(AvroUtils.unwrapIfNullable(f.schema()).getType(),is(Schema.Type.INT));
  assertThat(f.name(),is("String_Node_Str"));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_LABEL),is("String_Node_Str"));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_COLUMN_TALEND_TYPE),is("String_Node_Str"));
  f=s.getFields().get(1);
  assertThat(f.schema().getType(),is(Schema.Type.STRING));
  assertThat(f.name(),is("String_Node_Str"));
  assertFalse(AvroUtils.isNullable(f.schema()));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_LABEL),is("String_Node_Str"));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_COLUMN_TALEND_TYPE),is("String_Node_Str"));
  f=s.getFields().get(2);
  assertThat(f.schema().getType(),is(Schema.Type.BOOLEAN));
  assertThat(f.name(),is("String_Node_Str"));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_LABEL),is("String_Node_Str"));
  assertThat(f.getProp(Talend6SchemaConstants.TALEND6_COLUMN_TALEND_TYPE),is("String_Node_Str"));
  assertThat(s.getProp(SchemaConstants.INCLUDE_ALL_FIELDS),is("String_Node_Str"));
  assertThat(s.getProp(Talend6SchemaConstants.TALEND6_DYNAMIC_COLUMN_NAME),is("String_Node_Str"));
  assertThat(s.getProp(Talend6SchemaConstants.TALEND6_DYNAMIC_COLUMN_POSITION),is("String_Node_Str"));
  assertThat(s.getProp(Talend6SchemaConstants.TALEND6_COLUMN_TALEND_TYPE),is("String_Node_Str"));
}