use of io.cdap.cdap.api.dataset.lib.partitioned.ConsumerWorkingSet in project cdap by caskdata.
the class ConsumerWorkingSetTest method testByteSerialization.
@Test
public void testByteSerialization() {
ConsumerWorkingSet workingSet = new ConsumerWorkingSet();
// test with empty partitions lists
testSerDe(workingSet);
// test with two elements in AVAILABLE and none in IN_PROGRESS
workingSet.getPartitions().add(new DefaultConsumablePartition(generateUniqueKey()));
workingSet.getPartitions().add(new DefaultConsumablePartition(generateUniqueKey()));
testSerDe(workingSet);
// test with three elements in partitions and none in inProgressPartitions
workingSet.getPartitions().add(new DefaultConsumablePartition(generateUniqueKey()));
testSerDe(workingSet);
// mark the first element as IN_PROGRESS
workingSet.getPartitions().get(0).take();
workingSet.getPartitions().get(0).setTimestamp(System.currentTimeMillis());
testSerDe(workingSet);
}
use of io.cdap.cdap.api.dataset.lib.partitioned.ConsumerWorkingSet in project cdap by caskdata.
the class ConsumerWorkingSetTest method testSerDe.
private void testSerDe(ConsumerWorkingSet stateToSerialize) {
byte[] bytes = stateToSerialize.toBytes();
// Assert that the serialization format version is 0
Assert.assertEquals(0, bytes[0]);
ConsumerWorkingSet deserializedState = ConsumerWorkingSet.fromBytes(bytes);
Assert.assertEquals(stateToSerialize, deserializedState);
}
Aggregations