Skip to content

Commit afa610f

Browse files
author
Wusi
committed
kotlin-emails
1 parent 7344d93 commit afa610f

File tree

4 files changed

+134
-0
lines changed

4 files changed

+134
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
target
2+
.idea
3+
*.iml

kotlin-email-test-example/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-include ../.env
2+
3+
test:
4+
API_KEY=$(API_KEY) mvn install test

kotlin-email-test-example/pom.xml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.mailslurp.examples</groupId>
7+
<artifactId>kotlin-test-example</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
11+
<name>com.mailslurp.examples kotlin-test-example</name>
12+
13+
<properties>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
<kotlin.version>1.4.30</kotlin.version>
16+
<kotlin.code.style>official</kotlin.code.style>
17+
<junit.version>4.12</junit.version>
18+
</properties>
19+
20+
<dependencies>
21+
<dependency>
22+
<groupId>com.mailslurp</groupId>
23+
<artifactId>mailslurp-client-kotlin</artifactId>
24+
<version>11.7.0</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.jetbrains.kotlin</groupId>
28+
<artifactId>kotlin-reflect</artifactId>
29+
<version>${kotlin.version}</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.jetbrains.kotlin</groupId>
33+
<artifactId>kotlin-stdlib</artifactId>
34+
<version>${kotlin.version}</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.jetbrains.kotlin</groupId>
38+
<artifactId>kotlin-test-junit</artifactId>
39+
<version>${kotlin.version}</version>
40+
<scope>test</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>junit</groupId>
44+
<artifactId>junit</artifactId>
45+
<version>${junit.version}</version>
46+
<scope>test</scope>
47+
</dependency>
48+
</dependencies>
49+
50+
<build>
51+
<sourceDirectory>src/main/kotlin</sourceDirectory>
52+
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
53+
54+
<plugins>
55+
<plugin>
56+
<groupId>org.jetbrains.kotlin</groupId>
57+
<artifactId>kotlin-maven-plugin</artifactId>
58+
<version>${kotlin.version}</version>
59+
<executions>
60+
<execution>
61+
<id>compile</id>
62+
<phase>compile</phase>
63+
<goals>
64+
<goal>compile</goal>
65+
</goals>
66+
</execution>
67+
<execution>
68+
<id>test-compile</id>
69+
<phase>test-compile</phase>
70+
<goals>
71+
<goal>test-compile</goal>
72+
</goals>
73+
</execution>
74+
</executions>
75+
</plugin>
76+
</plugins>
77+
</build>
78+
79+
</project>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.mailslurp.examples
2+
3+
import com.mailslurp.apis.InboxControllerApi
4+
import com.mailslurp.apis.WaitForControllerApi
5+
import com.mailslurp.models.SendEmailOptions
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
import org.junit.runners.JUnit4
9+
import kotlin.test.assertEquals
10+
import kotlin.test.assertTrue
11+
12+
@RunWith(JUnit4::class)
13+
class MailSlurpKotlinTest {
14+
15+
private val apiKey: String by lazy { System.getenv("API_KEY") }
16+
17+
@Test
18+
fun `can create inboxes`() {
19+
val inboxController = InboxControllerApi(apiKey)
20+
val inbox = inboxController.createInbox(null, null, null, null, null, null, null, null, null)
21+
assertTrue(inbox.emailAddress?.contains("@mailslurp") ?: false)
22+
}
23+
24+
@Test
25+
fun `can send and receive email`() {
26+
// create inbox
27+
val inboxController = InboxControllerApi(apiKey)
28+
val waitForController = WaitForControllerApi(apiKey)
29+
val inbox = inboxController.createInbox(null, null, null, null, null, null, null, null, null)
30+
31+
val testSubject = "test-subject"
32+
val confirmation = inboxController.sendEmailAndConfirm(
33+
inboxId = inbox.id!!,
34+
sendEmailOptions = SendEmailOptions(
35+
to = listOf(inbox.emailAddress!!),
36+
subject = testSubject
37+
)
38+
)
39+
assertEquals(confirmation.inboxId, inbox.id)
40+
41+
val email = waitForController.waitForLatestEmail(
42+
inboxId = inbox.id!!,
43+
timeout = 60_000,
44+
unreadOnly = true
45+
)
46+
assertTrue(email.subject == "test-subject")
47+
}
48+
}

0 commit comments

Comments
 (0)