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.DependencyControllerTest.java
@Test public void testListMissingItemId() throws Exception { when(this.dependencyManagerMock.dependsOn(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString())).thenReturn(generateItemListMock()); this.mockMvc.perform(get("/api/1/dependency/list/sample?operation=op").accept(MediaType.ALL)) .andExpect(status().isBadRequest()); verify(this.dependencyManagerMock, times(0)).dependsOn(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString());/*from w w w . ja va2s . c om*/ }
From source file:org.craftercms.studio.controller.services.rest.DependencyControllerTest.java
@Test public void testListMissingOperation() throws Exception { when(this.dependencyManagerMock.dependsOn(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString())).thenReturn(generateItemListMock()); this.mockMvc.perform(get("/api/1/dependency/list/sample?itemId=1").accept(MediaType.ALL)) .andExpect(status().isBadRequest()); verify(this.dependencyManagerMock, times(0)).dependsOn(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString());// w ww .ja va2s . c o m }
From source file:org.craftercms.studio.controller.services.rest.DependencyControllerTest.java
@Test public void testRefresh() throws Exception { when(this.dependencyManagerMock.refresh(Mockito.any(Context.class), Mockito.anyString())) .thenReturn(generateItemListMock()); this.mockMvc.perform(get("/api/1/dependency/refresh/sample?itemId=1").accept(MediaType.ALL)) .andExpect(status().isOk()); verify(this.dependencyManagerMock, times(1)).refresh(Mockito.any(Context.class), Mockito.anyString()); }
From source file:org.craftercms.studio.controller.services.rest.DependencyControllerTest.java
@Test public void testRefreshMissingItemId() throws Exception { when(this.dependencyManagerMock.refresh(Mockito.any(Context.class), Mockito.anyString())) .thenReturn(generateItemListMock()); this.mockMvc.perform(get("/api/1/dependency/refresh/sample").accept(MediaType.ALL)) .andExpect(status().isBadRequest()); verify(this.dependencyManagerMock, times(0)).refresh(Mockito.any(Context.class), Mockito.anyString()); }
From source file:org.craftercms.studio.controller.services.rest.DependencyControllerTest.java
@Test public void testAdd() throws Exception { doAnswer(new Answer<Void>() { @Override//from www . jav a 2 s . c o m public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.dependencyManagerMock).add(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.anyListOf(Item.class)); String itemsJSONList = generateRequestBody(generateItemListMock()); this.mockMvc.perform(post("/api/1/dependency/add/sample").accept(MediaType.ALL).param("itemId", "1") .param("operation", RandomStringUtils.randomAlphabetic(10)).content(itemsJSONList.getBytes())) .andExpect(status().isOk()); verify(this.dependencyManagerMock, times(1)).add(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.anyListOf(Item.class)); }
From source file:org.craftercms.studio.controller.services.rest.DependencyControllerTest.java
@Test public void testAddMissingItemId() throws Exception { doAnswer(new Answer<Void>() { @Override//from ww 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.dependencyManagerMock).add(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.anyListOf(Item.class)); String itemsJSONList = generateRequestBody(generateItemListMock()); this.mockMvc.perform(post("/api/1/dependency/add/sample").accept(MediaType.ALL) .param("operation", RandomStringUtils.randomAlphabetic(10)).content(itemsJSONList.getBytes())) .andExpect(status().isBadRequest()); verify(this.dependencyManagerMock, times(0)).add(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.anyListOf(Item.class)); }
From source file:org.craftercms.studio.controller.services.rest.DependencyControllerTest.java
@Test public void testAddMissingOperation() throws Exception { doAnswer(new Answer<Void>() { @Override//www . j a v a2 s . co m public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.dependencyManagerMock).add(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.anyListOf(Item.class)); String itemsJSONList = generateRequestBody(generateItemListMock()); this.mockMvc.perform(post("/api/1/dependency/add/sample").accept(MediaType.ALL).param("itemId", "1") .content(itemsJSONList.getBytes())).andExpect(status().isBadRequest()); verify(this.dependencyManagerMock, times(0)).add(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.anyListOf(Item.class)); }
From source file:org.craftercms.studio.controller.services.rest.DependencyControllerTest.java
@Test public void testAddMissingDependencies() throws Exception { doAnswer(new Answer<Void>() { @Override// w w w. j a va 2 s .c om public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.dependencyManagerMock).add(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.anyListOf(Item.class)); this.mockMvc.perform(post("/api/1/dependency/add/sample").accept(MediaType.ALL).param("itemId", "1") .param("operation", RandomStringUtils.randomAlphabetic(10)).content(StringUtils.EMPTY.getBytes())) .andExpect(status().isBadRequest()); verify(this.dependencyManagerMock, times(0)).add(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.anyListOf(Item.class)); }
From source file:org.craftercms.studio.controller.services.rest.DependencyControllerTest.java
@Test public void testRemove() throws Exception { doAnswer(new Answer<Void>() { @Override/*w w w. j a va 2 s .c o m*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.dependencyManagerMock).remove(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.anyListOf(Item.class)); String itemsJSONList = generateRequestBody(generateItemListMock()); this.mockMvc.perform(post("/api/1/dependency/remove/sample").accept(MediaType.ALL).param("itemId", "1") .param("operation", RandomStringUtils.randomAlphabetic(10)).content(itemsJSONList.getBytes())) .andExpect(status().isOk()); verify(this.dependencyManagerMock, times(1)).remove(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.anyListOf(Item.class)); }
From source file:org.craftercms.studio.controller.services.rest.DependencyControllerTest.java
@Test public void testRemoveMissingItemId() throws Exception { doAnswer(new Answer<Void>() { @Override/*from w w w . j a va 2 s. c om*/ public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.dependencyManagerMock).remove(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.anyListOf(Item.class)); String itemsJSONList = generateRequestBody(generateItemListMock()); this.mockMvc.perform(post("/api/1/dependency/remove/sample").accept(MediaType.ALL) .param("operation", RandomStringUtils.randomAlphabetic(10)).content(itemsJSONList.getBytes())) .andExpect(status().isBadRequest()); verify(this.dependencyManagerMock, times(0)).remove(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.anyListOf(Item.class)); }