mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
* 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
46 lines
1013 B
Java
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");
|
|
});
|
|
}
|
|
}
|