Skip to content

Commit

Permalink
Ab2d-6007/update reguest file (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
smirnovaae authored Mar 13, 2024
1 parent c4d4233 commit 9c616c5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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));
}


Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down

0 comments on commit 9c616c5

Please sign in to comment.