generated from 2martens/template-service
Added operation to request all agenda items in a body
This commit is contained in:
parent
c3c20d9ecf
commit
d2b8ae5b6d
|
@ -252,6 +252,24 @@ public class OParlController {
|
|||
});
|
||||
}
|
||||
|
||||
@GetMapping("/body/{id}/agendaItems")
|
||||
@Operation(summary = "List of all agenda items in body",
|
||||
description = "returns a list of all agenda items in requested body", responses = {
|
||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.class))),
|
||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||
schema = @Schema(implementation = ErrorObject.class)))
|
||||
})
|
||||
public ObjectList<AgendaItem> agendaItemsInBody(
|
||||
@PathVariable
|
||||
@Parameter(description = "body ID", example = "0")
|
||||
String id) {
|
||||
log.info("invoked method /v1.1/body/{}/agendaItems", id);
|
||||
return service.getAgendaItemsInBody(id).orElseThrow(() -> {
|
||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
||||
});
|
||||
}
|
||||
|
||||
@GetMapping("/agendaItem/{id}")
|
||||
@Operation(summary = "information about agenda item", description = "returns the requested agenda item", responses = {
|
||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||
|
|
|
@ -16,6 +16,10 @@ public class OParlService {
|
|||
this.properties = properties;
|
||||
}
|
||||
|
||||
public Optional<ObjectList<AgendaItem>> getAgendaItemsInBody(String bodyID) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public Optional<AgendaItem> getAgendaItem(String id) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
|
|
@ -303,6 +303,24 @@ class OParlControllerTest {
|
|||
.andReturn();
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnAgendaItemsInBody() throws Exception {
|
||||
BDDMockito.given(service.getAgendaItemsInBody("0"))
|
||||
.willReturn(Optional.of(
|
||||
ObjectList.<AgendaItem>builder().data(List.of(testItem)).pagination(testPagination).links(testLinks).build()
|
||||
));
|
||||
|
||||
mvc.perform(MockMvcRequestBuilders.get("/v1.1/body/0/agendaItems")
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.aMapWithSize(3)))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data", Matchers.hasSize(1)))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0]", Matchers.aMapWithSize(11)))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/AgendaItem")))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0].deleted", Matchers.equalTo(false)))
|
||||
.andReturn();
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnAgendaItem() throws Exception {
|
||||
BDDMockito.given(service.getAgendaItem("0"))
|
||||
|
|
Loading…
Reference in New Issue