Add Core Lambda Unit tests

This commit is contained in:
NMerz
2020-10-07 00:04:17 -04:00
parent da14953daf
commit c9751d4f95
11 changed files with 241 additions and 27 deletions

View File

@@ -13,13 +13,12 @@ public class DBConnector {
Connection connection;
public DBConnector() throws IOException, SQLException, ClassNotFoundException {
this(loadProperties("dbProperties.json"));
this(loadProperties(DBConnector.class.getResource("dbProperties.json").getPath()));
}
public DBConnector(Properties dbProperties) throws SQLException, ClassNotFoundException {
Class.forName("org.mariadb.jdbc.Driver");
System.out.println(dbProperties);
System.out.println(DBConnector.buildURL(dbProperties));
connection = DriverManager.getConnection(dbProperties.get("url").toString(), dbProperties.get("user").toString(), dbProperties.get("password").toString());
System.out.println(connection);
}
@@ -43,11 +42,4 @@ public class DBConnector {
propertiesJSON.keys().forEachRemaining(key -> toReturn.setProperty(key, propertiesJSON.get(key).toString()));
return toReturn;
}
public static String buildURL(Properties dbProperties) {
String dbURL = dbProperties.get("url").toString();
dbURL += "?user=" + dbProperties.get("user").toString();
dbURL += "&password=" + dbProperties.get("password").toString();
return dbURL;
}
}

View File

@@ -10,12 +10,7 @@ public class InputUtils {
public static String getCognitoIDFromBody(Map<String, Object> inputMap) {
System.out.println(inputMap.keySet());
System.out.println(inputMap.entrySet());
Map<String, Object> contextMap;
if ((inputMap.get("context") != null) && (inputMap.get("context") instanceof Map<?, ?>)) {
contextMap = ((Map<String, Object>) inputMap.get("context"));
} else {
throw new IllegalArgumentException("The key \"context\" must exist and be a map");
}
Map<String, Object> contextMap = getMap(inputMap, "context");
System.out.println(inputMap.get("context"));
System.out.println(contextMap.get("sub"));
return contextMap.get("sub").toString();
@@ -25,20 +20,8 @@ public class InputUtils {
return getMap(inputMap, "body");
}
private static String getQueryString(Map<String, Object> inputMap) {
return (String) (getMap(inputMap, "params").get("querystring"));
}
public static HashMap<String, String> getQueryParams(Map<String, Object> inputMap) {
return (HashMap<String, String>) (getMap(inputMap, "params").get("querystring"));
// String queryString = getQueryString(inputMap);
// List<NameValuePair> queryparams = URLEncodedUtils.parse(queryString, StandardCharsets.UTF_8);
// HashMap<String, String> mappedParams = new HashMap<>();
// for (NameValuePair param : queryparams) {
// mappedParams.put(param.getName(), param.getValue());
// }
// return mappedParams;
}