mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 02:38:47 +00:00
Test id retrieval
This commit is contained in:
parent
b07fead480
commit
d14383ff2e
@ -14,6 +14,16 @@ public class TestListGetter {
|
||||
conductListGetterTest(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListIDGetterValid() {
|
||||
conductListIDGetterTest(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListIDGetterError() {
|
||||
conductListIDGetterTest(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListGetterError() {
|
||||
conductListGetterTest(true);
|
||||
@ -60,4 +70,36 @@ public class TestListGetter {
|
||||
assert shouldThrow;
|
||||
}
|
||||
}
|
||||
|
||||
public void conductListIDGetterTest(boolean shouldThrow) {
|
||||
|
||||
|
||||
ArrayList<Object> rsReturns = new ArrayList<>();
|
||||
rsReturns.add(1);
|
||||
rsReturns.add(2);
|
||||
rsReturns.add(3);
|
||||
rsReturns.add(4);
|
||||
|
||||
StatementInjector injector = null;
|
||||
try {
|
||||
injector = new StatementInjector(null, rsReturns, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
ListGetter getter = new ListGetter(injector, "id");
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore);
|
||||
queryParams.put("id", "-1");
|
||||
try {
|
||||
Object conductReturn = getter.conductAction(TestInputUtils.addBody(ignore), queryParams, "cognitoID");
|
||||
assert !shouldThrow;
|
||||
assert (conductReturn.getClass() == ArrayList.class);
|
||||
ArrayList<Integer> listIDsReturn = (ArrayList<Integer>) conductReturn;
|
||||
System.out.println(listIDsReturn.toString());
|
||||
assert (listIDsReturn.toString().equals("[1, 2, 3, 4]"));
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert shouldThrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user