Skip to content

Commit bdcc977

Browse files
author
Gaurav Gandhi
committed
add end of assertions println for debugging + update readme
1 parent 69976c3 commit bdcc977

File tree

6 files changed

+70
-67
lines changed

6 files changed

+70
-67
lines changed

ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/docTests/updateReadmeTests/UpdateReadmeLatestChanges/MakeChangesFlowTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class MakeChangesFlowTest {
8383
println("result: $result")
8484
assertTrue(result.contains("Test Successful"))
8585
assertFalse(result.contains("Error: Test Failed"))
86+
println("assertions done")
8687
}
8788
}
8889

ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/docTests/updateReadmeTests/UpdateReadmeLatestChanges/PromptedToConfirmFolderTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class PromptedToConfirmFolderTest {
8484
println("result: $result")
8585
assertTrue(result.contains("Test Successful"))
8686
assertFalse(result.contains("Error: Test Failed"))
87+
println("assertions done")
8788
}
8889
}
8990

ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/docTests/updateReadmeTests/UpdateReadmeLatestChanges/UpdateReadmeLatestChangesTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ class UpdateReadmeLatestChangesTest {
8484
val readme = File(readmePath.toUri())
8585
assertTrue(readme.exists())
8686
println("result: ${readme.readText()}")
87-
assertTrue(readme.readText().contains("tancode"))
88-
assertTrue(readme.readText().contains("HealthController"))
87+
assertTrue(readme.readText().contains("tancode", ignoreCase = true))
88+
assertTrue(readme.readText().contains("healthcontroller.java", ignoreCase = true))
89+
println("assertions done")
8990
}
9091
}
9192

ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/docTests/updateReadmeTests/UpdateReadmeSpecificChanges/MakeChangesFlowTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class MakeChangesFlowTest {
8383
println("result: $result")
8484
assertTrue(result.contains("Test Successful"))
8585
assertFalse(result.contains("Error: Test Failed"))
86+
println("assertions done")
8687
}
8788
}
8889

ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/docTests/updateReadmeTests/UpdateReadmeSpecificChanges/UpdateReadmeSpecificChangesTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ class UpdateReadmeSpecificChangesTest {
8484
val readme = File(readmePath.toUri())
8585
assertTrue(readme.exists())
8686
println("result: ${readme.readText()}")
87-
assertTrue(readme.readText().contains("### Installation"))
87+
assertTrue(readme.readText().contains("Installation", ignoreCase = true))
88+
println("assertions done")
8889
}
8990
}
9091

Lines changed: 62 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,108 @@
1-
# Spring Boot REST API: A Simple and Robust Microservice Template
1+
# Spring Boot REST API for Simple Data Management
22

3-
This Spring Boot application provides a lightweight REST API template with built-in health monitoring and data management capabilities. It offers a production-ready foundation for building microservices with comprehensive health checks, status monitoring, and data operations.
3+
This Spring Boot application provides a lightweight REST API for managing data items with a simple key-value storage mechanism. It offers a clean and efficient way to store and retrieve data items through RESTful endpoints with built-in monitoring capabilities via Spring Actuator.
44

5-
The application implements a RESTful service with health monitoring endpoints and a flexible data management interface. It features configurable logging levels, actuator endpoints for operational insights, and a clean architecture that separates concerns between controllers and data models. Built with Spring Boot 3.2.0, it leverages modern Java 17 features and includes comprehensive test support through JUnit.
5+
The application implements a RESTful service with in-memory storage, making it ideal for prototyping, testing, or scenarios requiring temporary data persistence. It features comprehensive logging configuration, health monitoring through Spring Actuator, and follows Spring Boot best practices for configuration management. The service is built using Java 17 and managed with Gradle, ensuring modern Java features and reliable dependency management.
66

77
## Repository Structure
88
```
99
.
10-
├── build.gradle # Gradle build configuration with Spring Boot 3.2.0 and dependencies
10+
├── build.gradle # Gradle build configuration with Spring Boot dependencies
1111
├── config/
12-
│ └── application-local.yml # Local environment configuration (port, app name, logging)
12+
│ └── application-local.yml # Local environment configuration (port, logging, app name)
1313
└── src/
1414
└── com/example/
15-
├── App.java # Main application entry point with Spring Boot configuration
16-
├── controller/ # REST API endpoint definitions
17-
│ ├── HealthController.java # Health and status monitoring endpoints
18-
│ └── SampleController.java # Data management endpoints
15+
├── App.java # Main application entry point with Spring Boot configuration
16+
├── controller/
17+
│ └── SampleController.java # REST endpoints for data management
1918
└── model/
20-
└── DataItem.java # Data model for API operations
19+
└── DataItem.java # Data model class for storing items
2120
```
2221

2322
## Usage Instructions
2423

2524
### Prerequisites
2625
- Java Development Kit (JDK) 17 or higher
27-
- Gradle 8.x or higher
28-
- Basic understanding of Spring Boot and REST APIs
26+
- Gradle 8.x (or use the included Gradle wrapper)
2927

30-
31-
### Quick Start
32-
1. Start the application:
33-
```bash
34-
./gradlew bootRun
35-
```
36-
37-
2. Verify the application is running by accessing the health endpoint:
38-
```bash
39-
curl http://localhost:8080/api/health
40-
```
28+
2. The application will be available at `http://localhost:8080`
4129

4230
### More Detailed Examples
4331

44-
1. Check Application Status
32+
#### Storing a Data Item
4533
```bash
46-
curl http://localhost:8080/api/status
34+
curl -X PUT http://localhost:8080/api/data/123 \
35+
-H "Content-Type: application/json" \
36+
-d '{"content": "Sample content"}'
4737
```
38+
4839
Expected response:
4940
```json
5041
{
51-
"timestamp": "2024-01-01T12:00:00",
52-
"service": "sample-rest-app",
53-
"status": "running"
42+
"id": "123",
43+
"content": "Sample content"
5444
}
5545
```
5646

57-
2. Health Check
47+
#### Retrieving a Data Item
5848
```bash
59-
curl http://localhost:8080/api/health
49+
curl http://localhost:8080/api/data/123
6050
```
51+
6152
Expected response:
6253
```json
6354
{
64-
"status": "UP",
65-
"message": "Service is healthy"
55+
"id": "123",
56+
"content": "Sample content"
6657
}
6758
```
6859

6960
### Troubleshooting
7061

71-
1. Application Won't Start
72-
- **Problem**: Application fails to start with port binding issues
73-
- **Solution**:
74-
```bash
75-
# Check if port 8080 is already in use
76-
lsof -i :8080
77-
# Modify port in config/application-local.yml if needed
78-
```
79-
80-
2. Debugging
81-
- Enable debug logging by modifying `config/application-local.yml`:
82-
```yaml
83-
logging:
84-
level:
85-
com.example: DEBUG
86-
```
87-
- Check logs in console output for detailed information
88-
- Use Spring Boot Actuator endpoints for health monitoring:
89-
```bash
90-
curl http://localhost:8080/actuator/health
91-
```
62+
#### Common Issues
63+
64+
1. Application fails to start
65+
- **Problem**: Port 8080 already in use
66+
- **Solution**: Modify the port in `config/application-local.yml`:
67+
```yaml
68+
server:
69+
port: 8081
70+
```
71+
72+
2. Logging issues
73+
- **Problem**: Insufficient logging information
74+
- **Solution**: Adjust logging levels in `application-local.yml`:
75+
```yaml
76+
logging:
77+
level:
78+
com.example: DEBUG
79+
```
80+
81+
#### Debugging
82+
- Enable debug logging by adding `--debug` flag:
83+
```bash
84+
./gradlew bootRun --debug
85+
```
86+
- View logs in console output
87+
- Application logs are written to standard output and can be redirected to a file:
88+
```bash
89+
./gradlew bootRun > application.log
90+
```
9291

9392
## Data Flow
9493

95-
The application processes HTTP requests through a layered architecture, transforming REST calls into data operations with proper error handling and response formatting.
94+
The application implements a simple data flow where REST requests are processed through controllers and stored in an in-memory map structure.
9695

9796
```ascii
98-
Client Request → Controller Layer → Data Processing → Response
99-
↑ | | ↓
100-
└──────────────┴────────Error Handling─────────────┘
97+
Client Request → REST Controller → In-Memory Storage
98+
↑ |
99+
└────────────────────────────────────┘
100+
Response with stored data
101101
```
102102

103103
Key component interactions:
104-
1. Controllers receive HTTP requests and validate inputs
105-
2. Request data is mapped to internal data models
106-
3. Business logic processes the data operations
107-
4. Responses are formatted as JSON and returned to the client
108-
5. Error handling is managed across all layers
109-
6. Health monitoring provides real-time system status
110-
7. Logging captures operation details at configurable levels
104+
1. REST requests are received by `SampleController`
105+
2. Controller methods handle GET and PUT operations
106+
3. Data is stored in an in-memory HashMap within the controller
107+
4. Responses are wrapped in Spring's ResponseEntity for proper HTTP status codes
108+
5. Spring Boot handles JSON serialization/deserialization automatically

0 commit comments

Comments
 (0)