Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
smirnovaae committed Mar 7, 2024
1 parent d7ff459 commit 5d2aa14
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
15 changes: 12 additions & 3 deletions optout/src/main/java/gov/cms/ab2d/optout/OptOutS3.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ public BufferedReader openFileS3() {

public String createResponseOptOutFile(String responseContent) {
try {
var key = CONF_FILE_NAME
+ new SimpleDateFormat(CONF_FILE_NAME_PATTERN).format(new Date())
+ CONF_FILE_FORMAT;
var key = getOutFileName();

var objectRequest = PutObjectRequest.builder()
.bucket(bfdBucket)
Expand Down Expand Up @@ -93,5 +91,16 @@ public void deleteFileFromS3() {
}
}

public String getOutFileName() {
//bfdeft01/ab2d/in/testing.txt
var name = CONF_FILE_NAME
+ new SimpleDateFormat(CONF_FILE_NAME_PATTERN).format(new Date())
+ CONF_FILE_FORMAT;

String[] path = fileName.split("in");

return path[0] + "out/" + name;
}


}
12 changes: 10 additions & 2 deletions optout/src/test/java/gov/cms/ab2d/optout/OptOutS3Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
import java.nio.file.Files;
import java.nio.file.Paths;

import static gov.cms.ab2d.optout.OptOutConstants.TEST_BFD_BUCKET_NAME;
import static gov.cms.ab2d.optout.OptOutConstants.TEST_FILE_NAME;
import static gov.cms.ab2d.optout.OptOutConstants.*;
import static gov.cms.ab2d.optout.S3MockAPIExtension.S3_CLIENT;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -58,4 +57,13 @@ void deleteFileFromS3Test() {
OPT_OUT_S3.deleteFileFromS3();
Assertions.assertFalse(S3MockAPIExtension.isObjectExists(TEST_FILE_NAME));
}

@Test
void getOutFileName() {
var subFolders = "bfdeft01/ab2d";
OPT_OUT_S3 = new OptOutS3(S3_CLIENT, subFolders + "/in/" + TEST_FILE_NAME, TEST_BFD_BUCKET_NAME, mock(LambdaLogger.class));
var outFileName = OPT_OUT_S3.getOutFileName();
Assertions.assertTrue(outFileName.startsWith(subFolders + "/out/" + CONF_FILE_NAME));
Assertions.assertTrue(outFileName.endsWith(CONF_FILE_FORMAT));
}
}

0 comments on commit 5d2aa14

Please sign in to comment.