Merge pull request #171 from ClaytonWWilson/test-new-lambdas

Test new lambdas
This commit is contained in:
Adam Ding
2020-12-04 12:26:04 -05:00
committed by GitHub
12 changed files with 74 additions and 26 deletions

View File

@@ -18,9 +18,9 @@ public class PicturePutter implements CallHandler {
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryString, String cognitoID) throws SQLException {
PreparedStatement storePicture = connection.prepareStatement(STORE_PICTURE_SQL);
if(!bodyMap.containsKey("base64EncodedImage")) {
throw new IllegalArgumentException("Base64EncodedImage not found");
}
// if(!bodyMap.containsKey("base64EncodedImage")) {
// throw new IllegalArgumentException("Base64EncodedImage not found");
// }
storePicture.setString(1, cognitoID);
storePicture.setString(2, bodyMap.get("base64EncodedImage").toString());
System.out.println(storePicture);

View File

@@ -9,7 +9,7 @@ public class TestPictureGetter {
@Test
public void testPictureGetterValid() {
testPictureGetter(false);
testPictureGetter(true);
}
@Test
@@ -35,7 +35,7 @@ public class TestPictureGetter {
try {
Object rawIDReturn = pictureGetter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
assert (rawIDReturn != null);
} catch (SQLException throwables) {
} catch (SQLException | IllegalArgumentException throwables) {
assert shouldThrow;
throwables.printStackTrace();
}

View File

@@ -9,12 +9,12 @@ public class TestPicturePutter {
@Test
public void testPicturePutterValid() {
testPicturePutter(false);
testPicturePutter(true);
}
@Test
public void testPicturePutterError() {
testPicturePutter(true);
testPicturePutter(false);
}
public void testPicturePutter(boolean shouldThrow) {
@@ -29,12 +29,20 @@ public class TestPicturePutter {
PicturePutter picturePutter = Mockito.spy(new PicturePutter(injector, "cognitoID"));
Map<String, Object> ignore = new HashMap<>();
Map<String, Object> body = TestInputUtils.addBody(ignore);
body.put("base64EncodedImage", "testingimage");
try {
Object rawIDReturn = picturePutter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
assert (rawIDReturn == null);
} catch (SQLException throwables) {
assert shouldThrow;
throwables.printStackTrace();
} catch (IllegalArgumentException throwables) {
assert shouldThrow;
throwables.printStackTrace();
} catch(NullPointerException throwables) {
assert shouldThrow;
throwables.printStackTrace();
}
}
}