Files
ebean/src/test/java/org/tests/transaction/TestNested.java
T
Roland PramlandRob Bygrave b66f18bfd6 Fix warnings 2 (#1130)
* FIX: warnings (add generics, overrides, fix imports) - should be no effecive code change

* replaced deprecated methods by default methods

* FIX: more compiler warnings

* FIX more warnings - no code changes

* FIX: deprecated call to JsonParseException

* Remove unused code, check unused variables
2017-09-14 00:32:48 +12:00

46 lines
1013 B
Java

package org.tests.transaction;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import org.junit.Test;
import javax.persistence.PersistenceException;
import java.util.concurrent.Callable;
import static org.assertj.core.api.Assertions.assertThat;
public class TestNested extends BaseTestCase {
@Test
public void testRunnableFail() {
try {
Ebean.execute(this::willFail);
} catch (PersistenceException e) {
assertThat(e.getMessage()).contains("test runnable rollback");
}
}
@Test
public void testCallableFail() {
try {
Ebean.execute(this::willFailCallable);
} catch (PersistenceException e) {
assertThat(e.getMessage()).contains("test callable rollback");
}
}
private void willFail() {
Ebean.executeCall(() -> {
throw new RuntimeException("test runnable rollback");
});
}
private void willFailCallable() {
Ebean.executeCall((Callable<String>) () -> {
throw new Exception("test callable rollback");
});
}
}