Skip to content

Commit

Permalink
restore public methods
Browse files Browse the repository at this point in the history
  • Loading branch information
baulea committed Mar 12, 2024
1 parent cbfc93d commit 895f834
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.lang.StringUtils;
import org.jsmart.zerocode.core.di.provider.ObjectMapperProvider;
import org.jsmart.zerocode.core.engine.assertion.FieldAssertionMatcher;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -72,6 +74,36 @@ public static Map<String, Object> readObjectAsMap(Object jsonContent) {
return map;
}

public static String createAndReturnAssertionResultJson(int httpResponseCode,
String resultBodyContent, String locationHref) {
LOGGER.debug("\n#locationHref: " + locationHref);

if (StringUtils.isEmpty(resultBodyContent)) {
resultBodyContent = "{}";
}
String locationField = locationHref != null ? " \"Location\" : \"" + locationHref + "\",\n" : "";
String assertJson = "{\n" +
" \"status\" : " + httpResponseCode + ",\n" +
locationField +
" \"body\" : " + resultBodyContent + "\n" +
" }";

String formattedStr = SmartUtils.prettyPrintJson(assertJson);

return formattedStr;
}

public static String javaObjectAsString(Object value) {

try {
ObjectMapper ow = new ObjectMapperProvider().get();
return ow.writeValueAsString(value);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("Exception while converting IPT Java Object to JsonString" + e);
}
}


public static List<FieldAssertionMatcher> strictComparePayload(String expectedResult, String actualResult) {
List<FieldAssertionMatcher> matchers = new ArrayList<>();
Expand Down

0 comments on commit 895f834

Please sign in to comment.