Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsamson7 committed Mar 22, 2024
1 parent c197f3b commit 8c39836
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions portal/core/src/test/java/com/serious/portal/mapper/MapperTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,60 @@ class MapperTest {

// test

class From (var name: String = "")

data class To(var name: String)

class ReadOnly(val name: String)

@Test()
fun testReadOnlyException() {
try {
Mapper(
Mapping.build(From::class, ReadOnly::class) {
map { "name" to "name"}
})

throw Exception("ouch")
}
catch(exception: MapperDefinitionException) {
println()
}
}

@Test()
fun testExceptionMissingSpec() {
try {
Mapper(
Mapping.build(From::class, To::class) {
map { }
})

throw Exception("ouch")
}
catch(exception: MapperDefinitionException) {

}
}

@Test
fun test1() {
val from = From()
from.name = "from"

val mapper = Mapper(
Mapping.build(From::class, To::class) {
map { properties() }
})

println(mapper.describe())

val result = mapper.map<To>(from)

assertEquals("from", result?.name)
}


@Test
fun test() {
val mapper = Mapper(
Expand Down

0 comments on commit 8c39836

Please sign in to comment.