-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for moving items between lists.
- Loading branch information
Showing
3 changed files
with
88 additions
and
41 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
subprojects/integrationTest/src/test/kotlin/cloud/cosmin/checklister/it/ItemMoveSpec.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cloud.cosmin.checklister.it | ||
|
||
import cloud.cosmin.checklister.it.TestHelper.post | ||
import cloud.cosmin.checklister.it.TestHelper.put | ||
import cloud.cosmin.checklister.lib.dto.ItemPostDto | ||
import cloud.cosmin.checklister.lib.dto.ListPostDto | ||
import io.kotlintest.shouldBe | ||
import io.kotlintest.specs.WordSpec | ||
|
||
class ItemMoveSpec: WordSpec({ | ||
"Checklister" should { | ||
"move an item between lists" { | ||
val list1 = ListPostDto("list1").post() | ||
val list2 = ListPostDto("list2").post() | ||
|
||
val item = ItemPostDto(list1.id, "content", "type").post() | ||
item.list!!.shouldBe(list1.id) | ||
|
||
val movedItem = ItemPostDto(list2.id, "content", "type").put(item.id!!) | ||
movedItem.list!!.shouldBe(list2.id) | ||
} | ||
} | ||
}) |
55 changes: 55 additions & 0 deletions
55
subprojects/integrationTest/src/test/kotlin/cloud/cosmin/checklister/it/TestHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package cloud.cosmin.checklister.it | ||
|
||
import cloud.cosmin.checklister.lib.dto.ItemGetDto | ||
import cloud.cosmin.checklister.lib.dto.ItemPostDto | ||
import cloud.cosmin.checklister.lib.dto.ListGetDto | ||
import cloud.cosmin.checklister.lib.dto.ListPostDto | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule | ||
import com.fasterxml.jackson.module.kotlin.registerKotlinModule | ||
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule | ||
import com.github.kittinunf.fuel.Fuel | ||
import com.github.kittinunf.fuel.core.extensions.jsonBody | ||
import com.github.kittinunf.fuel.jackson.responseObject | ||
import io.kotlintest.shouldBe | ||
import java.util.UUID | ||
|
||
object TestHelper { | ||
val baseUrl = "http://localhost:8180/api/v1" | ||
|
||
val mapper = ObjectMapper() | ||
.registerKotlinModule() | ||
.registerModule(ParameterNamesModule()) | ||
.registerModule(Jdk8Module()) | ||
.registerModule(JavaTimeModule()) | ||
|
||
fun ListPostDto.toJson(): String { | ||
return mapper.writeValueAsString(this) | ||
} | ||
|
||
fun ItemPostDto.toJson(): String { | ||
return mapper.writeValueAsString(this) | ||
} | ||
|
||
fun ListPostDto.post(): ListGetDto { | ||
val (_, _, listResult) = Fuel.post("$baseUrl/list") | ||
.jsonBody(this.toJson()) | ||
.responseObject<ListGetDto>(mapper) | ||
return listResult.get() | ||
} | ||
|
||
fun ItemPostDto.post(): ItemGetDto { | ||
val (_, _, updateItemResult) = Fuel.post("$baseUrl/item") | ||
.jsonBody(this.toJson()) | ||
.responseObject<ItemGetDto>(mapper) | ||
return updateItemResult.get() | ||
} | ||
|
||
fun ItemPostDto.put(id: UUID): ItemGetDto { | ||
val (_, _, updateItemResult) = Fuel.put("$baseUrl/item/$id") | ||
.jsonBody(this.toJson()) | ||
.responseObject<ItemGetDto>(mapper) | ||
return updateItemResult.get() | ||
} | ||
} |
51 changes: 10 additions & 41 deletions
51
subprojects/integrationTest/src/test/kotlin/cloud/cosmin/checklister/it/TimestampSpec.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters