mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-13 09:48:47 +00:00
ListItemSearcher tests added
This commit is contained in:
parent
16e4805d2c
commit
9e22d5388d
43
Lambdas/Lists/ItemSearch/test/TestItemSearcher.java
Normal file
43
Lambdas/Lists/ItemSearch/test/TestItemSearcher.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 TestItemSearcher {
|
||||
|
||||
@Test
|
||||
public void testItemSearcherValid() {
|
||||
testItemSearcherMock(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItemSearcherError() {
|
||||
testItemSearcherMock(true);
|
||||
}
|
||||
|
||||
public void testItemSearcherMock(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
ItemSearcher listItemSearcher = Mockito.spy(new ItemSearcher(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
body.put("id", 1);
|
||||
|
||||
try {
|
||||
Object rawIDReturn = listItemSearcher.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert !shouldThrow;
|
||||
assert (rawIDReturn != null);
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.Mockito.*;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user