Browse Source

Added operation to retrieve single agenda item

master
Jim Martens 10 months ago
parent
commit
8787784067
  1. 10
      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. 39
      oparl-server/src/test/java/de/twomartens/oparlservice/control/OParlControllerTest.java

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

@ -156,4 +156,14 @@ public class OParlController {
log.info("invoked method /v1.1/meeting/{}", id);
return service.getMeeting(id);
}
@GetMapping("/agendaItem/{id}")
@Operation(summary = "information about agenda item", description = "returns the requested agenda item")
public AgendaItem agendaItem(
@PathVariable
@Parameter(description = "agendaItem ID", example = "0")
String id) {
log.info("invoked method /v1.1/agendaItem/{}", id);
return service.getAgendaItem(id);
}
}

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

@ -73,6 +73,10 @@ public class OParlService {
.build();
}
public AgendaItem getAgendaItem(String id) {
return null;
}
public List<Body> getBodies() {
return List.of(exampleBody);
}

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

@ -29,12 +29,17 @@ class OParlControllerTest {
@MockBean
private OParlService service;
private AgendaItem testItem;
private Body testBody;
private Consultation testConsultation;
private File testFile;
private LegislativeTerm testTerm;
private Location testLocation;
private Meeting testMeeting;
private Membership testMembership;
private Organization testOrganization;
private Organization testPartyOrganization;
private Paper testPaper;
private Person testPerson;
private System testSystem;
@ -214,7 +219,7 @@ class OParlControllerTest {
.contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(1)))
.andExpect(MockMvcResultMatchers.jsonPath("$[0]", Matchers.aMapWithSize(8)))
.andExpect(MockMvcResultMatchers.jsonPath("$[0]", Matchers.aMapWithSize(9)))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/Meeting")))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].deleted", Matchers.equalTo(false)))
.andReturn();
@ -229,7 +234,7 @@ class OParlControllerTest {
.contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(1)))
.andExpect(MockMvcResultMatchers.jsonPath("$[0]", Matchers.aMapWithSize(8)))
.andExpect(MockMvcResultMatchers.jsonPath("$[0]", Matchers.aMapWithSize(9)))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/Meeting")))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].deleted", Matchers.equalTo(false)))
.andReturn();
@ -243,12 +248,26 @@ class OParlControllerTest {
mvc.perform(MockMvcRequestBuilders.get("/v1.1/meeting/0")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.aMapWithSize(8)))
.andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.aMapWithSize(9)))
.andExpect(MockMvcResultMatchers.jsonPath("$.type", Matchers.equalTo("https://schema.oparl.org/1.1/Meeting")))
.andExpect(MockMvcResultMatchers.jsonPath("$.deleted", Matchers.equalTo(false)))
.andReturn();
}
@Test
void shouldReturnAgendaItem() throws Exception {
BDDMockito.given(service.getAgendaItem("0"))
.willReturn(testItem);
mvc.perform(MockMvcRequestBuilders.get("/v1.1/agendaItem/0")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.aMapWithSize(11)))
.andExpect(MockMvcResultMatchers.jsonPath("$.type", Matchers.equalTo("https://schema.oparl.org/1.1/AgendaItem")))
.andExpect(MockMvcResultMatchers.jsonPath("$.deleted", Matchers.equalTo(false)))
.andReturn();
}
void initializeTestValues() {
testSystem = System.builder()
.id("/v1.1/")
@ -368,6 +387,19 @@ class OParlControllerTest {
.startDate(LocalDate.parse("2019-06-06"))
.onBehalfOf("/v1.1/organization/1")
.build();
testItem = AgendaItem.builder()
.id("/v1.1/agendaItem/0")
.type("https://schema.oparl.org/1.1/AgendaItem")
.created(ZonedDateTime.now())
.modified(ZonedDateTime.now())
.deleted(false)
.meeting("/v1.1/meeting/0")
.number("1")
.order(0)
.name("Formalia")
.isPublic(true)
.consultation("/v1.1/consultation/0")
.build();
testMeeting = Meeting.builder()
.id("/v1.1/meeting/0")
.type("https://schema.oparl.org/1.1/Meeting")
@ -377,6 +409,7 @@ class OParlControllerTest {
.name("Konstituierende Sitzung der Bezirksversammlung")
.meetingState(MeetingState.FINISHED)
.cancelled(false)
.agendaItem(List.of(testItem))
.build();
}
}
Loading…
Cancel
Save