Browse Source

Added operation to request all agenda items in a body

master
Jim Martens 10 months ago
parent
commit
d2b8ae5b6d
  1. 18
      oparl-server/src/main/java/de/twomartens/oparlservice/control/OParlController.java
  2. 4
      oparl-server/src/main/java/de/twomartens/oparlservice/service/OParlService.java
  3. 18
      oparl-server/src/test/java/de/twomartens/oparlservice/control/OParlControllerTest.java

18
oparl-server/src/main/java/de/twomartens/oparlservice/control/OParlController.java

@ -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",

4
oparl-server/src/main/java/de/twomartens/oparlservice/service/OParlService.java

@ -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();
}

18
oparl-server/src/test/java/de/twomartens/oparlservice/control/OParlControllerTest.java

@ -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…
Cancel
Save