public void should_exception_when_failing_cas_update() throws Exception {
//Given
final EntityWithEnum entityWithEnum = new EntityWithEnum(10L, "John", EACH_QUORUM);
final EntityWithEnum managed = manager.insert(entityWithEnum);
Map<String, Object> expectedCurrentValues = ImmutableMap.<String, Object>of("[applied]", false, "consistency_level", EACH_QUORUM.name(), "name", "John");
AchillesLightWeightTransactionException casException = null;
managed.setName("Helen");
//When
try {
manager.update(managed, ifConditions(new CASCondition("name", "name"), new CASCondition("consistency_level", EACH_QUORUM)));
} catch (AchillesLightWeightTransactionException ace) {
casException = ace;
}
assertThat(casException).isNotNull();
assertThat(casException.operation()).isEqualTo(UPDATE);
assertThat(casException.currentValues()).isEqualTo(expectedCurrentValues);
assertThat(casException.toString()).isEqualTo("CAS operation UPDATE cannot be applied. Current values are: {[applied]=false, consistency_level=EACH_QUORUM, name=John}");
}