import com.google.common.util.concurrent.FluentFuture;
import com.typesafe.config.ConfigFactory;
import java.util.Collection;
-import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
kit.testWriteTransaction(dataStore, TestModel.TEST_PATH, node);
verify(cohort).canCommit(any(Object.class), any(EffectiveModelContext.class), candidateCapt.capture());
assertDataTreeCandidate((DOMDataTreeCandidate) candidateCapt.getValue().iterator().next(), TEST_ID,
- ModificationType.WRITE, Optional.of(node), Optional.empty());
+ ModificationType.WRITE, node, null);
reset(cohort);
doReturn(PostCanCommitStep.NOOP_SUCCESSFUL_FUTURE).when(cohort).canCommit(any(Object.class),
verify(cohort).canCommit(any(Object.class), any(EffectiveModelContext.class), candidateCapture.capture());
assertDataTreeCandidate((DOMDataTreeCandidate) candidateCapture.getValue().iterator().next(),
new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, optimaPath), ModificationType.WRITE,
- Optional.of(optimaNode), Optional.empty());
+ optimaNode, null);
// Write replace the cars container with 2 new car entries. The cohort should get invoked with 3
// DOMDataTreeCandidates: once for each of the 2 new car entries (WRITE mod) and once for the deleted prior
assertDataTreeCandidate(findCandidate(candidateCapture, sportagePath), new DOMDataTreeIdentifier(
LogicalDatastoreType.CONFIGURATION, sportagePath), ModificationType.WRITE,
- Optional.of(sportageNode), Optional.empty());
+ sportageNode, null);
assertDataTreeCandidate(findCandidate(candidateCapture, soulPath), new DOMDataTreeIdentifier(
LogicalDatastoreType.CONFIGURATION, soulPath), ModificationType.WRITE,
- Optional.of(soulNode), Optional.empty());
+ soulNode, null);
assertDataTreeCandidate(findCandidate(candidateCapture, optimaPath), new DOMDataTreeIdentifier(
LogicalDatastoreType.CONFIGURATION, optimaPath), ModificationType.DELETE,
- Optional.empty(), Optional.of(optimaNode));
+ null, optimaNode);
// Delete the cars container - cohort should be invoked for the 2 deleted car entries.
assertDataTreeCandidate(findCandidate(candidateCapture, sportagePath), new DOMDataTreeIdentifier(
LogicalDatastoreType.CONFIGURATION, sportagePath), ModificationType.DELETE,
- Optional.empty(), Optional.of(sportageNode));
+ null, sportageNode);
assertDataTreeCandidate(findCandidate(candidateCapture, soulPath), new DOMDataTreeIdentifier(
LogicalDatastoreType.CONFIGURATION, soulPath), ModificationType.DELETE,
- Optional.empty(), Optional.of(soulNode));
+ null, soulNode);
}
}
private static void assertDataTreeCandidate(final DOMDataTreeCandidate candidate,
final DOMDataTreeIdentifier expTreeId, final ModificationType expType,
- final Optional<NormalizedNode> expDataAfter, final Optional<NormalizedNode> expDataBefore) {
+ final NormalizedNode expDataAfter, final NormalizedNode expDataBefore) {
assertNotNull("Expected candidate for path " + expTreeId.getRootIdentifier(), candidate);
assertEquals("rootPath", expTreeId, candidate.getRootPath());
assertEquals("modificationType", expType, candidate.getRootNode().modificationType());
-
- assertEquals("dataAfter present", expDataAfter.isPresent(),
- candidate.getRootNode().findDataAfter().isPresent());
- if (expDataAfter.isPresent()) {
- assertEquals("dataAfter", expDataAfter.orElseThrow(),
- candidate.getRootNode().findDataAfter().orElseThrow());
- }
-
- assertEquals("dataBefore present", expDataBefore.isPresent(),
- candidate.getRootNode().findDataBefore().isPresent());
- if (expDataBefore.isPresent()) {
- assertEquals("dataBefore", expDataBefore.orElseThrow(),
- candidate.getRootNode().findDataBefore().orElseThrow());
- }
+ assertEquals("dataAfter", expDataAfter, candidate.getRootNode().dataAfter());
+ assertEquals("dataBefore", expDataBefore, candidate.getRootNode().dataBefore());
}
}
// Simple data validation - verify the year, if present, is >= 1990
final DataTreeCandidateNode rootNode = candidate.getRootNode();
- final Optional<NormalizedNode> dataAfter = rootNode.getDataAfter();
+ final NormalizedNode dataAfter = rootNode.dataAfter();
LOG.info("In canCommit: modificationType: {}, dataBefore: {}, dataAfter: {}",
- rootNode.getModificationType(), rootNode.getDataBefore(), dataAfter);
+ rootNode.modificationType(), rootNode.dataBefore(), dataAfter);
// Note: we don't want to process DELETE modifications but we don't need to explicitly check the
// ModificationType because dataAfter will not be present. Also dataAfter *should* always contain a
// MapEntryNode but we verify anyway.
- if (dataAfter.isPresent()) {
- final NormalizedNode normalizedNode = dataAfter.orElseThrow();
- Verify.verify(normalizedNode instanceof DataContainerNode,
- "Expected type DataContainerNode, actual was %s", normalizedNode.getClass());
- DataContainerNode entryNode = (DataContainerNode) normalizedNode;
+ if (dataAfter != null) {
+ Verify.verify(dataAfter instanceof DataContainerNode,
+ "Expected type DataContainerNode, actual was %s", dataAfter.getClass());
+ DataContainerNode entryNode = (DataContainerNode) dataAfter;
final Optional<DataContainerChild> possibleYear = entryNode.findChildByArg(YEAR_NODE_ID);
if (possibleYear.isPresent()) {
final Number year = (Number) possibleYear.orElseThrow().body();