Mocked ListShareTest

This commit is contained in:
Adam Ding 2020-11-30 18:53:05 -05:00
parent 8f3840e0d7
commit 89ecda9f6b

View File

@ -1,4 +1,6 @@
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.Mockito.*;
import java.security.AccessControlException; import java.security.AccessControlException;
import java.sql.SQLException; import java.sql.SQLException;
@ -9,15 +11,15 @@ public class TestListSharer {
@Test @Test
public void testListSharerWOAccess() { public void testListSharerWOAccess() {
testListEntryAdderCore(false, false); testListEntryAdderCoreMock(false, false);
} }
@Test @Test
public void testListSharerError() { public void testListSharerError() {
testListEntryAdderCore(true, true); testListEntryAdderCoreMock(true, true);
} }
public void testListEntryAdderCore(boolean shouldThrow, boolean hasAccess) { public void testListEntryAdderCoreMock(boolean shouldThrow, boolean hasAccess) {
StatementInjector injector; StatementInjector injector;
try { try {
injector = new StatementInjector(null, null, shouldThrow); injector = new StatementInjector(null, null, shouldThrow);
@ -26,7 +28,7 @@ public class TestListSharer {
assert false; //Error in test infrastructure assert false; //Error in test infrastructure
return; return;
} }
ListSharer listSharer = new ListSharer(injector, "cognitoID"); ListSharer listSharer = Mockito.spy(new ListSharer(injector, "cognitoID"));
Map<String, Object> ignore = new HashMap<>(); Map<String, Object> ignore = new HashMap<>();
Map<String, Object> body = TestInputUtils.addBody(ignore); Map<String, Object> body = TestInputUtils.addBody(ignore);
body.put("listID", 49); body.put("listID", 49);