Milestone 1: 1 — Project Scaffold, Core Email Parsing, and CLI Entry Point#44
Open
mcode-app-dev[bot] wants to merge 1 commit into
Open
Conversation
Migrate the Python email slicer to Java 17 with standard Maven layout, Maven Wrapper, EmailParts record, EmailSlicer parser, Messages constants, Main CLI entry point, and JUnit 5 test suite (8 tests).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
View Milestone
Table of Contents
Status
The milestone was successfully completed. All scope items from the Milestone Instructions are implemented:
EmailPartsJava 17 record implementedEmailSlicer.parse()static method with validation (null/blank, missing@, multiple@, empty username, empty domain)MainCLI entry point matching the original Python output formatDeviations from Milestone Instructions: None. The output format of the Java CLI matches the Python original exactly (including the trailing space produced by Python's comma-separated
print). AMessagesclass was added per the error handling guidelines to centralize user-facing strings; this was not explicitly listed in the Milestone Instructions but is prescribed by the project-level instruction file on error handling.Feature Overview
This milestone establishes the Java 17 Email Slicer project — a 1:1 migration of the Python
emailSlicer.pyCLI tool. The application:stdin@with non-empty username and domain partsYour username is: <username>andYour domain is: <domain>tostdoutPlease enter a valid Email Id.and exits with code 1 on invalid inputA user can build and run the application with:
Testing
Automated testing
EmailSlicerTest.javacontains 8 JUnit 5 tests exercisingEmailSlicer.parse()directly:validEmailavimax37@gmail.comEmailParts("avimax37", "gmail.com")leadingTrailingWhitespaceuser@example.orgEmailParts("user", "example.org")missingAtSigninvalidemailIllegalArgumentExceptionemptyString""IllegalArgumentExceptionnullInputnullIllegalArgumentExceptionmultipleAtSignsa@b@c.comIllegalArgumentExceptionemptyUsername@domain.comIllegalArgumentExceptionemptyDomainuser@IllegalArgumentExceptionRun with:
./mvnw testManual testing
Architecture
Overview
graph TD subgraph Legend L1[New]:::newNode L2[Reference Only]:::refNode end subgraph "emailslicer-dkasargod (Python - Reference)" PY[emailSlicer.py]:::refNode end subgraph "emailslicer-dkasargod-java (Java 17)" MAIN[Main.java - CLI Entry Point]:::newNode SLICER[EmailSlicer.java - Parse Logic]:::newNode PARTS[EmailParts.java - Record]:::newNode MSGS[Messages.java - Constants]:::newNode end PY -.->|migrated to| MAIN MAIN --> SLICER SLICER --> PARTS MAIN --> MSGS SLICER --> MSGS classDef newNode fill:#90EE90,stroke:#333,color:#000 classDef refNode fill:#D3D3D3,stroke:#333,color:#000Changes
CLI Entry Point (
Main.java)Handles all console I/O: prints the prompt, reads a line from
stdin, delegates toEmailSlicer.parse(), and prints the result. On invalid input, catchesIllegalArgumentException, prints the error message, and callsSystem.exit(1).Parse Logic (
EmailSlicer.java)Contains a single static method
parse(String): EmailPartsthat encapsulates all validation and splitting logic. Validates that input is non-null/non-blank, contains exactly one@, and has non-empty username and domain segments. ThrowsIllegalArgumentExceptionon any violation.Result Record (
EmailParts.java)A Java 17
recordholdingusernameanddomain. Provides immutability and automaticequals/hashCode/toString, which simplifies test assertions.User-Facing Messages (
Messages.java)Centralizes all user-facing strings (
PROMPT_MESSAGE,INVALID_EMAIL_MESSAGE,USERNAME_PREFIX,DOMAIN_PREFIX) aspublic static finalconstants, per the error handling guidelines.Build Configuration (
pom.xml, Maven Wrapper)Maven
pom.xmltargets Java 17, declares JUnit 5 as the sole (test-scoped) dependency, and configuresmaven-jar-pluginto produce an executable JAR withMain-Classmanifest entry. The Maven Wrapper (mvnw,mvnw.cmd,.mvn/wrapper/maven-wrapper.properties) enables building without a pre-installed Maven.Design Decisions
Separation of parsing logic from I/O
EmailSlicer(pure function) is separated fromMain(console I/O).input()/print()with string slicing. Separating these concerns allows unit testing the parse logic directly without mockingSystem.in/System.out.Java 17
recordfor result typeEmailPartsis declared as arecordrather than a POJO.equals/hashCode/toStringautomatically, enabling conciseassertEqualsassertions in tests.IllegalArgumentExceptionfor invalid inputEmailSlicer.parse()throwsIllegalArgumentExceptionon invalid input;Maincatches it and prints the message.IllegalArgumentExceptionfor precondition violations. Produces cleanassertThrowstest assertions and establishes a convention for future validation enhancements.Centralized
MessagesclassMessages.java.Suggested Order of Review
emailslicer-dkasargod-java/pom.xml— Build configuration, dependencies, and packagingemailslicer-dkasargod-java/.mvn/wrapper/maven-wrapper.properties— Maven Wrapper configurationemailslicer-dkasargod-java/mvnw— Maven Wrapper shell scriptemailslicer-dkasargod-java/src/main/java/com/emailslicer/EmailParts.java— Data model (record)emailslicer-dkasargod-java/src/main/java/com/emailslicer/Messages.java— Constants used across the appemailslicer-dkasargod-java/src/main/java/com/emailslicer/EmailSlicer.java— Core parse logicemailslicer-dkasargod-java/src/main/java/com/emailslicer/Main.java— CLI entry point consuming the aboveemailslicer-dkasargod-java/src/test/java/com/emailslicer/EmailSlicerTest.java— Test suite validating parse logic