mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2026-03-10 18:55:03 +00:00
Picture tests addec
This commit is contained in:
43
Lambdas/Lists/Picture/test/TestPictureGetter.java
Normal file
43
Lambdas/Lists/Picture/test/TestPictureGetter.java
Normal file
@@ -0,0 +1,43 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestPictureGetter {
|
||||
|
||||
@Test
|
||||
public void testPictureGetterValid() {
|
||||
testPictureGetter(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPictureGetterError() {
|
||||
testPictureGetter(true);
|
||||
}
|
||||
|
||||
public void testPictureGetter(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
PictureGetter pictureGetter = Mockito.spy(new PictureGetter(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
body.put("id", 1);
|
||||
body.put("profile", 1);
|
||||
|
||||
try {
|
||||
Object rawIDReturn = pictureGetter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert (rawIDReturn != null);
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Lambdas/Lists/Picture/test/TestPicturePutter.java
Normal file
40
Lambdas/Lists/Picture/test/TestPicturePutter.java
Normal file
@@ -0,0 +1,40 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestPicturePutter {
|
||||
|
||||
@Test
|
||||
public void testPicturePutterValid() {
|
||||
testPicturePutter(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPicturePutterError() {
|
||||
testPicturePutter(true);
|
||||
}
|
||||
|
||||
public void testPicturePutter(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
PicturePutter picturePutter = Mockito.spy(new PicturePutter(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
try {
|
||||
Object rawIDReturn = picturePutter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert (rawIDReturn == null);
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user