List of usage examples for com.google.api.client.googleapis.services.json AbstractGoogleJsonClientRequest getJsonContent
public Object getJsonContent()
From source file:com.google.jenkins.plugins.util.MockExecutor.java
License:Open Source License
/** * {@inheritDoc}/*from w ww . j a v a 2 s.co m*/ */ @Override public <T> T execute(AbstractGoogleJsonClientRequest<T> request) throws IOException, ExecutorException { Class<?> requestClass = request.getClass(); if (requestTypes.isEmpty()) { sawUnexpected = true; throw new IllegalStateException("Unexpected request: " + requestClass); } // Remove all three states to keep the lists in sync Class<?> clazz = requestTypes.removeFirst(); Object response = responses.removeFirst(); Exception exception = exceptions.removeFirst(); Predicate<AbstractGoogleJsonClientRequest<T>> predicate = (Predicate<AbstractGoogleJsonClientRequest<T>>) predicates .removeFirst(); if (requestClass != clazz) { sawUnexpected = true; throw new IllegalStateException( "Unexpected (or out of order) request: " + requestClass + " expected: " + clazz); } if (!predicate.apply(request)) { sawUnexpected = true; throw new IllegalStateException( "User predicate: " + predicate + " failed for request: " + requestClass); } if (response == null) { if (exception != null) { if (exception instanceof IOException) { throw (IOException) exception; // throwWhen(IOException) } else { throw (ExecutorException) exception; // throwWhen(ExecutorException) } } return (T) request.getJsonContent(); // passThruWhen } return (T) response; // when }