List of usage examples for org.springframework.http MediaType ALL
MediaType ALL
To view the source code for org.springframework.http MediaType ALL.
Click Source Link
From source file:org.craftercms.studio.controller.services.rest.RepositoryControllerTest.java
@Test public void testDeleteContentMissingItems() throws Exception { doAnswer(new Answer<Void>() { @Override/*from w ww .j av a2 s . co m*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.contentManagerMock).delete(Mockito.any(Context.class), Mockito.anyListOf(Item.class)); this.mockMvc .perform( post("/api/1/content/delete/site").accept(MediaType.ALL).content((new String()).getBytes())) .andExpect(status().isBadRequest()); verify(this.contentManagerMock, times(0)).delete(Mockito.any(Context.class), Mockito.anyListOf(Item.class)); }
From source file:org.craftercms.studio.controller.services.rest.RepositoryControllerTest.java
@Test public void testCopy() throws Exception { doAnswer(new Answer<Void>() { @Override/*from w ww .j a v a 2s. c o m*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.contentManagerMock).copy(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString(), Mockito.anyBoolean()); String itemsJSONList = generateRequestBody(generateItemListMock()); this.mockMvc.perform(post("/api/1/content/copy/site").accept(MediaType.ALL) .param("destinationPath", RandomStringUtils.randomAlphabetic(10)) .param("includeChildren", (new Random()).nextBoolean() ? "true" : "false") .content(itemsJSONList.getBytes())).andExpect(status().isOk()); verify(this.contentManagerMock, times(1)).copy(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString(), Mockito.anyBoolean()); }
From source file:org.craftercms.studio.controller.services.rest.RepositoryControllerTest.java
@Test public void testCopyMissingIncludeChildren() throws Exception { doAnswer(new Answer<Void>() { @Override/*w w w . j a v a 2 s . c o m*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.contentManagerMock).copy(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString(), Mockito.anyBoolean()); String itemsJSONList = generateRequestBody(generateItemListMock()); this.mockMvc.perform(post("/api/1/content/copy/site").accept(MediaType.ALL) .param("destinationPath", RandomStringUtils.randomAlphabetic(10)).content(itemsJSONList.getBytes())) .andExpect(status().isOk()); verify(this.contentManagerMock, times(1)).copy(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString(), Mockito.eq(true)); }
From source file:org.craftercms.studio.controller.services.rest.RepositoryControllerTest.java
@Test public void testCopyMissingDestinationPath() throws Exception { doAnswer(new Answer<Void>() { @Override// w w w. ja va2 s .co m public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.contentManagerMock).copy(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString(), Mockito.anyBoolean()); String itemsJSONList = generateRequestBody(generateItemListMock()); this.mockMvc.perform(post("/api/1/content/copy/site").accept(MediaType.ALL) .param("includeChildren", (new Random()).nextBoolean() ? "true" : "false") .content(itemsJSONList.getBytes())).andExpect(status().isBadRequest()); verify(this.contentManagerMock, times(0)).copy(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString(), Mockito.anyBoolean()); }
From source file:org.craftercms.studio.controller.services.rest.RepositoryControllerTest.java
@Test public void testCopyMissingItems() throws Exception { doAnswer(new Answer<Void>() { @Override/* ww w .j a va 2 s . co m*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.contentManagerMock).copy(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString(), Mockito.anyBoolean()); this.mockMvc.perform(post("/api/1/content/copy/site").accept(MediaType.ALL) .param("destinationPath", RandomStringUtils.randomAlphabetic(10)) .param("includeChildren", (new Random()).nextBoolean() ? "true" : "false") .content(StringUtils.EMPTY.getBytes())).andExpect(status().isBadRequest()); verify(this.contentManagerMock, times(0)).copy(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString(), Mockito.anyBoolean()); }
From source file:org.craftercms.studio.controller.services.rest.RepositoryControllerTest.java
@Test public void testMove() throws Exception { doAnswer(new Answer<Void>() { @Override/*w w w .j av a 2 s . c om*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.contentManagerMock).move(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString()); String itemsJSONList = generateRequestBody(generateItemListMock()); this.mockMvc.perform(post("/api/1/content/move/site").accept(MediaType.ALL) .param("destinationPath", RandomStringUtils.randomAlphabetic(10)).content(itemsJSONList.getBytes())) .andExpect(status().isOk()); verify(this.contentManagerMock, times(1)).move(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString()); }
From source file:org.craftercms.studio.controller.services.rest.RepositoryControllerTest.java
@Test public void testMoveMissingItems() throws Exception { doAnswer(new Answer<Void>() { @Override/*from w ww . ja v a 2s. co m*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.contentManagerMock).move(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString()); this.mockMvc.perform(post("/api/1/content/move/site").accept(MediaType.ALL) .param("destinationPath", RandomStringUtils.randomAlphabetic(10)) .content(StringUtils.EMPTY.getBytes())).andExpect(status().isBadRequest()); verify(this.contentManagerMock, times(0)).move(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString()); }
From source file:org.craftercms.studio.controller.services.rest.RepositoryControllerTest.java
@Test public void testMoveMissingDestinationPath() throws Exception { doAnswer(new Answer<Void>() { @Override/*from w w w . j av a 2 s. c o m*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.contentManagerMock).move(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString()); String itemsJSONList = generateRequestBody(generateItemListMock()); this.mockMvc .perform(post("/api/1/content/move/site").accept(MediaType.ALL).content(itemsJSONList.getBytes())) .andExpect(status().isBadRequest()); verify(this.contentManagerMock, times(0)).move(Mockito.any(Context.class), Mockito.anyListOf(Item.class), Mockito.anyString()); }
From source file:org.craftercms.studio.controller.services.rest.RepositoryControllerTest.java
@Test public void testLock() throws Exception { when(this.contentManagerMock.lock(Mockito.any(Context.class), Mockito.anyListOf(Item.class))) .thenReturn(createLockHandleMock()); String itemsJSONList = generateRequestBody(generateItemListMock()); this.mockMvc/*from w w w.j a v a2s. c o m*/ .perform(post("/api/1/content/lock/site").accept(MediaType.ALL).content(itemsJSONList.getBytes())) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)); verify(this.contentManagerMock, times(1)).lock(Mockito.any(Context.class), Mockito.anyListOf(Item.class)); }
From source file:org.craftercms.studio.controller.services.rest.RepositoryControllerTest.java
@Test public void testLockMissingItems() throws Exception { when(this.contentManagerMock.lock(Mockito.any(Context.class), Mockito.anyListOf(Item.class))) .thenReturn(createLockHandleMock()); this.mockMvc.perform( post("/api/1/content/lock/site").accept(MediaType.ALL).content(StringUtils.EMPTY.getBytes())) .andExpect(status().isBadRequest()); verify(this.contentManagerMock, times(0)).lock(Mockito.any(Context.class), Mockito.anyListOf(Item.class)); }