I am writing test cases with rest assured and gauge. I can not fix the response parsing when it comes to complex objects (with List it works well). I have the following structures:
public class SearchResult {
private List<T> pageEntries;
private long totalCount;
private long size;
}
The endpoint waits SearchResult
JSON received: "pageEntries": [ { "id": "12345", "name": "VpfIRPxVNHHYfTRPAgZDBstgFIqMtubBUpClnhlwJRQZWpkWlOzEKkrYZXRgdFbtoe", } ], "totalCount": 1, "size": 1 }
I saved the response into gauge datastore as Searchresult object but the type of pageEntries is a LinkedHashmap and not DummyResult as expected.
@Step("Save result as <storeKey>")
public void saveResultX(final String storeKey) {
final Class className = (Class) suiteDataStore.get(RESPONSE_CLASS);
saveDTO(className, storeKey);
final SearchResult dto = (SearchResult) suiteDataStore.get(storeKey);
log.info(dto.getPageEntries().get(0).getClass().getName());
}
and I got java.util.LinkedHashMap ....
Any idea how to map the DummyResult class from response (without extracting extract().path("pageEntries")?
Aucun commentaire:
Enregistrer un commentaire