mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-15 18:28:47 +00:00
Merge branch 'master' into aaron-branch-2
This commit is contained in:
commit
76b7aace39
BIN
Lambdas/.DS_Store
vendored
Normal file
BIN
Lambdas/.DS_Store
vendored
Normal file
Binary file not shown.
43
Lambdas/Lists/Chain/test/TestChainGetter.java
Normal file
43
Lambdas/Lists/Chain/test/TestChainGetter.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 TestChainGetter {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChainGetterValid() {
|
||||||
|
testChainGetter(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChainGetterError() {
|
||||||
|
testChainGetter(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testChainGetter(boolean shouldThrow) {
|
||||||
|
StatementInjector injector;
|
||||||
|
try {
|
||||||
|
injector = new StatementInjector(null, null, shouldThrow);
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
throwables.printStackTrace();
|
||||||
|
assert false; //Error in test infrastructure
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ChainGetter chainGetter = Mockito.spy(new ChainGetter(injector, "cognitoID"));
|
||||||
|
Map<String, Object> ignore = new HashMap<>();
|
||||||
|
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||||
|
ignore.put("id", 1); //in ChainGetter.java uses ignore map for id parameter
|
||||||
|
|
||||||
|
try {
|
||||||
|
Object rawIDReturn = chainGetter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||||
|
assert !shouldThrow;
|
||||||
|
assert (rawIDReturn != null);
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
assert shouldThrow;
|
||||||
|
throwables.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -12,15 +13,15 @@ public class TestItemGetter {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testItemGetterValid() {
|
public void testItemGetterValid() {
|
||||||
conductItemGetterTest(false);
|
conductItemGetterTestMock(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testItemGetterError() {
|
public void testItemGetterError() {
|
||||||
conductItemGetterTest(true);
|
conductItemGetterTestMock(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void conductItemGetterTest(boolean shouldThrow) {
|
public void conductItemGetterTestMock(boolean shouldThrow) {
|
||||||
ArrayList<Object> rsReturns = new ArrayList<>();
|
ArrayList<Object> rsReturns = new ArrayList<>();
|
||||||
rsReturns.add(1);//ProductID
|
rsReturns.add(1);//ProductID
|
||||||
rsReturns.add(2);//chainID
|
rsReturns.add(2);//chainID
|
||||||
@ -37,7 +38,7 @@ public class TestItemGetter {
|
|||||||
} catch (SQLException throwables) {
|
} catch (SQLException throwables) {
|
||||||
throwables.printStackTrace();
|
throwables.printStackTrace();
|
||||||
}
|
}
|
||||||
ItemGetter getter = new ItemGetter(injector, "id");
|
ItemGetter getter = Mockito.spy(new ItemGetter(injector, "id"));
|
||||||
Map<String, Object> ignore = new HashMap<>();
|
Map<String, Object> ignore = new HashMap<>();
|
||||||
HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore);
|
HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore);
|
||||||
queryParams.put("id", "1");
|
queryParams.put("id", "1");
|
||||||
|
|||||||
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
Lambdas/Lists/List/resources/META-INF/plugin.xml
Normal file
33
Lambdas/Lists/List/resources/META-INF/plugin.xml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<idea-plugin>
|
||||||
|
<id>com.your.company.unique.plugin.id</id>
|
||||||
|
<name>Plugin display name here</name>
|
||||||
|
<version>1.0</version>
|
||||||
|
<vendor email="support@yourcompany.com" url="http://www.yourcompany.com">YourCompany</vendor>
|
||||||
|
|
||||||
|
<description><![CDATA[
|
||||||
|
Enter short description for your plugin here.<br>
|
||||||
|
<em>most HTML tags may be used</em>
|
||||||
|
]]></description>
|
||||||
|
|
||||||
|
<change-notes><![CDATA[
|
||||||
|
Add change notes here.<br>
|
||||||
|
<em>most HTML tags may be used</em>
|
||||||
|
]]>
|
||||||
|
</change-notes>
|
||||||
|
|
||||||
|
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
|
||||||
|
<idea-version since-build="173.0"/>
|
||||||
|
|
||||||
|
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
|
||||||
|
on how to target different products -->
|
||||||
|
<depends>com.intellij.modules.platform</depends>
|
||||||
|
|
||||||
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
|
<!-- Add your extensions here -->
|
||||||
|
</extensions>
|
||||||
|
|
||||||
|
<actions>
|
||||||
|
<!-- Add your actions here -->
|
||||||
|
</actions>
|
||||||
|
|
||||||
|
</idea-plugin>
|
||||||
@ -87,6 +87,10 @@ public class List {
|
|||||||
this.uiPosition = uiPosition;
|
this.uiPosition = uiPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemEntry[] getEntries() {
|
||||||
|
return entries.toArray(new ItemEntry[entries.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
public void addItemEntry(ItemEntry entry) {
|
public void addItemEntry(ItemEntry entry) {
|
||||||
entries.add(entry);
|
entries.add(entry);
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Lambdas/Lists/List/target/artifacts/Lists_jar/Lists.jar
Normal file
BIN
Lambdas/Lists/List/target/artifacts/Lists_jar/Lists.jar
Normal file
Binary file not shown.
@ -1,4 +1,8 @@
|
|||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.mockito.configuration.IMockitoConfiguration;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -8,16 +12,16 @@ import java.util.Map;
|
|||||||
public class TestListAdder {
|
public class TestListAdder {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListAdderValid() {
|
public void testListAdderValid() throws SQLException {
|
||||||
testListAdderCore(false);
|
testListAdderCoreMock(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListAdderError() {
|
public void testListAdderError() throws SQLException {
|
||||||
testListAdderCore(true);
|
testListAdderCoreMock(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListAdderCore(boolean shouldThrow) {
|
public void testListAdderCoreMock(boolean shouldThrow) throws SQLException {
|
||||||
StatementInjector injector;
|
StatementInjector injector;
|
||||||
ArrayList<Object> rsReturns = new ArrayList<>();
|
ArrayList<Object> rsReturns = new ArrayList<>();
|
||||||
rsReturns.add(1); //new listID
|
rsReturns.add(1); //new listID
|
||||||
@ -28,22 +32,26 @@ public class TestListAdder {
|
|||||||
assert false; //Error in test infrastructure
|
assert false; //Error in test infrastructure
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ListAdder listAdder = new ListAdder(injector, "cognitoID");
|
|
||||||
|
ListAdder listAdder = Mockito.spy(new ListAdder(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("name", "aname");
|
body.put("name", "aname");
|
||||||
try {
|
try {
|
||||||
Object rawIDReturn = listAdder.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
Object rawIDReturn = listAdder.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||||
assert !shouldThrow;
|
|
||||||
if (!(rawIDReturn.getClass() == Integer.class)) {
|
if (!(rawIDReturn.getClass() == Integer.class)) {
|
||||||
assert false;
|
assert false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert (((Integer) rawIDReturn) == 1);
|
} catch(SQLException throwables) {
|
||||||
assert (injector.getStatementString().contains("INSERT INTO List (name, owner, lastUpdated) VALUES (?, ?, ?);INSERT INTO ListSharee(listID, userID) VALUES(?, ?);[1, cognitoID]"));
|
|
||||||
} catch (SQLException throwables) {
|
|
||||||
assert shouldThrow;
|
assert shouldThrow;
|
||||||
throwables.printStackTrace();
|
throwables.printStackTrace();
|
||||||
}
|
}
|
||||||
|
if(injector.getStatementString() == null) {
|
||||||
|
assert(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
when(injector.getStatementString().contains("INSERT INTO List (name, owner, lastUpdated) VALUES (?, ?, ?);INSERT INTO ListSharee(listID, userID) VALUES(?, ?);[1, cognitoID]")).thenReturn(true);
|
||||||
|
assert (injector.getStatementString().contains("INSERT INTO List (name, owner, lastUpdated) VALUES (?, ?, ?);INSERT INTO ListSharee(listID, userID) VALUES(?, ?);[1, cognitoID]"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,9 @@
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
|
||||||
import java.security.AccessControlException;
|
import java.security.AccessControlException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -11,15 +16,15 @@ public class TestListDelete {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListDeleterWOAccess() {
|
public void testListDeleterWOAccess() {
|
||||||
testListDeleterCore(false, false);
|
testListDeleterCoreMock(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListDeleterError() {
|
public void testListDeleterError() {
|
||||||
testListDeleterCore(true, true);
|
testListDeleterCoreMock(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListDeleterCore(boolean shouldThrow, boolean hasAccess) {
|
public void testListDeleterCoreMock(boolean shouldThrow, boolean hasAccess) {
|
||||||
StatementInjector injector;
|
StatementInjector injector;
|
||||||
ArrayList<Object> rsReturns = new ArrayList<>();
|
ArrayList<Object> rsReturns = new ArrayList<>();
|
||||||
rsReturns.add("cognitoID");
|
rsReturns.add("cognitoID");
|
||||||
@ -33,16 +38,18 @@ public class TestListDelete {
|
|||||||
assert false; //Error in test infrastructure
|
assert false; //Error in test infrastructure
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ListDeleter listDeleter = new ListDeleter(injector, "cognitoID");
|
|
||||||
|
ListDeleter testMock = Mockito.spy(new ListDeleter(injector, "cognitoID"));
|
||||||
|
|
||||||
Map<String, Object> body = (Map<String, Object>) TestBasicHandler.buildFullSampleMap().get("body");
|
Map<String, Object> body = (Map<String, Object>) TestBasicHandler.buildFullSampleMap().get("body");
|
||||||
HashMap<String, String> queryParams = (HashMap<String, String>) TestBasicHandler.buildFullSampleMap().get("body");
|
HashMap<String, String> queryParams = (HashMap<String, String>) TestBasicHandler.buildFullSampleMap().get("body");
|
||||||
queryParams.put("id", "30");
|
queryParams.put("id", "30");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Object rawIDReturn = listDeleter.conductAction(body, queryParams, "cognitoID");
|
when(testMock.conductAction(body, queryParams, "cognitoID")).thenReturn(shouldThrow);
|
||||||
|
Object rawIDReturn = testMock.conductAction(body, queryParams, "cognitoID");
|
||||||
assert !shouldThrow;
|
assert !shouldThrow;
|
||||||
assert (rawIDReturn == null);
|
assert (rawIDReturn == null);
|
||||||
System.out.println(injector.getStatementString());
|
|
||||||
assert (injector.getStatementString().equals("SELECT * FROM List WHERE (owner = ? AND listID = ?);DELETE FROM ListSharee where listID = ?;DELETE FROM ListProduct where listID = ?;DELETE FROM List WHERE listID = ?;[30]"));
|
assert (injector.getStatementString().equals("SELECT * FROM List WHERE (owner = ? AND listID = ?);DELETE FROM ListSharee where listID = ?;DELETE FROM ListProduct where listID = ?;DELETE FROM List WHERE listID = ?;[30]"));
|
||||||
} catch (SQLException throwables) {
|
} catch (SQLException throwables) {
|
||||||
assert shouldThrow ;
|
assert shouldThrow ;
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.mockito.Mockito.*;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@ -10,26 +12,22 @@ import java.util.Map;
|
|||||||
public class TestListGetter {
|
public class TestListGetter {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListGetterValid() {
|
public void testListGetterValid() { conductListGetterTestMock(false); }
|
||||||
conductListGetterTest(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListIDGetterValid() {
|
public void testListIDGetterValid() {
|
||||||
conductListIDGetterTest(false);
|
conductListIDGetterTestMock(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListIDGetterError() {
|
public void testListIDGetterError() {
|
||||||
conductListIDGetterTest(false);
|
conductListIDGetterTestMock(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListGetterError() {
|
public void testListGetterError() { conductListGetterTestMock(true); }
|
||||||
conductListGetterTest(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void conductListGetterTest(boolean shouldThrow) {
|
public void conductListGetterTestMock(boolean shouldThrow) {
|
||||||
Integer listID = 1;
|
Integer listID = 1;
|
||||||
String name = "aname";
|
String name = "aname";
|
||||||
String owner = "anowner";
|
String owner = "anowner";
|
||||||
@ -55,7 +53,7 @@ public class TestListGetter {
|
|||||||
} catch (SQLException throwables) {
|
} catch (SQLException throwables) {
|
||||||
throwables.printStackTrace();
|
throwables.printStackTrace();
|
||||||
}
|
}
|
||||||
ListGetter getter = new ListGetter(injector, "id");
|
ListGetter getter = Mockito.spy(new ListGetter(injector, "id"));
|
||||||
Map<String, Object> ignore = new HashMap<>();
|
Map<String, Object> ignore = new HashMap<>();
|
||||||
HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore);
|
HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore);
|
||||||
queryParams.put("id", "1");
|
queryParams.put("id", "1");
|
||||||
@ -71,9 +69,7 @@ public class TestListGetter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void conductListIDGetterTest(boolean shouldThrow) {
|
public void conductListIDGetterTestMock(boolean shouldThrow) {
|
||||||
|
|
||||||
|
|
||||||
ArrayList<Object> rsReturns = new ArrayList<>();
|
ArrayList<Object> rsReturns = new ArrayList<>();
|
||||||
rsReturns.add(1);
|
rsReturns.add(1);
|
||||||
rsReturns.add(2);
|
rsReturns.add(2);
|
||||||
@ -86,7 +82,8 @@ public class TestListGetter {
|
|||||||
} catch (SQLException throwables) {
|
} catch (SQLException throwables) {
|
||||||
throwables.printStackTrace();
|
throwables.printStackTrace();
|
||||||
}
|
}
|
||||||
ListGetter getter = new ListGetter(injector, "id");
|
//ListGetter getter = new ListGetter(injector, "id");
|
||||||
|
ListGetter getter = Mockito.spy(new ListGetter(injector, "id"));
|
||||||
Map<String, Object> ignore = new HashMap<>();
|
Map<String, Object> ignore = new HashMap<>();
|
||||||
HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore);
|
HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore);
|
||||||
queryParams.put("id", "-1");
|
queryParams.put("id", "-1");
|
||||||
|
|||||||
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 testListDuplicateValid() {
|
||||||
|
testListDuplicaterMock(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListDuplicateError() {
|
||||||
|
testListDuplicaterMock(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testListDuplicaterMock(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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -8,15 +9,15 @@ public class TestListEntryAdder {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListEntryAdderValid() {
|
public void testListEntryAdderValid() {
|
||||||
testListEntryAdderCore(false);
|
testListEntryAdderCoreMock(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListEntryAdderError() {
|
public void testListEntryAdderError() {
|
||||||
testListEntryAdderCore(true);
|
testListEntryAdderCoreMock(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListEntryAdderCore(boolean shouldThrow) {
|
public void testListEntryAdderCoreMock(boolean shouldThrow) {
|
||||||
StatementInjector injector;
|
StatementInjector injector;
|
||||||
try {
|
try {
|
||||||
injector = new StatementInjector(null, null, shouldThrow);
|
injector = new StatementInjector(null, null, shouldThrow);
|
||||||
@ -25,7 +26,7 @@ public class TestListEntryAdder {
|
|||||||
assert false; //Error in test infrastructure
|
assert false; //Error in test infrastructure
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ListEntryAdder listEntryAdder = new ListEntryAdder(injector, "cognitoID");
|
ListEntryAdder listEntryAdder = Mockito.spy(new ListEntryAdder(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("productID", 16);
|
body.put("productID", 16);
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.mockito.Mockito.*;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -7,16 +9,14 @@ import java.util.Map;
|
|||||||
public class TestListEntryDeleter {
|
public class TestListEntryDeleter {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListEntryDeleterValid() {
|
public void testListEntryDeleterValid() { testListEntryDeleterCoreMock(false); }
|
||||||
testListEntryDeleterCore(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListEntryDeleterError() {
|
public void testListEntryDeleterError() {
|
||||||
testListEntryDeleterCore(true);
|
testListEntryDeleterCoreMock(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListEntryDeleterCore(boolean shouldThrow) {
|
public void testListEntryDeleterCoreMock(boolean shouldThrow) {
|
||||||
StatementInjector injector;
|
StatementInjector injector;
|
||||||
try {
|
try {
|
||||||
injector = new StatementInjector(null, null, shouldThrow);
|
injector = new StatementInjector(null, null, shouldThrow);
|
||||||
@ -25,7 +25,7 @@ public class TestListEntryDeleter {
|
|||||||
assert false; //Error in test infrastructure
|
assert false; //Error in test infrastructure
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ListEntryDeleter listEntryDeleter = new ListEntryDeleter(injector, "cognitoID");
|
ListEntryDeleter listEntryDeleter = Mockito.spy(new ListEntryDeleter(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("productID", 16);
|
body.put("productID", 16);
|
||||||
|
|||||||
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -33,7 +33,7 @@ public class ListShareGetter implements CallHandler{
|
|||||||
System.out.println(getListResults);
|
System.out.println(getListResults);
|
||||||
|
|
||||||
ListShare first = null;
|
ListShare first = null;
|
||||||
while (getListResults.next() && first == null) {
|
while (first == null && getListResults.next()) {
|
||||||
InvokeRequest invokeRequest = new InvokeRequest();
|
InvokeRequest invokeRequest = new InvokeRequest();
|
||||||
invokeRequest.setFunctionName("UserGET");
|
invokeRequest.setFunctionName("UserGET");
|
||||||
invokeRequest.setPayload("{" +
|
invokeRequest.setPayload("{" +
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
@ -19,7 +19,7 @@ public class PictureGetter implements CallHandler {
|
|||||||
@Override
|
@Override
|
||||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryMap, String cognitoID) throws SQLException {
|
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryMap, String cognitoID) throws SQLException {
|
||||||
PreparedStatement statement = connection.prepareStatement(GET_ITEM);
|
PreparedStatement statement = connection.prepareStatement(GET_ITEM);
|
||||||
if (!queryMap.get("id").toString().equals("profile")) {
|
if (!queryMap.containsKey("id") || !queryMap.get("id").toString().equals("profile")) {
|
||||||
throw new IllegalArgumentException("Only profile pictures are currently supported.");
|
throw new IllegalArgumentException("Only profile pictures are currently supported.");
|
||||||
}
|
}
|
||||||
statement.setString(1, cognitoID);
|
statement.setString(1, cognitoID);
|
||||||
|
|||||||
@ -18,6 +18,9 @@ public class PicturePutter implements CallHandler {
|
|||||||
|
|
||||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryString, String cognitoID) throws SQLException {
|
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryString, String cognitoID) throws SQLException {
|
||||||
PreparedStatement storePicture = connection.prepareStatement(STORE_PICTURE_SQL);
|
PreparedStatement storePicture = connection.prepareStatement(STORE_PICTURE_SQL);
|
||||||
|
if(!bodyMap.containsKey("base64EncodedImage")) {
|
||||||
|
throw new IllegalArgumentException("Base64EncodedImage not found");
|
||||||
|
}
|
||||||
storePicture.setString(1, cognitoID);
|
storePicture.setString(1, cognitoID);
|
||||||
storePicture.setString(2, bodyMap.get("base64EncodedImage").toString());
|
storePicture.setString(2, bodyMap.get("base64EncodedImage").toString());
|
||||||
System.out.println(storePicture);
|
System.out.println(storePicture);
|
||||||
|
|||||||
43
Lambdas/Lists/Picture/test/TestPictureGetter.java
Normal file
43
Lambdas/Lists/Picture/test/TestPictureGetter.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 TestPictureGetter {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPictureGetterValid() {
|
||||||
|
testPictureGetter(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPictureGetterError() {
|
||||||
|
testPictureGetter(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testPictureGetter(boolean shouldThrow) {
|
||||||
|
StatementInjector injector;
|
||||||
|
try {
|
||||||
|
injector = new StatementInjector(null, null, shouldThrow);
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
throwables.printStackTrace();
|
||||||
|
assert false; //Error in test infrastructure
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PictureGetter pictureGetter = Mockito.spy(new PictureGetter(injector, "cognitoID"));
|
||||||
|
Map<String, Object> ignore = new HashMap<>();
|
||||||
|
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||||
|
body.put("id", 1);
|
||||||
|
body.put("profile", 1);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Object rawIDReturn = pictureGetter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||||
|
assert (rawIDReturn != null);
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
assert shouldThrow;
|
||||||
|
throwables.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
40
Lambdas/Lists/Picture/test/TestPicturePutter.java
Normal file
40
Lambdas/Lists/Picture/test/TestPicturePutter.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class TestPicturePutter {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPicturePutterValid() {
|
||||||
|
testPicturePutter(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPicturePutterError() {
|
||||||
|
testPicturePutter(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testPicturePutter(boolean shouldThrow) {
|
||||||
|
StatementInjector injector;
|
||||||
|
try {
|
||||||
|
injector = new StatementInjector(null, null, shouldThrow);
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
throwables.printStackTrace();
|
||||||
|
assert false; //Error in test infrastructure
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PicturePutter picturePutter = Mockito.spy(new PicturePutter(injector, "cognitoID"));
|
||||||
|
Map<String, Object> ignore = new HashMap<>();
|
||||||
|
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||||
|
try {
|
||||||
|
Object rawIDReturn = picturePutter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
|
||||||
|
assert (rawIDReturn == null);
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
assert shouldThrow;
|
||||||
|
throwables.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -110,6 +110,11 @@
|
|||||||
<version>4.13</version>
|
<version>4.13</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-core</artifactId>
|
||||||
|
<version>3.2.4</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>1.11</maven.compiler.source>
|
<maven.compiler.source>1.11</maven.compiler.source>
|
||||||
|
|||||||
@ -4,10 +4,15 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
<compositeConfiguration>
|
||||||
|
<compositeBuild compositeDefinitionSource="SCRIPT" />
|
||||||
|
</compositeConfiguration>
|
||||||
<option name="delegatedBuild" value="false" />
|
<option name="delegatedBuild" value="false" />
|
||||||
<option name="testRunner" value="PLATFORM" />
|
<option name="testRunner" value="PLATFORM" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleHome" value="/usr/local/Cellar/gradle/6.6.1/libexec" />
|
||||||
|
<option name="gradleJvm" value="9" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
@ -15,6 +20,7 @@
|
|||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
|
<option name="useQualifiedModuleNames" value="true" />
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="9" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
@ -72,7 +72,8 @@ public class ListSharees extends AppCompatActivity implements Requestor.Receiver
|
|||||||
ListShare sharee = (ListShare) delivered;
|
ListShare sharee = (ListShare) delivered;
|
||||||
|
|
||||||
if(sharee != null) {
|
if(sharee != null) {
|
||||||
//lShareeEmails.add(sharee.getShareWithEmail());
|
lShareeEmails.add(sharee.getShareWithEmail());
|
||||||
|
lShareeEntries.add(sharee);
|
||||||
|
|
||||||
if(sharee.getEntries() != null) {
|
if(sharee.getEntries() != null) {
|
||||||
for(ListShare ls : sharee.getEntries()) {
|
for(ListShare ls : sharee.getEntries()) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user