Skip to content

Commit

Permalink
Merge pull request #14 from darkredz/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
darkredz committed Apr 28, 2020
2 parents f128db4 + 57ed173 commit d85772d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ps: Zeko turns out to be rabbit in Croatian, thus the logo :D
<dependency>
<groupId>io.zeko</groupId>
<artifactId>zeko-data-mapper</artifactId>
<version>1.6.0</version>
<version>1.6.1</version>
</dependency>


Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.zeko</groupId>
<artifactId>zeko-data-mapper</artifactId>
<version>1.6.1-SNAPSHOT</version>
<version>1.6.2-SNAPSHOT</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down Expand Up @@ -81,8 +81,8 @@
</pluginRepositories>

<properties>
<kotlin.version>1.3.60</kotlin.version>
<vertx.version>3.8.5</vertx.version>
<kotlin.version>1.3.61</kotlin.version>
<vertx.version>3.9.0</vertx.version>
<spek.version>2.0.9</spek.version>
<jupiter.version>5.2.0</jupiter.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -121,7 +121,7 @@
<dependency>
<groupId>io.zeko</groupId>
<artifactId>zeko-sql-builder</artifactId>
<version>1.0.7</version>
<version>1.1.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -138,7 +138,7 @@
<dependency>
<groupId>com.github.jasync-sql</groupId>
<artifactId>jasync-common</artifactId>
<version>0.8.54</version>
<version>1.0.17</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
Expand Down
23 changes: 13 additions & 10 deletions src/test/kotlin/io/zeko/model/DataMapperPOJOSpec.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.zeko.model

import io.vertx.core.json.Json
import java.util.LinkedHashMap
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
Expand All @@ -12,7 +13,7 @@ class User : Entity {
constructor(vararg props: Pair<String, Any?>) : super(*props)
var id: Int? by map
var name: String? by map
var role_id: Int? by map
var roleId: Int? by map
var role: List<Role>? by map
var address: List<Address>? by map
}
Expand All @@ -21,15 +22,15 @@ class Role : Entity {
constructor(map: Map<String, Any?>) : super(map)
constructor(vararg props: Pair<String, Any?>) : super(*props)
val id: Int? by map
val role_name: String? by map
val user_id: Int? by map
val roleName: String? by map
val userId: Int? by map
}

class Address : Entity {
constructor(map: Map<String, Any?>) : super(map)
constructor(vararg props: Pair<String, Any?>) : super(*props)
var id: Int? by map
var user_id: Int? by map
var userId: Int? by map
var street1: String? by map
var street2: String? by map
}
Expand Down Expand Up @@ -87,6 +88,8 @@ class DataMapperPOJOSpec : Spek({
val mapper = DataMapper()
val result = mapper.mapStruct(table, all) as List<User>

println(Json.encodePrettily(result))

context("mapping of result") {
it("should not be null") {
assertEquals(false, result == null)
Expand All @@ -108,7 +111,7 @@ class DataMapperPOJOSpec : Spek({
it("the first object in the array mapped should have all the user fields selected") {
assertEquals(1, result[0].id)
assertEquals("Leng", result[0].name)
assertEquals(2, result[0].role_id)
assertEquals(2, result[0].roleId)
}

val roles = result[0].role
Expand All @@ -130,8 +133,8 @@ class DataMapperPOJOSpec : Spek({

it("should have role name, role id, user id matched") {
assertEquals(2, role.id)
assertEquals("Super Admin", role.role_name)
assertEquals(1, role.user_id)
assertEquals("Super Admin", role.roleName)
assertEquals(1, role.userId)
}
}

Expand Down Expand Up @@ -169,7 +172,7 @@ class DataMapperPOJOSpec : Spek({
it("the 2nd object in the array mapped should have all the user fields selected") {
assertEquals(2, result[1].id)
assertEquals("Superman", result[1].name)
assertEquals(2, result[1].role_id)
assertEquals(2, result[1].roleId)
}

val roles2 = result[1].role
Expand All @@ -191,8 +194,8 @@ class DataMapperPOJOSpec : Spek({

it("should have role name, role id, user id matched") {
assertEquals(2, role2.id)
assertEquals("Super Admin", role2.role_name)
assertEquals(2, role2.user_id)
assertEquals("Super Admin", role2.roleName)
assertEquals(2, role2.userId)
}
}

Expand Down

0 comments on commit d85772d

Please sign in to comment.