Skip to content
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

OE-1156 Update error messages #166

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 44 additions & 38 deletions Skyflow/src/androidTest/java/com/Skyflow/GetByIdsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ class GetByIdsTest {

override fun onFailure(exception: Any) {
Log.d("exp",exception.toString())
val skyflowError = SkyflowError(SkyflowErrorCode.ELEMENT_EMPTY_TABLE_NAME)
val skyflowError = SkyflowError(
SkyflowErrorCode.EMPTY_TABLE_KEY, params = arrayOf("0")
)
assertEquals(skyflowError.getErrorMessage(),
getErrorMessage(exception as JSONObject))
}
Expand All @@ -162,8 +164,7 @@ class GetByIdsTest {
}

@Test
fun testEmptyRedaction()
{
fun testEmptyRedaction() {
val recordsArray = JSONArray()
val record = JSONObject()
record.put("table","cards")
Expand All @@ -176,17 +177,17 @@ class GetByIdsTest {
recordsArray.put(record)
val records = JSONObject()
records.put("records",recordsArray)
skyflowClient.getById(records,object : Callback
{
override fun onSuccess(responseBody: Any) {
}
skyflowClient.getById(records,object : Callback {

override fun onSuccess(responseBody: Any) {}

override fun onFailure(exception: Any) {
val skyflowError = SkyflowError(SkyflowErrorCode.MISSING_REDACTION_VALUE)
val skyflowError = SkyflowError(
SkyflowErrorCode.EMPTY_REDACTION_VALUE, params = arrayOf("0")
)
assertEquals(skyflowError.getErrorMessage(),
getErrorMessage(exception as JSONObject))
}

})
}

Expand All @@ -211,7 +212,9 @@ class GetByIdsTest {
}

override fun onFailure(exception: Any) {
val skyflowError = SkyflowError(SkyflowErrorCode.INVALID_REDACTION_TYPE)
val skyflowError = SkyflowError(
SkyflowErrorCode.INVALID_REDACTION_TYPE, params = arrayOf("0")
)
assertEquals(skyflowError.getErrorMessage(),
getErrorMessage(exception as JSONObject))
}
Expand Down Expand Up @@ -240,7 +243,9 @@ class GetByIdsTest {
}

override fun onFailure(exception: Any) {
val skyflowError = SkyflowError(SkyflowErrorCode.INVALID_TABLE_NAME)
val skyflowError = SkyflowError(
SkyflowErrorCode.INVALID_TABLE_NAME, params = arrayOf("0")
)
assertEquals(skyflowError.getErrorMessage(),
getErrorMessage(exception as JSONObject))
}
Expand Down Expand Up @@ -268,7 +273,9 @@ class GetByIdsTest {
}

override fun onFailure(exception: Any) {
val skyflowError = SkyflowError(SkyflowErrorCode.TABLE_KEY_ERROR)
val skyflowError = SkyflowError(
SkyflowErrorCode.TABLE_KEY_NOY_FOUND, params = arrayOf("0")
)
assertEquals(skyflowError.getErrorMessage(),
getErrorMessage(exception as JSONObject))
}
Expand All @@ -277,8 +284,7 @@ class GetByIdsTest {
}

@Test
fun testMissingRedaction()
{
fun testMissingRedaction() {
val recordsArray = JSONArray()
val record = JSONObject()
record.put("table","cards")
Expand All @@ -291,17 +297,17 @@ class GetByIdsTest {
recordsArray.put(record)
val records = JSONObject()
records.put("records",recordsArray)
skyflowClient.getById(records,object : Callback
{
override fun onSuccess(responseBody: Any) {
}
skyflowClient.getById(records,object : Callback {

override fun onSuccess(responseBody: Any) {}

override fun onFailure(exception: Any) {
val skyflowError = SkyflowError(SkyflowErrorCode.REDACTION_KEY_ERROR)
val skyflowError = SkyflowError(
SkyflowErrorCode.REDACTION_KEY_NOT_FOUND, params = arrayOf("0")
)
assertEquals(skyflowError.getErrorMessage(),
getErrorMessage(exception as JSONObject))
}

})
}

Expand Down Expand Up @@ -356,7 +362,9 @@ class GetByIdsTest {
}

override fun onFailure(exception: Any) {
val skyflowError = SkyflowError(SkyflowErrorCode.INVALID_RECORDS)
val skyflowError = SkyflowError(
SkyflowErrorCode.INVALID_RECORDS
)
assertEquals(skyflowError.getErrorMessage(),
getErrorMessage(exception as JSONObject))
}
Expand Down Expand Up @@ -395,8 +403,7 @@ class GetByIdsTest {


@Test
fun testMissingIds()
{
fun testMissingIds() {
val recordsArray = JSONArray()
val record = JSONObject()
record.put("table","cards")
Expand All @@ -409,17 +416,17 @@ class GetByIdsTest {
recordsArray.put(record)
val records = JSONObject()
records.put("records",recordsArray)
skyflowClient.getById(records,object : Callback
{
override fun onSuccess(responseBody: Any) {
}
skyflowClient.getById(records,object : Callback {

override fun onSuccess(responseBody: Any) {}

override fun onFailure(exception: Any) {
val skyflowError = SkyflowError(SkyflowErrorCode.MISSING_IDS)
val skyflowError = SkyflowError(
SkyflowErrorCode.IDS_KEY_NOT_FOUND, params = arrayOf("0")
)
assertEquals(skyflowError.getErrorMessage(),
getErrorMessage(exception as JSONObject))
}

})
}

Expand All @@ -442,7 +449,9 @@ class GetByIdsTest {
}

override fun onFailure(exception: Any) {
val skyflowError = SkyflowError(SkyflowErrorCode.EMPTY_RECORD_IDS)
val skyflowError = SkyflowError(
SkyflowErrorCode.EMPTY_RECORD_IDS, params = arrayOf("0")
)
assertEquals(skyflowError.getErrorMessage(),
getErrorMessage(exception as JSONObject))
}
Expand All @@ -451,8 +460,7 @@ class GetByIdsTest {
}

@Test
fun testInvalidIds()
{
fun testInvalidIds() {
val recordsArray = JSONArray()
val record = JSONObject()
record.put("table","cards")
Expand All @@ -462,17 +470,15 @@ class GetByIdsTest {
recordsArray.put(record)
val records = JSONObject()
records.put("records",recordsArray)
skyflowClient.getById(records,object : Callback
{
override fun onSuccess(responseBody: Any) {
}
skyflowClient.getById(records,object : Callback {

override fun onSuccess(responseBody: Any) {}

override fun onFailure(exception: Any) {
val skyflowError = SkyflowError(SkyflowErrorCode.INVALID_RECORD_IDS)
val skyflowError = SkyflowError(SkyflowErrorCode.INVALID_IDS, params = arrayOf("0"))
assertEquals(skyflowError.getErrorMessage(),
getErrorMessage(exception as JSONObject))
}

})
}

Expand Down
5 changes: 3 additions & 2 deletions Skyflow/src/androidTest/java/com/Skyflow/GetTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.Skyflow

import Skyflow.*
import android.content.Context
import android.util.Log
import androidx.test.core.app.ApplicationProvider
import junit.framework.Assert.assertEquals
import org.json.JSONArray
Expand Down Expand Up @@ -130,7 +129,9 @@ class GetTest {
}

override fun onFailure(exception: Any) {
val skyflowError = SkyflowError(SkyflowErrorCode.MISSING_TOKEN)
val skyflowError = SkyflowError(
SkyflowErrorCode.TOKEN_KEY_NOT_FOUND, params = arrayOf("0")
)
assertEquals(skyflowError.getErrorMessage(),getErrorMessage(exception as JSONObject))
}

Expand Down
Loading
Loading