### Question:
ThriftListenerUtils { public static List<ObjectPair<Integer, byte[]>> toObjectPairs(Table table, List<Partition> partitions) { List<ObjectPair<Integer, byte[]>> pairs = new ArrayList<>(partitions.size()); for (Partition partition : partitions) { Map<String, String> partitionSpec = Warehouse.makeSpecFromValues(table.getPartitionKeys(), partition.getValues()); ExprNodeGenericFuncDesc partitionExpression; try { partitionExpression = new ExpressionBuilder(table, partitionSpec).build(); } catch (SemanticException e) { throw new RuntimeException("Unable to build expression", e); } ObjectPair<Integer, byte[]> serializedPartitionExpression = new ObjectPair<>(partitionSpec.size(), SerializationUtilities.serializeExpressionToKryo(partitionExpression)); pairs.add(serializedPartitionExpression); } return pairs; } private  ThriftListenerUtils(); static List<ObjectPair<Integer, byte[]>> toObjectPairs(Table table, List<Partition> partitions);  }### Answer:
@Test public void singlePartitionCol() { List<ObjectPair<Integer, byte[]>> pairs = ThriftListenerUtils .toObjectPairs(createTable(new FieldSchema("part", "string", null)), Arrays.asList(createPartition("a"), createPartition("b"))); assertThat(pairs.size()).isEqualTo(2); for (ObjectPair<Integer, byte[]> pair : pairs) { assertThat(pair.getFirst()).isEqualTo(1); } }
@Test public void twoPartitionCols() { List<ObjectPair<Integer, byte[]>> pairs = ThriftListenerUtils .toObjectPairs(createTable(new FieldSchema("part_1", "string", null), new FieldSchema("part_2", "int", null)), Arrays.asList(createPartition("a", "1"), createPartition("b", "2"))); assertThat(pairs.size()).isEqualTo(2); for (ObjectPair<Integer, byte[]> pair : pairs) { assertThat(pair.getFirst()).isEqualTo(2); } }
@Test(expected = RuntimeException.class) public void moreValuesThanPartitionCols() { ThriftListenerUtils .toObjectPairs(createTable(new FieldSchema("part", "string", null)), Arrays.asList(createPartition("a", "1"))); }