Skip to content

Commit

Permalink
Ab2d-6039/trailing junk on timestamp (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
smirnovaae authored Apr 4, 2024
1 parent 720593a commit fea0adc
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void copyDataToFile(Connection connection) {
writer.newLine();
long records = 0;
while (rs.next()) {
var line = getResponseLine(rs.getString(1), rs.getTimestamp(2), rs.getBoolean(3));
var line = getResponseLine(rs.getString(1), rs.getDate(2), rs.getBoolean(3));
writer.write(line);
writer.newLine();
records++;
Expand All @@ -54,7 +54,7 @@ void copyDataToFile(Connection connection) {
}
}

String getResponseLine(String currentMbi, Timestamp effectiveDate, Boolean optOutFlag) {
String getResponseLine(String currentMbi, Date effectiveDate, Boolean optOutFlag) {
var result = new StringBuilder();
result.append(currentMbi);
// Adding spaces to the end of a string to achieve the required position index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Scanner;
import java.util.*;

import static gov.cms.ab2d.attributionDataShare.AttributionDataShareConstants.*;
import static gov.cms.ab2d.attributionDataShare.AttributionDataShareHelper.getExecuteQuery;
Expand All @@ -43,7 +40,7 @@ public class AttributionDataShareTest {
String FILE_FULL_PATH = FILE_PATH + FILE_NAME;
String MBI_1 = "DUMMY000001";
String MBI_2 = "DUMMY000002";
Timestamp DATE = Timestamp.valueOf("2024-02-26 00:00:00");
Date DATE = new GregorianCalendar(2024, Calendar.FEBRUARY, 26).getTime();
AttributionDataShareHelper helper;

@BeforeEach
Expand All @@ -57,7 +54,7 @@ void copyDataToFileTest() throws IOException, SQLException {
var stmt = mock(Statement.class);
var rs = new MockResultSet("");
rs.addColumn("mbi", Arrays.asList(MBI_1, MBI_2));
rs.addColumn("effective_date", Arrays.asList(DATE, null));
rs.addColumn("effective_date", Arrays.asList("2024-02-26", null));
rs.addColumn("opt_out_flag", Arrays.asList(true, null));
when(connection.createStatement()).thenReturn(stmt);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class OptOutConstants {
public static final String CONF_FILE_NAME = "#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.current_mbi\n" +
"SET opt_out_flag = ?, effective_date = current_timestamp\n" +
"SET opt_out_flag = ?, effective_date = current_date\n" +
"WHERE mbi = ?";

private OptOutConstants() {
Expand Down
2 changes: 0 additions & 2 deletions optout/src/main/java/gov/cms/ab2d/optout/OptOutS3.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public String createResponseOptOutFile(String responseContent) {
.build();

s3Client.putObject(objectRequest, RequestBody.fromString(responseContent));
logger.log("Response file done");
return key;
} catch (AmazonS3Exception ex) {
var errorMessage = "Response OptOut file cannot be created. ";
Expand All @@ -86,7 +85,6 @@ public void deleteFileFromS3() {
.build();

s3Client.deleteObject(request);
logger.log("delete file done");
} catch (SdkClientException ex) {
logger.log(ex.getMessage());
}
Expand Down
4 changes: 2 additions & 2 deletions optout/src/test/resources/optOutDummy.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
HDR_BENEDATARSP20240123
1S00E00JG37N
1S00E00JG37Y
7SP1D00AA00N
2SY1D00AA00Y
7SF9C00AA00N
6SF9C00AA00N
7SF6F00AA00N
DUMMY000006Y
DUMMY000007N
TRL_BENEDATARSP202401230000000007

0 comments on commit fea0adc

Please sign in to comment.