Skip to content

Commit 8775c30

Browse files
committed
Release 0.7.0.1
Adds isSuccessful to CompositeQueryResponse Signed-off-by: Gopal S Akshintala <[email protected]>
1 parent 59740df commit 8775c30

File tree

7 files changed

+53
-44
lines changed

7 files changed

+53
-44
lines changed

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ endif::[]
1818
:pmtemplates: src/integrationTest/resources/pm-templates
1919
:imagesdir: docs/images
2020
:prewrap!:
21-
:revoman-version: 0.7.0
21+
:revoman-version: 0.7.0.1
2222

2323
'''
2424

buildSrc/src/main/kotlin/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
* ************************************************************************************************
77
*/
88
const val GROUP_ID = "com.salesforce.revoman"
9-
const val VERSION = "0.7.0"
9+
const val VERSION = "0.7.0.1"
1010
const val ARTIFACT_ID = "revoman"
1111
const val STAGING_PROFILE_ID = "1ea0a23e61ba7d"

src/main/kotlin/com/salesforce/revoman/input/json/adapters/salesforce/CompositeGraphResponse.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ data class CompositeGraphResponse(val graphs: List<Graph>) {
5555
@get:JvmName("errorResponses")
5656
val errorResponses: List<CompositeErrorResponse> by lazy {
5757
graphResponse.compositeResponse.filter {
58-
it.httpStatusCode !in SUCCESSFUL &&
58+
it.httpStatusCode !in SUCCESSFUL_HTTP_STATUSES &&
5959
it.body.firstOrNull()?.let { error ->
6060
error.errorCode == PROCESSING_HALTED ||
6161
error.message == OPERATION_IN_TRANSACTION_FAILED_ERROR

src/main/kotlin/com/salesforce/revoman/input/json/adapters/salesforce/CompositeQueryResponse.kt

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ data class CompositeQueryResponse(val compositeResponse: List<QueryResponse>) {
3838
@JsonClass(generateAdapter = true)
3939
data class Body(val done: Boolean, val records: List<Record>, val totalSize: Int) {
4040
@JsonClass(generateAdapter = true)
41-
@AdaptedBy(RecordAdapterFactory::class)
41+
@AdaptedBy(RecordFactory::class)
4242
data class Record(val attributes: Attributes, val recordBody: Map<String, Any?>) {
4343
@JsonClass(generateAdapter = true)
4444
data class Attributes(val type: String, val url: String)
4545
}
4646
}
4747

48-
class RecordAdapterFactory : JsonAdapter.Factory {
48+
class RecordFactory : JsonAdapter.Factory {
4949
override fun create(
5050
type: Type,
5151
annotations: Set<Annotation>,
@@ -57,42 +57,42 @@ data class CompositeQueryResponse(val compositeResponse: List<QueryResponse>) {
5757
null
5858
}
5959
}
60-
}
6160

62-
class RecordAdapter(val moshi: Moshi) : JsonAdapter<Record>() {
63-
private val options = JsonReader.Options.of("attributes")
64-
@OptIn(ExperimentalStdlibApi::class)
65-
private val attributesJsonAdapter = moshi.adapter<Attributes>()
66-
@OptIn(ExperimentalStdlibApi::class) private val dynamicJsonAdapter = moshi.adapter<Any>()
67-
68-
override fun fromJson(reader: JsonReader): Record? {
69-
reader.beginObject()
70-
var attributes: Attributes? = null
71-
val recordBody = mutableMapOf<String, Any?>()
72-
while (reader.hasNext()) {
73-
when (reader.selectName(options)) {
74-
0 -> {
75-
if (attributes != null) {
76-
throw JsonDataException("Duplicate attributes Node")
61+
class RecordAdapter(val moshi: Moshi) : JsonAdapter<Record>() {
62+
private val options = JsonReader.Options.of("attributes")
63+
@OptIn(ExperimentalStdlibApi::class)
64+
private val attributesJsonAdapter = moshi.adapter<Attributes>()
65+
@OptIn(ExperimentalStdlibApi::class) private val dynamicJsonAdapter = moshi.adapter<Any>()
66+
67+
override fun fromJson(reader: JsonReader): Record? {
68+
reader.beginObject()
69+
var attributes: Attributes? = null
70+
val recordBody = mutableMapOf<String, Any?>()
71+
while (reader.hasNext()) {
72+
when (reader.selectName(options)) {
73+
0 -> {
74+
if (attributes != null) {
75+
throw JsonDataException("Duplicate attributes Node")
76+
}
77+
attributes = attributesJsonAdapter.fromJson(reader)
7778
}
78-
attributes = attributesJsonAdapter.fromJson(reader)
79+
-1 -> recordBody[reader.nextName()] = reader.readJsonValue()!!
80+
else -> throw AssertionError()
7981
}
80-
-1 -> recordBody[reader.nextName()] = reader.readJsonValue()!!
81-
else -> throw AssertionError()
8282
}
83+
reader.endObject()
84+
return Record(attributes!!, recordBody)
8385
}
84-
reader.endObject()
85-
return Record(attributes!!, recordBody)
86-
}
8786

88-
override fun toJson(writer: JsonWriter, record: Record?) =
89-
with(writer) {
90-
objW(record) {
91-
name("attributes")
92-
attributesJsonAdapter.toJson(this@with, attributes)
93-
mapW(recordBody, dynamicJsonAdapter)
87+
override fun toJson(writer: JsonWriter, record: Record?) =
88+
with(writer) {
89+
objW(record) {
90+
name("attributes")
91+
attributesJsonAdapter.toJson(this@with, attributes)
92+
mapW(recordBody, dynamicJsonAdapter)
93+
}
9494
}
95-
}
95+
}
9696
}
9797
}
9898

@@ -116,21 +116,31 @@ data class CompositeQueryResponse(val compositeResponse: List<QueryResponse>) {
116116
compositeResponse
117117
.mapNotNull { it as? ErrorQueryResponse }
118118
.filter {
119-
it.httpStatusCode !in SUCCESSFUL &&
119+
it.httpStatusCode !in SUCCESSFUL_HTTP_STATUSES &&
120120
it.body.firstOrNull()?.let { error ->
121121
error.errorCode == PROCESSING_HALTED &&
122122
error.message == OPERATION_IN_TRANSACTION_FAILED_ERROR
123123
} != true
124124
}
125125
}
126126

127+
@Json(ignore = true)
128+
@get:JvmName("isSuccessful")
129+
val isSuccessful: Boolean by lazy {
130+
compositeResponse.all { it.httpStatusCode in SUCCESSFUL_HTTP_STATUSES }
131+
}
132+
127133
@Json(ignore = true)
128134
@get:JvmName("errorResponseCount")
129-
val errorResponseCount: Int by lazy { errorResponses.size }
135+
val errorResponseCount: Int by lazy {
136+
compositeResponse.count { it.httpStatusCode !in SUCCESSFUL_HTTP_STATUSES }
137+
}
130138

131139
@Json(ignore = true)
132140
@get:JvmName("successResponseCount")
133-
val successResponseCount: Int by lazy { compositeResponse.size - errorResponseCount }
141+
val successResponseCount: Int by lazy {
142+
compositeResponse.count { it.httpStatusCode in SUCCESSFUL_HTTP_STATUSES }
143+
}
134144

135145
@Json(ignore = true)
136146
@get:JvmName("firstErrorResponse")
@@ -148,7 +158,7 @@ data class CompositeQueryResponse(val compositeResponse: List<QueryResponse>) {
148158
DiMorphicAdapter.of(
149159
QueryResponse::class.java,
150160
"httpStatusCode",
151-
{ it.nextInt() in SUCCESSFUL },
161+
{ it.nextInt() in SUCCESSFUL_HTTP_STATUSES },
152162
SuccessQueryResponse::class.java,
153163
ErrorQueryResponse::class.java,
154164
)

src/main/kotlin/com/salesforce/revoman/input/json/adapters/salesforce/Constants.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
*/
88
package com.salesforce.revoman.input.json.adapters.salesforce
99

10-
internal val SUCCESSFUL = 200..299
11-
internal val CLIENT_ERROR = 400..499
10+
internal val SUCCESSFUL_HTTP_STATUSES = 200..299
1211
internal const val PROCESSING_HALTED = "PROCESSING_HALTED"
1312
internal const val OPERATION_IN_TRANSACTION_FAILED_ERROR =
1413
"The transaction was rolled back since another operation in the same transaction failed."

src/test/java/com/salesforce/revoman/input/json/JsonPojoUtilsTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ void compositeQueryResponseDiMorphicMarshallUnmarshall() throws JSONException {
9191
jsonFileConfig
9292
.jsonFilePath("composite/query/resp/query-response-all-success.json")
9393
.done());
94+
assertThat(successCompositeQueryResponse.isSuccessful()).isTrue();
9495
successCompositeQueryResponse
9596
.getCompositeResponse()
9697
.forEach(
@@ -102,6 +103,7 @@ void compositeQueryResponseDiMorphicMarshallUnmarshall() throws JSONException {
102103
jsonFileConfig
103104
.jsonFilePath("composite/query/resp/query-response-all-error.json")
104105
.done());
106+
assertThat(errorCompositeQueryResponse.isSuccessful()).isFalse();
105107
errorCompositeQueryResponse
106108
.getCompositeResponse()
107109
.forEach(
@@ -115,6 +117,7 @@ void compositeQueryResponseDiMorphicMarshallUnmarshall() throws JSONException {
115117
jsonFileConfig
116118
.jsonFilePath("composite/query/resp/query-response-partial-success.json")
117119
.done());
120+
assertThat(partialSuccessCompositeQueryResponse.isSuccessful()).isFalse();
118121
assertThat(partialSuccessCompositeQueryResponse.getCompositeResponse().getFirst())
119122
.isInstanceOf(SuccessQueryResponse.class);
120123
assertThat(partialSuccessCompositeQueryResponse.getCompositeResponse().get(1))

src/test/kotlin/com/salesforce/revoman/output/report/PostmanEnvironmentKtTest.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import io.kotest.matchers.equals.shouldBeEqual
1414
import io.kotest.matchers.maps.shouldContainExactly
1515
import io.kotest.matchers.maps.shouldNotBeEmpty
1616
import io.kotest.matchers.shouldBe
17-
import io.kotest.matchers.types.shouldBeInstanceOf
1817
import org.junit.jupiter.api.Test
1918
import org.skyscreamer.jsonassert.JSONAssert
2019
import org.skyscreamer.jsonassert.JSONCompareMode
@@ -73,9 +72,7 @@ class PostmanEnvironmentKtTest {
7372
pmEnv.getObj<List<Int>>("key3")!! shouldBeEqual env["key3"] as List<Int>
7473
pmEnv.getObj<Map<String, Int>>("key4")!! shouldContainExactly env["key4"] as Map<String, Int>
7574
pmEnv.getObj<List<String>>("key5")!! shouldContainExactly env["key5"] as List<String>
76-
pmEnv
77-
.getObj<Map<String, Any?>>("key6")!!
78-
.shouldNotBeEmpty()
75+
pmEnv.getObj<Map<String, Any?>>("key6")!!.shouldNotBeEmpty()
7976
pmEnv.getObj<Any>("key7") shouldBe null
8077
}
8178
}

0 commit comments

Comments
 (0)