Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AB2D-6036 File trailer need to be changed #97

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class AttributionDataShareConstants {
public static final String FILE_PATH = "/tmp/";
public static final String REQ_FILE_NAME = "#EFT.ON.AB2D.NGD.REQ.";
public static final String REQ_FILE_NAME_PATTERN = "'D'yyMMdd.'T'HHmmsss";
public static final String FIRST_LINE = "HDR_BENEDATAREQ";
public static final String LAST_LINE = "TLR_BENEDATAREQ";
public static final String AB2D_HEADER_REQ = "HDR_BENEDATAREQ";
public static final String AB2D_TRAILER_REQ = "TRL_BENEDATAREQ";
public static final String SELECT_STATEMENT = "SELECT * FROM public.current_mbi";
public static final int CURRENT_MBI_LENGTH = 11;
public static final String EFFECTIVE_DATE_PATTERN = "yyyyMMdd";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void copyDataToFile(Connection connection) {

var rs = getExecuteQuery(stmt);

writer.write(FIRST_LINE + date);
writer.write(AB2D_HEADER_REQ + date);
writer.newLine();
long records = 0;
while (rs.next()) {
Expand All @@ -45,7 +45,7 @@ void copyDataToFile(Connection connection) {
writer.newLine();
records++;
}
writer.write(LAST_LINE + date + String.format("%010d", records));
writer.write(AB2D_TRAILER_REQ + date + String.format("%010d", records));

} catch (SQLException | IOException ex) {
String errorMessage = "An error occurred while exporting data to a file. ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Scanner;

import static gov.cms.ab2d.attributionDataShare.AttributionDataShareConstants.*;
import static gov.cms.ab2d.attributionDataShare.AttributionDataShareHelper.getExecuteQuery;
Expand Down Expand Up @@ -64,6 +65,14 @@ void copyDataToFileTest() throws IOException, SQLException {
assertDoesNotThrow(() -> helper.copyDataToFile(connection));

assertTrue(Files.exists(Paths.get(FILE_FULL_PATH)));

var scanner = new Scanner(Paths.get(FILE_FULL_PATH), StandardCharsets.UTF_8);
var content = scanner.useDelimiter("\\A").next();
scanner.close();

assertTrue(content.contains(AB2D_HEADER_REQ));
assertTrue(content.contains(AB2D_TRAILER_REQ));

FileUtil.deleteDirectoryRecursion(Paths.get(FILE_FULL_PATH));
}

Expand Down
4 changes: 2 additions & 2 deletions optout/src/main/java/gov/cms/ab2d/optout/OptOutConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public class OptOutConstants {
public static final String ENDPOINT = "https://s3.amazonaws.com";
public static final Region S3_REGION = Region.US_EAST_1;
public static final String HEADER_RESP = "HDR_BENEDATARSP";
public static final String TRAILER_RESP = "TLR_BENEDATARSP";
public static final String TRAILER_RESP = "TRL_BENEDATARSP";
public static final String AB2D_HEADER_CONF = "HDR_BENECONFIRM";
public static final String AB2D_TRAILER_CONF = "TLR_BENECONFIRM";
public static final String AB2D_TRAILER_CONF = "TRL_BENECONFIRM";
public static final int MBI_INDEX_START = 0;
public static final int MBI_INDEX_END = 11;
public static final int OPTOUT_FLAG_INDEX = 11;
Expand Down
2 changes: 1 addition & 1 deletion optout/src/test/resources/optOutDummy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ DUMMY000004N
DUMMY000005N
DUMMY000006Y
DUMMY000007N
TLR_BENEDATARSP202401230000000007
TRL_BENEDATARSP202401230000000007
Loading