-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
89 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.github.avew; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class CsvSftpValue extends CsvewValue { | ||
|
||
private String identityId; | ||
private String identityType; | ||
private String identityName; | ||
private String docNo; | ||
private String docDate; | ||
private String docTemplate; | ||
private String docKopur; | ||
private String docPassword; | ||
private String docReference; | ||
} |
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,57 @@ | ||
package io.github.avew; | ||
|
||
import io.github.avew.reader.CsvewReader; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.io.InputStream; | ||
|
||
public class CsvewSftpParserTest extends CsvewReader<CsvSftpValue> { | ||
|
||
static String[] HEADER = { | ||
"Identity Number", | ||
"Identity Type", | ||
"Identity Name", | ||
"Document Number", | ||
"Document Date", | ||
"Template Code", | ||
"Transaction Value", | ||
"Password", | ||
"Document Reference", | ||
}; | ||
|
||
@Test | ||
public void testReadSuccess() { | ||
InputStream is = this.getClass().getResourceAsStream("/csv/1.csv"); | ||
CsvewResultReader<CsvSftpValue> read = process(0, is); | ||
System.out.println(read.getValues().toString()); | ||
} | ||
|
||
|
||
@Override | ||
public CsvewResultReader<CsvSftpValue> process(int startAt, InputStream is) { | ||
CsvewParser csvParseUser = new CsvewParser(); | ||
return read(true, | ||
startAt, | ||
is, | ||
HEADER, | ||
";", | ||
(line, columns, validations, value) -> { | ||
csvParseUser.parseString(line, 0, HEADER[0], columns[0], true, validations, value::setIdentityId); | ||
csvParseUser.parseString(line, 1, HEADER[1], columns[1], true, validations, value::setIdentityType); | ||
csvParseUser.parseString(line, 2, HEADER[2], columns[2], true, validations, value::setIdentityName); | ||
csvParseUser.parseString(line, 3, HEADER[3], columns[3], true, validations, value::setDocNo); | ||
csvParseUser.parseString(line, 4, HEADER[4], columns[4], true, validations, value::setDocDate); | ||
csvParseUser.parseString(line, 5, HEADER[5], columns[5], true, validations, value::setDocTemplate); | ||
csvParseUser.parseString(line, 6, HEADER[6], columns[6], false, validations, value::setDocKopur); | ||
|
||
try { | ||
csvParseUser.parseString(line, 7, HEADER[7], columns[7], false, validations, value::setDocPassword); | ||
csvParseUser.parseString(line, 8, HEADER[8], columns[8], false, validations, value::setDocReference); | ||
} catch (IndexOutOfBoundsException ignore) { | ||
} | ||
}); | ||
} | ||
|
||
|
||
} |
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 @@ | ||
0000111122224444;NOW;RAAM TEST;0614_19112019_000001_082343;19-11-20192;E001;4897546;;;;true;FIELD_VALIDATION;Identity Type should only be NIK (Citizenship ID Number) or NPWP (Taxpayer ID Number) |