mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-23 14:40:49 +08:00
Add update endpoints for tags and categories
This commit is contained in:
@@ -64,4 +64,23 @@ class CategoryControllerTest {
|
||||
.andExpect(jsonPath("$[0].describe").value("d2"))
|
||||
.andExpect(jsonPath("$[0].icon").value("i2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateCategory() throws Exception {
|
||||
Category c = new Category();
|
||||
c.setId(3L);
|
||||
c.setName("tech");
|
||||
c.setDescribe("d3");
|
||||
c.setIcon("i3");
|
||||
Mockito.when(categoryService.updateCategory(eq(3L), eq("tech"), eq("d3"), eq("i3"))).thenReturn(c);
|
||||
|
||||
mockMvc.perform(put("/api/categories/3")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content("{\"name\":\"tech\",\"describe\":\"d3\",\"icon\":\"i3\"}"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.id").value(3))
|
||||
.andExpect(jsonPath("$.name").value("tech"))
|
||||
.andExpect(jsonPath("$.describe").value("d3"))
|
||||
.andExpect(jsonPath("$.icon").value("i3"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,4 +65,23 @@ class TagControllerTest {
|
||||
.andExpect(jsonPath("$[0].describe").value("d2"))
|
||||
.andExpect(jsonPath("$[0].icon").value("i2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateTag() throws Exception {
|
||||
Tag t = new Tag();
|
||||
t.setId(3L);
|
||||
t.setName("java");
|
||||
t.setDescribe("d3");
|
||||
t.setIcon("i3");
|
||||
Mockito.when(tagService.updateTag(eq(3L), eq("java"), eq("d3"), eq("i3"))).thenReturn(t);
|
||||
|
||||
mockMvc.perform(put("/api/tags/3")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content("{\"name\":\"java\",\"describe\":\"d3\",\"icon\":\"i3\"}"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.id").value(3))
|
||||
.andExpect(jsonPath("$.name").value("java"))
|
||||
.andExpect(jsonPath("$.describe").value("d3"))
|
||||
.andExpect(jsonPath("$.icon").value("i3"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user