Example usage for org.springframework.http HttpMethod DELETE

List of usage examples for org.springframework.http HttpMethod DELETE

Introduction

In this page you can find the example usage for org.springframework.http HttpMethod DELETE.

Prototype

HttpMethod DELETE

To view the source code for org.springframework.http HttpMethod DELETE.

Click Source Link

Usage

From source file:com.ge.predix.test.utils.PrivilegeHelper.java

public void deleteResource(final RestTemplate restTemplate, final String acsUrl, final String resourceId,
        final HttpHeaders headers) throws Exception {
    if (resourceId != null) {
        URI resourceUri = URI.create(acsUrl + ACS_RESOURCE_API_PATH + URLEncoder.encode(resourceId, "UTF-8"));
        restTemplate.exchange(resourceUri, HttpMethod.DELETE, new HttpEntity<>(headers), String.class);
    }//from   ww  w  . j  a  va 2  s  .co  m
}

From source file:org.mitreid.multiparty.web.ResourceController.java

/**
 * @param oldSharedResourceSet/*from  w  ww. j ava2s. c o  m*/
 * @param accessTokenValue
 */
private void unregisterOldResourceSet(SharedResourceSet oldSharedResourceSet, String accessTokenValue,
        Principal p) {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    headers.add("Authorization", "Bearer " + accessTokenValue);

    HttpEntity<String> request = new HttpEntity<>(headers);

    restTemplate.exchange(oldSharedResourceSet.getLocation(), HttpMethod.DELETE, request, String.class);

    resourceService.unshareResourceSet(p);
}

From source file:gateway.test.DeploymentTests.java

/**
 * Test deleting a deployment group//from w w  w. j  a  va  2s . c o m
 */
@Test
public void testDeleteDeploymentGroup() {
    // Mock
    Mockito.doReturn(new ResponseEntity<PiazzaResponse>(new SuccessResponse(), HttpStatus.OK))
            .when(restTemplate).exchange(Mockito.anyString(), Mockito.eq(HttpMethod.DELETE), Mockito.any(),
                    Mockito.eq(PiazzaResponse.class));

    // Test
    ResponseEntity<PiazzaResponse> response = deploymentController.deleteDeploymentGroup("123456", user);

    // Verify
    assertTrue(response.getBody() instanceof SuccessResponse);
}

From source file:com.ge.predix.integration.test.PrivilegeManagementAccessControlServiceIT.java

public void testCreateBatchSubjectsWithMalformedJSON() {
    try {/*from   w  w w . j a  v a2 s  .co  m*/
        String badSubject = "{\"subject\":{\"name\" : \"good-subject-brittany\"},"
                + "{\"subject\": bad-subject-sarah\"}";
        MultiValueMap<String, String> headers = new HttpHeaders();
        headers.add("Content-type", "application/json");
        headers.add(PolicyHelper.PREDIX_ZONE_ID, this.acsZone1Name);
        HttpEntity<String> httpEntity = new HttpEntity<String>(badSubject, headers);
        this.acsAdminRestTemplate.postForEntity(this.acsUrl + PrivilegeHelper.ACS_SUBJECT_API_PATH, httpEntity,
                Subject[].class);
    } catch (HttpClientErrorException e) {
        Assert.assertEquals(e.getStatusCode(), HttpStatus.BAD_REQUEST);
        return;
    }
    this.acsAdminRestTemplate.exchange(
            this.acsUrl + PrivilegeHelper.ACS_SUBJECT_API_PATH + "/bad-subject-sarah", HttpMethod.DELETE,
            new HttpEntity<>(this.zone1Headers), ResponseEntity.class);
    this.acsAdminRestTemplate.exchange(
            this.acsUrl + PrivilegeHelper.ACS_SUBJECT_API_PATH + "/good-subject-brittany", HttpMethod.DELETE,
            new HttpEntity<>(this.zone1Headers), ResponseEntity.class);
    Assert.fail("testCreateBatchSubjectsWithMalformedJSON should have failed!");
}

From source file:com.orange.ngsi2.client.Ngsi2Client.java

/**
 * Delete an entity/*from   w ww . j av a  2 s  .  c  o m*/
 * @param entityId the entity ID
 * @param type optional entity type to avoid ambiguity when multiple entities have the same ID, null or zero-length for empty
 * @return the listener to notify of completion
 */
public ListenableFuture<Void> deleteEntity(String entityId, String type) {
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseURL);
    builder.path("v2/entities/{entityId}");
    addParam(builder, "type", type);
    return adapt(request(HttpMethod.DELETE, builder.buildAndExpand(entityId).toUriString(), null, Void.class));
}

From source file:org.cloudfoundry.identity.uaa.integration.ClientAdminEndpointsIntegrationTests.java

@Test
public void testDeleteClient() throws Exception {
    BaseClientDetails client = createClient("client_credentials");

    client.setResourceIds(Collections.singleton("foo"));

    ResponseEntity<Void> result = serverRunning.getRestTemplate().exchange(
            serverRunning.getUrl("/oauth/clients/{client}"), HttpMethod.DELETE,
            new HttpEntity<BaseClientDetails>(client, headers), Void.class, client.getClientId());
    assertEquals(HttpStatus.OK, result.getStatusCode());
}

From source file:de.hska.ld.core.AbstractIntegrationTest.java

protected HttpRequestWrapper delete() {
    return new HttpRequestWrapper(HttpMethod.DELETE);
}

From source file:com.appglu.impl.CrudTemplateTest.java

@Test
public void delete() {
    mockServer.expect(requestTo("http://localhost/appglu/v1/tables/user/1"))
            .andExpect(method(HttpMethod.DELETE)).andRespond(withSuccess().headers(responseHeaders));

    boolean success = crudOperations.delete("user", 1);
    Assert.assertTrue(success);//from  w ww. j  a va 2s  . com

    mockServer.verify();
}

From source file:com.orange.ngsi2.client.Ngsi2ClientTest.java

@Test
public void testDeleteEntity_OK() throws Exception {

    mockServer.expect(requestTo(baseURL + "/v2/entities/room1?type=Room")).andExpect(method(HttpMethod.DELETE))
            .andRespond(withNoContent());

    ngsiClient.deleteEntity("room1", "Room").get();
}

From source file:ru.anr.base.facade.web.api.RestClient.java

/**
 * PUT method./*from   w ww .  ja va2  s  . c om*/
 * 
 * @param path
 *            Relative or absolute path
 * @return Response with a body and state
 */
public ResponseEntity<String> delete(String path) {

    return exchange(path, HttpMethod.DELETE, null, String.class);
}