diff --git a/oparl-server/src/main/java/de/twomartens/oparlservice/control/OParlController.java b/oparl-server/src/main/java/de/twomartens/oparlservice/control/OParlController.java
index 4ec55fb..068f20e 100644
--- a/oparl-server/src/main/java/de/twomartens/oparlservice/control/OParlController.java
+++ b/oparl-server/src/main/java/de/twomartens/oparlservice/control/OParlController.java
@@ -32,7 +32,7 @@ public class OParlController {
@GetMapping("/bodies")
@Operation(summary = "List of available bodies", description = "returns a list of available bodies in this OParl system")
- public List
bodies() {
+ public ObjectList bodies() {
log.info("method invoked /v1.1/bodies");
return this.service.getBodies();
}
@@ -59,7 +59,7 @@ public class OParlController {
@GetMapping("/body/{id}/organizations")
@Operation(summary = "List of all organizations in body", description = "returns a list of all organizations in requested body")
- public List organizationsInBody(
+ public ObjectList organizationsInBody(
@PathVariable
@Parameter(description = "body ID", example = "0")
String id) {
@@ -79,7 +79,7 @@ public class OParlController {
@GetMapping("/body/{id}/persons")
@Operation(summary = "List of all persons in body", description = "returns a list of all persons in requested body")
- public List persons(
+ public ObjectList persons(
@PathVariable
@Parameter(description = "body ID", example = "0")
String id) {
@@ -99,7 +99,7 @@ public class OParlController {
@GetMapping("/body/{id}/memberships")
@Operation(summary = "List of all memberships in body", description = "returns a list of all memberships in requested body")
- public List membershipsInBody(
+ public ObjectList membershipsInBody(
@PathVariable
@Parameter(description = "body ID", example = "0")
String id) {
@@ -109,7 +109,7 @@ public class OParlController {
@GetMapping("/organization/{id}/memberships")
@Operation(summary = "List of all memberships in organization", description = "returns a list of all memberships in requested organization")
- public List membershipsInOrganization(
+ public ObjectList membershipsInOrganization(
@PathVariable
@Parameter(description = "organization ID", example = "0")
String id) {
@@ -129,7 +129,7 @@ public class OParlController {
@GetMapping("/body/{id}/meetings")
@Operation(summary = "List of all meetings in body", description = "returns a list of all meetings in requested body")
- public List meetingsInBody(
+ public ObjectList meetingsInBody(
@PathVariable
@Parameter(description = "body ID", example = "0")
String id) {
@@ -139,7 +139,7 @@ public class OParlController {
@GetMapping("/organization/{id}/meetings")
@Operation(summary = "List of all meetings in organization", description = "returns a list of all meetings in requested organization")
- public List meetingsInOrganization(
+ public ObjectList meetingsInOrganization(
@PathVariable
@Parameter(description = "organization ID", example = "0")
String id) {
diff --git a/oparl-server/src/main/java/de/twomartens/oparlservice/service/OParlService.java b/oparl-server/src/main/java/de/twomartens/oparlservice/service/OParlService.java
index 92afe3d..d49a5f7 100644
--- a/oparl-server/src/main/java/de/twomartens/oparlservice/service/OParlService.java
+++ b/oparl-server/src/main/java/de/twomartens/oparlservice/service/OParlService.java
@@ -1,13 +1,12 @@
package de.twomartens.oparlservice.service;
import de.twomartens.oparlservice.configs.OParlServiceProperties;
-import de.twomartens.oparlservice.entity.*;
import de.twomartens.oparlservice.entity.System;
+import de.twomartens.oparlservice.entity.*;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.ZonedDateTime;
-import java.util.Collections;
import java.util.List;
@Service
@@ -77,8 +76,8 @@ public class OParlService {
return null;
}
- public List getBodies() {
- return List.of(exampleBody);
+ public ObjectList getBodies() {
+ return null;
}
public Body getBody(String id) {
@@ -93,36 +92,36 @@ public class OParlService {
return null;
}
- public List getMeetingsInBody(String bodyID) {
- return Collections.emptyList();
+ public ObjectList getMeetingsInBody(String bodyID) {
+ return null;
}
- public List getMeetingsInOrganization(String organizationID) {
- return Collections.emptyList();
+ public ObjectList getMeetingsInOrganization(String organizationID) {
+ return null;
}
public Membership getMembership(String id) {
return null;
}
- public List getMembershipsInBody(String bodyID) {
- return Collections.emptyList();
+ public ObjectList getMembershipsInBody(String bodyID) {
+ return null;
}
- public List getMembershipsInOrganization(String organizationID) {
- return Collections.emptyList();
+ public ObjectList getMembershipsInOrganization(String organizationID) {
+ return null;
}
- public List getOrganizationsInBody(String bodyID) {
- return Collections.emptyList();
+ public ObjectList getOrganizationsInBody(String bodyID) {
+ return null;
}
public Organization getOrganization(String id) {
return null;
}
- public List getPersonsInBody(String bodyID) {
- return Collections.emptyList();
+ public ObjectList getPersonsInBody(String bodyID) {
+ return null;
}
public Person getPerson(String id) {
diff --git a/oparl-server/src/test/java/de/twomartens/oparlservice/control/OParlControllerTest.java b/oparl-server/src/test/java/de/twomartens/oparlservice/control/OParlControllerTest.java
index ff052a4..e0b02cf 100644
--- a/oparl-server/src/test/java/de/twomartens/oparlservice/control/OParlControllerTest.java
+++ b/oparl-server/src/test/java/de/twomartens/oparlservice/control/OParlControllerTest.java
@@ -34,11 +34,13 @@ class OParlControllerTest {
private Consultation testConsultation;
private File testFile;
private LegislativeTerm testTerm;
+ private Links testLinks;
private Location testLocation;
private Meeting testMeeting;
private Membership testMembership;
private Organization testOrganization;
private Organization testPartyOrganization;
+ private Pagination testPagination;
private Paper testPaper;
private Person testPerson;
private System testSystem;
@@ -66,15 +68,20 @@ class OParlControllerTest {
@Test
void shouldReturnListOfBodies() throws Exception {
BDDMockito.given(service.getBodies())
- .willReturn(List.of(testBody));
+ .willReturn(ObjectList.builder()
+ .data(List.of(testBody))
+ .pagination(testPagination)
+ .links(testLinks)
+ .build());
mvc.perform(MockMvcRequestBuilders.get("/v1.1/bodies")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
- .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(1)))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0]", Matchers.aMapWithSize(24)))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/Body")))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0].deleted", Matchers.equalTo(false)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.aMapWithSize(3)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data", Matchers.hasSize(1)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0]", Matchers.aMapWithSize(24)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/Body")))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0].deleted", Matchers.equalTo(false)))
.andReturn();
}
@@ -110,15 +117,16 @@ class OParlControllerTest {
@Test
void shouldReturnOrganizationsInBody() throws Exception {
BDDMockito.given(service.getOrganizationsInBody("0"))
- .willReturn(List.of(testOrganization, testPartyOrganization));
+ .willReturn(ObjectList.builder().data(List.of(testOrganization, testPartyOrganization)).pagination(testPagination).links(testLinks).build());
mvc.perform(MockMvcRequestBuilders.get("/v1.1/body/0/organizations")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
- .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(2)))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0]", Matchers.aMapWithSize(15)))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/Organization")))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0].deleted", Matchers.equalTo(false)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.aMapWithSize(3)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data", Matchers.hasSize(2)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0]", Matchers.aMapWithSize(15)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/Organization")))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0].deleted", Matchers.equalTo(false)))
.andReturn();
}
@@ -139,15 +147,16 @@ class OParlControllerTest {
@Test
void shouldReturnPersonsInBody() throws Exception {
BDDMockito.given(service.getPersonsInBody("0"))
- .willReturn(List.of(testPerson));
+ .willReturn(ObjectList.builder().data(List.of(testPerson)).pagination(testPagination).links(testLinks).build());
mvc.perform(MockMvcRequestBuilders.get("/v1.1/body/0/persons")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
- .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(1)))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0]", Matchers.aMapWithSize(13)))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/Person")))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0].deleted", Matchers.equalTo(false)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.aMapWithSize(3)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data", Matchers.hasSize(1)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0]", Matchers.aMapWithSize(13)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/Person")))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0].deleted", Matchers.equalTo(false)))
.andReturn();
}
@@ -168,30 +177,32 @@ class OParlControllerTest {
@Test
void shouldReturnMembershipsInBody() throws Exception {
BDDMockito.given(service.getMembershipsInBody("0"))
- .willReturn(List.of(testMembership));
+ .willReturn(ObjectList.builder().data(List.of(testMembership)).pagination(testPagination).links(testLinks).build());
mvc.perform(MockMvcRequestBuilders.get("/v1.1/body/0/memberships")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
- .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(1)))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0]", Matchers.aMapWithSize(11)))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/Membership")))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0].deleted", Matchers.equalTo(false)))
+ .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/Membership")))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0].deleted", Matchers.equalTo(false)))
.andReturn();
}
@Test
void shouldReturnMembershipsInOrganization() throws Exception {
BDDMockito.given(service.getMembershipsInOrganization("0"))
- .willReturn(List.of(testMembership));
+ .willReturn(ObjectList.builder().data(List.of(testMembership)).pagination(testPagination).links(testLinks).build());
mvc.perform(MockMvcRequestBuilders.get("/v1.1/organization/0/memberships")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
- .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(1)))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0]", Matchers.aMapWithSize(11)))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/Membership")))
- .andExpect(MockMvcResultMatchers.jsonPath("$[0].deleted", Matchers.equalTo(false)))
+ .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/Membership")))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0].deleted", Matchers.equalTo(false)))
.andReturn();
}
@@ -213,30 +224,32 @@ class OParlControllerTest {
@Test
void shouldReturnMeetingsInBody() throws Exception {
BDDMockito.given(service.getMeetingsInBody("0"))
- .willReturn(List.of(testMeeting));
+ .willReturn(ObjectList.builder().data(List.of(testMeeting)).pagination(testPagination).links(testLinks).build());
mvc.perform(MockMvcRequestBuilders.get("/v1.1/body/0/meetings")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
- .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(1)))
- .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)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.aMapWithSize(3)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data", Matchers.hasSize(1)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0]", Matchers.aMapWithSize(9)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/Meeting")))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0].deleted", Matchers.equalTo(false)))
.andReturn();
}
@Test
void shouldReturnMeetingsInOrganization() throws Exception {
BDDMockito.given(service.getMeetingsInOrganization("0"))
- .willReturn(List.of(testMeeting));
+ .willReturn(ObjectList.builder().data(List.of(testMeeting)).pagination(testPagination).links(testLinks).build());
mvc.perform(MockMvcRequestBuilders.get("/v1.1/organization/0/meetings")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
- .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(1)))
- .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)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.aMapWithSize(3)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data", Matchers.hasSize(1)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0]", Matchers.aMapWithSize(9)))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/Meeting")))
+ .andExpect(MockMvcResultMatchers.jsonPath("$.data[0].deleted", Matchers.equalTo(false)))
.andReturn();
}
@@ -411,5 +424,9 @@ class OParlControllerTest {
.cancelled(false)
.agendaItem(List.of(testItem))
.build();
+ testPagination = Pagination.builder().build();
+ testLinks = Links.builder()
+ .next("")
+ .build();
}
}
\ No newline at end of file