generated from 2martens/template-service
Added operation to retrieve single agenda item
This commit is contained in:
parent
cdba815c32
commit
8787784067
|
@ -156,4 +156,14 @@ public class OParlController {
|
||||||
log.info("invoked method /v1.1/meeting/{}", id);
|
log.info("invoked method /v1.1/meeting/{}", id);
|
||||||
return service.getMeeting(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,10 @@ public class OParlService {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AgendaItem getAgendaItem(String id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Body> getBodies() {
|
public List<Body> getBodies() {
|
||||||
return List.of(exampleBody);
|
return List.of(exampleBody);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,17 @@ class OParlControllerTest {
|
||||||
@MockBean
|
@MockBean
|
||||||
private OParlService service;
|
private OParlService service;
|
||||||
|
|
||||||
|
private AgendaItem testItem;
|
||||||
private Body testBody;
|
private Body testBody;
|
||||||
|
private Consultation testConsultation;
|
||||||
|
private File testFile;
|
||||||
private LegislativeTerm testTerm;
|
private LegislativeTerm testTerm;
|
||||||
|
private Location testLocation;
|
||||||
private Meeting testMeeting;
|
private Meeting testMeeting;
|
||||||
private Membership testMembership;
|
private Membership testMembership;
|
||||||
private Organization testOrganization;
|
private Organization testOrganization;
|
||||||
private Organization testPartyOrganization;
|
private Organization testPartyOrganization;
|
||||||
|
private Paper testPaper;
|
||||||
private Person testPerson;
|
private Person testPerson;
|
||||||
private System testSystem;
|
private System testSystem;
|
||||||
|
|
||||||
|
@ -214,7 +219,7 @@ class OParlControllerTest {
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(1)))
|
.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].type", Matchers.equalTo("https://schema.oparl.org/1.1/Meeting")))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].deleted", Matchers.equalTo(false)))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].deleted", Matchers.equalTo(false)))
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
@ -229,7 +234,7 @@ class OParlControllerTest {
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(1)))
|
.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].type", Matchers.equalTo("https://schema.oparl.org/1.1/Meeting")))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].deleted", Matchers.equalTo(false)))
|
.andExpect(MockMvcResultMatchers.jsonPath("$[0].deleted", Matchers.equalTo(false)))
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
@ -243,12 +248,26 @@ class OParlControllerTest {
|
||||||
mvc.perform(MockMvcRequestBuilders.get("/v1.1/meeting/0")
|
mvc.perform(MockMvcRequestBuilders.get("/v1.1/meeting/0")
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
.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("$.type", Matchers.equalTo("https://schema.oparl.org/1.1/Meeting")))
|
||||||
.andExpect(MockMvcResultMatchers.jsonPath("$.deleted", Matchers.equalTo(false)))
|
.andExpect(MockMvcResultMatchers.jsonPath("$.deleted", Matchers.equalTo(false)))
|
||||||
.andReturn();
|
.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() {
|
void initializeTestValues() {
|
||||||
testSystem = System.builder()
|
testSystem = System.builder()
|
||||||
.id("/v1.1/")
|
.id("/v1.1/")
|
||||||
|
@ -368,6 +387,19 @@ class OParlControllerTest {
|
||||||
.startDate(LocalDate.parse("2019-06-06"))
|
.startDate(LocalDate.parse("2019-06-06"))
|
||||||
.onBehalfOf("/v1.1/organization/1")
|
.onBehalfOf("/v1.1/organization/1")
|
||||||
.build();
|
.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()
|
testMeeting = Meeting.builder()
|
||||||
.id("/v1.1/meeting/0")
|
.id("/v1.1/meeting/0")
|
||||||
.type("https://schema.oparl.org/1.1/Meeting")
|
.type("https://schema.oparl.org/1.1/Meeting")
|
||||||
|
@ -377,6 +409,7 @@ class OParlControllerTest {
|
||||||
.name("Konstituierende Sitzung der Bezirksversammlung")
|
.name("Konstituierende Sitzung der Bezirksversammlung")
|
||||||
.meetingState(MeetingState.FINISHED)
|
.meetingState(MeetingState.FINISHED)
|
||||||
.cancelled(false)
|
.cancelled(false)
|
||||||
|
.agendaItem(List.of(testItem))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue