mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-15 18:28:47 +00:00
TestSearchHistory tests added
This commit is contained in:
parent
9e22d5388d
commit
e3d4e931b0
@ -0,0 +1,42 @@
|
|||||||
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
public class TestSearchHistoryGetter {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchHistoryValid() {
|
||||||
|
testSearchHistoryGetterMock(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchHistoryError() {
|
||||||
|
testSearchHistoryGetterMock(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSearchHistoryGetterMock(boolean shouldThrow) {
|
||||||
|
StatementInjector injector;
|
||||||
|
try {
|
||||||
|
injector = new StatementInjector(null, null, shouldThrow);
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
throwables.printStackTrace();
|
||||||
|
assert false; //Error in test infrastructure
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SearchHistoryGetter searchHistoryGetter = Mockito.spy(new SearchHistoryGetter(injector, "cognitoID"));
|
||||||
|
Map<String, Object> ignore = new HashMap<>();
|
||||||
|
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Object rawIDReturn = searchHistoryGetter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||||
|
assert (rawIDReturn != null);
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
assert shouldThrow;
|
||||||
|
throwables.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class TestSearchHistoryUpdater {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchHistoryUpdaterValid() {
|
||||||
|
testSearchHistoryUpdater(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchHistoryUpdaterError() {
|
||||||
|
testSearchHistoryUpdater(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSearchHistoryUpdater(boolean shouldThrow) {
|
||||||
|
StatementInjector injector;
|
||||||
|
try {
|
||||||
|
injector = new StatementInjector(null, null, shouldThrow);
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
throwables.printStackTrace();
|
||||||
|
assert false; //Error in test infrastructure
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SearchHistoryUpdater testSearchHistoryUpdater = Mockito.spy(new SearchHistoryUpdater(injector, "cognitoID"));
|
||||||
|
Map<String, Object> ignore = new HashMap<>();
|
||||||
|
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Object rawIDReturn = testSearchHistoryUpdater.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||||
|
assert (rawIDReturn == null);
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
assert shouldThrow;
|
||||||
|
throwables.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user