Skip to content

Commit

Permalink
https://github.com/javers/javers/issues/76
Browse files Browse the repository at this point in the history
fixing tests
  • Loading branch information
bartoszwalacik committed Jan 28, 2015
1 parent 37d5e59 commit fd699fe
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
@@ -1,6 +1,5 @@
package org.javers.core

import org.fest.assertions.error.ShouldBe
import org.javers.common.exception.JaversException
import org.javers.common.exception.JaversExceptionCode
import org.javers.core.commit.CommitAssert
Expand All @@ -10,6 +9,7 @@ import org.javers.core.model.DummyUserDetails
import org.javers.core.model.SnapshotEntity
import spock.lang.Specification

import static org.javers.common.exception.JaversExceptionCode.VALUE_OBJECT_IS_NOT_SUPPORTED_AS_MAP_KEY
import static org.javers.core.JaversBuilder.javers
import static org.javers.core.metamodel.object.InstanceIdDTO.instanceId
import static org.javers.core.metamodel.object.ValueObjectIdDTO.valueObjectId
Expand Down Expand Up @@ -213,4 +213,19 @@ class JaversCommitE2ETest extends Specification {
!secondCommit.snapshots
!secondCommit.diff.changes
}

def "should not support Map of <ValueObject,?>, no good idea how to handle this"() {
given:
def javers = javers().build()
def cdo = new SnapshotEntity(mapVoToPrimitive: [(new DummyAddress("London")):"this"])

when:
javers.commit("author", cdo)
javers.commit("author", cdo)

then:
def e = thrown(JaversException)
e.code == VALUE_OBJECT_IS_NOT_SUPPORTED_AS_MAP_KEY
}

}
Expand Up @@ -34,14 +34,14 @@ class MapTypeTest extends Specification{
mType.fullyParametrized == false

when:
mType.getKeyClass()
mType.getKeyType()

then:
def e = thrown(JaversException)
e.code == GENERIC_TYPE_NOT_PARAMETRIZED;

when:
mType.getValueClass()
mType.getValueType()

then:
e = thrown(JaversException)
Expand All @@ -60,7 +60,7 @@ class MapTypeTest extends Specification{

then:
mType.baseJavaType == new TypeToken<Map<String,Integer>>(){}.type
mType.keyClass == String
mType.valueClass == Integer
mType.keyType == String
mType.valueType == Integer
}
}
Expand Up @@ -125,8 +125,8 @@ class TypeMapperTest extends Specification {

then:
jType.baseJavaType == givenJavaType
jType.keyClass == String
jType.valueClass == Integer
jType.keyType == String
jType.valueType == Integer

where:
givenJavaType << [new TypeToken<Map<String, Integer>>(){}.type,new TypeToken<HashMap<String, Integer>>(){}.type]
Expand Down
Expand Up @@ -172,19 +172,6 @@ class SnapshotFactoryTest extends Specification{
]
}

def "should not support Map of <ValueObject,?>, no good idea how to handle this"() {
given:
def snapshotFactory = javers.snapshotFactory

when:
def cdo = new SnapshotEntity(mapVoToPrimitive: [(new DummyAddress("London")):"this"])
snapshotFactory.create(cdo, javers.instanceId(cdo), new CommitMetadata("kazik", LocalDateTime.now(), new CommitId(1, 0)))

then:
def e = thrown(JaversException)
e.code == VALUE_OBJECT_IS_NOT_SUPPORTED_AS_MAP_KEY
}

def "should throw exception when property Type is not fully parametrized"() {
given:
def snapshotFactory = javers.snapshotFactory
Expand Down

0 comments on commit fd699fe

Please sign in to comment.