mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
The existence of a BeanFindController should not break the use of single attribute queries + still allow auto-tuning.
59 lines
1.8 KiB
Java
59 lines
1.8 KiB
Java
package io.ebean.xtest.plugin;
|
|
|
|
import io.ebean.xtest.BaseTestCase;
|
|
import io.ebean.DB;
|
|
import io.ebean.Database;
|
|
import io.ebean.plugin.BeanType;
|
|
import io.ebean.plugin.SpiServer;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.tests.model.basic.Customer;
|
|
import org.tests.model.basic.VwCustomer;
|
|
|
|
import java.util.List;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
|
|
public class SpiServerTest extends BaseTestCase {
|
|
|
|
@Test
|
|
public void test() {
|
|
|
|
Database defaultServer = DB.getDefault();
|
|
SpiServer pluginApi = defaultServer.pluginApi();
|
|
|
|
BeanType<Customer> beanType = pluginApi.beanType(Customer.class);
|
|
assertEquals("o_customer", beanType.baseTable());
|
|
assertNotNull(pluginApi.databasePlatform());
|
|
assertNotNull(beanType.findController());
|
|
assertNotNull(beanType.persistController());
|
|
assertNull(beanType.persistListener());
|
|
assertNull(beanType.queryAdapter());
|
|
|
|
assertTrue(beanType.isValidExpression("name"));
|
|
assertTrue(beanType.isValidExpression("contacts.firstName"));
|
|
assertTrue(beanType.isValidExpression("contacts.group.name"));
|
|
assertFalse(beanType.isValidExpression("junk"));
|
|
assertFalse(beanType.isValidExpression("Name"));
|
|
assertFalse(beanType.isValidExpression("contacts.name"));
|
|
|
|
Customer customer = new Customer();
|
|
customer.setId(42);
|
|
|
|
assertEquals(42, beanType.id(customer));
|
|
|
|
List<? extends BeanType<?>> beanTypes = pluginApi.beanTypes("o_customer");
|
|
assertEquals(2, beanTypes.size());
|
|
|
|
BeanType<VwCustomer> vwBeanType = pluginApi.beanType(VwCustomer.class);
|
|
|
|
assertThat(beanTypes.contains(beanType)).isTrue();
|
|
assertThat(beanTypes.contains(vwBeanType)).isTrue();
|
|
|
|
List<? extends BeanType<?>> allTypes = pluginApi.beanTypes();
|
|
assertFalse(allTypes.isEmpty());
|
|
}
|
|
|
|
}
|