Skip to content

Commit

Permalink
fix for #494
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszwalacik committed Jan 24, 2017
1 parent a313b0b commit 45c0559
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class JaversRepositoryE2ETest extends Specification {

def "should persist various primitive types"(){
given:
def javers = javers().build()
def s = new PrimitiveEntity(id:1)

when:
Expand All @@ -60,23 +59,14 @@ class JaversRepositoryE2ETest extends Specification {
s.ByteField = 10
s.ShortField = 10
s.BooleanField = true
s.IntegerList = [10,11]
s.LongList = [10,11]
s.DoubleList = [1.1, 1.2]
s.FloatList = [1.1,1.2]
s.ByteList = [10,11]
s.ShortList = [10,11]
s.BooleanList = [true,false]

javers.commit("author",s)

then:
javers.findChanges(QueryBuilder.anyDomainObject().build()).size() == 22
javers.findChanges(QueryBuilder.anyDomainObject().build()).size() == 15
}

def "should support EmbeddedId as Entity Id"(){
given:
def javers = javers().build()
def cdo = new DummyEntityWithEmbeddedId(point: new DummyPoint(1,2), someVal: 5)

when:
Expand All @@ -89,7 +79,6 @@ class JaversRepositoryE2ETest extends Specification {

def "should support long numbers as Entity Id "(){
given:
def javers = javers().build()
def longId = 1000000000L*1000
def category = new Category(longId)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.javers.core.model;

import javax.persistence.Id;
import java.util.List;

/**
* @author bartosz walacik
Expand All @@ -25,12 +24,4 @@ public class PrimitiveEntity {
private Byte ByteField;
private Short ShortField;
private Boolean BooleanField;

private List<Integer> IntegerList;
private List<Long> LongList;
private List<Double> DoubleList;
private List<Float> FloatList;
private List<Byte> ByteList;
private List<Short> ShortList;
private List<Boolean> BooleanList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ private static Object fromJsonElement(JsonElement jsonElement) {
if (jsonPrimitive.isNumber()) {
return jsonElement.getAsNumber();
}

if (jsonPrimitive.isBoolean()) {
return jsonElement.getAsBoolean();
}
}

if (jsonElement instanceof JsonArray) {
Expand Down Expand Up @@ -88,6 +92,10 @@ private static JsonElement createJsonElement(Object dbObject) {
return new JsonPrimitive((Number)dbObject);
}

if (dbObject instanceof Boolean) {
return new JsonPrimitive((Boolean) dbObject);
}

if (dbObject instanceof List) {
JsonArray array = new JsonArray();
for (Object e : (List) dbObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class JaversMongoRepositoryE2ETest extends JaversRepositoryE2ETest {
protected JaversRepository prepareJaversRepository() {
MongoRepository mongoRepository = new MongoRepository(getMongoDb())
mongoRepository.clean()
return mongoRepository;
mongoRepository
}

def "should commit and read snapshot of Entity containing map field with dot keys"() {
Expand Down

0 comments on commit 45c0559

Please sign in to comment.