Search in sources :

Example 61 with HttpDelete

use of org.apache.http.client.methods.HttpDelete in project openkit-android by OpenKit.

the class AsyncHttpClient method delete.

/**
     * Perform a HTTP DELETE request.
     * @param context the Android Context which initiated the request.
     * @param url the URL to send the request to.
     * @param responseHandler the response handler instance that should handle the response.
     */
public void delete(Context context, String url, AsyncHttpResponseHandler responseHandler) {
    final HttpDelete delete = new HttpDelete(url);
    sendRequest(httpClient, httpContext, delete, null, responseHandler, context);
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete)

Example 62 with HttpDelete

use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.

the class HistoricProcessInstanceCommentResourceTest method testDeleteComment.

/**
   * Test deleting a comment for a task.
   * DELETE runtime/tasks/{taskId}/comments/{commentId}
   */
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testDeleteComment() throws Exception {
    ProcessInstance pi = null;
    try {
        pi = runtimeService.startProcessInstanceByKey("oneTaskProcess");
        // Add a comment as "kermit"
        identityService.setAuthenticatedUserId("kermit");
        Comment comment = taskService.addComment(null, pi.getId(), "This is a comment...");
        identityService.setAuthenticatedUserId(null);
        closeResponse(executeRequest(new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE_COMMENT, pi.getId(), comment.getId())), HttpStatus.SC_NO_CONTENT));
        // Test with unexisting instance
        closeResponse(executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE_COMMENT, "unexistinginstance", "123")), HttpStatus.SC_NOT_FOUND));
        // Test with unexisting comment
        closeResponse(executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE_COMMENT, pi.getId(), "unexistingcomment")), HttpStatus.SC_NOT_FOUND));
    } finally {
        if (pi != null) {
            List<Comment> comments = taskService.getProcessInstanceComments(pi.getId());
            for (Comment c : comments) {
                taskService.deleteComment(c.getId());
            }
        }
    }
}
Also used : Comment(org.activiti.engine.task.Comment) HttpDelete(org.apache.http.client.methods.HttpDelete) HttpGet(org.apache.http.client.methods.HttpGet) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 63 with HttpDelete

use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.

the class UserResourceTest method testDeleteUser.

/**
   * Test deleting a single user.
   */
public void testDeleteUser() throws Exception {
    User savedUser = null;
    try {
        User newUser = identityService.newUser("testuser");
        newUser.setFirstName("Fred");
        newUser.setLastName("McDonald");
        newUser.setEmail("no-reply@activiti.org");
        identityService.saveUser(newUser);
        savedUser = newUser;
        closeResponse(executeRequest(new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId())), HttpStatus.SC_NO_CONTENT));
        // Check if user is deleted
        assertEquals(0, identityService.createUserQuery().userId(newUser.getId()).count());
        savedUser = null;
    } finally {
        // Delete user after test fails
        if (savedUser != null) {
            identityService.deleteUser(savedUser.getId());
        }
    }
}
Also used : User(org.activiti.engine.identity.User) HttpDelete(org.apache.http.client.methods.HttpDelete)

Example 64 with HttpDelete

use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.

the class JobResourceTest method testDeleteUnexistingJob.

/**
   * Test getting an unexisting job.
   */
public void testDeleteUnexistingJob() throws Exception {
    HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB, "unexistingjob"));
    CloseableHttpResponse response = executeRequest(httpDelete, HttpStatus.SC_NOT_FOUND);
    closeResponse(response);
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse)

Example 65 with HttpDelete

use of org.apache.http.client.methods.HttpDelete in project Activiti by Activiti.

the class ModelResourceTest method testDeleteUnexistingModel.

public void testDeleteUnexistingModel() throws Exception {
    HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL, "unexisting"));
    closeResponse(executeRequest(httpDelete, HttpStatus.SC_NOT_FOUND));
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete)

Aggregations

HttpDelete (org.apache.http.client.methods.HttpDelete)108 HttpResponse (org.apache.http.HttpResponse)25 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)22 Test (org.junit.Test)21 HttpGet (org.apache.http.client.methods.HttpGet)16 HttpPut (org.apache.http.client.methods.HttpPut)16 HttpPost (org.apache.http.client.methods.HttpPost)15 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)14 IOException (java.io.IOException)12 Deployment (org.activiti.engine.test.Deployment)12 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)11 Task (org.activiti.engine.task.Task)9 StringEntity (org.apache.http.entity.StringEntity)9 URI (java.net.URI)7 RequestExecutor (org.apache.stanbol.commons.testing.http.RequestExecutor)7 URISyntaxException (java.net.URISyntaxException)6 Header (org.apache.http.Header)6 HttpEntity (org.apache.http.HttpEntity)6 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)6 User (org.activiti.engine.identity.User)5