
com.couchbase.transactions.util.TransactionMock Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of couchbase-transactions Show documentation
Show all versions of couchbase-transactions Show documentation
Transaction Support for Couchbase on top of the Java SDK
The newest version!
/*
* Copyright 2021 Couchbase, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.couchbase.transactions.util;
import com.couchbase.client.core.annotation.Stability;
import com.couchbase.transactions.AttemptContextReactive;
import reactor.core.publisher.Mono;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
/**
* Can be used for testing transactions, but is for internal use only.
*
* This is the preferred way to mock out transactions now, instead of Mockito.
*/
@Stability.Internal
public class TransactionMock {
// Just for testing so these are public
public Mono standard = Mono.just(1);
public Function> beforeAtrCommit = (ctx) -> standard;
public Function> beforeAtrCommitAmbiguityResolution = (ctx) -> standard;
public Function> afterAtrCommit = (ctx) -> standard;
public BiFunction> beforeDocCommitted = (ctx, x) -> Mono.just(1);
@Deprecated // The algorithm no longer uses this
public BiFunction> beforeRemovingDocDuringStagedInsert = (ctx, x) -> Mono.just(1);
public BiFunction> beforeRollbackDeleteInserted = (ctx, x) -> Mono.just(1);
public BiFunction> afterDocCommittedBeforeSavingCAS = (ctx, x) -> Mono.just(1);
public BiFunction> afterDocCommitted = (ctx, x) -> Mono.just(1);
public BiFunction> beforeStagedInsert = (ctx, x) -> Mono.just(1);
public BiFunction> beforeStagedRemove = (ctx, x) -> Mono.just(1);
public BiFunction> beforeStagedReplace = (ctx, x) -> Mono.just(1);
public BiFunction> beforeDocRemoved = (ctx, x) -> Mono.just(1);
public BiFunction> beforeDocRolledBack = (ctx, x) -> Mono.just(1);
public BiFunction> afterDocRemovedPreRetry = (ctx, x) -> Mono.just(1);
public BiFunction> afterDocRemovedPostRetry = (ctx, x) -> Mono.just(1);
public BiFunction> afterGetComplete = (ctx, x) -> Mono.just(1);
public BiFunction> afterStagedReplaceComplete = (ctx, x) -> Mono.just(1);
public BiFunction> afterStagedRemoveComplete = (ctx, x) -> Mono.just(1);
public BiFunction> afterStagedInsertComplete = (ctx, x) -> Mono.just(1);
public BiFunction> afterRollbackReplaceOrRemove = (ctx, x) -> Mono.just(1);
public BiFunction> afterRollbackDeleteInserted = (ctx, x) -> Mono.just(1);
public BiFunction> beforeCheckATREntryForBlockingDoc = (ctx, x) -> Mono.just(1);
public BiFunction> beforeDocGet = (ctx, x) -> Mono.just(1);
public BiFunction> beforeGetDocInExistsDuringStagedInsert = (ctx, x) -> Mono.just(1);
public BiFunction> beforeOverwritingStagedInsertRemoval = (ctx, x) -> Mono.just(1);
public BiFunction> beforeRemoveStagedInsert = (ctx, x) -> Mono.just(1);
public BiFunction> afterRemoveStagedInsert = (ctx, x) -> Mono.just(1);
public Function> afterDocsCommitted = (ctx) -> standard;
public Function> afterDocsRemoved = (ctx) -> standard;
public Function> afterAtrPending = (ctx) -> standard;
public Function> beforeAtrPending = (ctx) -> standard;
public Function> beforeAtrComplete = (ctx) -> standard;
public Function> beforeAtrRolledBack = (ctx) -> standard;
public Function> afterAtrComplete = (ctx) -> standard;
@Deprecated // The algorithm no longer uses this
public Function> beforeGetAtrForAbort = (ctx) -> standard;
public Function> beforeAtrAborted = (ctx) -> standard;
public Function> afterAtrAborted = (ctx) -> standard;
public Function> afterAtrRolledBack = (ctx) -> standard;
public BiFunction> beforeQuery = (ctx, x) -> Mono.just(1);
public BiFunction> afterQuery = (ctx, x) -> Mono.just(1);
public Function> randomAtrIdForVbucket = (ctx) -> Optional.empty();
public TriFunction, Boolean> hasExpiredClientSideHook = (ctx, place, docId) -> false;
public BiFunction> beforeUnlockGet = (ctx, x) -> Mono.just(1);
public BiFunction> beforeUnlockInsert = (ctx, x) -> Mono.just(1);
public BiFunction> beforeUnlockReplace = (ctx, x) -> Mono.just(1);
public BiFunction> beforeUnlockRemove = (ctx, x) -> Mono.just(1);
public BiFunction> beforeUnlockQuery = (ctx, x) -> Mono.just(1);
public BiFunction> beforeDocChangedDuringCommit = (ctx, x) -> Mono.just(1);
public BiFunction> beforeDocChangedDuringStaging = (ctx, x) -> Mono.just(1);
public BiFunction> beforeDocChangedDuringRollback = (ctx, x) -> Mono.just(1);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy