use of org.springframework.test.web.servlet.MockMvc in project spring-sync by spring-projects.
the class DiffSyncControllerTest method patchRemovesAnItem.
@Test
public void patchRemovesAnItem() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
mvc.perform(patch(RESOURCE_PATH).content(resource("patch-remove-item")).accept(JSON_PATCH).contentType(JSON_PATCH)).andExpect(status().isOk()).andExpect(content().string("[]")).andExpect(content().contentType(JSON_PATCH));
List<Todo> all = (List<Todo>) repository.findAll();
assertEquals(2, all.size());
assertEquals(all.get(0), new Todo(1L, "A", false));
assertEquals(all.get(1), new Todo(3L, "C", false));
}
use of org.springframework.test.web.servlet.MockMvc in project spring-sync by spring-projects.
the class DiffSyncControllerTest method patchUpdatesStatusOnOneItemAndRemovesTwoOtherItems.
@Test
public void patchUpdatesStatusOnOneItemAndRemovesTwoOtherItems() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
mvc.perform(patch(RESOURCE_PATH).content(resource("patch-change-status-and-delete-two-items")).accept(JSON_PATCH).contentType(JSON_PATCH)).andExpect(status().isOk()).andExpect(content().string("[]")).andExpect(content().contentType(JSON_PATCH));
List<Todo> all = (List<Todo>) repository.findAll();
assertEquals(1, all.size());
assertEquals(all.get(0), new Todo(1L, "A", true));
}
use of org.springframework.test.web.servlet.MockMvc in project spring-sync by spring-projects.
the class DiffSyncControllerTest method patchSendsEntityDescriptionChange.
@Test
public void patchSendsEntityDescriptionChange() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
mvc.perform(patch(RESOURCE_PATH + "/2").content(resource("patch-change-entity-description")).accept(JSON_PATCH).contentType(JSON_PATCH)).andExpect(status().isOk()).andExpect(content().string("[]")).andExpect(content().contentType(JSON_PATCH));
List<Todo> all = (List<Todo>) repository.findAll();
assertEquals(3, all.size());
assertEquals(new Todo(1L, "A", false), all.get(0));
assertEquals(new Todo(2L, "BBB", false), all.get(1));
assertEquals(new Todo(3L, "C", false), all.get(2));
}
use of org.springframework.test.web.servlet.MockMvc in project spring-sync by spring-projects.
the class DiffSyncControllerTest method patchRemovesTwoItems.
@Test
public void patchRemovesTwoItems() throws Exception {
TodoRepository todoRepository = todoRepository();
MockMvc mvc = mockMvc(todoRepository);
mvc.perform(patch(RESOURCE_PATH).content(resource("patch-remove-two-items")).accept(JSON_PATCH).contentType(JSON_PATCH)).andExpect(status().isOk()).andExpect(content().string("[]")).andExpect(content().contentType(JSON_PATCH));
List<Todo> all = (List<Todo>) repository.findAll();
assertEquals(1, all.size());
assertEquals(all.get(0), new Todo(1L, "A", false));
}
use of org.springframework.test.web.servlet.MockMvc in project spring-boot by spring-projects.
the class MetricFilterAutoConfigurationTests method gaugeServiceThatThrows.
@Test
public void gaugeServiceThatThrows() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class, MetricFilterAutoConfiguration.class);
GaugeService gaugeService = context.getBean(GaugeService.class);
willThrow(new IllegalStateException()).given(gaugeService).submit(anyString(), anyDouble());
Filter filter = context.getBean(Filter.class);
MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController()).addFilter(filter).build();
mvc.perform(get("/templateVarTest/foo")).andExpect(status().isOk());
verify(context.getBean(CounterService.class)).increment("status.200.templateVarTest.someVariable");
verify(context.getBean(GaugeService.class)).submit(eq("response.templateVarTest.someVariable"), anyDouble());
context.close();
}
Aggregations