Skip to content

Commit 154d043

Browse files
committed
Apply formatter
1 parent e5c0fb4 commit 154d043

File tree

2 files changed

+35
-26
lines changed

2 files changed

+35
-26
lines changed

aws-api/src/test/java/com/amplifyframework/api/aws/AppSyncErrorPropagationTest.kt

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.amplifyframework.testutils.Await
2323
import io.kotest.matchers.nulls.shouldNotBeNull
2424
import io.kotest.matchers.shouldBe
2525
import io.kotest.matchers.types.shouldBeInstanceOf
26+
import java.io.IOException
2627
import okhttp3.HttpUrl
2728
import okhttp3.mockwebserver.MockResponse
2829
import okhttp3.mockwebserver.MockWebServer
@@ -33,7 +34,6 @@ import org.junit.Before
3334
import org.junit.Test
3435
import org.junit.runner.RunWith
3536
import org.robolectric.RobolectricTestRunner
36-
import java.io.IOException
3737

3838
/**
3939
* Integration tests for error cause propagation in GraphQL operations.
@@ -59,12 +59,15 @@ class AppSyncErrorPropagationTest {
5959
baseUrl = webServer.url("/")
6060

6161
val configuration = JSONObject()
62-
.put("graphQlApi", JSONObject()
63-
.put("endpointType", "GraphQL")
64-
.put("endpoint", baseUrl.toUrl())
65-
.put("region", "us-east-1")
66-
.put("authorizationType", "API_KEY")
67-
.put("apiKey", "FAKE-API-KEY"))
62+
.put(
63+
"graphQlApi",
64+
JSONObject()
65+
.put("endpointType", "GraphQL")
66+
.put("endpoint", baseUrl.toUrl())
67+
.put("region", "us-east-1")
68+
.put("authorizationType", "API_KEY")
69+
.put("apiKey", "FAKE-API-KEY")
70+
)
6871

6972
plugin = AWSApiPlugin.builder().build()
7073
plugin.configure(configuration, ApplicationProvider.getApplicationContext())
@@ -95,10 +98,12 @@ class AppSyncErrorPropagationTest {
9598
}]
9699
}
97100
""".trimIndent()
98-
99-
webServer.enqueue(MockResponse()
100-
.setResponseCode(401)
101-
.setBody(errorResponse))
101+
102+
webServer.enqueue(
103+
MockResponse()
104+
.setResponseCode(401)
105+
.setBody(errorResponse)
106+
)
102107

103108
// Act - execute query and capture error
104109
val error = Await.error { onResult, onError ->
@@ -108,13 +113,13 @@ class AppSyncErrorPropagationTest {
108113
// Assert - verify error has proper cause chain
109114
error.shouldNotBeNull()
110115
error.shouldBeInstanceOf<ApiException.NonRetryableException>()
111-
116+
112117
val cause = error.cause
113118
cause.shouldNotBeNull()
114119
cause.shouldBeInstanceOf<GraphQLResponseException>()
115120

116121
cause.errors.size.shouldBe(1)
117-
122+
118123
val firstError = cause.errors[0]
119124
firstError.errorType.shouldBe("UnauthorizedException")
120125
firstError.message.shouldBe("You are not authorized to make this call.")
@@ -127,10 +132,12 @@ class AppSyncErrorPropagationTest {
127132
fun queryInvalidJsonPreservesJsonException() {
128133
// Arrange - mock a 400 response with invalid JSON
129134
val invalidJson = "not valid json at all"
130-
131-
webServer.enqueue(MockResponse()
132-
.setResponseCode(400)
133-
.setBody(invalidJson))
135+
136+
webServer.enqueue(
137+
MockResponse()
138+
.setResponseCode(400)
139+
.setBody(invalidJson)
140+
)
134141

135142
// Act
136143
val error = Await.error { onResult, onError ->
@@ -142,7 +149,7 @@ class AppSyncErrorPropagationTest {
142149
val cause = error.cause
143150
cause.shouldNotBeNull()
144151
cause.shouldBeInstanceOf<IOException>()
145-
152+
146153
// The IOException should have a JSONException as its cause
147154
val jsonCause = cause.cause
148155
jsonCause.shouldNotBeNull()

aws-api/src/test/java/com/amplifyframework/api/aws/GraphQLResponseExceptionTest.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ class GraphQLResponseExceptionTest {
5050
// Assert
5151
exception.shouldNotBeNull()
5252
exception.message.shouldBe("UnauthorizedException: You are not authorized to make this call. (code: null)")
53-
53+
5454
val errors = exception.errors
5555
errors.size.shouldBe(1)
56-
56+
5757
val error = errors[0]
5858
error.errorType.shouldBe("UnauthorizedException")
5959
error.message.shouldBe("You are not authorized to make this call.")
@@ -84,7 +84,7 @@ class GraphQLResponseExceptionTest {
8484
// Assert
8585
val errors = exception.errors
8686
errors.size.shouldBe(1)
87-
87+
8888
val error = errors[0]
8989
error.errorType.shouldBe("UnauthorizedException")
9090
error.message.shouldBe("You are not authorized to make this call.")
@@ -121,10 +121,10 @@ class GraphQLResponseExceptionTest {
121121
// Assert
122122
val errors = exception.errors
123123
errors.size.shouldBe(2)
124-
124+
125125
errors[0].errorType.shouldBe("UnauthorizedException")
126126
errors[0].message.shouldBe("First error")
127-
127+
128128
errors[1].errorType.shouldBe("ValidationException")
129129
errors[1].message.shouldBe("Second error")
130130
errors[1].errorCode.shouldBe(400)
@@ -157,8 +157,10 @@ class GraphQLResponseExceptionTest {
157157

158158
// Assert - message should contain both errors separated by semicolon
159159
val message = exception.message
160-
message.shouldBe("FirstError: This should be in the message (code: null); " +
161-
"SecondError: This should also be in the message (code: null)")
160+
message.shouldBe(
161+
"FirstError: This should be in the message (code: null); " +
162+
"SecondError: This should also be in the message (code: null)"
163+
)
162164
}
163165

164166
/**
@@ -182,7 +184,7 @@ class GraphQLResponseExceptionTest {
182184
// Assert
183185
val errors = exception.errors
184186
errors.size.shouldBe(1)
185-
187+
186188
val error = errors[0]
187189
error.errorType.shouldBeNull()
188190
error.message.shouldBe("Something went wrong")

0 commit comments

Comments
 (0)