-
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.
* feat: add new authentication group/resource * fix: lint * feat: add new authentication api test * docs: update README with authentication api
- Loading branch information
1 parent
a02bb4d
commit 6250a3c
Showing
7 changed files
with
90 additions
and
1 deletion.
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
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
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
10 changes: 10 additions & 0 deletions
10
pinata/src/main/java/net/onyxmueller/pinata/authentication/AuthenticationApi.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,10 @@ | ||
package net.onyxmueller.pinata.authentication | ||
|
||
import net.onyxmueller.pinata.PinataApiResponse | ||
import net.onyxmueller.pinata.authentication.model.AuthTestResponse | ||
import retrofit2.http.GET | ||
|
||
interface AuthenticationApi { | ||
@GET("data/testAuthentication") | ||
suspend fun test(): PinataApiResponse<AuthTestResponse> | ||
} |
3 changes: 3 additions & 0 deletions
3
pinata/src/main/java/net/onyxmueller/pinata/authentication/model/AuthTestResponse.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,3 @@ | ||
package net.onyxmueller.pinata.authentication.model | ||
|
||
data class AuthTestResponse(var message: String) |
31 changes: 31 additions & 0 deletions
31
pinata/src/test/java/net/onyxmueller/pinata/AuthenticationApiTest.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,31 @@ | ||
package net.onyxmueller.pinata | ||
|
||
import kotlinx.coroutines.test.runTest | ||
import net.onyxmueller.pinata.authentication.AuthenticationApi | ||
import org.hamcrest.CoreMatchers.`is` | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
|
||
@RunWith(JUnit4::class) | ||
internal class AuthenticationApiTest : ApiAbstract<AuthenticationApi>() { | ||
private lateinit var api: AuthenticationApi | ||
|
||
@Before | ||
fun initApi() { | ||
api = createService(AuthenticationApi::class.java) | ||
} | ||
|
||
@Test | ||
fun testAuthenticationApiTest() = | ||
runTest { | ||
enqueueResponse("test.json") | ||
|
||
val response = api.test() | ||
val responseBody = requireNotNull((response as PinataApiResponse.Success).data) | ||
|
||
assertThat(responseBody.message, `is`("Congratulations! You are communicating with the Pinata API!")) | ||
} | ||
} |
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,3 @@ | ||
{ | ||
"message": "Congratulations! You are communicating with the Pinata API!" | ||
} |