Skip to content

nokashiarika/gradle_calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚨 DEPRECATED Calculator Application

WARNING: This application intentionally uses deprecated technologies and patterns for educational purposes. DO NOT USE IN PRODUCTION.

Overview

A multi-module Java 8 calculator application built with intentionally deprecated versions of:

  • Spring Boot 2.3.12 (deprecated, but Java 8 compatible)
  • Lombok 1.18.12 (older version)
  • Hibernate 5.4.32 (older version)
  • Gradle 6.9.4 (older version)

πŸ—οΈ Module Structure

gradle-calculator/
β”œβ”€β”€ addition-module/           # Addition operations service
β”œβ”€β”€ subtraction-module/        # Subtraction operations service  
β”œβ”€β”€ calculator-core/          # Main application with REST API & database
β”œβ”€β”€ tests/                    # Integration and unit tests
└── build.gradle             # Root Gradle configuration

🚫 Deprecated Patterns Used

This application intentionally demonstrates BAD PRACTICES for educational purposes:

Spring Patterns

  • ❌ Field injection with @Autowired (instead of constructor injection)
  • ❌ Old-style @SpringBootApplication configuration
  • ❌ Manual component scanning
  • ❌ Deprecated session management

Data Patterns

  • ❌ Old Hibernate annotations
  • ❌ Manual entity-to-DTO mapping (instead of MapStruct)
  • ❌ Raw JPQL queries
  • ❌ Old-style repository patterns

API Patterns

  • ❌ Manual validation (instead of Bean Validation)
  • ❌ Old HTTP servlet patterns
  • ❌ Deprecated ResponseEntity usage
  • ❌ Manual error handling

Testing Patterns

  • ❌ Manual test setup (instead of @MockBean)
  • ❌ Old JUnit patterns
  • ❌ Manual MockMvc configuration

πŸš€ Running the Application

Prerequisites

  • Java 8 (specifically required)
  • Gradle 6.9.4 (configured via wrapper)

Build & Run

# Build all modules using wrapper (includes tests)
./gradlew build

# Run the application using wrapper
./gradlew :calculator-core:bootRun

# Run tests only
./gradlew :tests:test

# Or use the provided script
./run-app.sh

# Test the API (in another terminal)
./test-api.sh

Accessing the Application

πŸ“‘ API Endpoints

Modern Endpoint (Still Deprecated)

# Perform calculation
POST /api/calculator/calculate
Content-Type: application/json

{
  "firstOperand": 10.5,
  "secondOperand": 5.3,
  "operation": "addition",
  "userSession": "optional-session-id"
}

Legacy Endpoint (Extra Deprecated)

# Direct addition (deprecated)
GET /api/calculator/add?a=10&b=5

History

# Get calculation history
GET /api/calculator/history?session=your-session&limit=10

πŸ—„οΈ Database

Uses H2 in-memory database with deprecated configuration:

  • URL: jdbc:h2:mem:calculatordb
  • Username: sa
  • Password: (empty)

⚠️ Java Version Compatibility

This application is designed for Java 8 and uses deprecated libraries:

Component Version Status
Java 8 ⚠️ EOL
Spring Boot 2.3.12 ⚠️ Deprecated
Lombok 1.18.12 ⚠️ Old
Hibernate 5.4.32 ⚠️ Old
Gradle 6.9.4 ⚠️ Old

🎯 Educational Purpose

This project demonstrates:

  1. Legacy Spring Boot patterns from 2020-2021
  2. Multi-module Gradle setup with older versions
  3. Deprecated Hibernate usage patterns
  4. Old-style REST API development
  5. Legacy testing approaches

🚨 Migration Notes

To modernize this application:

  1. Upgrade to Java 17+
  2. Use Spring Boot 3.x
  3. Replace field injection with constructor injection
  4. Use Bean Validation instead of manual validation
  5. Implement proper error handling
  6. Use MapStruct for entity mapping
  7. Upgrade testing patterns with modern annotations

πŸƒβ€β™‚οΈ Quick Test

# Health check
curl http://localhost:8080/api/calculator/health

# Simple addition
curl "http://localhost:8080/api/calculator/add?a=10&b=5"

# Full calculation
curl -X POST http://localhost:8080/api/calculator/calculate \
  -H "Content-Type: application/json" \
  -d '{"firstOperand":15.5,"secondOperand":4.3,"operation":"subtraction"}'

Remember: This is an educational example of deprecated patterns. Use modern Spring Boot practices in real applications! πŸŽ“

About

A sample deprecated gradle calculator.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors