mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
No effective change - tidy tests
This commit is contained in:
@@ -8,14 +8,13 @@ import io.ebean.annotation.TxType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class DummyDao {
|
||||
|
||||
Logger logger = LoggerFactory.getLogger(DummyDao.class);
|
||||
private final Logger logger = LoggerFactory.getLogger(DummyDao.class);
|
||||
|
||||
@Transactional(type = TxType.REQUIRES_NEW)
|
||||
public void doSomething() {
|
||||
@@ -30,18 +29,12 @@ public class DummyDao {
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void addToObject(Long id, Double anotherNumber, List<Long> ids) throws EntityNotFoundException {
|
||||
// and more code
|
||||
}
|
||||
|
||||
|
||||
@Transactional(batch = PersistBatch.ALL, batchOnCascade = PersistBatch.ALL, batchSize = 99)
|
||||
public void doWithBatchOptionsSet() {
|
||||
private void doWithBatchOptionsSet() {
|
||||
|
||||
Transaction txn = Ebean.currentTransaction();
|
||||
assertEquals(PersistBatch.ALL, txn.getBatch());
|
||||
assertEquals(PersistBatch.ALL, txn.getBatchOnCascade());
|
||||
assertTrue(txn.isBatchMode());
|
||||
assertTrue(txn.isBatchOnCascade());
|
||||
assertEquals(99, txn.getBatchSize());
|
||||
}
|
||||
|
||||
@@ -51,15 +44,15 @@ public class DummyDao {
|
||||
|
||||
Transaction txn = Ebean.currentTransaction();
|
||||
|
||||
assertEquals(PersistBatch.ALL, txn.getBatch());
|
||||
assertEquals(PersistBatch.NONE, txn.getBatchOnCascade());
|
||||
assertTrue(txn.isBatchMode());
|
||||
assertFalse(txn.isBatchOnCascade());
|
||||
assertEquals(77, txn.getBatchSize());
|
||||
|
||||
doWithBatchOptionsSet();
|
||||
|
||||
// batch options set back
|
||||
assertEquals(PersistBatch.ALL, txn.getBatch());
|
||||
assertEquals(PersistBatch.NONE, txn.getBatchOnCascade());
|
||||
assertTrue(txn.isBatchMode());
|
||||
assertFalse(txn.isBatchOnCascade());
|
||||
assertEquals(77, txn.getBatchSize());
|
||||
|
||||
}
|
||||
|
||||
@@ -3,20 +3,20 @@ package org.tests.text.json;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.text.json.JsonContext;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.Animal;
|
||||
import org.tests.model.basic.Cat;
|
||||
import org.tests.model.basic.Dog;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TestJsonInheritanceDiscriminator extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void testNoDiscriminator() throws IOException {
|
||||
public void testNoDiscriminator() {
|
||||
|
||||
Cat cat = new Cat();
|
||||
cat.setName("Gemma");
|
||||
@@ -28,17 +28,17 @@ public class TestJsonInheritanceDiscriminator extends BaseTestCase {
|
||||
|
||||
Cat cat2 = json.toBean(Cat.class, jsonContent);
|
||||
|
||||
Assert.assertEquals(cat.getId(), cat2.getId());
|
||||
Assert.assertEquals(cat.getName(), cat2.getName());
|
||||
Assert.assertEquals(cat.getVersion(), cat2.getVersion());
|
||||
assertEquals(cat.getId(), cat2.getId());
|
||||
assertEquals(cat.getName(), cat2.getName());
|
||||
assertEquals(cat.getVersion(), cat2.getVersion());
|
||||
|
||||
String noDiscriminator = "{\"id\":1,\"name\":\"Gemma\",\"version\":1}";
|
||||
|
||||
Cat cat3 = json.toBean(Cat.class, noDiscriminator);
|
||||
|
||||
Assert.assertEquals(1L, cat3.getId().longValue());
|
||||
Assert.assertEquals("Gemma", cat3.getName());
|
||||
Assert.assertEquals(1L, cat3.getVersion().longValue());
|
||||
assertEquals(1L, cat3.getId().longValue());
|
||||
assertEquals("Gemma", cat3.getName());
|
||||
assertEquals(1L, cat3.getVersion().longValue());
|
||||
|
||||
Dog dog = new Dog();
|
||||
dog.setRegistrationNumber("ABC123");
|
||||
@@ -51,11 +51,11 @@ public class TestJsonInheritanceDiscriminator extends BaseTestCase {
|
||||
String listJson = json.toJson(animals);
|
||||
|
||||
List<Animal> animals2 = json.toList(Animal.class, listJson);
|
||||
Assert.assertEquals(animals.size(), animals2.size());
|
||||
assertEquals(animals.size(), animals2.size());
|
||||
|
||||
String noDiscList = "[{\"id\":1,\"name\":\"Gemma\",\"version\":1},{\"name\":\"PussCat\",\"version\":1},{\"species\":\"CAT\",\"name\":\"PussCat\",\"version\":1}]";
|
||||
List<Cat> cats = json.toList(Cat.class, noDiscList);
|
||||
Assert.assertEquals(cats.size(), 3);
|
||||
assertEquals(cats.size(), 3);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user