You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -86,13 +89,21 @@ The API uses request and response records instead of exposing the JPA entity dir
86
89
87
90
| Method | Endpoint | Success | Purpose |
88
91
|---|---|---:|---|
89
-
|`GET`|`/api/process-checks`|`200 OK`| Return all process-check records |
90
-
|`GET`|`/api/process-checks?status=OK`|`200 OK`| Filter records by `OK`, `WARNING` or `CRITICAL`|
92
+
|`GET`|`/api/process-checks?page=0&size=20`|`200 OK`| Return one page of process-check records |
93
+
|`GET`|`/api/process-checks?status=OK&page=0&size=20`|`200 OK`| Filter and page records by status|
91
94
|`GET`|`/api/process-checks/{id}`|`200 OK`| Return one process-check record by ID |
92
95
|`POST`|`/api/process-checks`|`201 Created`| Create a record and return its URI in `Location`|
93
96
|`PUT`|`/api/process-checks/{id}`|`200 OK`| Replace the editable values of an existing record |
94
97
|`DELETE`|`/api/process-checks/{id}`|`204 No Content`| Delete an existing record |
95
98
99
+
List endpoints accept the standard Spring Data parameters:
100
+
101
+
-`page`: zero-based page number, default `0`
102
+
-`size`: requested page size, default `20`, capped at `100`
103
+
-`sort`: field and direction, for example `sort=processName,asc`
104
+
105
+
The default list order is `lastCheckedAt,desc`.
106
+
96
107
Typical client errors:
97
108
98
109
| Situation | Result |
@@ -103,27 +114,39 @@ Typical client errors:
103
114
104
115
---
105
116
106
-
## Example Process-Check Record
117
+
## Example Paged Response
107
118
108
119
```json
109
120
{
110
-
"id": 1,
111
-
"processName": "Daily sales import",
112
-
"owner": "Data Operations",
113
-
"status": "OK",
114
-
"lastCheckedAt": "2026-07-10T00:25:00",
115
-
"slaMinutes": 60
121
+
"content": [
122
+
{
123
+
"id": 1,
124
+
"processName": "Daily sales import",
125
+
"owner": "Data Operations",
126
+
"status": "OK",
127
+
"lastCheckedAt": "2026-07-10T00:25:00",
128
+
"slaMinutes": 60
129
+
}
130
+
],
131
+
"page": {
132
+
"size": 20,
133
+
"totalElements": 1,
134
+
"totalPages": 1,
135
+
"number": 0
136
+
}
116
137
}
117
138
```
118
139
119
140
Request validation requires:
120
141
121
-
- a non-blank `processName`
122
-
- a non-blank `owner`
142
+
- a non-blank `processName` with at most 120 characters
143
+
- a non-blank `owner` with at most 120 characters
123
144
- a valid status: `OK`, `WARNING` or `CRITICAL`
124
145
- a non-null ISO local date-time value
125
146
-`slaMinutes` of at least `1`
126
147
148
+
The entity mirrors the non-null and maximum-length constraints so the API and database schema enforce the same basic rules.
149
+
127
150
---
128
151
129
152
## Error Response Example
@@ -164,10 +187,18 @@ Then open:
164
187
http://localhost:8080/api/process-checks
165
188
```
166
189
167
-
At first startup, the API returns an empty JSON array because the H2 database is empty:
190
+
At first startup, the H2 database is empty, so the list endpoint returns an empty page:
168
191
169
192
```json
170
-
[]
193
+
{
194
+
"content": [],
195
+
"page": {
196
+
"size": 20,
197
+
"totalElements": 0,
198
+
"totalPages": 0,
199
+
"number": 0
200
+
}
201
+
}
171
202
```
172
203
173
204
---
@@ -189,13 +220,14 @@ At first startup, the API returns an empty JSON array because the H2 database is
189
220
The automated suite verifies:
190
221
191
222
- application context startup
223
+
- default and requested pagination
192
224
- unfiltered and status-filtered list requests
193
225
- empty filter results
194
226
- invalid status handling
195
227
- lookup by ID
196
228
-`404` Problem Detail responses
197
229
- successful creation with `201 Created` and `Location`
198
-
-request validation failures
230
+
-blank, invalid and oversized request values
199
231
- update behavior and persisted values
200
232
- successful deletion with `204 No Content`
201
233
- update and delete behavior for unknown IDs
@@ -223,11 +255,12 @@ The workflow has read-only repository permissions and cancels superseded runs fo
223
255
The full CRUD flow can also be exercised manually with curl, an API client or an IDE HTTP client:
224
256
225
257
```text
226
-
POST /api/process-checks create a process-check record
227
-
GET /api/process-checks list all process-check records
228
-
GET /api/process-checks/1 read one process-check record
229
-
PUT /api/process-checks/1 update one process-check record
230
-
DELETE /api/process-checks/1 delete one process-check record
258
+
POST /api/process-checks
259
+
GET /api/process-checks?page=0&size=20
260
+
GET /api/process-checks?status=OK&page=0&size=20
261
+
GET /api/process-checks/1
262
+
PUT /api/process-checks/1
263
+
DELETE /api/process-checks/1
231
264
```
232
265
233
266
Example test data:
@@ -242,6 +275,14 @@ slaMinutes: 60
242
275
243
276
---
244
277
278
+
## Logging
279
+
280
+
Create, update and delete operations write one parameterized application log entry containing the record ID and, where useful, its status.
281
+
282
+
Read requests and complete request bodies are not logged. This keeps the example useful for troubleshooting without producing noisy logs or copying input data unnecessarily.
283
+
284
+
---
285
+
245
286
## H2 Database Note
246
287
247
288
This project uses an **H2 in-memory database** for local development and API testing.
@@ -314,12 +355,14 @@ This repository demonstrates a small but realistic backend foundation:
314
355
- Spring Boot application structure
315
356
- REST endpoint and HTTP-status design
316
357
- JSON request and response handling
317
-
-CRUD operations and status filtering
358
+
-paginated list queries and status filtering
318
359
- layered backend organization
319
-
- request validation
360
+
- request validation aligned with persistence constraints
320
361
- standard Problem Detail error responses
321
362
- explicit transaction boundaries
363
+
- JPA dirty checking for managed updates
322
364
- persistence abstraction with Spring Data JPA
365
+
- restrained parameterized logging
323
366
- local development and testing with H2
324
367
- automated integration testing
325
368
- reproducible Maven builds
@@ -332,7 +375,7 @@ This repository demonstrates a small but realistic backend foundation:
332
375
333
376
This is a learning project.
334
377
335
-
It does not include production database configuration, Docker deployment, authentication and authorization, a frontend UI, cloud deployment, monitoring infrastructure, pagination or enterprise-scale operational error handling.
378
+
It does not include production database configuration, Docker deployment, authentication and authorization, a frontend UI, cloud deployment, metrics, tracing or enterprise-scale operational error handling.
336
379
337
380
These omissions are intentional. The current scope is limited to a clean, understandable and tested Spring Boot REST API baseline.
Copy file name to clipboardExpand all lines: docs/index.md
+32-15Lines changed: 32 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Small Java 21 / Spring Boot REST API portfolio project
5
5
6
6
# Spring Boot Process API Basics
7
7
8
-
**Small Java 21 / Spring Boot REST API project exposing validated process-check data through a layered backend structure, automated tests and H2 persistence.**
8
+
**Small Java 21 / Spring Boot REST API project exposing validated and paginated process-check data through a layered backend structure, automated tests and H2 persistence.**
9
9
10
10
[View repository](https://github.com/DataTideHH/spring-boot-process-api-basics) · [Read the full README](https://github.com/DataTideHH/spring-boot-process-api-basics/blob/main/README.md) · [View CI](https://github.com/DataTideHH/spring-boot-process-api-basics/actions/workflows/ci.yml) · [DataTideHH portfolio](https://datatidehh.de/)
11
11
@@ -17,7 +17,7 @@ This project is a deliberately compact backend learning project.
17
17
18
18
It demonstrates how process-related records can be represented, validated, persisted and exposed through a small REST API using Spring Boot.
19
19
20
-
The goal is not to present a production service or an enterprise backend system. The goal is to document a clean first step from Java basics toward a small layered REST API with explicit HTTP behavior, persistence and automated verification.
20
+
The goal is not to present a production service or an enterprise backend system. The goal is to document a clean first step from Java basics toward a small layered REST API with explicit HTTP behavior, bounded list queries, persistence and automated verification.
21
21
22
22
---
23
23
@@ -37,11 +37,14 @@ It follows the [IPv4 Subnet Calculator Multilang](https://datatidehh.github.io/i
37
37
- controller, service and repository separation
38
38
- Spring Data JPA repository usage
39
39
- request and response records
40
-
- Jakarta Validation
40
+
- Jakarta Validation aligned with entity constraints
41
41
- H2 in-memory persistence
42
42
- CRUD endpoints for process-check data
43
-
- optional status filtering
43
+
- status filtering and pagination
44
+
- stable page metadata through Spring Data `PagedModel`
44
45
- standard `ProblemDetail` error responses
46
+
- explicit transaction boundaries and JPA dirty checking
47
+
- restrained parameterized logging for write operations
45
48
- integration tests with Spring Boot Test and MockMvc
46
49
- reproducible Maven Wrapper builds
47
50
- GitHub Actions verification on Java 21
@@ -52,30 +55,44 @@ It follows the [IPv4 Subnet Calculator Multilang](https://datatidehh.github.io/i
52
55
53
56
| Method | Endpoint | Result | Purpose |
54
57
|---|---|---:|---|
55
-
|`GET`|`/api/process-checks`|`200`| List all records |
56
-
|`GET`|`/api/process-checks?status=OK`|`200`| Filter by `OK`, `WARNING` or `CRITICAL`|
58
+
|`GET`|`/api/process-checks?page=0&size=20`|`200`| List one page of records |
59
+
|`GET`|`/api/process-checks?status=OK&page=0&size=20`|`200`| Filter and page by status|
57
60
|`GET`|`/api/process-checks/{id}`|`200`| Read one record |
58
61
|`POST`|`/api/process-checks`|`201`| Create a record and return `Location`|
59
62
|`PUT`|`/api/process-checks/{id}`|`200`| Update a record |
60
63
|`DELETE`|`/api/process-checks/{id}`|`204`| Delete a record |
61
64
65
+
The list endpoint defaults to 20 records, sorts by `lastCheckedAt` descending and caps requested page sizes at 100.
66
+
62
67
Invalid input returns `400 Bad Request`. Unknown record IDs return `404 Not Found` as `application/problem+json`.
63
68
64
69
---
65
70
66
-
## Example process-check record
71
+
## Example paged response
67
72
68
73
```json
69
74
{
70
-
"id": 1,
71
-
"processName": "Daily sales import",
72
-
"owner": "Data Operations",
73
-
"status": "OK",
74
-
"lastCheckedAt": "2026-07-10T00:25:00",
75
-
"slaMinutes": 60
75
+
"content": [
76
+
{
77
+
"id": 1,
78
+
"processName": "Daily sales import",
79
+
"owner": "Data Operations",
80
+
"status": "OK",
81
+
"lastCheckedAt": "2026-07-10T00:25:00",
82
+
"slaMinutes": 60
83
+
}
84
+
],
85
+
"page": {
86
+
"size": 20,
87
+
"totalElements": 1,
88
+
"totalPages": 1,
89
+
"number": 0
90
+
}
76
91
}
77
92
```
78
93
94
+
`processName` and `owner` are required and limited to 120 characters. The JPA entity mirrors these length and nullability rules.
The integration suite covers list and filter behavior, lookup by ID, creation, validation failures, updates, deletion, persistence effects and `404` Problem Detail responses.
124
+
The integration suite covers pagination, sorting, status filtering, lookup by ID, creation, blank and oversized input, updates, deletion, persistence effects and `404` Problem Detail responses.
108
125
109
126
The GitHub Actions workflow runs `clean verify` with Eclipse Temurin Java 21 for pull requests and pushes to `main`.
110
127
@@ -136,4 +153,4 @@ The project uses an H2 in-memory database. Data is reset when the application st
136
153
137
154
The sample data is synthetic and does not contain personal, customer or production data.
138
155
139
-
This is a learning project with a deliberately limited scope. It does not claim production deployment, authentication, cloud operationor enterprise-scale infrastructure.
156
+
This is a learning project with a deliberately limited scope. It does not claim production deployment, authentication, cloud operation, monitoring infrastructure or enterprise-scale operation.
0 commit comments