Added operation to retrieve single agenda item

This commit is contained in:
Jim Martens 2020-07-11 19:33:11 +02:00
parent cdba815c32
commit 8787784067
3 changed files with 50 additions and 3 deletions

View File

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

View File

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

View File

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