Skip to content

Milestone 1: 1 — Project Scaffolding, Core Email Slicing Logic, and Build Pipeline#45

Open
mcode-app-dev[bot] wants to merge 5 commits into
project_base_run_456from
emailslicer-dkasargod-milestone_1-abcdc7
Open

Milestone 1: 1 — Project Scaffolding, Core Email Slicing Logic, and Build Pipeline#45
mcode-app-dev[bot] wants to merge 5 commits into
project_base_run_456from
emailslicer-dkasargod-milestone_1-abcdc7

Conversation

@mcode-app-dev

@mcode-app-dev mcode-app-dev Bot commented Mar 20, 2026

Copy link
Copy Markdown

View Milestone


Table of Contents


Status

The milestone was successfully completed. All goals specified in the Milestone Instructions — Maven project scaffolding, core email-slicing logic, console I/O, centralized messages, and JUnit 5 unit tests — have been implemented. The build produces an executable JAR and all tests pass.

One intentional deviation from the Modernization Instructions: The Modernization Instructions specify that inputs like "@", "@domain", and "user@" should be rejected as invalid. However, the Milestone Instructions explicitly require matching the Python original's behavior in this milestone (split on first @; only reject inputs lacking @ entirely). The current implementation follows the Milestone Instructions, deferring stricter regex-based validation to Milestone 2.


Feature Overview

This milestone migrates the Python Email Slicer (emailSlicer.py) to an idiomatic Java 17 console application. The user can:

  • Build the project: ./mvnw package
  • Run the application: java -jar target/email-slicer.jar
  • Enter an email address at the prompt and receive the parsed username and domain as output — matching the Python original's behavior

Testing

Automated Testing

EmailSlicerTest.java contains 11 test cases (via JUnit 5 parameterized and standard tests) covering:

Category Cases
Valid emails avimax37@gmail.com, first.last@example.org, user@mail.example.co.uk
Whitespace stripping " user@test.com "
Multiple @ signs "a@b@c.com" — splits on first @, matching Python
Missing @ "invalidemail.com", "justtext"
Null / empty / blank null, "", " "
Edge cases "@domain.com", "user@", "@"

Run with: ./mvnw test

Manual Testing

  1. Build: ./mvnw package
  2. Run: java -jar target/email-slicer.jar
  3. Enter avimax37@gmail.com at the prompt
  4. Expected output:
    Your username is:  avimax37
    Your domain is:  gmail.com
    
  5. Run again with invalidemail.com — expected output: Please enter a valid Email Id.

Architecture

Overview

graph TD
    subgraph Legend
        L1[Modified]
        L2[New]
    end

    subgraph "Console Application"
        MAIN["Main.java\n(Console I/O Entry Point)"]
        MSGS["Messages.java\n(User-facing Strings)"]
    end

    subgraph "Core Logic"
        SLICER["EmailSlicer.java\n(Parsing Logic)"]
        RESULT["EmailSlicerResult.java\n(Result Record)"]
    end

    subgraph "Build System"
        POM["pom.xml + Maven Wrapper\n(Build Pipeline)"]
    end

    MAIN --> SLICER
    MAIN --> MSGS
    SLICER --> RESULT
    POM --> MAIN

    style L1 fill:#ffff00,color:#000
    style L2 fill:#00cc00,color:#000
    style MAIN fill:#00cc00,color:#000
    style MSGS fill:#00cc00,color:#000
    style SLICER fill:#00cc00,color:#000
    style RESULT fill:#00cc00,color:#000
    style POM fill:#00cc00,color:#000
Loading

Changes

Build System (pom.xml, mvnw, .mvn/)

  • Hand-crafted pom.xml with Java 17 compiler settings, JUnit 5.10.2 test dependency, and three plugins: maven-compiler-plugin, maven-surefire-plugin, maven-jar-plugin
  • maven-jar-plugin configured with com.emailslicer.Main as the main class, producing target/email-slicer.jar
  • Maven Wrapper 3.2.0 (mvnw / mvnw.cmd / .mvn/wrapper/maven-wrapper.properties) checked in for zero-install builds
  • .gitignore added for Java/Maven/IDE artifacts

Core Logic (EmailSlicer.java, EmailSlicerResult.java)

  • EmailSlicer — final utility class with a single static method slice(String): Optional<EmailSlicerResult>. Strips whitespace, splits on the first @ via indexOf, and returns Optional.empty() for null/blank/missing-@ inputs. No I/O side effects.
  • EmailSlicerResult — Java 17 record with two components (username, domain), providing immutable value semantics with auto-generated equals(), hashCode(), toString().

Console Application (Main.java, Messages.java)

  • Main — thin I/O shell that prints a prompt, reads one line via Scanner, delegates to EmailSlicer.slice(), and prints the result or an error. Mirrors the Python script's top-level flow.
  • Messages — final constants class centralizing all user-facing strings (PROMPT_EMAIL, USERNAME_PREFIX, DOMAIN_PREFIX, INVALID_EMAIL). Output strings match the Python original exactly.

Documentation (README.md)

  • Replaced the Python-centric README with a Java 17-oriented version covering build, run, test instructions, example I/O, and project structure.

Design Decisions

  1. Hand-crafted minimal POM over archetype generation — The project has only four source files. A generated archetype would introduce unnecessary boilerplate. The hand-crafted pom.xml contains exactly three plugins and one test dependency, keeping configuration minimal and auditable.

  2. Separation of I/O from parsing logic — The Python script mixes input()/print() with @-splitting in a single file. The Java version separates Main (I/O) from EmailSlicer (pure logic), making the parsing function independently testable without system-in/system-out capture.

  3. Java 17 record for result typeEmailSlicerResult is defined as a record rather than a POJO, leveraging Java 17's concise syntax for immutable data carriers. This eliminates boilerplate while providing correct equals()/hashCode() semantics.

  4. Optional return type over nullEmailSlicer.slice() returns Optional<EmailSlicerResult> to explicitly represent invalid input at the type level, avoiding null-pointer errors and making the API self-documenting.

  5. Centralized Messages class — All user-facing strings are extracted into Messages.java constants, following the project's error handling guidelines and enabling Milestone 2 to add validation messages without scattering strings across classes.


Suggested Order of Review

  1. pom.xml — Build configuration, dependencies, plugins; establishes the project foundation
  2. src/main/java/com/emailslicer/EmailSlicerResult.java — The record type; simplest file, introduces the data model
  3. src/main/java/com/emailslicer/EmailSlicer.java — Core parsing logic; consumes the result record
  4. src/main/java/com/emailslicer/Messages.java — String constants used by Main
  5. src/main/java/com/emailslicer/Main.java — Console entry point; ties together EmailSlicer and Messages
  6. src/test/java/com/emailslicer/EmailSlicerTest.java — Unit tests validating the core logic
  7. README.md — Updated documentation
  8. .gitignore — Housekeeping

Modernization Agent added 5 commits March 20, 2026 17:34
Include patterns for Maven build output, compiled classes, IDE files,
and Python testing artifacts to prevent committing generated files.
Set up Maven build with Java 17 compiler, JUnit 5 dependency,
maven-jar-plugin for executable JAR, and Maven Wrapper (3.9.6)
for self-contained builds.
Add four source files migrated from emailSlicer.py:
- EmailSlicerResult: Java 17 record for username/domain pair
- EmailSlicer: pure parsing logic splitting on first '@'
- Messages: centralized user-facing string constants
- Main: console I/O shell matching Python original output format
Cover valid emails (simple, dots, subdomains), whitespace stripping,
multiple '@' signs (Python-compatible split on first '@'), missing '@',
null/empty/blank inputs, and edge cases ('@' at start/end/only).
13 test cases using @ParameterizedTest and @CsvSource.
Replace Python-specific content with Java build/run/test instructions,
project structure, and Maven Wrapper usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants