Skip to content

Commit fd866ba

Browse files
committed
2 parents f917665 + 62e3348 commit fd866ba

File tree

6 files changed

+27
-8
lines changed

6 files changed

+27
-8
lines changed

serenity-rest-assured/src/main/java/net/serenitybdd/rest/SerenityRest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import net.serenitybdd.rest.decorators.ResponseSpecificationDecorated;
3030
import net.serenitybdd.rest.decorators.request.RequestSpecificationDecorated;
3131
import net.serenitybdd.rest.utils.RestDecorationHelper;
32+
import net.serenitybdd.rest.utils.RestRuntimeException;
3233
import net.serenitybdd.rest.utils.RestSpecificationFactory;
3334

3435
import java.io.File;
@@ -372,7 +373,7 @@ public static ProxySpecification proxy(final String host) {
372373
try {
373374
return setDefaultProxy(new URI(host));
374375
} catch (URISyntaxException e) {
375-
throw new RuntimeException("Internal error in REST Assured when constructing URI for Proxy.", e);
376+
throw new RestRuntimeException("Internal error in REST Assured when constructing URI for Proxy.", e);
376377
}
377378
} else {
378379
return setDefaultProxy(host(host));

serenity-rest-assured/src/main/java/net/serenitybdd/rest/filters/FieldsRecordingFilter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io.restassured.response.Response;
88
import io.restassured.specification.FilterableRequestSpecification;
99
import io.restassured.specification.FilterableResponseSpecification;
10+
import net.serenitybdd.rest.utils.RestRuntimeException;
1011

1112
import java.io.ByteArrayOutputStream;
1213
import java.io.IOException;
@@ -48,9 +49,9 @@ public Response filter(final FilterableRequestSpecification requestSpec,
4849
this.recorded = this.recorded.replaceAll("\n$", "");
4950
return response;
5051
} catch (UnsupportedEncodingException e) {
51-
throw new RuntimeException("Incorrect implementation, should be used correct charset", e);
52+
throw new RestRuntimeException("Incorrect implementation, should be used correct charset", e);
5253
} catch (IOException e) {
53-
throw new RuntimeException("Some exception during recording fields", e);
54+
throw new RestRuntimeException("Some exception during recording fields", e);
5455
}
5556
}
5657

serenity-rest-assured/src/main/java/net/serenitybdd/rest/filters/UpdatingContextFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io.restassured.response.Response;
77
import io.restassured.specification.FilterableRequestSpecification;
88
import io.restassured.specification.FilterableResponseSpecification;
9+
import net.serenitybdd.rest.utils.RestRuntimeException;
910
import net.serenitybdd.rest.stubs.ResponseStub;
1011
import net.serenitybdd.rest.utils.ReflectionHelper;
1112
import net.serenitybdd.rest.utils.RestExecutionHelper;
@@ -39,7 +40,7 @@ public Response filter(final FilterableRequestSpecification requestSpec,
3940
if (RestExecutionHelper.restCallsAreDisabled()) {
4041
return stubbed();
4142
}
42-
throw new RuntimeException("Incorrect implementation, should update field without any problem", e);
43+
throw new RestRuntimeException("Incorrect implementation, should update field without any problem", e);
4344
}
4445
}
4546

serenity-rest-assured/src/main/java/net/serenitybdd/rest/utils/RestReportingHelper.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.Set;
2828

2929
import static net.thucydides.core.steps.StepEventBus.getEventBus;
30-
import static net.thucydides.core.steps.StepEventBus.getParallelEventBus;
3130
import static org.apache.commons.lang3.ObjectUtils.firstNonNull;
3231

3332

@@ -93,7 +92,13 @@ public void registerCall(final RestMethod method, final RequestSpecificationDeco
9392
final RuntimeException throwable, final Object... params) {
9493
RestQuery restQuery = recordRestSpecificationData(method, spec, path, params);
9594
ExecutedStepDescription description = ExecutedStepDescription.withTitle(restQuery.toString());
96-
StepFailure failure = new StepFailure(description, throwable);
95+
Throwable exception;
96+
if (throwable instanceof RestRuntimeException) {
97+
exception = throwable.getCause();
98+
} else {
99+
exception = throwable;
100+
}
101+
StepFailure failure = new StepFailure(description, exception);
97102
if (TestSession.isSessionStarted()) {
98103
TestSession.addEvent(new StepStartedEvent(description));
99104
TestSession.addEvent(new RecordRestQueryEvent(restQuery));

serenity-rest-assured/src/main/java/net/serenitybdd/rest/utils/RestResponseRecordingHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public Map<LogDetail, String> print(final Response response) {
5656

5757
}
5858
} catch (UnsupportedEncodingException e) {
59-
throw new RuntimeException("Incorrect implementation, should be used correct charset", e);
59+
throw new RestRuntimeException("Incorrect implementation, should be used correct charset", e);
6060
} catch (IOException e) {
61-
throw new RuntimeException("Some exception during recording fields", e);
61+
throw new RestRuntimeException("Some exception during recording fields", e);
6262
}
6363
}
6464
return result;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package net.serenitybdd.rest.utils;
2+
3+
public class RestRuntimeException extends RuntimeException {
4+
public RestRuntimeException(String message) {
5+
super(message);
6+
}
7+
8+
public RestRuntimeException(String message, Throwable cause) {
9+
super(message, cause);
10+
}
11+
}

0 commit comments

Comments
 (0)