Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
smirnovaae committed Mar 11, 2024
1 parent a10973a commit 982beb2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ public class AttributionDataShareTest {

@BeforeEach
public void beforeEach() {
// var sysMock = Mockito.mockStatic(System.class);
// System.setProperty("S3_UPLOAD_BUCKET", BUCKET_NAME);
// System.setProperty("S3_UPLOAD_PATH", UPLOAD_PATH);
// sysMock.when(() -> System.getProperty(BUCKET_NAME_PROP)).thenReturn(BUCKET_NAME);
// sysMock.when(() -> System.getProperty(UPLOAD_PATH_PROP)).thenReturn(UPLOAD_PATH);
helper = spy(new AttributionDataShareHelper(FILE_NAME, FILE_FULL_PATH, LOGGER));
}

Expand Down
31 changes: 1 addition & 30 deletions optout/src/main/java/gov/cms/ab2d/optout/OptOutS3.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,6 @@ public OptOutS3(S3Client s3Client, String fileName, String bfdBucket, LambdaLogg
this.logger = logger;
}

public void doesBucketExist(){
try {
logger.log("Bucket name: " + bfdBucket);
logger.log("File name: " + fileName);

HeadBucketRequest headBucketRequest = HeadBucketRequest.builder()
.bucket(bfdBucket).build();

s3Client.headBucket(headBucketRequest);
logger.log("Bucket exists");

} catch (SdkClientException ex) {
var errorMessage = "Unable to load credentials to connect S3 bucket";
logger.log(errorMessage);
throw new OptOutException(errorMessage, ex);
} catch (S3Exception ex) {
if (ex.statusCode() == 404) {

var errorMessage = "Object " + fileName + " does not exist. " + ex.getMessage();
logger.log(errorMessage);
throw new OptOutException(errorMessage, ex);
} else {
logger.log(ex.getMessage());
throw ex;
}
}

}

public BufferedReader openFileS3() {
try {
//Checking if object exists
Expand Down Expand Up @@ -131,7 +102,7 @@ public String getOutFileName() {

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

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


Expand Down

0 comments on commit 982beb2

Please sign in to comment.