-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from joutvhu/development
v1.1.4
- Loading branch information
Showing
7 changed files
with
66 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
2 changes: 0 additions & 2 deletions
2
src/main/java/com/joutvhu/fixedwidth/parser/util/IgnoreError.java
This file contains 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
This file contains 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
60 changes: 60 additions & 0 deletions
60
src/test/java/com/joutvhu/fixedwidth/parser/OptionTests.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.joutvhu.fixedwidth.parser; | ||
|
||
import com.joutvhu.fixedwidth.parser.annotation.FixedField; | ||
import com.joutvhu.fixedwidth.parser.annotation.FixedObject; | ||
import com.joutvhu.fixedwidth.parser.constraint.FixedOption; | ||
import com.joutvhu.fixedwidth.parser.domain.KeepPadding; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
class OptionTests { | ||
private FixedParser fixedParser; | ||
|
||
@BeforeAll | ||
public void beforeTest() { | ||
this.fixedParser = FixedParser.parser(); | ||
} | ||
|
||
@Test | ||
void optionsWithDropPadding() { | ||
DropPaddingStone stone = new DropPaddingStone("blue"); | ||
|
||
assertEquals("blue ", fixedParser.export(stone)); | ||
assertEquals("blue", fixedParser.parse(DropPaddingStone.class, "blue ").color); | ||
} | ||
|
||
@Test | ||
void optionsWithKeepPadding() { | ||
KeepPaddingStone stone = new KeepPaddingStone("blue"); | ||
|
||
assertEquals("blue ", fixedParser.export(stone)); | ||
assertEquals("blue ", fixedParser.parse(KeepPaddingStone.class, "blue ").color); | ||
} | ||
|
||
@FixedObject | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class DropPaddingStone { | ||
@FixedField(length = 5, keepPadding = KeepPadding.DROP) | ||
@FixedOption(options = {"blue ", "white"}) | ||
private String color; | ||
} | ||
|
||
@FixedObject | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class KeepPaddingStone { | ||
@FixedField(length = 5, keepPadding = KeepPadding.KEEP) | ||
@FixedOption(options = {"blue ", "white"}) | ||
private String color; | ||
} | ||
} |