
com.eclecticlogic.pedal.testing.NoopTransactionMock Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pedal-tx Show documentation
Show all versions of pedal-tx Show documentation
Pedal is an idiomatic JPA and Spring based DAO framework.
/**
* Copyright (c) 2014 Eclectic Logic LLC
*
* 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.eclecticlogic.pedal.testing;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import org.springframework.transaction.annotation.Propagation;
import com.eclecticlogic.pedal.Context;
import com.eclecticlogic.pedal.Transaction;
import com.eclecticlogic.pedal.TransactionRunner;
/**
* @author kabram.
*
*/
public class NoopTransactionMock implements Transaction {
/**
* @see com.eclecticlogic.pedal.TransactionRunner#run(java.util.function.Consumer)
*/
@Override
public void run(Consumer block) {
block.accept(new NoopContext());
}
/**
* @see com.eclecticlogic.pedal.TransactionRunner#run(java.lang.Runnable)
*/
@Override
public void run(Runnable block) {
block.run();
}
/**
* @see com.eclecticlogic.pedal.TransactionRunner#exec(java.util.function.Supplier)
*/
@Override
public R exec(Supplier block) {
return block.get();
}
/**
* @see com.eclecticlogic.pedal.TransactionRunner#exec(java.util.function.Function)
*/
@Override
public R exec(Function block) {
return block.apply(new NoopContext());
}
/**
* @see com.eclecticlogic.pedal.TransactionRunner#flush()
*/
@Override
public void flush() {
// Noop
}
/**
* @see com.eclecticlogic.pedal.Transaction#with(org.springframework.transaction.annotation.Propagation)
*/
@Override
public TransactionRunner with(Propagation propagation) {
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy