mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-15 18:28:47 +00:00
Mocked List Adder
This commit is contained in:
parent
f5d71a0fff
commit
bf1b0e0a98
BIN
Lambdas/.DS_Store
vendored
Normal file
BIN
Lambdas/.DS_Store
vendored
Normal file
Binary file not shown.
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>
|
||||
@ -83,14 +83,16 @@ 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()]);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// public void addItemEntry(ItemEntry entry) {
|
||||
// //entries.add(entry);
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
@ -72,7 +72,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;
|
||||
|
||||
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,7 @@
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.configuration.IMockitoConfiguration;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@ -13,8 +16,8 @@ public class TestListAdder {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListAdderError() {
|
||||
testListAdderCore(true);
|
||||
public void testListAdderError() throws SQLException {
|
||||
testListAdderCoreMock(true);
|
||||
}
|
||||
|
||||
public void testListAdderCore(boolean shouldThrow) {
|
||||
@ -46,4 +49,25 @@ public class TestListAdder {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void testListAdderCoreMock(boolean shouldThrow) throws SQLException {
|
||||
StatementInjector injector;
|
||||
ArrayList<Object> rsReturns = new ArrayList<>();
|
||||
rsReturns.add(1); //new listID
|
||||
injector = mock(StatementInjector.class);
|
||||
injector.returnedStatement = null;
|
||||
injector.rsReturns = new ArrayList(rsReturns);
|
||||
injector.shouldThrow = shouldThrow;
|
||||
|
||||
ListAdder listAdder = new ListAdder(injector, "cognitoID");
|
||||
Map<String, Object> ignore = new HashMap<>();
|
||||
Map<String, Object> body = TestInputUtils.addBody(ignore);
|
||||
body.put("name", "aname");
|
||||
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]"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,6 +110,11 @@
|
||||
<version>4.13</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.2.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.source>1.11</maven.compiler.source>
|
||||
|
||||
@ -4,10 +4,15 @@
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<compositeConfiguration>
|
||||
<compositeBuild compositeDefinitionSource="SCRIPT" />
|
||||
</compositeConfiguration>
|
||||
<option name="delegatedBuild" value="false" />
|
||||
<option name="testRunner" value="PLATFORM" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<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">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
@ -15,6 +20,7 @@
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
<option name="useQualifiedModuleNames" value="true" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user