Merge remote-tracking branch 'upstream/master' into ebean-new

# Conflicts:
#	ebean-api/pom.xml
#	ebean-api/src/main/java/io/ebean/config/dbplatform/db2/DB2Platform.java
#	ebean-autotune/pom.xml
#	ebean-bom/pom.xml
#	ebean-core-type/pom.xml
#	ebean-core/pom.xml
#	ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java
#	ebean-ddl-generator/pom.xml
#	ebean-externalmapping-api/pom.xml
#	ebean-externalmapping-xml/pom.xml
#	ebean-postgis/pom.xml
#	ebean-querybean/pom.xml
#	ebean-redis/pom.xml
#	ebean-test/pom.xml
#	ebean-test/src/test/resources/ebean.properties
#	ebean-test/testconfig/ebean-mariadb-10.3.properties
#	ebean-test/testconfig/ebean-mariadb.properties
#	ebean-test/testconfig/ebean-mysql.properties
#	ebean-test/testconfig/ebean-sqlserver17.properties
#	ebean/pom.xml
#	kotlin-querybean-generator/pom.xml
#	pom.xml
#	querybean-generator/pom.xml
This commit is contained in:
Roland Praml committed 2021-12-17 08:27:59 +01:00
commit 6b0d04547e
96 files changed
+3220 -190

No files matched your search

@@ -208,19 +208,33 @@ public class DtoQueryTest extends BaseTestCase {
ResetBasicData.reset();
LoggedSql.start();
List<Integer> ids = Arrays.asList(1, 2);
List<DCust> list = server().findDto(DCust.class, "select id, name from o_customer where id = any(?)")
List<DCust> list = DB.findDto(DCust.class, "select id, name from o_customer where id = any(?)")
.setParameter(ids)
.findList();
assertThat(list).isNotEmpty();
list = server().findDto(DCust.class, "select id, name from o_customer where id in (:idList)")
List<DCust> list1 = DB.findDto(DCust.class, "select id, name from o_customer where id in (:idList)")
.setParameter("idList", ids)
.findList();
assertThat(list).isNotEmpty();
assertThat(list1).isNotEmpty();
List<DCust> list2 = DB.findDto(DCust.class, "select id, name from o_customer where id = any(:idList)")
.setArrayParameter("idList", ids)
.findList();
assertThat(list2).isNotEmpty();
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(3);
assertThat(sql.get(0)).contains(" id = any(?)");
assertThat(sql.get(1)).contains(" id in (?,?)");
assertThat(sql.get(2)).contains(" id = any(?)");
}
@ForPlatform(Platform.POSTGRES)
@@ -34,8 +34,10 @@ public class DtoMetaBuilderTest {
Map<String, Method> methods = getIncludedMethodsFor(D0.class);
assertThat(methods).hasSize(2);
assertThat(DtoMetaBuilder.propertyType(methods.get("setName"))).isEqualTo(String.class);
assertThat(DtoMetaBuilder.propertyType(methods.get("setId"))).isEqualTo(long.class);
assertThat(DtoMetaProperty.propertyClass(methods.get("setName"))).isEqualTo(String.class);
assertThat(DtoMetaProperty.propertyClass(methods.get("setId"))).isEqualTo(long.class);
assertThat(DtoMetaProperty.propertyType(methods.get("setName"))).isEqualTo(String.class);
assertThat(DtoMetaProperty.propertyType(methods.get("setId"))).isEqualTo(long.class);
}
@Test
@@ -5,25 +5,32 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class BasicProfileLocationTest {
class BasicProfileLocationTest {
@Test
public void obtain() {
void obtain() {
DProfileLocation loc = new DTimedProfileLocation(12, "foo", MetricFactory.get().createTimedMetric("junk"));
String javaVersion = System.getProperty("java.version");
assertThat(loc.obtain()).isTrue();
assertThat(loc.fullLocation()).endsWith(":12)");
if (System.getProperty("java.version").startsWith("1.8")) {
if (javaVersion.startsWith("1.8")) {
assertThat(loc.fullLocation()).endsWith("invoke0(Native Method:12)");
assertThat(loc.location()).isEqualTo("sun.reflect.NativeMethodAccessorImpl.invoke0");
assertThat(loc.label()).isEqualTo("NativeMethodAccessorImpl.invoke0");
} else if (javaVersion.startsWith("18")){
assertThat(loc.fullLocation()).endsWith("jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)");
assertThat(loc.location()).isEqualTo("java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke");
assertThat(loc.label()).isEqualTo("DirectMethodHandleAccessor.invoke");
} else {
assertThat(loc.fullLocation()).endsWith("jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method:12)");
assertThat(loc.location()).isEqualTo("java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0");
assertThat(loc.label()).isEqualTo("NativeMethodAccessorImpl.invoke0");
}
assertThat(loc.label()).isEqualTo("NativeMethodAccessorImpl.invoke0");
}
@Test
public void basic_trimPackage() {
void basic_trimPackage() {
BasicProfileLocation loc = new BasicProfileLocation("com.foo.Bar.all");
assertThat(loc.obtain()).isFalse();
@@ -33,7 +40,7 @@ public class BasicProfileLocationTest {
}
@Test
public void basic_trimSinglePackage() {
void basic_trimSinglePackage() {
BasicProfileLocation loc = new BasicProfileLocation("foo.Bar.all");
assertThat(loc.obtain()).isFalse();
@@ -5,17 +5,59 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class JsonTrimTest {
class JsonTrimTest {
@Test
public void trim_array() {
void trim_array() {
final String trimmed = JsonTrim.trim("[{\"name\": \"one\", \"along\": 1, \"timestamp\": 1629609021559}, {\"name\": \"two\", \"along\": 2, \"timestamp\": 1629609021559}]");
assertThat(trimmed).isEqualTo("[{\"name\":\"one\",\"along\":1,\"timestamp\":1629609021559},{\"name\":\"two\",\"along\":2,\"timestamp\":1629609021559}]");
}
@Test
public void trim_object() {
void trim_object() {
final String trimmed = JsonTrim.trim("{\"name\": \"one\",\t \t \"along\": 1, \"timestamp\": 1629609021559}");
assertThat(trimmed).isEqualTo("{\"name\":\"one\",\"along\":1,\"timestamp\":1629609021559}");
}
@Test
void trim_object_embeddedEscapeSlash() {
final String trimmed = JsonTrim.trim("{\"a\": \"o\\nf\",\t \t \n \"b\": 1}");
assertThat(trimmed).isEqualTo("{\"a\":\"o\\nf\",\"b\":1}");
}
@Test
void trim_escapedTabNewLine() {
final String trimmed = JsonTrim.trim("{\"a\": \"o\\t\\nf\",\t \t \n \"b\": 1}");
assertThat(trimmed).isEqualTo("{\"a\":\"o\\t\\nf\",\"b\":1}");
}
@Test
void trim_leadingEscapedNewLine() {
final String trimmed = JsonTrim.trim("{\"a\": \"\\no\\t\\nf\\n\",\t \t \n \"b\": 1}");
assertThat(trimmed).isEqualTo("{\"a\":\"\\no\\t\\nf\\n\",\"b\":1}");
}
@Test
void trim_trailingEscapedNewLine() {
final String trimmed = JsonTrim.trim("{\"a\": \"o\\t\\nf\\n\",\t \t \n \"b\": 1}");
assertThat(trimmed).isEqualTo("{\"a\":\"o\\t\\nf\\n\",\"b\":1}");
}
@Test
void trim_trailingEscapedSlash() {
final String trimmed = JsonTrim.trim("{\"a\": \"o\\t\\nf\\\\\",\t \t \n \"b\": 1}");
assertThat(trimmed).isEqualTo("{\"a\":\"o\\t\\nf\\\\\",\"b\":1}");
}
@Test
void trim_object_embeddedEscaped() {
final String trimmed = JsonTrim.trim("{\"name\": \"one\nfoo\nbar\\bazz\tboo\",\t \t \n \"along\": 1}");
assertThat(trimmed).isEqualTo("{\"name\":\"one\nfoo\nbar\\bazz\tboo\",\"along\":1}");
}
@Test
void trim_escaped() {
final String trimmed = JsonTrim.trim(" \t \n {\"a\": \n \"\\t1\\t2\\n3\\\\\",\t \n \"b\": \"\\t1\\t2\\n3\\\\\" , \t \n \"c\": \"\\t1\\t2\\n3\\\\\" \t \n }");
assertThat(trimmed).isEqualTo("{\"a\":\"\\t1\\t2\\n3\\\\\",\"b\":\"\\t1\\t2\\n3\\\\\",\"c\":\"\\t1\\t2\\n3\\\\\"}");
}
}
@@ -13,13 +13,12 @@ import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;
public class TestLoadBeanCache extends BaseTestCase {
class TestLoadBeanCache extends BaseTestCase {
@Test
public void testLoad() {
void testLoad() {
ResetBasicData.reset();
@@ -35,32 +34,29 @@ public class TestLoadBeanCache extends BaseTestCase {
// this will hit the cache
Country nz = DB.find(Country.class, "NZ");
assertTrue(loadedNz == nz);
assertSame(loadedNz, nz);
}
@Test
public void testLoadWithFindMap() {
void testLoadWithFindMap() {
ResetBasicData.reset();
List<Object> ids = DB.find(Customer.class).findIds();
assertEquals(ids.size(), 4);
assertThat(ids).isNotEmpty();
DB.getDefault().pluginApi().cacheManager().clearAll();
// hit database
LoggedSql.start();
DB.find(Customer.class).where().idIn(ids).findMap();
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
// hit beanCache
LoggedSql.start();
DB.find(Customer.class).where().idIn(ids).findMap();
sql = LoggedSql.stop();
assertThat(sql).hasSize(0);
}
}
@@ -5,13 +5,15 @@ import io.ebean.BaseTestCase;
import io.ebean.DB;
import org.junit.jupiter.api.Test;
import org.tests.model.basic.TWithPreInsert;
import org.tests.model.basic.TWithPreInsertChild;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class TestPreInsertValidation extends BaseTestCase {
class TestPreInsertValidation extends BaseTestCase {
@Test
public void test() {
void test() {
TWithPreInsert e = new TWithPreInsert();
e.setTitle("Mister");
@@ -22,15 +24,45 @@ public class TestPreInsertValidation extends BaseTestCase {
// the save worked and name set in preInsert
assertNotNull(e.getId());
assertNotNull(e.getName());
assertThat(e.requestCascadeState()).isEqualTo(2);
TWithPreInsert e1 = DB.find(TWithPreInsert.class, e.getId());
e1.setTitle("Missus");
DB.save(e1);
assertThat(e1.requestCascadeState()).isEqualTo(12);
}
@Test
public void testStatelessUpdate() {
void test_cascade() {
TWithPreInsert e = new TWithPreInsert();
e.setTitle("ParentCascading");
e.children().add(new TWithPreInsertChild("Child0"));
// the perInsert should populate the
// name with should not be null
DB.save(e);
// the save worked and name set in preInsert
assertNotNull(e.getId());
assertNotNull(e.getName());
assertThat(e.requestCascadeState()).isEqualTo(2);
assertThat(e.children().get(0).requestCascadeState()).isEqualTo(1);
TWithPreInsert e1 = DB.find(TWithPreInsert.class, e.getId());
assert e1 != null;
e1.setTitle("ParentCascading-changed");
e1.children().get(0).setName("Child0-changed");
DB.save(e1);
assertThat(e1.requestCascadeState()).isEqualTo(12);
assertThat(e1.children().get(0).requestCascadeState()).isEqualTo(11);
}
@Test
void testStatelessUpdate() {
TWithPreInsert e = new TWithPreInsert();
e.setName("BeanForUpdateTest");
@@ -0,0 +1,63 @@
package org.tests.json;
import io.ebean.Database;
import io.ebean.DatabaseFactory;
import io.ebean.ValuePair;
import io.ebean.annotation.ForPlatform;
import io.ebean.annotation.MutationDetection;
import io.ebean.annotation.Platform;
import io.ebean.config.DatabaseConfig;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.tests.model.json.EBasicJsonList;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
class TestJsonSourceDefault {
@Test
@ForPlatform(Platform.H2)
@Disabled
void testDirtyValues_diffSource() {
DatabaseConfig config = new DatabaseConfig();
config.getDataSourceConfig()
.setUsername("sa")
.setPassword("")
.setUrl("jdbc:h2:mem:testJsonSourceDirtyValues");
config.setName("jsonSource");
config.setDefaultServer(false);
config.setRegister(false);
config.setDdlGenerate(true);
config.setDdlRun(true);
config.setDdlExtra(false);
config.addClass(EBasicJsonList.class);
config.setJsonMutationDetection(MutationDetection.SOURCE);
Database db = DatabaseFactory.create(config);
try {
assertThat(db).isNotNull();
EBasicJsonList bean = new EBasicJsonList();
bean.getTags().add("aa");
bean.getTags().add("bb");
db.save(bean);
bean = db.find(EBasicJsonList.class, bean.getId());
bean.getTags().add("cc");
final Map<String, ValuePair> dirtyValues = db.beanState(bean).dirtyValues();
assertThat(dirtyValues).containsOnlyKeys("tags");
final ValuePair diff = dirtyValues.get("tags");
assertThat(diff.getOldValue()).isInstanceOf(List.class).asList().containsExactly("aa", "bb");
assertThat(diff.getNewValue()).isInstanceOf(List.class).asList().containsExactly("aa", "bb", "cc");
} finally {
if (db != null) {
db.shutdown();
}
}
}
}
@@ -1,9 +1,6 @@
package org.tests.model.array;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Query;
import io.ebean.SqlRow;
import io.ebean.*;
import io.ebean.annotation.ForPlatform;
import io.ebean.annotation.IgnorePlatform;
import io.ebean.annotation.Platform;
@@ -272,4 +269,123 @@ public class TestDbArray_basic extends BaseTestCase {
assertThat(found.getUids()).hasSameElementsAs(uids);
assertThat(found.getStatuses()).hasSameElementsAs(statuses);
}
@Test
@ForPlatform(Platform.POSTGRES)
public void asDto_withArray() {
DB.find(EArrayBean.class).delete();
bean.setName("array in dto test");
List<String> phNumbers = bean.getPhoneNumbers();
phNumbers.add("4321");
phNumbers.add("9823");
List<Double> doubs = bean.getDoubs();
doubs.add(1.23);
doubs.add(4.56);
DB.save(bean);
// Data is saved correctly
LoggedSql.start();
DtoQuery<EArrayBeanDto> query = DB.find(EArrayBean.class)
// Interestingly writing `select("id,name,phone_numbers,doubs")`
// generates `select t0.id, t0.name, t0.id, t0.doubs`
// surprisingly changing unknown property to id
.select("id,name,phoneNumbers,doubs")
.asDto(EArrayBeanDto.class)
// Shouldn't be necessary
// But without it I see error
// Unable to map DB column phone_numbers to a property with a setter method on class org.tests.model.array.TestDbArray_basic$EArrayBeanDto
.setRelaxedMode();
List<EArrayBeanDto> dtos = query.findList();
List<String> sql = LoggedSql.stop();
assertSql(sql.get(0)).contains("select t0.id, t0.name, t0.phone_numbers, t0.doubs");
for (EArrayBeanDto dto : dtos) {
assertThat(dto.id).isNotNull();
assertThat(dto.name).isNotNull();
// Failure: null
assertThat(dto.phoneNumbers).isNotNull();
// Failure: null
assertThat(dto.doubs).isNotNull();
}
}
@Test
@ForPlatform(Platform.POSTGRES)
public void sqlUpdate_withArray() {
DB.find(EArrayBean.class).delete();
bean.setName("array in sql update test");
DB.save(bean);
// Data is saved correctly
List<String> phNumbers = new ArrayList<>();
phNumbers.add("4321");
phNumbers.add("9823");
LoggedSql.start();
// Positional param works
SqlUpdate update1 = DB.sqlUpdate("UPDATE earray_bean SET phone_numbers = ?")
.setParameter(1, phNumbers);
update1.execute();
System.out.println("done");
// Named param fails with
// javax.persistence.PersistenceException:
// ERROR: syntax error at or near "$2"
SqlUpdate update2 = DB.sqlUpdate("UPDATE earray_bean SET phone_numbers = :pns")
.setArrayParameter("pns", phNumbers);
update2.execute();
found = DB.find(EArrayBean.class, bean.getId());
System.out.println(found);
assertEquals("array in sql update test", found.getName());
assertThat(found.getPhoneNumbers()).containsExactly("4321", "9823");
}
public static class EArrayBeanDto {
Integer id;
List<String> phoneNumbers;
List<Double> doubs;
String name;
@Override
public String toString() {
return "id:" + id + " name:" + name + " phoneNumbers:" + phoneNumbers + " doubs:" + doubs;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getPhoneNumbers() {
return phoneNumbers;
}
public void setPhoneNumbers(List<String> phoneNumbers) {
this.phoneNumbers = phoneNumbers;
}
public List<Double> getDoubs() {
return doubs;
}
public void setDoubs(List<Double> doubs) {
this.doubs = doubs;
}
}
}
@@ -2,10 +2,15 @@ package org.tests.model.basic;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import static javax.persistence.CascadeType.PERSIST;
@Entity
public class TWithPreInsert {
public class TWithPreInsert implements TWithPreInsertCommon {
@Id
private Integer id;
@@ -15,6 +20,14 @@ public class TWithPreInsert {
private String title;
@OneToMany(cascade = PERSIST)
private List<TWithPreInsertChild> children = new ArrayList<>();
/**
* For testing what happened in persist controller.
*/
transient int requestCascadeState;
public Integer getId() {
return id;
}
@@ -39,4 +52,15 @@ public class TWithPreInsert {
this.title = title;
}
public List<TWithPreInsertChild> children() {
return children;
}
public int requestCascadeState() {
return requestCascadeState;
}
public void requestCascadeState(int requestCascadeState) {
this.requestCascadeState = requestCascadeState;
}
}
@@ -0,0 +1,58 @@
package org.tests.model.basic;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
@Entity
public class TWithPreInsertChild implements TWithPreInsertCommon {
@Id
private Integer id;
@NotNull
private String name;
private String title;
/**
* For testing what happened in persist controller.
*/
transient int requestCascadeState;
public TWithPreInsertChild(String name) {
this.name = name;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int requestCascadeState() {
return requestCascadeState;
}
public void requestCascadeState(int requestCascadeState) {
this.requestCascadeState = requestCascadeState;
}
}
@@ -0,0 +1,14 @@
package org.tests.model.basic;
public interface TWithPreInsertCommon {
String getName();
void setName(String name);
String getTitle();
void setTitle(String title);
void requestCascadeState(int requestCascadeState);
}
@@ -2,36 +2,33 @@ package org.tests.model.basic.event;
import io.ebean.event.BeanPersistAdapter;
import io.ebean.event.BeanPersistRequest;
import org.tests.model.basic.TWithPreInsert;
import org.tests.model.basic.TWithPreInsertCommon;
public class TWithPreInsertPersistAdapter extends BeanPersistAdapter {
@Override
public boolean isRegisterFor(Class<?> cls) {
return TWithPreInsert.class.equals(cls);
return TWithPreInsertCommon.class.isAssignableFrom(cls);
}
@Override
public boolean preInsert(BeanPersistRequest<?> request) {
TWithPreInsert e = (TWithPreInsert) request.bean();
if (e.getName() == null) {
e.setName("set on preInsert");
TWithPreInsertCommon bean = (TWithPreInsertCommon) request.bean();
if (bean.getName() == null) {
bean.setName("set on preInsert");
}
bean.requestCascadeState(request.isCascade() ? 1 : 2);
return true;
}
@Override
public boolean preUpdate(BeanPersistRequest<?> request) {
TWithPreInsert b = (TWithPreInsert) request.bean();
System.out.println("preUpdate - title is: " + b.getTitle());
if (b.getTitle() == null) {
b.setTitle("set on preUpdate");
TWithPreInsertCommon bean = (TWithPreInsertCommon) request.bean();
System.out.println("preUpdate - title is: " + bean.getTitle());
if (bean.getTitle() == null) {
bean.setTitle("set on preUpdate");
}
// request.getEbeanServer().refresh(b);
// System.out.println("title is Mister:"+b.getTitle());
bean.requestCascadeState(request.isCascade() ? 11 : 12);
return super.preUpdate(request);
}
@@ -6,18 +6,19 @@ import io.ebean.Transaction;
import io.ebean.test.LoggedSql;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat;
public class TestIdClassScalar extends BaseTestCase {
class TestIdClassScalar extends BaseTestCase {
private BUser user = new BUser("Fiona");
private BSite site = new BSite("avaje.io");
private final BUser user = new BUser("Fiona");
private final BSite site = new BSite("avaje.io");
@Test
public void testBEmbId_equalsHashcode() {
void testBEmbId_equalsHashcode() {
BEmbId a = new BEmbId(UUID.randomUUID(), UUID.randomUUID());
BEmbId b = new BEmbId(a.getSiteId(), a.getUserId());
@@ -35,13 +36,11 @@ public class TestIdClassScalar extends BaseTestCase {
assertThat(a).isNotEqualTo(d);
assertThat(a.hashCode()).isNotEqualTo(d.hashCode());
assertThat(a.hashCode()).isEqualTo(a.otherHash());
}
@Test
public void fetchMany() {
void fetchMany() {
UUID siteId = UUID.randomUUID();
UUID userId = UUID.randomUUID();
@@ -59,7 +58,7 @@ public class TestIdClassScalar extends BaseTestCase {
}
@Test
public void insertBatch() {
void insertBatch() {
UUID siteId = UUID.randomUUID();
UUID userId = UUID.randomUUID();
@@ -81,11 +80,9 @@ public class TestIdClassScalar extends BaseTestCase {
}
@Test
public void test() {
void test() {
DB.save(user);
DB.save(site);
insertUpdateBridgeD(user, site);
insertUpdateBridgeE(user, site);
}
@@ -94,7 +91,6 @@ public class TestIdClassScalar extends BaseTestCase {
* Test where matching by db column naming convention.
*/
private void insertUpdateBridgeD(BUser user, BSite site) {
LoggedSql.start();
BSiteUserD access = new BSiteUserD(BAccessLevel.ONE, site.id, user.id);
@@ -139,7 +135,6 @@ public class TestIdClassScalar extends BaseTestCase {
* Test where matching by db column naming convention.
*/
private void insertUpdateBridgeE(BUser user, BSite site) {
LoggedSql.start();
BSiteUserE access = new BSiteUserE(BAccessLevel.ONE, site, user);
@@ -181,4 +176,47 @@ public class TestIdClassScalar extends BaseTestCase {
assertSql(sql.get(1)).contains("update bsite_user_e set access_level=? where site_id=? and user_id=?");
}
@Test
void idClass_existsQuery() {
BUser user = new BUser("JunkUser2");
BSite site = new BSite("JunkSite2");
BSiteUserE access = new BSiteUserE(BAccessLevel.ONE, site, user);
DB.save(user);
DB.save(site);
DB.save(access);
boolean exists = DB.find(BSiteUserE.class)
.where().eq("user.id", user.id)
.exists();
assertThat(exists).isTrue();
assertThat(DB.find(BSiteUserE.class).where().eq("user.id", user.id).findCount()).isEqualTo(1);
DB.delete(access);
DB.deleteAll(Arrays.asList(user, site));
}
@Test
void idClass_existsQuery_scalarImportedProperties() {
BUser user = new BUser("JunkUser3");
BSite site = new BSite("JunkSite3");
DB.save(user);
DB.save(site);
BSiteUserD access = new BSiteUserD(BAccessLevel.ONE, site.id, user.id);
DB.save(access);
boolean exists = DB.find(BSiteUserD.class)
.where().eq("userId", user.id)
.exists();
assertThat(exists).isTrue();
assertThat(DB.find(BSiteUserD.class).where().eq("userId", user.id).findCount()).isEqualTo(1);
DB.delete(access);
DB.deleteAll(Arrays.asList(user, site));
}
}
@@ -10,11 +10,10 @@ import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
public class TestElementCollectionBasicSet extends BaseTestCase {
class TestElementCollectionBasicSet extends BaseTestCase {
@Test
public void test() {
void test() {
LoggedSql.start();
EcsPerson person = new EcsPerson("Fiona021");
@@ -172,8 +171,7 @@ public class TestElementCollectionBasicSet extends BaseTestCase {
}
@Test
public void json() {
void json() {
EcsPerson person = new EcsPerson("Fiona021");
person.getPhoneNumbers().add("021 1234");
person.getPhoneNumbers().add("021 4321");
@@ -25,7 +25,7 @@ ebean.packages=org.tests,org.etest
datasource.default=h2
#datasource.h2.capturestacktrace=true
ebean.dumpMetricsOnShutdown=true
#ebean.dumpMetricsOnShutdown=true
ebean.dumpMetricsOptions=sql,hash,loc
#ebean.queryPlan.thresholdMicros=1000
ebean.queryPlan.enable=true
@@ -182,7 +182,7 @@ datasource.nuodb.url=jdbc:com.nuodb://localhost/testdb
#datasource.nuodb.driver=com.nuodb.jdbc.Driver
datasource.db2.username=unit
datasource.db2.password=unit
datasource.db2.password=test
datasource.db2.url=jdbc:db2://127.0.0.1:50000/unit
#datasource.db2.driver=com.ibm.db2.jcc.DB2Driver