Feature/acs 4462 mtls e2e test (#1861)

ACS-4462 add empty response handling
This commit is contained in:
Kacper Magdziarz
2023-04-05 08:22:25 +02:00
committed by GitHub
parent 8b4285afbd
commit 959cf8f13f
2 changed files with 14 additions and 10 deletions

View File

@@ -680,17 +680,22 @@ public class RestWrapper extends DSLWrapper<RestWrapper>
} }
else else
{ {
if (returnedResponse.getContentType().contains("image/png")) if (returnedResponse.asString().isEmpty())
{
LOG.info("On {} {}, received the response with an image and headers: \n{}", restRequest.getHttpMethod(), restRequest.getPath(),
returnedResponse.getHeaders().toString());
}
else if (returnedResponse.getContentType().contains("application/json") && !returnedResponse.asString().isEmpty())
{ {
LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(), LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(),
Utility.prettyPrintJsonString(returnedResponse.asString())); returnedResponse.getStatusCode());
} }
else if (returnedResponse.getContentType().contains("application/xml") && !returnedResponse.asString().isEmpty()) else if (returnedResponse.getContentType().contains("image/png"))
{
LOG.info("On {} {}, received the response with an image and headers: \n{}", restRequest.getHttpMethod(), restRequest.getPath(),
returnedResponse.getHeaders().toString());
}
else if (returnedResponse.getContentType().contains("application/json"))
{
LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(),
Utility.prettyPrintJsonString(returnedResponse.asString()));
}
else if (returnedResponse.getContentType().contains("application/xml"))
{ {
String response = parseXML(returnedResponse); String response = parseXML(returnedResponse);
LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(), response); LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(), response);
@@ -698,7 +703,7 @@ public class RestWrapper extends DSLWrapper<RestWrapper>
else else
{ {
LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(), LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(),
ToStringBuilder.reflectionToString(returnedResponse.asString(), ToStringStyle.MULTI_LINE_STYLE)); ToStringBuilder.reflectionToString(returnedResponse.asString(), ToStringStyle.MULTI_LINE_STYLE));
} }
} }
} }

View File

@@ -47,7 +47,6 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
/** /**