/** * Extract status from response */ public Status extractStatus(final Response response) throws IOException { Status status = response.getStatus(); assertThat(status, notNullValue()); return status; }
@Override protected boolean matchesSafely(Response item) { Status status = item.getStatus(); assertThat(status, notNullValue()); return status.isRedirection(); }
@Override protected boolean matchesSafely( Response item ) { return item.getStatus().getCode() == expectedStatusCode; }
@Override protected boolean matchesSafely( Response resp ) { return resp.getStatus().isError(); }
public static Status run( String taskId ) throws IOException { String serviceURI = "service/local/schedule_run/" + taskId; Response response = RequestFacade.doGetRequest( serviceURI ); return response.getStatus(); }
@Override protected boolean matchesSafely( Response item ) { Status status = item.getStatus(); assertThat( status, notNullValue() ); return status.isRedirection(); }
public RoleResource getRole( String roleId ) throws IOException { Response response = this.sendMessage( Method.GET, null, roleId ); if ( !response.getStatus().isSuccess() ) { Assert.fail( "Could not find role: " + roleId + " got: " + response.getStatus() ); } // get the Resource object return this.getResourceFromResponse( response ); }
public List<PrivilegeStatusResource> createPrivileges( PrivilegeResource resource ) throws IOException { Response response = this.sendMessage( Method.POST, resource ); if ( !response.getStatus().isSuccess() ) { Assert.fail( "Could not create privilege: " + response.getStatus() ); } // get the Resource object List<PrivilegeStatusResource> statusResources = this.getResourceListFromResponse( response ); SecurityConfigUtil.verifyPrivileges( statusResources ); return statusResources; }
/** * Use {@link #getResourceFromText(String)} instead. */ @Deprecated public RepositoryRouteResource getResourceFromResponse(Response response) throws IOException { String responseString = response.getEntity().getText(); LOG.debug("responseText: " + responseString); Assert.assertTrue(response.getStatus() + "\n" + responseString, response.getStatus().isSuccess()); return getResourceFromText(responseString); }
/** * Updates a resource representation. * * @param uri * The resource URI. * @return The resource representation. */ public Status updateResource(String uri, Representation updatedRepresentation) { return getClientDispatcher().put(uri, updatedRepresentation) .getStatus(); }
public List<PrivilegeStatusResource> getList( ) throws IOException { Response response = this.sendMessage( Method.GET, null ); if ( !response.getStatus().isSuccess() ) { Assert.fail( "Could not get Privilege: " + response.getStatus() +"\n" + response.getEntity().getText()); } return this.getResourceListFromResponse( response ); }
public RoleResource findRole( String roleId ) throws IOException { Response response = this.sendMessage( Method.GET, null, roleId ); if ( !response.getStatus().isSuccess() ) { return null; } // get the Resource object return this.getResourceFromResponse( response ); }
public Status recoverUsername(String email) throws Exception { String serviceURI = "service/local/users_forgotid/" + email; XStreamRepresentation representation = new XStreamRepresentation(xstream, "", MediaType.APPLICATION_XML); representation.setPayload(null); return RequestFacade.sendMessage(serviceURI, Method.POST, representation).getStatus(); }
public static void removeAllTarget() throws IOException { List<RepositoryTargetListResource> targets = getList(); for ( RepositoryTargetListResource target : targets ) { Status status = RequestFacade.sendMessage( "service/local/repo_targets/" + target.getId(), Method.DELETE ).getStatus(); Assert.assertTrue( "Failt to delete: " + status.getDescription(), status.isSuccess() ); } }
public static void removeAllRoutes() throws IOException { List<RepositoryRouteListResource> routes = getList(); for ( RepositoryRouteListResource route : routes ) { Status status = delete( route.getResourceURI() ).getStatus(); Assert.assertTrue( "Unable to delete route: '" + route.getResourceURI() + "', due to: " + status.getDescription(), status.isSuccess() ); } }
public static Status save( GlobalConfigurationResource globalConfig ) throws IOException { String serviceURI = "service/local/global_settings/current"; GlobalConfigurationResourceResponse configResponse = new GlobalConfigurationResourceResponse(); configResponse.setData( globalConfig ); XStreamRepresentation representation = new XStreamRepresentation( xstream, "", MediaType.APPLICATION_XML ); representation.setPayload( configResponse ); Response response = RequestFacade.sendMessage( serviceURI, Method.PUT, representation ); return response.getStatus(); }
public static Status update( ScheduledServiceBaseResource task ) throws IOException { ScheduledServiceResourceResponse request = new ScheduledServiceResourceResponse(); request.setData( task ); XStreamRepresentation representation = new XStreamRepresentation( xstream, "", MediaType.APPLICATION_XML ); representation.setPayload( request ); String serviceURI = "service/local/schedules/" + task.getId(); Response response = RequestFacade.sendMessage( serviceURI, Method.PUT, representation ); return response.getStatus(); }
public static void removeAllTarget() throws IOException { List<RepositoryTargetListResource> targets = getList(); for (RepositoryTargetListResource target : targets) { Status status = RequestFacade.sendMessage("service/local/repo_targets/" + target.getId(), Method.DELETE).getStatus(); Assert.assertTrue("Failt to delete: " + status.getDescription(), status.isSuccess()); } }
public static Status update( RoleResource role ) throws IOException { RoleResourceRequest request = new RoleResourceRequest(); request.setData( role ); XStreamRepresentation representation = new XStreamRepresentation( xStream, "", MediaType.APPLICATION_XML ); representation.setPayload( request ); String serviceURI = "service/local/roles/" + role.getId(); Response response = RequestFacade.sendMessage( serviceURI, Method.PUT, representation ); return response.getStatus(); }
public static void removeAllRoutes() throws IOException { List<RepositoryRouteListResource> routes = getList(); for (RepositoryRouteListResource route : routes) { Status status = delete(route.getResourceURI()).getStatus(); Assert.assertTrue("Unable to delete route: '" + route.getResourceURI() + "', due to: " + status.getDescription(), status.isSuccess()); } }