mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-13 09:48:47 +00:00
ListReposition tests added
This commit is contained in:
parent
0c3839cec3
commit
16e4805d2c
@ -8,12 +8,12 @@ import java.util.Map;
|
||||
public class TestListDuplicate {
|
||||
|
||||
@Test
|
||||
public void testListEntryAdderValid() {
|
||||
public void testListDuplicateValid() {
|
||||
testListDuplicaterMock(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListEntryAdderError() {
|
||||
public void testListDuplicateError() {
|
||||
testListDuplicaterMock(true);
|
||||
}
|
||||
|
||||
|
||||
43
Lambdas/Lists/ListReposition/test/TestListReposition.java
Normal file
43
Lambdas/Lists/ListReposition/test/TestListReposition.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 TestListReposition {
|
||||
|
||||
@Test
|
||||
public void testListRepositionValid() {
|
||||
testListRepositioneMock(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListRepositionError() {
|
||||
testListRepositioneMock(true);
|
||||
}
|
||||
|
||||
public void testListRepositioneMock(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
ListRepositionActor listRepositionActor = Mockito.spy(new ListRepositionActor(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
body.put("listID", 1);
|
||||
body.put("newPosition", 2);
|
||||
|
||||
try {
|
||||
Object rawIDReturn = listRepositionActor.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert (rawIDReturn == null);
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user