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.DeploymentControllerTest.java
@Test public void testUpdateChannel() throws Exception { doAnswer(new Answer<Void>() { @Override//from w ww .j a v a 2 s. c o m public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.deploymentManagerMock).updateChannel(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class)); this.mockMvc.perform(post("/api/1/deployment/update_channel/sample").contentType(MediaType.APPLICATION_JSON) .content(generateRequestBody(createDeploymentChannelMock()).getBytes()).accept(MediaType.ALL)) .andExpect(status().isOk()); verify(this.deploymentManagerMock, times(1)).updateChannel(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class)); }
From source file:org.craftercms.studio.controller.services.rest.DeploymentControllerTest.java
@Test public void testUpdateChannelMissingRequestBody() throws Exception { doAnswer(new Answer<Void>() { @Override/* w ww . j a v a 2 s.c om*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.deploymentManagerMock).updateChannel(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class)); this.mockMvc .perform(post("/api/1/deployment/update_channel/sample").contentType(MediaType.APPLICATION_JSON) .content(StringUtils.EMPTY.getBytes()).accept(MediaType.ALL)) .andExpect(status().isBadRequest()); verify(this.deploymentManagerMock, times(0)).updateChannel(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class)); }
From source file:org.craftercms.studio.controller.services.rest.DeploymentControllerTest.java
@Test public void testRemoveChannel() throws Exception { doAnswer(new Answer<Void>() { @Override/*w w w . j ava 2 s. c o m*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.deploymentManagerMock).removeChannel(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class)); this.mockMvc.perform(post("/api/1/deployment/remove_channel/sample").contentType(MediaType.APPLICATION_JSON) .content(generateRequestBody(createDeploymentChannelMock()).getBytes()).accept(MediaType.ALL)) .andExpect(status().isOk()); verify(this.deploymentManagerMock, times(1)).removeChannel(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class)); }
From source file:org.craftercms.studio.controller.services.rest.DeploymentControllerTest.java
@Test public void testRemoveChannelMissingRequestBody() throws Exception { doAnswer(new Answer<Void>() { @Override/*from w ww. j a v a 2s . c om*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.deploymentManagerMock).removeChannel(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class)); this.mockMvc .perform(post("/api/1/deployment/remove_channel/sample").contentType(MediaType.APPLICATION_JSON) .content(StringUtils.EMPTY.getBytes()).accept(MediaType.ALL)) .andExpect(status().isBadRequest()); verify(this.deploymentManagerMock, times(0)).removeChannel(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class)); }
From source file:org.craftercms.studio.controller.services.rest.DeploymentControllerTest.java
@Test public void testDeploy() throws Exception { doAnswer(new Answer<Void>() { @Override/*from ww w . ja v a2 s . co m*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.deploymentManagerMock).deploy(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyListOf(String.class)); this.mockMvc .perform(post("/api/1/deployment/deploy/sample").param("itemIds", UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString()).accept(MediaType.ALL)) .andExpect(status().isOk()); verify(this.deploymentManagerMock, times(1)).deploy(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyListOf(String.class)); }
From source file:org.craftercms.studio.controller.services.rest.DeploymentControllerTest.java
@Test public void testDeployMissingItems() throws Exception { doAnswer(new Answer<Void>() { @Override/*from w w w. j a v a 2 s . co m*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.deploymentManagerMock).deploy(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyListOf(String.class)); this.mockMvc.perform(post("/api/1/deployment/deploy/sample").accept(MediaType.ALL)) .andExpect(status().isBadRequest()); verify(this.deploymentManagerMock, times(0)).deploy(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyListOf(String.class)); }
From source file:org.craftercms.studio.controller.services.rest.DeploymentControllerTest.java
@Test public void testStatus() throws Exception { when(this.deploymentManagerMock.status(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class))).thenReturn(RandomStringUtils.randomAlphanumeric(200)); this.mockMvc.perform(get("/api/1/deployment/status/sample").contentType(MediaType.APPLICATION_JSON) .content(generateRequestBody(createDeploymentChannelMock()).getBytes()).accept(MediaType.ALL)) .andExpect(status().isOk()); verify(this.deploymentManagerMock, times(1)).status(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class)); }
From source file:org.craftercms.studio.controller.services.rest.DeploymentControllerTest.java
@Test public void testStatusMissingChannel() throws Exception { when(this.deploymentManagerMock.status(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class))).thenReturn(RandomStringUtils.randomAlphanumeric(200)); this.mockMvc/*from w w w . j av a 2 s .c om*/ .perform(get("/api/1/deployment/status/sample").contentType(MediaType.APPLICATION_JSON) .content(StringUtils.EMPTY.getBytes()).accept(MediaType.ALL)) .andExpect(status().isBadRequest()); verify(this.deploymentManagerMock, times(0)).status(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class)); }
From source file:org.craftercms.studio.controller.services.rest.DeploymentControllerTest.java
@Test public void testVersion() throws Exception { when(this.deploymentManagerMock.version(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class))).thenReturn((long) (Math.random() * Long.MAX_VALUE)); this.mockMvc.perform(get("/api/1/deployment/version/sample").contentType(MediaType.APPLICATION_JSON) .content(generateRequestBody(createDeploymentChannelMock()).getBytes()).accept(MediaType.ALL)) .andExpect(status().isOk()); verify(this.deploymentManagerMock, times(1)).version(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class)); }
From source file:org.craftercms.studio.controller.services.rest.DeploymentControllerTest.java
@Test public void testVersionMissingRequestBody() throws Exception { when(this.deploymentManagerMock.version(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class))).thenReturn((long) (Math.random() * Long.MAX_VALUE)); this.mockMvc/*from ww w . jav a2 s . c o m*/ .perform(get("/api/1/deployment/version/sample").contentType(MediaType.APPLICATION_JSON) .content(StringUtils.EMPTY.getBytes()).accept(MediaType.ALL)) .andExpect(status().isBadRequest()); verify(this.deploymentManagerMock, times(0)).version(Mockito.any(Context.class), Mockito.anyString(), Mockito.any(DeploymentChannel.class)); }