From 9c616c5d2bc7ea578d251c1abd5e7a8063a1ded0 Mon Sep 17 00:00:00 2001 From: Anna Smirnova <132938234+smirnovaae@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:37:48 -0700 Subject: [PATCH] Ab2d-6007/update reguest file (#92) --- .../AttributionDataShareConstants.java | 3 +-- .../AttributionDataShareHelper.java | 8 +++---- .../AttributionDataShareTest.java | 22 +++++++++---------- .../gov/cms/ab2d/optout/OptOutConstants.java | 2 +- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/attribution-data-file-share/src/main/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareConstants.java b/attribution-data-file-share/src/main/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareConstants.java index f97cd9a..45eaa7f 100644 --- a/attribution-data-file-share/src/main/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareConstants.java +++ b/attribution-data-file-share/src/main/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareConstants.java @@ -12,14 +12,13 @@ public class AttributionDataShareConstants { public static final String TEST_ENDPOINT = "http://127.0.0.1:8001"; public static final Region S3_REGION = Region.US_EAST_1; public static final String FILE_PATH = "/tmp/"; - public static final String REQ_FILE_NAME = "P.AB2D.NGD.REQ."; + public static final String REQ_FILE_NAME = "P#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 SELECT_STATEMENT = "SELECT * FROM public.current_mbi"; public static final int CURRENT_MBI_LENGTH = 11; public static final String EFFECTIVE_DATE_PATTERN = "yyyyMMdd"; - public static final int EFFECTIVE_DATE_LENGTH = 8; public static final String BUCKET_NAME_PROP = "S3_UPLOAD_BUCKET"; public static final String UPLOAD_PATH_PROP = "S3_UPLOAD_PATH"; diff --git a/attribution-data-file-share/src/main/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareHelper.java b/attribution-data-file-share/src/main/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareHelper.java index 565ed8f..b05f25e 100644 --- a/attribution-data-file-share/src/main/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareHelper.java +++ b/attribution-data-file-share/src/main/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareHelper.java @@ -56,12 +56,10 @@ String getResponseLine(String currentMbi, Timestamp effectiveDate, Boolean optOu if (currentMbi.length() < CURRENT_MBI_LENGTH) result.append(" ".repeat(Math.max(0, CURRENT_MBI_LENGTH - currentMbi.length()))); - if (effectiveDate == null) - result.append(" ".repeat(EFFECTIVE_DATE_LENGTH)); - else + if (effectiveDate != null) { result.append(new SimpleDateFormat(EFFECTIVE_DATE_PATTERN).format(effectiveDate)); - - result.append((optOutFlag) ? 'Y' : 'N'); + result.append((optOutFlag) ? 'Y' : 'N'); + } return result.toString(); } diff --git a/attribution-data-file-share/src/test/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareTest.java b/attribution-data-file-share/src/test/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareTest.java index d3defea..6193804 100644 --- a/attribution-data-file-share/src/test/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareTest.java +++ b/attribution-data-file-share/src/test/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareTest.java @@ -21,7 +21,7 @@ import java.sql.Statement; import java.sql.Timestamp; import java.text.SimpleDateFormat; -import java.util.Collections; +import java.util.Arrays; import java.util.Date; import static gov.cms.ab2d.attributionDataShare.AttributionDataShareConstants.*; @@ -38,11 +38,11 @@ public class AttributionDataShareTest { @Container private static final PostgreSQLContainer POSTGRE_SQL_CONTAINER = new AB2DPostgresqlContainer(); LambdaLogger LOGGER = mock(LambdaLogger.class); - String FILE_NAME = REQ_FILE_NAME + new SimpleDateFormat(REQ_FILE_NAME_PATTERN).format(new Date()); String FILE_FULL_PATH = FILE_PATH + FILE_NAME; - - String MBI = "DUMMY000001"; + String MBI_1 = "DUMMY000001"; + String MBI_2 = "DUMMY000002"; + Timestamp DATE = Timestamp.valueOf("2024-02-26 00:00:00"); AttributionDataShareHelper helper; @BeforeEach @@ -55,9 +55,9 @@ void copyDataToFileTest() throws IOException, SQLException { var connection = mock(Connection.class); var stmt = mock(Statement.class); var rs = new MockResultSet(""); - rs.addColumn("mbi", Collections.singletonList(MBI)); - rs.addColumn("effective_date", Collections.singletonList(null)); - rs.addColumn("opt_out_flag", Collections.singletonList(true)); + rs.addColumn("mbi", Arrays.asList(MBI_1, MBI_2)); + rs.addColumn("effective_date", Arrays.asList(DATE, null)); + rs.addColumn("opt_out_flag", Arrays.asList(true, null)); when(connection.createStatement()).thenReturn(stmt); when(getExecuteQuery(stmt)).thenReturn(rs); @@ -69,9 +69,9 @@ void copyDataToFileTest() throws IOException, SQLException { @Test void getResponseLineTest() { - assertEquals(MBI + " Y", helper.getResponseLine(MBI, null, true)); - assertEquals(MBI + "20240226N", helper.getResponseLine(MBI, Timestamp.valueOf("2024-02-26 00:00:00"), false)); - assertEquals("A Y", helper.getResponseLine("A", null, true)); + assertEquals(MBI_1, helper.getResponseLine(MBI_1, null, null)); + assertEquals(MBI_2 + "20240226N", helper.getResponseLine(MBI_2, DATE, false)); + assertEquals("A 20240226Y", helper.getResponseLine("A", DATE, true)); } @@ -95,7 +95,7 @@ void getUploadPathTest() { private void createTestFile() throws IOException { PrintWriter writer = new PrintWriter(FILE_FULL_PATH, StandardCharsets.UTF_8); - writer.println("Test"); + writer.println(MBI_1); writer.close(); } } diff --git a/optout/src/main/java/gov/cms/ab2d/optout/OptOutConstants.java b/optout/src/main/java/gov/cms/ab2d/optout/OptOutConstants.java index 34ab5a6..b0ae898 100644 --- a/optout/src/main/java/gov/cms/ab2d/optout/OptOutConstants.java +++ b/optout/src/main/java/gov/cms/ab2d/optout/OptOutConstants.java @@ -19,7 +19,7 @@ public class OptOutConstants { public static final String EFFECTIVE_DATE_PATTERN = "yyyyMMdd"; public static final int EFFECTIVE_DATE_LENGTH = 8; public static final String LINE_SEPARATOR = System.getProperty("line.separator"); - public static final String CONF_FILE_NAME = "P.AB2D.NGD.CONF."; + public static final String CONF_FILE_NAME = "P#EFT.ON.AB2D.NGD.CONF."; public static final String CONF_FILE_NAME_PATTERN = "'D'yyMMdd.'T'hhmmsss"; public static final String UPDATE_STATEMENT = "UPDATE public.coverage\n" + "SET opt_out_flag = ?, effective_date = current_timestamp\n" +