Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Jan 29, 2025
2 parents f917665 + 62e3348 commit fd866ba
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.serenitybdd.rest.decorators.ResponseSpecificationDecorated;
import net.serenitybdd.rest.decorators.request.RequestSpecificationDecorated;
import net.serenitybdd.rest.utils.RestDecorationHelper;
import net.serenitybdd.rest.utils.RestRuntimeException;
import net.serenitybdd.rest.utils.RestSpecificationFactory;

import java.io.File;
Expand Down Expand Up @@ -372,7 +373,7 @@ public static ProxySpecification proxy(final String host) {
try {
return setDefaultProxy(new URI(host));
} catch (URISyntaxException e) {
throw new RuntimeException("Internal error in REST Assured when constructing URI for Proxy.", e);
throw new RestRuntimeException("Internal error in REST Assured when constructing URI for Proxy.", e);
}
} else {
return setDefaultProxy(host(host));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.restassured.response.Response;
import io.restassured.specification.FilterableRequestSpecification;
import io.restassured.specification.FilterableResponseSpecification;
import net.serenitybdd.rest.utils.RestRuntimeException;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down Expand Up @@ -48,9 +49,9 @@ public Response filter(final FilterableRequestSpecification requestSpec,
this.recorded = this.recorded.replaceAll("\n$", "");
return response;
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Incorrect implementation, should be used correct charset", e);
throw new RestRuntimeException("Incorrect implementation, should be used correct charset", e);
} catch (IOException e) {
throw new RuntimeException("Some exception during recording fields", e);
throw new RestRuntimeException("Some exception during recording fields", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.restassured.response.Response;
import io.restassured.specification.FilterableRequestSpecification;
import io.restassured.specification.FilterableResponseSpecification;
import net.serenitybdd.rest.utils.RestRuntimeException;
import net.serenitybdd.rest.stubs.ResponseStub;
import net.serenitybdd.rest.utils.ReflectionHelper;
import net.serenitybdd.rest.utils.RestExecutionHelper;
Expand Down Expand Up @@ -39,7 +40,7 @@ public Response filter(final FilterableRequestSpecification requestSpec,
if (RestExecutionHelper.restCallsAreDisabled()) {
return stubbed();
}
throw new RuntimeException("Incorrect implementation, should update field without any problem", e);
throw new RestRuntimeException("Incorrect implementation, should update field without any problem", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.Set;

import static net.thucydides.core.steps.StepEventBus.getEventBus;
import static net.thucydides.core.steps.StepEventBus.getParallelEventBus;
import static org.apache.commons.lang3.ObjectUtils.firstNonNull;


Expand Down Expand Up @@ -93,7 +92,13 @@ public void registerCall(final RestMethod method, final RequestSpecificationDeco
final RuntimeException throwable, final Object... params) {
RestQuery restQuery = recordRestSpecificationData(method, spec, path, params);
ExecutedStepDescription description = ExecutedStepDescription.withTitle(restQuery.toString());
StepFailure failure = new StepFailure(description, throwable);
Throwable exception;
if (throwable instanceof RestRuntimeException) {
exception = throwable.getCause();
} else {
exception = throwable;
}
StepFailure failure = new StepFailure(description, exception);
if (TestSession.isSessionStarted()) {
TestSession.addEvent(new StepStartedEvent(description));
TestSession.addEvent(new RecordRestQueryEvent(restQuery));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public Map<LogDetail, String> print(final Response response) {

}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Incorrect implementation, should be used correct charset", e);
throw new RestRuntimeException("Incorrect implementation, should be used correct charset", e);
} catch (IOException e) {
throw new RuntimeException("Some exception during recording fields", e);
throw new RestRuntimeException("Some exception during recording fields", e);
}
}
return result;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package net.serenitybdd.rest.utils;

public class RestRuntimeException extends RuntimeException {
public RestRuntimeException(String message) {
super(message);
}

public RestRuntimeException(String message, Throwable cause) {
super(message, cause);
}
}

0 comments on commit fd866ba

Please sign in to comment.