Java Interview Assignment - Network device management system with Spring Shell CLI.
- Device registration (type, MAC, uplink)
- List devices sorted by type
- Find device by MAC
- Network topology visualization
- Subtopology from specific device
# Build and run
mvn package
java -jar target/network-device-cli-1.0.0.jarPrerequisites: Java 21+
Note: For best experience, use terminal with emoji font support
# Show all commands
help
# Show detailed help for specific command
help register-device
# Basic usage
register-device --type GATEWAY --mac aa:bb:cc:dd:ee:01
register-device --type SWITCH --mac aa:bb:cc:dd:ee:02 --uplink aa:bb:cc:dd:ee:01
list-devices
find-device --mac aa:bb:cc:dd:ee:01
show-topology
show-topology-from --mac aa:bb:cc:dd:ee:02
clearTech Stack: Spring Boot 3.5.4, Spring Shell 3.4.1, Java 21, Maven
Design:
- Bidirectional tree structure (parent/children references)
- HashMap storage for O(1) MAC lookup
- Custom MAC validation with normalization
- Global exception handling
Key Features:
- Prevents circular references (tree-only topology)
- Duplicate device validation
- Type-based sorting (Gateway > Switch > Access Point)
- Interactive CLI with sample data
- Integration tests for all CLI commands
- Unit tests for validation and exceptions
- Edge case coverage (duplicates, invalid MACs)
# application.yml
network:
device:
initialize-default-data: true # Load sample network on startup
max-devices-per-uplink: 100 # Max children per parent device
max-network-depth: 10 # Max topology tree depth
enable-mac-normalization: true # Convert MAC formats (aa-bb to aa:bb)🌐 Gateway: aa:bb:cc:dd:ee:01
├── 🔀 Switch: aa:bb:cc:dd:ee:02
│ ├── 📡 Access Point: aa:bb:cc:dd:ee:04
│ └── 📡 Access Point: aa:bb:cc:dd:ee:05
└── 🔀 Switch: aa:bb:cc:dd:ee:03
└── 📡 Access Point: aa:bb:cc:dd:ee:06