### Question:
HashPartitioner extends Partitioner { @Override public int getPartition(Tuple tuple) { if (numPartitions == 0) return 0; for (int i = 0; i < partitionKeyIds.length; i++) { keyTuple.put(i, tuple.get(partitionKeyIds[i])); } return (keyTuple.hashCode() & Integer.MAX_VALUE) % (numPartitions == 32 ? numPartitions-1 : numPartitions); } HashPartitioner(final int [] keys, final int numPartitions); @Override int getPartition(Tuple tuple);  }### Answer:
@Test public final void testGetPartition() { Tuple tuple1 = new VTuple(3); tuple1.put(new Datum[] { DatumFactory.createInt4(1), DatumFactory.createInt4(2), DatumFactory.createInt4(3) }); Tuple tuple2 = new VTuple(3); tuple2.put(new Datum[] { DatumFactory.createInt4(1), DatumFactory.createInt4(2), DatumFactory.createInt4(4) }); Tuple tuple3 = new VTuple(3); tuple3.put(new Datum[] { DatumFactory.createInt4(1), DatumFactory.createInt4(2), DatumFactory.createInt4(5) }); Tuple tuple4 = new VTuple(3); tuple4.put(new Datum[] { DatumFactory.createInt4(2), DatumFactory.createInt4(2), DatumFactory.createInt4(3) }); Tuple tuple5 = new VTuple(3); tuple5.put(new Datum[] { DatumFactory.createInt4(2), DatumFactory.createInt4(2), DatumFactory.createInt4(4) }); int [] partKeys = {0,1}; Partitioner p = new HashPartitioner(partKeys, 2); int part1 = p.getPartition(tuple1); assertEquals(part1, p.getPartition(tuple2)); assertEquals(part1, p.getPartition(tuple3)); int part2 = p.getPartition(tuple4); assertEquals(part2, p.getPartition(tuple5)); }