Skip to content

Commit 6ecda14

Browse files
committed
Release 0.34.2
- IgnoreUnknownFactory bug fix on write - Change StepReport, TxnInfo toString Signed-off-by: Gopal S Akshintala <[email protected]>
1 parent e9dd335 commit 6ecda14

File tree

10 files changed

+60
-22
lines changed

10 files changed

+60
-22
lines changed

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ endif::[]
1616
:pmtemplates: src/integrationTest/resources/pm-templates
1717
:imagesdir: docs/images
1818
:prewrap!:
19-
:revoman-version: 0.33.7
19+
:revoman-version: 0.34.2
2020

2121
'''
2222

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.34.0"
9+
const val VERSION = "0.34.2"
1010
const val ARTIFACT_ID = "revoman"
1111
const val STAGING_PROFILE_ID = "1ea0a23e61ba7d"

src/integrationTest/java/com/salesforce/revoman/input/json/JsonPojoUtils2Test.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
import static com.google.common.truth.Truth.assertThat;
1111
import static com.salesforce.revoman.input.FileUtils.readFileInResourcesToString;
1212
import static com.salesforce.revoman.integration.core.pq.adapters.ConnectInputRepWithGraphAdapter.adapter;
13+
import static org.junit.jupiter.api.Assertions.assertNotNull;
1314
import static org.junit.jupiter.api.Assertions.assertThrows;
1415

16+
import com.salesforce.revoman.integration.core.pq.adapters.IDAdapter;
1517
import com.salesforce.revoman.integration.core.pq.connect.request.PlaceQuoteInputRepresentation;
1618
import com.salesforce.revoman.integration.core.pq.connect.request.PricingPreferenceEnum;
19+
import com.salesforce.revoman.integration.core.pq.connect.response.PlaceQuoteOutputRepresentation;
1720
import com.squareup.moshi.JsonDataException;
1821
import java.util.List;
1922
import org.json.JSONException;
@@ -55,6 +58,20 @@ void pqPayloadJsonToPQInputRep() {
5558
assertThat(graph.getRecords().getRecordsList()).hasSize(6);
5659
}
5760

61+
@Test
62+
@DisplayName("JSON --> PQ Response --> JSON")
63+
void unmarshallMarshallPqResponse() throws JSONException {
64+
final var pqResponseFromJson = readFileInResourcesToString("json/pq-response.json");
65+
final var pqResp =
66+
JsonPojoUtils.<PlaceQuoteOutputRepresentation>jsonToPojo(
67+
PlaceQuoteOutputRepresentation.class, pqResponseFromJson, List.of(new IDAdapter()));
68+
assertNotNull(pqResp);
69+
final var pqOutputRepJson =
70+
JsonPojoUtils.pojoToJson(
71+
PlaceQuoteOutputRepresentation.class, pqResp, List.of(new IDAdapter()));
72+
JSONAssert.assertEquals(pqResponseFromJson, pqOutputRepJson, JSONCompareMode.STRICT);
73+
}
74+
5875
@Test
5976
@DisplayName("Read Enum Case Insensitive")
6077
void readEnumCaseInsensitive() {

src/integrationTest/java/com/salesforce/revoman/integration/core/pq/PQE2EWithSMTest.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@
2222
import com.salesforce.revoman.ReVoman;
2323
import com.salesforce.revoman.input.config.Kick;
2424
import com.salesforce.revoman.input.json.adapters.CompositeGraphResponse;
25+
import com.salesforce.revoman.integration.core.pq.adapters.IDAdapter;
2526
import com.salesforce.revoman.integration.core.pq.connect.request.PlaceQuoteInputRepresentation;
26-
import com.salesforce.revoman.integration.core.pq.connect.response.ID;
2727
import com.salesforce.revoman.integration.core.pq.connect.response.PlaceQuoteOutputRepresentation;
2828
import com.salesforce.revoman.output.postman.PostmanEnvironment;
2929
import com.salesforce.revoman.output.report.StepReport;
30-
import com.squareup.moshi.FromJson;
31-
import com.squareup.moshi.ToJson;
3230
import java.util.List;
3331
import java.util.Map;
3432
import kotlin.random.Random;
@@ -168,17 +166,4 @@ private enum PricingPref {
168166
this.completeStatus = completeStatus;
169167
}
170168
}
171-
172-
// * NOTE 10 Mar 2024 gopala.akshintala: Custom Type Adapter
173-
static class IDAdapter {
174-
@FromJson
175-
ID fromJson(String id) {
176-
return new ID(id);
177-
}
178-
179-
@ToJson
180-
String toJson(ID id) {
181-
return id.getId();
182-
}
183-
}
184169
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/***************************************************************************************************
2+
* Copyright (c) 2023, Salesforce, Inc. All rights reserved. SPDX-License-Identifier:
3+
* Apache License Version 2.0
4+
* For full license text, see the LICENSE file in the repo root or
5+
* http://www.apache.org/licenses/LICENSE-2.0
6+
**************************************************************************************************/
7+
8+
package com.salesforce.revoman.integration.core.pq.adapters;
9+
10+
import com.salesforce.revoman.integration.core.pq.connect.response.ID;
11+
import com.squareup.moshi.FromJson;
12+
import com.squareup.moshi.ToJson;
13+
14+
// * NOTE 10 Mar 2024 gopala.akshintala: Custom Type Adapter
15+
public class IDAdapter {
16+
@FromJson
17+
ID fromJson(String id) {
18+
return new ID(id);
19+
}
20+
21+
@ToJson
22+
String toJson(ID id) {
23+
return id.getId();
24+
}
25+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"quoteId": "0Q0xx0000004E2mCAE",
3+
"requestIdentifier": "95Txx0000004E60",
4+
"responseError": [],
5+
"statusURL": "/services/data/v58.0/sobjects/RevenueAsyncOperation/95Txx0000004E60EAE",
6+
"success": true
7+
}

src/main/kotlin/com/salesforce/revoman/input/json/JsonWriterUtils.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ fun JsonWriter.mapW(map: Map<String, Any?>, dynamicJsonAdapter: JsonAdapter<Any>
9999
}
100100
}
101101

102+
/** BeanUtils is used to read even the private fields with a getter */
102103
fun <T> JsonWriter.writeProps(
103104
pojoType: Class<T>,
104105
bean: T,

src/main/kotlin/com/salesforce/revoman/internal/json/factories/IgnoreUnknownFactory.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ internal class IgnoreUnknownFactory(private val typesToIgnore: Set<Class<out Any
2020
val rawType: Class<*> = Types.getRawType(type)
2121
return if (typesToIgnore.contains(rawType)) {
2222
object : JsonAdapter<Type>() {
23-
override fun fromJson(reader: JsonReader): Type? = null
23+
override fun fromJson(reader: JsonReader): Type? {
24+
reader.skipValue()
25+
return null
26+
}
2427

2528
override fun toJson(writer: JsonWriter, value: Type?) {
26-
// do nothing
29+
writer.nullValue()
2730
}
2831
}
2932
} else null

src/main/kotlin/com/salesforce/revoman/output/report/StepReport.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private constructor(
117117
when {
118118
exeFailure != null -> "$exeFailure\n${exeFailure.failure.stackTraceToString()}"
119119
!isHttpStatusSuccessful ->
120-
" ⚠️️Unsuccessful HTTP Status: ${responseInfo?.get()?.httpMsg?.status} \n${requestInfo?.get()}, ${responseInfo?.get()}"
120+
" ⚠️️Unsuccessful HTTP Status: ${responseInfo?.get()?.httpMsg?.status} \n${requestInfo?.get()} \n${responseInfo?.get()}"
121121
else -> "${requestInfo?.get()}, ${responseInfo?.get()}"
122122
}
123123
}

src/main/kotlin/com/salesforce/revoman/output/report/TxnInfo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ data class TxnInfo<HttpMsgT : HttpMessage>(
5151
is Response -> "ResponseInfo⬇️"
5252
else -> "TxnInfo"
5353
}
54-
return "$prefix(Type=$txnObjType, Obj=$txnObj, $httpMsg)"
54+
return "$prefix ~~>\nType=$txnObjType\nObj=$txnObj\n$httpMsg"
5555
}
5656

5757
companion object {

0 commit comments

Comments
 (0)