-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kotlin samples #401
Merged
Merged
Kotlin samples #401
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6a77706
initial kotlin example
tsiq-karold 14e6530
initial kotlin example
tsiq-karold 82b6bd8
Merge branch 'master' into kotlin-samples
tsiq-karold 1894624
Merge branch 'master' into kotlin-samples
tsiq-karold 4123536
move kotlin samples into existing module
tsiq-karold File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -26,6 +26,10 @@ | |
|
||
<artifactId>webtau-junit5-examples</artifactId> | ||
|
||
<properties> | ||
<kotlin.version>1.3.41</kotlin.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.twosigma.webtau</groupId> | ||
|
@@ -76,6 +80,11 @@ | |
<artifactId>webtau-junit5-groovy</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-stdlib</artifactId> | ||
<version>${kotlin.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
|
@@ -151,6 +160,61 @@ | |
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-maven-plugin</artifactId> | ||
<version>${kotlin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>compile</id> | ||
<goals> <goal>compile</goal> </goals> | ||
<configuration> | ||
<sourceDirs> | ||
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir> | ||
<sourceDir>${project.basedir}/src/main/java</sourceDir> | ||
</sourceDirs> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>test-compile</id> | ||
<goals> <goal>test-compile</goal> </goals> | ||
<configuration> | ||
<sourceDirs> | ||
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir> | ||
<sourceDir>${project.basedir}/src/test/java</sourceDir> | ||
</sourceDirs> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.5.1</version> | ||
<executions> | ||
<!-- Replacing default-compile as it is treated specially by maven --> | ||
<execution> | ||
<id>default-compile</id> | ||
<phase>none</phase> | ||
</execution> | ||
<!-- Replacing default-testCompile as it is treated specially by maven --> | ||
<execution> | ||
<id>default-testCompile</id> | ||
<phase>none</phase> | ||
</execution> | ||
<execution> | ||
<id>java-compile</id> | ||
<phase>compile</phase> | ||
<goals> <goal>compile</goal> </goals> | ||
</execution> | ||
<execution> | ||
<id>java-test-compile</id> | ||
<phase>test-compile</phase> | ||
<goals> <goal>testCompile</goal> </goals> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. weird formatting... |
||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.codehaus.gmavenplus</groupId> | ||
<artifactId>gmavenplus-plugin</artifactId> | ||
|
@@ -175,4 +239,4 @@ | |
</plugin> | ||
</plugins> | ||
</build> | ||
</project> | ||
</project> |
63 changes: 63 additions & 0 deletions
63
...nit5-examples/src/test/kotlin/com/example/tests/junit5/CustomerCrudSeparatedKotlinTest.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,63 @@ | ||
package com.example.tests.junit5 | ||
|
||
import com.twosigma.webtau.WebTauDsl.* | ||
import com.twosigma.webtau.http.validation.HttpResponseValidatorWithReturn | ||
import com.twosigma.webtau.junit5.WebTau | ||
|
||
import org.junit.jupiter.api.* | ||
|
||
@WebTau | ||
@TestMethodOrder(MethodOrderer.OrderAnnotation::class) | ||
@DisplayName("customer") | ||
class CustomerCrudSeparatedKotlinTest { | ||
@Test | ||
@Order(1) | ||
fun `read customer record`() { | ||
http.get("/customers/$id") { _, body -> | ||
body.should(equal(customerPayload)) | ||
} | ||
} | ||
|
||
@Test | ||
@Order(2) | ||
fun `update customer record`() { | ||
http.put("/customers/$id", changedCustomerPayload) { _, body -> | ||
body.should(equal(changedCustomerPayload)) | ||
} | ||
|
||
http.get("/customers/$id") { _, body -> | ||
body.should(equal(changedCustomerPayload)) | ||
} | ||
} | ||
|
||
@Test | ||
@Order(3) | ||
fun `delete customer`() { | ||
http.delete("/customers/$id") { header, _ -> | ||
header.statusCode().should(equal(204)) | ||
} | ||
|
||
http.get("/customers/$id") { header, _ -> | ||
header.statusCode().should(equal(404)) | ||
} | ||
} | ||
|
||
companion object { | ||
private val customerPayload = mapOf( | ||
"firstName" to "FN", | ||
"lastName" to "LN" | ||
) | ||
private val changedCustomerPayload = mapOf( | ||
"lastName" to "NLN" | ||
) | ||
private val id by lazy { | ||
val id: Int = http.post("/customers", customerPayload, HttpResponseValidatorWithReturn { _, body -> | ||
body.get("id") | ||
}) | ||
|
||
actual(id).shouldNot(equal(0)) | ||
|
||
id | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird formatting...