fail("transform failed:" + e);
return;
}
List<WaveletOperation> expectedClient = Arrays.<WaveletOperation> asList(
new AddParticipant(CREATOR1_CONTEXT, new ParticipantId(TARGET1)));
List<WaveletOperation> expectedServer = Arrays.<WaveletOperation> asList(
new AddParticipant(CREATOR2_CONTEXT, new ParticipantId(TARGET2)));
assertEquals(expectedClient, transformed.clientOp().toWaveletOperations());
assertEquals(expectedServer, transformed.serverOp().toWaveletOperations());
}
// Test case where client ops are transformed away, and some server ops are kept
{
WaveAggregateOp op1 = new WaveOpBuilder(CREATOR1_ID).addParticipant(TARGET1).build();
WaveAggregateOp op2 =
new WaveOpBuilder(CREATOR2_ID).addParticipant(TARGET1).addParticipant(TARGET2).build();
OperationPair<WaveAggregateOp> transformed;
try {
transformed = WaveAggregateOp.transform(op1, op2);
} catch (TransformException e) {
fail("transform failed:" + e);
return;
}
List<WaveletOperation> expectedServer =
Arrays.<WaveletOperation> asList(new AddParticipant(CREATOR2_CONTEXT, new ParticipantId(
TARGET2)));
assertEquals(0, transformed.clientOp().toWaveletOperations().size());
assertEquals(expectedServer, transformed.serverOp().toWaveletOperations());
}
// Same as above, but server ops originate from 2 different creators. Test
// that the creators are preserved correctly through transform and
// composition.
{
WaveAggregateOp op1 = new WaveOpBuilder(CREATOR1_ID).addParticipant(TARGET1).build();
WaveAggregateOp op2a =
new WaveOpBuilder(CREATOR2_ID).addParticipant(TARGET1).build();
WaveAggregateOp op2b = new WaveOpBuilder(CREATOR1_ID).addParticipant(TARGET2).build();
WaveAggregateOp op2 = compose(op2a, op2b);
OperationPair<WaveAggregateOp> transformed;
try {
transformed = WaveAggregateOp.transform(op1, op2);
} catch (TransformException e) {
fail("transform failed:" + e);
return;
}
List<WaveletOperation> expectedServer =
Arrays.<WaveletOperation> asList(new AddParticipant(CREATOR1_CONTEXT, new ParticipantId(
TARGET2)));
assertEquals(0, transformed.clientOp().toWaveletOperations().size());
assertEquals(expectedServer, transformed.serverOp().toWaveletOperations());
}