Update DOMStoreThreePhaseCommitCohort design
[mdsal.git] / dom / mdsal-dom-broker / src / test / java / org / opendaylight / mdsal / dom / broker / TestCommitCohort.java
index a380cf02aa68e0e4f6bd29d4c31ae806ba56b1b5..79aba5f0df2bc10f9f9c2ebbf5ce5c809566fdbe 100644 (file)
@@ -9,53 +9,52 @@ package org.opendaylight.mdsal.dom.broker;
 
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.yangtools.yang.common.Empty;
 
 public enum TestCommitCohort implements DOMStoreThreePhaseCommitCohort {
+    ALLWAYS_SUCCESS(true, true, true, true),
+    CAN_COMMIT_FAILED(false, false, false, true),
+    PRE_COMMIT_FAILED(true, false, false, true),
+    COMMIT_FAILED(true, true, false, true);
 
-
-    ALLWAYS_SUCCESS(true, true, true, true), CAN_COMMIT_FAILED(false, false, false, true), PRE_COMMIT_FAILED(true,
-            false, false, true), COMMIT_FAILED(true, true, false, true);
-
+    private final ListenableFuture<Boolean> canCommit;
+    private final ListenableFuture<Empty> preCommit;
+    private final ListenableFuture<CommitInfo> commit;
+    private final ListenableFuture<Empty> abort;
 
     TestCommitCohort(final boolean canCommit, final boolean preCommit,
             final boolean commit, final boolean abort) {
         this.canCommit = Futures.immediateFuture(canCommit);
         this.preCommit = immediate(canCommit, new IllegalStateException());
-        this.commit = immediate(commit, new IllegalStateException());
+        this.commit = commit ? CommitInfo.emptyFluentFuture()
+            : Futures.immediateFailedFuture(new IllegalStateException());
         this.abort = immediate(abort, new IllegalStateException());
     }
 
 
-    private final ListenableFuture<Boolean> canCommit;
-    private final ListenableFuture<Void> preCommit;
-    private final ListenableFuture<Void> commit;
-    private final ListenableFuture<Void> abort;
-
     @Override
     public ListenableFuture<Boolean> canCommit() {
         return canCommit;
     }
 
     @Override
-    public ListenableFuture<Void> preCommit() {
+    public ListenableFuture<Empty> preCommit() {
         return preCommit;
     }
 
     @Override
-    public ListenableFuture<Void> abort() {
+    public ListenableFuture<Empty> abort() {
         return abort;
     }
 
     @Override
-    public ListenableFuture<Void> commit() {
+    public ListenableFuture<CommitInfo> commit() {
         return commit;
     }
 
-    private static ListenableFuture<Void> immediate(final boolean isSuccess, final Exception except) {
-        return isSuccess ? Futures.immediateFuture(null) : Futures.immediateFailedFuture(except);
+    private static ListenableFuture<Empty> immediate(final boolean isSuccess, final Exception except) {
+        return isSuccess ? Futures.immediateFuture(Empty.value()) : Futures.immediateFailedFuture(except);
     }
-
-
-
 }