TableInfo { public PartitionSpec getPartitionSpec() { PartitionSpec partitionSpec = new PartitionSpec(); for (String key : partSpec.keySet()) { partitionSpec.set(key, partSpec.get(key)); } return partitionSpec; } TableInfo(String projectName, String tblName, LinkedHashMap<String, String> partSpec,
                   String[] cols, String lable);  TableInfo();  TableInfo(TableInfo table); static TableInfoBuilder builder(); void validate(); String getProjectName(); PartitionSpec getPartitionSpec(); LinkedHashMap<String, String> getPartSpec(); String getPartPath(); void setPartSpec(LinkedHashMap<String, String> partSpec); void setPartSpec(String partPath); String[] getCols(); void setCols(String[] cols); String getTableName(); void setTableName(String name); String getLabel(); void setLable(String lable); Class<?> getMapperClass(); void setMapperClass(Class<?> mapperClass); void setProjectName(String projectName); @Override boolean equals(Object that); @Override String toString(); static final String DEFAULT_LABEL; static final String INNER_OUTPUT_LABEL; }
@Test public void testGetPartitionSpec() { PartitionSpec partitionSpec = new PartitionSpec("p2='1',p1='2'"); TableInfo tableInfo = TableInfo.builder().projectName("project1").tableName("table1") .partSpec(partitionSpec).build(); Assert.assertEquals("project1", tableInfo.getProjectName()); Assert.assertEquals("table1", tableInfo.getTableName()); partitionSpec = tableInfo.getPartitionSpec(); int i = 0; for (String key : partitionSpec.keys()) { if (i == 0) { Assert.assertEquals("p2=1", key + "=" + partitionSpec.get(key)); } else { Assert.assertEquals("p1=2", key + "=" + partitionSpec.get(key)); } i++; } partitionSpec = null; tableInfo = TableInfo.builder().projectName("project2").tableName("table2") .partSpec(partitionSpec).build(); Assert.assertEquals("project2", tableInfo.getProjectName()); Assert.assertEquals("table2", tableInfo.getTableName()); partitionSpec = tableInfo.getPartitionSpec(); Assert.assertEquals(true, partitionSpec.isEmpty()); }