예제 #1
0
 public <T> void to(T value) {
   if (value != null) {
     Serenity.getCurrentSession().put(key, value);
   } else {
     Serenity.getCurrentSession().remove(key);
   }
 }
 protected Response execute(
     final RestMethod method, final String path, final Object... pathParams) {
   Response response = null;
   RuntimeException exception = null;
   try {
     switch (method) {
       case POST:
         response = decorate(this.core.post(path, pathParams));
         break;
       case GET:
         response = decorate(this.core.get(path, pathParams));
         break;
       case DELETE:
         response = decorate(this.core.delete(path, pathParams));
         break;
       case PUT:
         response = decorate(this.core.put(path, pathParams));
         break;
       case HEAD:
         response = decorate(this.core.head(path, pathParams));
         break;
       case OPTIONS:
         response = decorate(this.core.options(path, pathParams));
         break;
       case PATCH:
         response = decorate(this.core.patch(path, pathParams));
         break;
     }
     if (RestExecutionHelper.restCallsAreEnabled()) {
       response = stubbed();
     }
   } catch (RuntimeException e) {
     exception = e;
   }
   if (exception != null) {
     if (Serenity.shouldThrowErrorsImmediately()) {
       throw exception;
     } else {
       response = stubbed();
     }
     reporting.registerCall(method, this, path, exception, pathParams);
   } else {
     reporting.registerCall(method, response, this, path, pathParams);
   }
   this.lastResponse = response;
   return response;
 }
예제 #3
0
 public SerenityConfigurer throwExceptionsImmediately() {
   Serenity.throwExceptionsImmediately();
   return this;
 }