Files
ebean/src/test/java/org/tests/model/m2o/TestManyToOneAsOne.java
T
Roland PramlandRob Bygrave 8d334ff2e8 Feature/contitional test runner (#1132)
* 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

* ADD: ContitonaltestRunner to skip tests for certain platforms

* Use annotations to control on which platforms a test shoud run

* FIX: compile errors
2017-09-15 21:03:03 +12:00

54 lines
1.3 KiB
Java

package org.tests.model.m2o;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import io.ebean.Platform;
import io.ebean.annotation.IgnorePlatform;
import io.ebean.annotation.Transactional;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class TestManyToOneAsOne extends BaseTestCase {
@Test
public void test_when_nonJdbcBatch() {
runInserts();
}
@Transactional(batchSize = 20)
@Test
@IgnorePlatform(Platform.SQLSERVER) // probably due the use of sequences - Empl has already an ID and Addr refers to it.
public void test_when_jdbcBatch() {
runInserts();
}
private void runInserts() {
Addr junk = new Addr();
junk.setName("junk");
Ebean.save(junk);
Empl emp = new Empl();
emp.setName("My Name");
Addr address = new Addr();
address.setName("home");
emp.getAddresses().add(address);
// if I do an interim Ebean.save here it works
//Ebean.save(emp);
address.setEmployee(emp);
emp.setDefaultAddress(address);
Ebean.save(emp);
assertThat(emp.getDefaultAddress().getId()).isNotNull();
assertThat(address.getEmployee().getId()).isNotNull();
Empl foundEmpl = Ebean.find(Empl.class, emp.getId());
assertThat(foundEmpl.getDefaultAddress().getId()).isEqualTo(address.getId());
}
}