Skip to content

Commit

Permalink
more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsamson7 committed Mar 21, 2024
1 parent 3dad1d7 commit cbb35d7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ class ConversionTest {
fun testVersion() {
val mapper = Mapper(
Mapping.build(Foo::class, Foo::class) {

map { "short" to "short" }
map { "short" to "short" }
map { "short" to "float" }
map { "int" to "double" }
map { "long" to "long" }
map { "long" to "long" convert {obj: Long-> obj}}
map { "double" to "int" }
map { "float" to "short" }
})
})

val foo = Foo()
val result = mapper.map<Foo>(foo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,42 @@ import kotlin.test.assertEquals


class InheritanceTest {
// local classes

open class Base {
var id = "id"
}

open class Derived : Base() {
var name = "name"
}

// test

@Test
fun testVersion() {
// eq
val baseMapping = Mapping.build(Base::class,Base::class) {
map { properties() }
}

val mapper = Mapper(
baseMapping,

Mapping.build(Derived::class, Derived::class) {
derives(baseMapping)

map { properties("name") }
}
)

val source = Derived()

source.id = "base"
source.name = "source"

val result = mapper.map<Derived>(source)

//assertEquals(true, Version("1.0").eq(Version("1.0")), "expected eq")
//assertEquals(false, Version("1.0").eq(Version("1.1.1.1")), "expected !eq")
assertEquals(result?.id, "base")
assertEquals(result?.name, "source")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ class MapperTest {

@Test
fun test() {

val mapper = Mapper(
Mapping.build(Money::class, Money::class) {
map { properties() }
},
Mapping.build(Product::class, Product::class) {
map { "id" to "id"}
map { properties("id") }
map { Product::isNull to Product::isNull}

map { path("innerComposite", "price", "value") to path("innerComposite", "price", "value")}
Expand Down

0 comments on commit cbb35d7

Please sign in to comment.