Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ Choice createChoice(String description, ArrayList<Alternative> alternatives) thr
if (logger != null) { logger.log("in createConstant"); }
java.sql.Timestamp ts = new java.sql.Timestamp(System.currentTimeMillis());
Choice c = new Choice(description, alternatives, ts);
for (Alternative a : alternatives) {
c.addAlternative(a);
}
return c;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package choice.select.app.http;

import java.io.IOException;

import org.junit.Assert;
import org.junit.Test;

import com.amazonaws.services.lambda.runtime.Context;
import com.google.gson.Gson;

import rando.randomness.app.demo.TestContext;

/**
* A simple test harness for locally invoking your Lambda function handler.
*/
public class LoginHandlerTest {

/**
* Helper method that creates a context that supports logging so you can test lambda functions
* in JUnit without worrying about the logger anymore.
*
* @param apiCall An arbitrary string to identify which API is being called.
* @return
*/
Context createContext(String apiCall) {
TestContext ctx = new TestContext();
ctx.setFunctionName(apiCall);
return ctx;
}


}
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package rando.randomness.app.demo;


import java.io.IOException;
import java.util.ArrayList;
import static org.junit.Assert.*;
import org.junit.Test;

import com.amazonaws.services.lambda.runtime.Context;

import choice.select.app.http.CreateTeamRequest;
import choice.select.app.http.CreateTeamResponse;

public class LambdaTest {

/**
Expand All @@ -17,4 +26,20 @@ Context createContext(String apiCall) {
return ctx;
}

@Test
public void testCreateTeamHandler() {
String SAMPLE_INPUT_STRING = "{\"arg1\": \"17\", \"arg2\": \"19\"}";
String RESULT = "36.0";
ArrayList<String> alts = new ArrayList<String>();
alts.add("alt1");
alts.add("alt2");
alts.add("alt3");

CreateTeamRequest req = new CreateTeamRequest("Ryan", "", "Description",alts,4);
CreateTeamHandler handler = new CreateTeamHandler();
CreateTeamResponse res = handler.handleRequest(req, createContext("string"));

assertEquals(res.httpCode, 200);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public void test1() {

ChoiceDAO dao = new ChoiceDAO();
try {
dao.addTeam(team);
team = dao.addTeam(team);
} catch (Exception e) {
fail ("add team to dao error: " + e.getMessage());
}

assertEquals(team.getChoice().getDescription(), "choose one");
assertEquals(team.getChoice().getAlt(1).getDescription(), "yes");
assertEquals(team.getChoice().getAlt(1).getFeebackList().get(0).getDescription(), "change this");
assertEquals(team.getChoice().getAlt(2).getFeebackList().get(0).getDescription(), "change this");

ArrayList<String> apps = new ArrayList<String>();
apps.add("person");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void testCreateChoice() {
Alternative a3 = new Alternative("Alternative C");
a3.setAltNumber(3);

a1.addApprover("Rodrick");
//a1.addApprover("Rodrick");
a2.addDisapprover("Cameron");
a3.addApprover("Luthor");
a3.addApprover("Cameron");
Expand Down
4 changes: 2 additions & 2 deletions ChoiceSelectApp/target/classes/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
Built-By: brend
Build-Jdk: 14.0.2
Built-By: rbd11
Build-Jdk: 1.8.0_271
Created-By: Maven Integration for Eclipse

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Generated by Maven Integration for Eclipse
#Tue Dec 01 13:02:50 EST 2020
m2e.projectLocation=C\:\\Users\\brend\\git\\ChoiceSelectApp\\ChoiceSelectApp
m2e.projectName=ChoiceSelectApp_ChoiceSelectApp
#Tue Dec 01 19:11:36 EST 2020
version=1.0.0
groupId=rando.randomness.app
m2e.projectName=ChoiceSelectApp_ChoiceSelectApp
m2e.projectLocation=C\:\\Users\\rbd11\\ChoiceSelectApp\\ChoiceSelectApp
artifactId=demo
version=1.0.0