Milestone 1: 1. Project Foundation and Core Email Parsing CLI#43
Open
mcode-app-dev[bot] wants to merge 1 commit into
Open
Milestone 1: 1. Project Foundation and Core Email Parsing CLI#43mcode-app-dev[bot] wants to merge 1 commit into
mcode-app-dev[bot] wants to merge 1 commit into
Conversation
Complete Maven project with: - EmailResult record (Java 17) for parsed email components - EmailSlicer utility with static slice() returning Optional<EmailResult> - Main class for CLI interaction matching Python original's I/O behavior - JUnit 5 test suite with 16 parameterized tests - Maven Wrapper for reproducible builds - Build: ./mvnw clean verify | Run: ./mvnw compile exec:java
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 goals described in the Milestone Instructions were implemented: the Maven project was scaffolded with wrapper, the core email parsing logic was separated from console I/O,
EmailResultwas modeled as a Java 17 record, and a JUnit 5 test suite was added.Deviation from spec: The Milestone Instructions noted that initial validation in
slice()should match the Python original's minimal@-presence check, deferring stricter regex validation to Milestone 2. The implementation follows this approach —slice()checks only for the presence of@viaindexOf, consistent with the Python baseline. Inputs like@domain.com(empty username) anduser@(empty domain) are accepted, matching the Python original's behavior. Tests explicitly document this parity.Feature Overview
This milestone migrates the Python
emailSlicer.pyCLI tool to a Java 17 project (emailslicer-java). The end user can:./mvnw compile exec:javato launch the Email Slicer CLIuser@domain.com)Please enter a valid Email Id.) for inputs without@The Java implementation preserves behavioral parity with the Python original while introducing proper class structure, type-safe return values (
EmailResultrecord), andOptional-based null safety.Testing
Automated testing
The
EmailSlicerTestclass contains 16 test cases run via./mvnw test:slice_validEmail_returnsExpectedPartsslice_leadingAndTrailingWhitespace_isTrimmed,slice_tabsAndNewlines_areTrimmedstrip()parity with Python'sstrip()@)slice_noAtSign_returnsEmptyslice_null_returnsEmpty@NullSourceslice_emptyUsername_returnsResult,slice_emptyDomain_returnsResult,slice_multipleAtSigns_splitsOnFirstemailResult_equalsAndHashCode,emailResult_toString_containsFieldsManual testing
Please enter your Email Id:prompt, typealice@example.comand press Enter.invalidemail(no@symbol). Verify the output:Architecture
Overview
graph TD subgraph Legend L1[New]:::newNode L2[Reference Only]:::refNode end subgraph "emailslicer-dkasargod (Python)" PY["emailSlicer.py<br/>Python CLI Script"]:::refNode end subgraph "emailslicer-java (Java 17)" MAIN["Main.java<br/>Console I/O"]:::newNode SLICER["EmailSlicer.java<br/>Parsing Logic"]:::newNode RECORD["EmailResult.java<br/>Java 17 Record"]:::newNode POM["pom.xml<br/>Maven Build"]:::newNode end PY -.->|"migrated to"| MAIN MAIN --> SLICER SLICER --> RECORD classDef newNode fill:#90EE90,stroke:#333,color:#000 classDef refNode fill:#D3D3D3,stroke:#333,color:#000Changes
Maven Build Configuration (
pom.xml)groupId=com.emailslicer,artifactId=emailslicer, Java 17 source/targetjunit-bomBOM importmaven-compiler-plugin(3.11.0),maven-surefire-plugin(3.2.5),maven-jar-plugin(3.3.0 withMain-Classmanifest),exec-maven-plugin(3.1.0).mvn/wrapper/andmvnw/mvnw.cmdscripts, targeting Maven 3.9.6EmailResult Record (
EmailResult.java)recordwith two fields:usernameanddomainequals(),hashCode(), andtoString()EmailSlicer Parsing Logic (
EmailSlicer.java)slice(String email)returningOptional<EmailResult>String.strip()(matching Python'sstrip()), checks for@viaindexOf, splits into username/domainOptional.empty()fornullinput or missing@Main Console I/O (
Main.java)Scanner-based stdin reading"Please enter your Email Id:", delegates toEmailSlicer.slice(), and prints results usingifPresentOrElse"Your username is: ..."/"Your domain is: ..."Design Decisions
Maven with
maven-jar-pluginovermaven-shade-pluginmaven-jar-pluginwith aMain-Classmanifest entry was chosen overmaven-shade-plugin(fat JAR). Since the project has zero runtime dependencies (JUnit is test-scoped only), a shade plugin adds unnecessary build complexity. The jar plugin satisfies thejava -jar target/emailslicer.jarrequirement from the Modernization Instructions.Separated concerns (3 classes) over single-class design
Main.javahandles I/O,EmailSlicer.javaholds pure parsing logic, andEmailResult.javais the value type. This separation — rather than mirroring the Python single-script approach — makes the parsing logic independently testable without stdout capture, aligning with the Modernization Instructions.Python-equivalent validation deferred to Milestone 2
slice()currently validates only@presence (matching the Python original'semail.find("@") != -1). Inputs like@domain.comoruser@are accepted. This establishes behavioral parity as a baseline; regex-based stricter validation is deferred to Milestone 2 per the Milestone Instructions.Suggested Order of Review
pom.xml— Start here to understand the build configuration, dependencies, and plugin setupsrc/main/java/com/emailslicer/EmailResult.java— The Java 17 record that models the parsed resultsrc/main/java/com/emailslicer/EmailSlicer.java— Core parsing logic; the primary API surfacesrc/main/java/com/emailslicer/Main.java— Console I/O entry point that consumesEmailSlicersrc/test/java/com/emailslicer/EmailSlicerTest.java— Test suite covering valid, invalid, and edge-case inputs.gitignore,mvnw/mvnw.cmd,.mvn/wrapper/— Supporting build infrastructure (skim only)