Skip to content

Commit

Permalink
Print environment variable keys for debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdriton committed Nov 8, 2024
1 parent b843693 commit b4e3164
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
session.transfer(flowFileHolder[0], REL_SUCCESS);

} catch (Exception ex) {
logger.error("Failed to process flow file", ex);
logger.error("Failed to process flow file: ", ex.getMessage());
flowFileHolder[0] = session.putAttribute(flowFileHolder[0], "aws.sms.error", ex.getMessage());
session.transfer(flowFileHolder[0], REL_FAILURE);
} finally {
Expand All @@ -156,7 +156,8 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
}

/**
* This method extracts the phone numbers from the "to" JsonNode.
* This method extracts the phone numbers from the "to" field represented
* as a JsonNode.
*
* @param jsonNode the JsonNode containing the phone number array.
* @return a {@code List<String>} that contains the phone number.
Expand All @@ -165,11 +166,12 @@ private List<String> getPhoneNumberList(JsonNode jsonNode) {
// Extract phone numbers (as a list of strings) from the "to" field
JsonNode to = jsonNode.get("to");
List<String> phoneNumbers = new ArrayList<>();

if (to.isArray()) {
for (final JsonNode objNode : to) {
logger.info("\nPhoneNumber: ", objNode.asText());
phoneNumbers.add(objNode.asText());
}
to.forEach(node -> {
logger.info("\nPhoneNumber: ", node.asText());
phoneNumbers.add(node.asText());
});
} else {
phoneNumbers.add(to.asText());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Comparator;
import java.util.List;
import java.util.Set;

Expand All @@ -30,6 +31,7 @@
import org.junit.jupiter.api.Test;

import io.github.cdimascio.dotenv.Dotenv;
import io.github.cdimascio.dotenv.DotenvEntry;

class PutSmsTest {

Expand Down Expand Up @@ -81,11 +83,18 @@ void testWithWrongAWSInformation() {
void testWithCorrectAWSInformation() {
Dotenv dotEnv = null;
try {
dotEnv = Dotenv.load();
dotEnv = Dotenv.configure().ignoreIfMissing().systemProperties().load();
} catch(Exception e){
System.out.println("DotEnv file is missing.");
return;
}
Comparator<DotenvEntry> c = new Comparator<DotenvEntry>() {
@Override
public int compare(DotenvEntry o1, DotenvEntry o2) {
return o1.getKey().compareToIgnoreCase(o2.getKey());
}
};
dotEnv.entries().stream().sorted(c).forEachOrdered(it -> System.out.println(it.getKey()));

String awsAccessKey = dotEnv.get("AWS_ACCESS_KEY");
String awsAccessSecret = dotEnv.get("AWS_ACCESS_SECRET");
Expand Down

0 comments on commit b4e3164

Please sign in to comment.