package parquet.hadoop.example;

import org.apache.hadoop.conf.Configuration;
import org.junit.Test;
import parquet.hadoop.api.ReadSupport;
import parquet.schema.MessageType;
import parquet.schema.MessageTypeParser;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;

public class GroupReadSupportTest {

  private String fullSchemaStr= "message example {\n" +
          "required int32 line;\n" +
          "optional binary content;\n" +
          "}";

  private String partialSchemaStr ="message example {\n" +
          "required int32 line;\n" +
          "optional binary content;\n" +
          "}";


  @Test
  public void testInitWithoutSpecifyingRequestSchema() throws Exception {
      GroupReadSupport s=new GroupReadSupport();
      Configuration configuration=new Configuration();
      Map<String,String> keyValueMetaData=new HashMap<String,String>();
    MessageType fileSchema= MessageTypeParser.parseMessageType(fullSchemaStr);
    ReadSupport.ReadContext context = s.init(configuration,keyValueMetaData,fileSchema);
    assertEquals(context.getRequestedSchema(), fileSchema);
  }

  @Test
  public void testInitWithPartialSchema(){
    GroupReadSupport s=new GroupReadSupport();
    Configuration configuration=new Configuration();
    Map<String,String> keyValueMetaData=new HashMap<String,String>();
    MessageType fileSchema= MessageTypeParser.parseMessageType(fullSchemaStr);
    MessageType partialSchema= MessageTypeParser.parseMessageType(partialSchemaStr);

    configuration.set(ReadSupport.PARQUET_READ_SCHEMA, partialSchemaStr);
    ReadSupport.ReadContext context = s.init(configuration, keyValueMetaData, fileSchema);
    assertEquals(context.getRequestedSchema(), partialSchema);
  }
}

@@ -209,16 +209,17 @@
 Parser;%0A
+%0A
 import j
@@ -254,24 +254,25 @@
 a.util.Map;%0A
+%0A
 import stati
@@ -372,16 +372,17 @@
 chemaStr
+ 
 = %22messa
@@ -528,16 +528,17 @@
 emaStr =
+ 
 %22message
@@ -594,49 +594,8 @@
 %22 +%0A
-          %22optional binary content;%5Cn%22 +%0A
     
@@ -689,18 +689,16 @@
 ption %7B%0A
-  
     Grou
@@ -703,33 +703,35 @@
 oupReadSupport s
-=
+ = 
 new GroupReadSup
@@ -734,26 +734,24 @@
 dSupport();%0A
-  
     Configur
@@ -761,33 +761,35 @@
 on configuration
-=
+ = 
 new Configuratio
@@ -797,18 +797,16 @@
 ();%0A    
-  
 Map%3CStri
@@ -800,32 +800,33 @@
 %0A    Map%3CString,
+ 
 String%3E keyValue
@@ -825,33 +825,35 @@
 keyValueMetaData
-=
+ = 
 new HashMap%3CStri
@@ -847,32 +847,33 @@
  HashMap%3CString,
+ 
 String%3E();%0A    M
@@ -885,32 +885,33 @@
 eType fileSchema
+ 
 = MessageTypePar
@@ -1006,16 +1006,17 @@
 uration,
+ 
 keyValue
@@ -1024,16 +1024,17 @@
 etaData,
+ 
 fileSche
@@ -1152,16 +1152,17 @@
 Schema()
+ 
 %7B%0A    Gr
@@ -1177,17 +1177,19 @@
 upport s
-=
+ = 
 new Grou
@@ -1235,17 +1235,19 @@
 guration
-=
+ = 
 new Conf
@@ -1270,24 +1270,25 @@
  Map%3CString,
+ 
 String%3E keyV
@@ -1299,17 +1299,19 @@
 MetaData
-=
+ = 
 new Hash
@@ -1321,16 +1321,17 @@
 %3CString,
+ 
 String%3E(
@@ -1355,24 +1355,25 @@
 e fileSchema
+ 
 = MessageTyp
@@ -1442,16 +1442,17 @@
 alSchema
+ 
 = Messag

fix test