Milestone 1: 1 — Project Foundation and Core Email Slicing#47
Open
mcode-app-dev[bot] wants to merge 5 commits into
Open
Milestone 1: 1 — Project Foundation and Core Email Slicing#47mcode-app-dev[bot] wants to merge 5 commits into
mcode-app-dev[bot] wants to merge 5 commits into
Conversation
added 5 commits
March 30, 2026 23:05
Set up the Java 17 Maven project structure for the email slicer migration including pom.xml with JUnit 5 dependency, Maven Wrapper scripts, .gitignore, and standard src/main/java + src/test/java layout.
Implement the core email slicing: EmailSliceResult Java 17 record for the parsed result, and EmailSlicer.slice() static method that trims input and splits on '@'. Throws IllegalArgumentException for null, blank, or missing-@ inputs, matching the original Python validation.
Implement the CLI entry point that prompts for an email address, calls EmailSlicer.slice(), and prints the username and domain. Catches IllegalArgumentException to print the error and exit with code 1, matching the original Python tool's behavior.
16 tests covering valid emails, whitespace trimming, missing @, null/empty/blank input, edge cases (@-only, empty username/domain, multiple @ symbols), and error message content verification.
Move all hardcoded user-facing message literals into Messages.java with public static final constants, per the error handling guidelines. Update EmailSlicer and Main to reference Messages constants.
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
Milestone 1 was successfully completed. All goals defined in the Milestone Instructions were implemented:
EmailSliceResultrecord,EmailSlicerparsing logic, andMainCLI entry point@, empty/blank input, whitespace trimming, and edge casesDeviation from Milestone Instructions: A
Messages.javaclass was added to centralize all user-facing strings. This was not explicitly called for in the spec but is a minor structural improvement that aids maintainability and future localization without changing any external behavior.The initial validation strategy uses
contains("@")(matching the original Python behavior), as prescribed by the Milestone Instructions for this milestone, with regex-based validation deferred to Milestone 2.Feature Overview
This milestone establishes the complete Java 17 Maven project and implements core email slicing functionality, migrating the original Python
emailSlicer.pyto an idiomatic Java CLI application.End-user capability: A user can run the application, enter an email address at the prompt, and see the username and domain printed to the console — matching the original Python tool's behavior.
Example session:
Testing
Automated Testing
EmailSlicerTest.javacontains 14 JUnit 5 tests organized into nested test classes:@@symbol, plain word@only,@at start,@at end, multiple@, three-part@Run tests with:
./mvnw testManual Testing
user@example.com— verify output:invalidemail— verify output:echo $?should print1).Architecture
Overview
graph TD subgraph Legend L1[New]:::newNode L2[Reference Only]:::refNode end A["emailSlicer.py<br/>(Original Python Script)"]:::refNode B["Main.java<br/>(CLI Entry Point)"]:::newNode C["EmailSlicer.java<br/>(Parsing Logic)"]:::newNode D["EmailSliceResult.java<br/>(Record)"]:::newNode E["Messages.java<br/>(User-Facing Strings)"]:::newNode F["pom.xml + Maven Wrapper<br/>(Build System)"]:::newNode A -.->|"migrated to"| B B -->|"delegates to"| C C -->|"returns"| D B -->|"uses"| E C -->|"uses"| E F -->|"builds"| B F -->|"builds"| C classDef newNode fill:#90EE90,stroke:#333,color:#000 classDef refNode fill:#D3D3D3,stroke:#333,color:#000Changes
Build System (
pom.xml+ Maven Wrapper)pom.xmlconfigured withgroupId=com.emailslicer,artifactId=email-slicer, targeting Java 17maven-compiler-plugin3.11.0,maven-surefire-plugin3.2.5,maven-jar-plugin3.3.0 (withMainas manifest main class, final nameemail-slicer)mvnw/mvnw.cmd+.mvn/wrapper/) checked in for zero-install builds.gitignoreconfigured for Maventarget/, IDE files, and OS artifactsParsing Logic (
EmailSlicer.java)slice(String email)String.strip()(matching Python'sstrip()behavior)@usingcontains("@")— matching original Python validation@usingindexOf+substringIllegalArgumentExceptionwith a user-friendly message for null, blank, or missing-@inputData Carrier (
EmailSliceResult.java)recordwith two fields:usernameanddomainequals/hashCode/toStringCLI Entry Point (
Main.java)System.inviaScanner, delegates toEmailSlicer.slice()System.out.printfIllegalArgumentException, prints the error message, and exits with code 1User-Facing Strings (
Messages.java)MainandEmailSlicerto ensure consistent messagingDesign Decisions
1. Two-class separation of parsing logic and console I/O
EmailSlicercontains pure parsing logic;Mainhandles all I/OSystem.in/System.out. Prescribed by the Modernization Instructions.2. Initial validation matches Python behavior (
contains("@"))3.
IllegalArgumentExceptionfor invalid input signalingOptional.empty()return typeassertThrows. Provides descriptive error messages to end users.4. Dedicated
Messagesclass for user-facing stringsMessages.javaMainandEmailSlicer, simplifies future localization, and makes message content easily reviewable in one place.Suggested Order of Review
pom.xml— Build configuration, dependencies, and pluginssrc/main/java/com/emailslicer/EmailSliceResult.java— Data carrier record (simplest class; introduces the core data model)src/main/java/com/emailslicer/Messages.java— User-facing string constants (referenced by the next two files)src/main/java/com/emailslicer/EmailSlicer.java— Core parsing logic (usesEmailSliceResultandMessages)src/main/java/com/emailslicer/Main.java— CLI entry point (uses all of the above)src/test/java/com/emailslicer/EmailSlicerTest.java— Unit tests (validates the parsing logic).gitignore— Repository ignore rules