public void isNoContent(String restMapping, MockMvc mockMvc) throws Exception { obtainResultActions(restMapping, mockMvc, null).andExpect(status().isNoContent()); }
public void isNoContent(String restMapping, MockMvc mockMvc, Object object) throws Exception { obtainResultActions(restMapping, mockMvc, object).andExpect(status().isNoContent()); }
public void isNoContent(String restMapping, MockMvc mockMvc, Object object) throws Exception { obtainResultActions(restMapping, mockMvc, object).andExpect(status().isNoContent()); }
public void isNoContent(String restMapping, MockMvc mockMvc, Map<String, String> param) throws Exception { obtainResultActions(restMapping, mockMvc, param).andExpect(status().isNoContent()); }
@Test public void whenCommitValidCursorsThenNoContent() throws Exception { when(cursorsService.commitCursors(any(), any(), any())) .thenReturn(ImmutableList.of()); postCursors(DUMMY_CURSORS) .andExpect(status().isNoContent()); }
/** * 获取Mock测试请求结果是否为204 * * @param mvc * @param builder * @return * @throws Exception */ public ResultActions isNoContent(MockMvc mvc, MockHttpServletRequestBuilder builder) throws Exception { return getResultActions(mvc, builder).andExpect(MockMvcResultMatchers.status().isNoContent()); }
@Test public void testDeleteUnusedStorage() throws Exception { doNothing().when(storageService).deleteStorage("s1", Optional.empty()); when(adminService.isAdmin(AuthorizationService.Operation.WRITE)).thenReturn(true); mockMvc.perform(delete("/storages/s1") .principal(mockPrincipal("nakadi"))) .andExpect(status().isNoContent()); }
@Test public void deleteOne() throws Exception { User user = json.readObject(new ClassPathResource("user.json")); mvc.perform(delete("/users/{id}", user.getId())) .andExpect(status().isNoContent()); } }
@Test public void shouldRespondWithNoContent() throws Exception { Mockito.when(chatClient.getMessagesAfter(null)).thenReturn(null); mockMvc.perform(get("/api/v1/messages") .accept(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isNoContent()); }
@Test public void delete_whenThereIsOneCredentialVersionWithTheCaseInsensitiveName_deletesTheCredential() throws Exception { RequestHelper.generateCa(mockMvc, CREDENTIAL_NAME, AuthConstants.ALL_PERMISSIONS_TOKEN); final MockHttpServletRequestBuilder request = delete("/api/v1/data?name=" + CREDENTIAL_NAME.toUpperCase()) .header("Authorization", "Bearer " + AuthConstants.ALL_PERMISSIONS_TOKEN); mockMvc.perform(request) .andExpect(status().isNoContent()); }
@Test public void whenDeleteSubscriptionThenNoContent() throws Exception { mockGetFromRepoSubscriptionWithOwningApp("sid", "nakadiClientId"); mockMvc.perform(delete("/subscriptions/sid")) .andExpect(status().isNoContent()); }
private void revokePermissions(final String credentialName, final String actorId) throws Exception { final MockHttpServletRequestBuilder request = delete(API_V1_PERMISSION_ENDPOINT + "?credential_name=" + credentialName + "&actor=" + actorId) .header("Authorization", "Bearer " + ALL_PERMISSIONS_TOKEN) .accept(APPLICATION_JSON); mockMvc.perform(request) .andExpect(status().isNoContent()); } }
@Test public void delete_whenThereIsOneCredentialVersionWithTheSlashPrependedName_deletesTheCredential() throws Exception { RequestHelper.generateCa(mockMvc, "/some-ca", AuthConstants.ALL_PERMISSIONS_TOKEN); final MockHttpServletRequestBuilder request = delete("/api/v1/data?name=" + "some-ca") .header("Authorization", "Bearer " + AuthConstants.ALL_PERMISSIONS_TOKEN); mockMvc.perform(request) .andExpect(status().isNoContent()); }
@Test public void deleteMessage() throws Exception { mockMvc.perform(delete("/messages/MSG003")) .andExpect(status().isNoContent()) .andExpect(content().string("")); }
@Test public void delete_whenThereAreMultipleCredentialVersionsWithTheName_deletesAllVersions() throws Exception { RequestHelper.generateCa(mockMvc, CREDENTIAL_NAME, AuthConstants.ALL_PERMISSIONS_TOKEN); RequestHelper.generateCa(mockMvc, CREDENTIAL_NAME, AuthConstants.ALL_PERMISSIONS_TOKEN); final MockHttpServletRequestBuilder request = delete("/api/v1/data?name=" + CREDENTIAL_NAME) .header("Authorization", "Bearer " + AuthConstants.ALL_PERMISSIONS_TOKEN); mockMvc.perform(request) .andExpect(status().isNoContent()); } }
@Test public void putMessage() throws Exception { mockMvc.perform(put("/messages/MSG003").contentType(MediaType.TEXT_PLAIN).content("MSG003")) .andExpect(status().isNoContent()) .andExpect(content().string("")); }
@Test public void DELETE_whenTheUserHasPermissionToDeleteTheCredential_succeeds() throws Exception { final MockHttpServletRequestBuilder deleteRequest = delete( "/api/v1/data?name=" + CREDENTIAL_NAME) .header("Authorization", "Bearer " + ALL_PERMISSIONS_TOKEN); mockMvc.perform(deleteRequest) .andExpect(status().isNoContent()); final MockHttpServletRequestBuilder getRequest = get("/api/v1/data?name=" + CREDENTIAL_NAME) .header("Authorization", "Bearer " + ALL_PERMISSIONS_TOKEN); mockMvc.perform(getRequest) .andExpect(status().isNotFound()); }
@Test @Description("Handles the DELETE request of deleting the auto assign distribution set from a target filter query within SP. Required Permission: DELETE_TARGET.") public void deleteAutoAssignDS() throws Exception { final TargetFilterQuery tfq = createTargetFilterQueryWithDS(createDistributionSet()); this.mockMvc .perform(delete( MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", tfq.getId())) .andExpect(status().isNoContent()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document(pathParameters( parameterWithName("targetFilterQueryId").description(ApiModelPropertiesGeneric.ITEM_ID)))); }
@Test @Description("Cancels an active action, only active actions can be deleted. Required Permission: UPDATE_TARGET.") public void deleteActionFromTarget() throws Exception { final Action actions = generateActionForTarget(targetId, false); mockMvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/{actionId}", targetId, actions.getId())) .andExpect(status().isNoContent()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID), parameterWithName("actionId").description(ApiModelPropertiesGeneric.ITEM_ID)))); }
@Test public void disconnect() throws Exception { FacebookConnectionFactory connectionFactory = new FacebookConnectionFactory("clientId", CLIENT_SECRET); Connection<Facebook> connection = connectionFactory.createConnection(new ConnectionData("facebook", "738140579", "", "", "", "", "", "", null)); StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository(); ConnectionRepository connectionRepository = usersConnectionRepository.createConnectionRepository("habuma"); connectionRepository.addConnection(connection); assertEquals(1, connectionRepository.findAllConnections().size()); DisconnectController controller = new DisconnectController(usersConnectionRepository, CLIENT_SECRET); MockMvc mockMvc = standaloneSetup(controller).build(); mockMvc.perform(post("/disconnect/facebook").param("signed_request", SIGNED_REQUEST)) .andExpect(status().isNoContent()); assertEquals(0, connectionRepository.findAllConnections().size()); }