mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-13 09:48:47 +00:00
ListDuplicate tests added
This commit is contained in:
parent
a60e26dc3a
commit
4b1f06cdcd
@ -83,15 +83,15 @@ public class List {
|
||||
return uiPosition;
|
||||
}
|
||||
|
||||
public void setUiPosition(Integer uiPosition) {
|
||||
this.uiPosition = uiPosition;
|
||||
}
|
||||
|
||||
public ItemEntry[] getEntries() {
|
||||
return entries.toArray(new ItemEntry[entries.size()]);
|
||||
}
|
||||
|
||||
public void addItemEntry(ItemEntry entry) {
|
||||
entries.add(entry);
|
||||
}
|
||||
// public void setUiPosition(Integer uiPosition) {
|
||||
// this.uiPosition = uiPosition;
|
||||
// }
|
||||
//
|
||||
// public ItemEntry[] getEntries() {
|
||||
// return entries.toArray(new ItemEntry[entries.size()]);
|
||||
// }
|
||||
//
|
||||
// public void addItemEntry(ItemEntry entry) {
|
||||
// entries.add(entry);
|
||||
// }
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ public class ListGetter implements CallHandler{
|
||||
getListEntries.setInt(1, id);
|
||||
ResultSet getEntryResults = getListEntries.executeQuery();
|
||||
while (getEntryResults.next()) {
|
||||
retrievedList.addItemEntry(new ItemEntry(id, getEntryResults));
|
||||
//retrievedList.addItemEntry(new ItemEntry(id, getEntryResults));
|
||||
}
|
||||
System.out.println(retrievedList);
|
||||
return retrievedList;
|
||||
|
||||
43
Lambdas/Lists/ListDuplicate/test/TestListDuplicate.java
Normal file
43
Lambdas/Lists/ListDuplicate/test/TestListDuplicate.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 TestListDuplicate {
|
||||
|
||||
@Test
|
||||
public void testListEntryAdderValid() {
|
||||
testListEntryAdderCoreMock(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListEntryAdderError() {
|
||||
testListEntryAdderCoreMock(true);
|
||||
}
|
||||
|
||||
public void testListEntryAdderCoreMock(boolean shouldThrow) {
|
||||
StatementInjector injector;
|
||||
try {
|
||||
injector = new StatementInjector(null, null, shouldThrow);
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
assert false; //Error in test infrastructure
|
||||
return;
|
||||
}
|
||||
ListDuplicater listDuplicater = Mockito.spy(new ListDuplicater(injector, "cognitoID"));
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
body.put("name", "list1");
|
||||
body.put("listID", 1);
|
||||
|
||||
try {
|
||||
Object rawIDReturn = listDuplicater.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||
assert (rawIDReturn != null);
|
||||
} catch (SQLException throwables) {
|
||||
assert shouldThrow;
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user