mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +00:00
Refactor move tests from ebean-core to ebean-test
This commit is contained in:
1 parent
0b00a14fd3
commit
eab56d323b
1650 files changed
+185
-147
No files matched your search
@@ -0,0 +1,20 @@
|
||||
package org.tests.enhancement;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import org.tests.model.basic.MRole;
|
||||
import org.tests.model.basic.MUser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestConstructorManyAddAll extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
List<MRole> startRoles = new ArrayList<>();
|
||||
MUser mUser = new MUser(startRoles);
|
||||
mUser.getRoles();
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package org.tests.enhancement;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.bean.EntityBeanIntercept;
|
||||
import org.tests.model.basic.PFile;
|
||||
import org.tests.model.basic.PFileContent;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class TestConstructorPutfieldReplacement extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes()));
|
||||
|
||||
EntityBean eb = (EntityBean) persistentFile;
|
||||
EntityBeanIntercept ebi = eb._ebean_getIntercept();
|
||||
|
||||
int namePos = ebi.findProperty("name");
|
||||
int fileContentPos = ebi.findProperty("fileContent");
|
||||
|
||||
assertTrue(ebi.isLoadedProperty(namePos));
|
||||
assertTrue(ebi.isLoadedProperty(fileContentPos));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.tests.enhancement;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.Product;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* Note take care if you run this test in an IDE with a debugger as that can trigger the equals and
|
||||
* hashCode (and the identity value can get populated un-normally).
|
||||
*/
|
||||
public class TestEnhancementEquals extends BaseTestCase {
|
||||
|
||||
|
||||
@Test
|
||||
public void testEqualsBasedOnIdValue() {
|
||||
|
||||
Product product1 = new Product();
|
||||
product1.setId(345);
|
||||
product1.setName("blah");
|
||||
|
||||
Product product2 = new Product();
|
||||
product2.setId(345);
|
||||
|
||||
assertEquals(product1, product2);
|
||||
assertEquals(product1.hashCode(), product2.hashCode());
|
||||
|
||||
product2.setName("kumera");
|
||||
assertEquals(product1, product2);
|
||||
assertEquals(product1.hashCode(), product2.hashCode());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWhenEqualsTouchedFirst() {
|
||||
|
||||
Product product1 = new Product();
|
||||
product1.setName("blah");
|
||||
int hashcode1 = product1.hashCode();
|
||||
|
||||
// equals has been called so the hashCode and 'identity' has been baked in
|
||||
product1.setId(345);
|
||||
int hashcode2 = product1.hashCode();
|
||||
|
||||
assertEquals(hashcode1, hashcode2);
|
||||
|
||||
Product product2 = new Product();
|
||||
product2.setId(345);
|
||||
|
||||
assertNotEquals(product1, product2);
|
||||
assertTrue(product1.hashCode() != product2.hashCode());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user