001package co.codewizards.cloudstore.ls.rest.client.request; 002 003import javax.ws.rs.core.MediaType; 004import javax.ws.rs.core.Response; 005 006public class TestRequest extends AbstractRequest<Void> { 007 008 private final boolean testException; 009 010 public TestRequest(final boolean testException) { 011 this.testException = testException; 012 } 013 014 @Override 015 public boolean isResultNullable() { 016 return true; 017 } 018 019 @Override 020 public Void execute() { 021 if (testException) { 022 final Response response = assignCredentials(createWebTarget("_test").queryParam("exception", true).request()).get(); 023 assertResponseIndicatesSuccess(response); 024 throw new IllegalStateException("Server sent response instead of exception: " + response); 025 } 026 else { 027 final String response = assignCredentials(createWebTarget("_test").request(MediaType.TEXT_PLAIN)).get(String.class); 028 if (!"SUCCESS".equals(response)) { 029 throw new IllegalStateException("Server response invalid: " + response); 030 } 031 } 032 return null; 033 } 034 035}