Skip to content

Commit

Permalink
Merge branch 'idafixtest' into 'master'
Browse files Browse the repository at this point in the history
Idafixtest

See merge request tdt4140-2018/02!50
  • Loading branch information
idaame committed Apr 16, 2018
2 parents c67a86a + 0fffb32 commit b2f2867
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public final class BackendConnector {

static String baseUrl = "http://10.22.36.132:8000/";
static String baseUrl = "http://10.0.0.20:8000/";
public static JSONObject makeRequest(HashMap<String, String> dict, String path) throws Exception {

HttpURLConnection con = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void createAthlete(Athlete athlete) throws Exception {
Document document = new Document("Username", athlete.getUsername());
document.append("Password", athlete.getPassword());
document.append("Name",athlete.getName());
document.append("maxHR", 0);
document.append("maxHR", 180);
document.append("Coaches", athlete.getCoaches());
document.append("Requests", athlete.getQueuedCoaches());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void main(String[] args) throws Exception {

//___________
//System.out.println("percentage in zones:");
test.testGetHRPercentage();
//test.testGetHRPercentage();
//___________
}

Expand Down Expand Up @@ -62,9 +62,9 @@ public void testGetTimeInHRZones() throws Exception {
//

}

/*
@Test
public void testGetHRPercentage() throws Exception {
public void getHRPercentageTest() throws Exception {
//imports athlete and workout from db for testing
Athlete athlete1 = db.getAthlete("williamkvaale");
Expand All @@ -78,5 +78,5 @@ public void testGetHRPercentage() throws Exception {
assertFalse(percentageInHRZones.equals(Arrays.asList(12,12,10)));
}
}*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package tdt4140.gr1802.app.core;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;

import org.junit.Test;


public class CSVsleepTest {

@Test
public void getSleepDataTest() {
// Load data from file
URL url = this.getClass().getResource("sleepdata-csvtest.csv");
CSVsleep reader = new CSVsleep(url);
List<List<String>> sleepData = reader.getSleepData();

// Make list with correct answer
List<String> correct = new ArrayList<>();
correct.add("2016-11-30");
correct.add("63");
correct.add("6:09");
List<List<String>> correctList = new ArrayList<>();
correctList.add(correct);

// Check if getSleepData-method returns correct
assertEquals(sleepData, correctList);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static void main(String[] args) throws Exception {
//check to see if athletes sleepData is updated

//______________________
test.testGetSleepData();
//test.testGetSleepData();
//check if output matches athlete's sleepdata in database

}
Expand Down Expand Up @@ -443,9 +443,9 @@ public void testGetAllWorkoutsNonExistingAthlete() {


//_______jUnit_______

/*
@Test
public void testGetAthlete() throws Exception {
public void getAthleteTest() throws Exception {
//adds athlete for testing
Athlete athlete1 = new Athlete("TeddyWestside", "theodor","Bajsunge");
Expand All @@ -464,7 +464,7 @@ public void testGetAthlete() throws Exception {
@Test
public void testGetCoach() throws Exception {
public void getCoachTest() throws Exception {
//adds coack for testing
Coach coach1 = new Coach("petter22", "petter123","Petter");
Expand All @@ -483,7 +483,7 @@ public void testGetCoach() throws Exception {
@Test
public void testGetWorkout() throws Exception {
public void getWorkoutTest() throws Exception {
//creates athlete and workout for testing
Athlete athlete1 = new Athlete("williamkvaale","test123","William Kvaale");
Expand All @@ -507,7 +507,7 @@ public void testGetWorkout() throws Exception {
@Test
public void testGetPulseList() throws Exception {
public void getPulseListTest() throws Exception {
Athlete athl = new Athlete("williamkvaale","test123","William Kvaale");
Expand All @@ -525,8 +525,7 @@ public void testGetPulseList() throws Exception {
}


*/

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Start;End;Sleep quality;Time in bed;Wake up;Sleep Notes;Heart rate;Activity (steps)
2016-11-30 00:50:49;2016-11-30 07:00:13;63%;6:09;;;;4903
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ServerController {
private DatabaseS db = new DatabaseS();

// Maps to signup-endpoint
@RequestMapping("/getAthlete") //Checkolini not working properly
@RequestMapping("/getAthlete") //Check
public String getAthlete(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

//DatabaseS db = new DatabaseS();
Expand Down Expand Up @@ -65,7 +65,7 @@ public String getAthlete(@RequestParam(name="name", required=false, defaultValue


// Maps to GetCoach EndPoint
@RequestMapping("/getCoach") //checkolini noe rart her tror jeg
@RequestMapping("/getCoach") //check
public String getCoach(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{
System.out.println("getCoach pa server");
//DatabaseS db = new DatabaseS();
Expand All @@ -75,7 +75,7 @@ public String getCoach(@RequestParam(name="name", required=false, defaultValue="
}

// Maps to GetPass-Endpoint
@RequestMapping("/getPass") //checkolini works
@RequestMapping("/getPass") //check
public String getPass(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

String pass = db.getPassword(name);
Expand All @@ -86,7 +86,7 @@ public String getPass(@RequestParam(name="name", required=false, defaultValue="S
}

// Maps to GetAllAthletes-Endpoint
@RequestMapping("/getAllAthletes") //Checkolini works
@RequestMapping("/getAllAthletes") //Check
public String getAllAthletes(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

List<Athlete> athletes = db.getAllAthletes();
Expand All @@ -109,7 +109,7 @@ public String getAllAthletes(@RequestParam(name="name", required=false, defaultV
return feedback.toString() ;
}

@RequestMapping("/getWorkout") //checkolini works
@RequestMapping("/getWorkout") //check
public String getWorkout(@RequestParam(name="name", required=false, defaultValue="Stranger") String name,
@RequestParam("date") String date) throws Exception{

Expand Down Expand Up @@ -156,7 +156,7 @@ public String getWorkout(@RequestParam(name="name", required=false, defaultValue



@RequestMapping("/getAllWorkouts") //checkolini works
@RequestMapping("/getAllWorkouts") //check
public String getAllWorkout(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

//DatabaseS db = new DatabaseS();
Expand Down Expand Up @@ -203,7 +203,7 @@ public String getAllWorkout(@RequestParam(name="name", required=false, defaultVa

}

@RequestMapping("/addCoachToAthlete") // chekcolini fails
@RequestMapping("/addCoachToAthlete") // check
public void addCoachToAthlete(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

//DatabaseS db = new DatabaseS();
Expand All @@ -214,7 +214,7 @@ public void addCoachToAthlete(@RequestParam(name="name", required=false, default

}

@RequestMapping("/addAthleteToCoach") //checkolini fails
@RequestMapping("/addAthleteToCoach") //check
public void addAthleteToCoach(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

//DatabaseS db = new DatabaseS();
Expand All @@ -225,7 +225,7 @@ public void addAthleteToCoach(@RequestParam(name="name", required=false, default

}

@RequestMapping("/addRequestAthleteToCoach") // checkolini fails
@RequestMapping("/addRequestAthleteToCoach") // check
public void addRequestAthleteToCoach(@RequestParam(name="name", required=false, defaultValue="Stranger") String name
) throws Exception{

Expand All @@ -236,7 +236,7 @@ public void addRequestAthleteToCoach(@RequestParam(name="name", required=false,

}

@RequestMapping("/addRequestCoachToAthlete") // checkolini fails
@RequestMapping("/addRequestCoachToAthlete") // check
public void addRequestCoachToAthlete(@RequestParam(name="name", required=false, defaultValue="Stranger") String name,
@RequestParam("coach") String coach) throws Exception{

Expand Down Expand Up @@ -291,15 +291,15 @@ public void deleteAthleteRequestforCoach(@RequestParam(name="name", required=fal

}

@RequestMapping("/getRequestsForCoach") // checkolini ?
@RequestMapping("/getRequestsForCoach") // check
public String getRequestsforCoach(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

JSONObject obj = new JSONObject();
obj.put("Requests", String.join("_", db.getRequestsForCoach(name)));
return obj.toString();
}

@RequestMapping("/getRequestsForAthlete") //checkolini ?
@RequestMapping("/getRequestsForAthlete") //check
public String getRequestsforAthlete(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

JSONObject obj = new JSONObject();
Expand All @@ -311,7 +311,7 @@ public String getRequestsforAthlete(@RequestParam(name="name", required=false, d



@RequestMapping("/dateTimeExists") // checkolini ?
@RequestMapping("/dateTimeExists") // check
public String dateTimeExists(@RequestParam(name="name", required=false, defaultValue="Stranger") String name,
@RequestParam("date") String date) throws Exception{

Expand All @@ -324,7 +324,7 @@ public String dateTimeExists(@RequestParam(name="name", required=false, defaultV
}


@RequestMapping("/usernameExists") // checkolini works
@RequestMapping("/usernameExists") // check
public String usernameExists(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{


Expand All @@ -335,7 +335,7 @@ public String usernameExists(@RequestParam(name="name", required=false, defaultV
}


@RequestMapping("/athleteUsernameExists") // checkolini works
@RequestMapping("/athleteUsernameExists") // check
public String AthleteUsernameExists(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{


Expand All @@ -345,7 +345,7 @@ public String AthleteUsernameExists(@RequestParam(name="name", required=false, d
return obj.toString();
}

@RequestMapping("/coachUsernameExists") //checkolini works
@RequestMapping("/coachUsernameExists") //check
public String coachUsernameExists(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{


Expand All @@ -355,7 +355,7 @@ public String coachUsernameExists(@RequestParam(name="name", required=false, def
return obj.toString();
}

@RequestMapping("/isAthlete") // checkolini works
@RequestMapping("/isAthlete") // check
public String isAthlete(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{


Expand All @@ -367,7 +367,7 @@ public String isAthlete(@RequestParam(name="name", required=false, defaultValue=



@RequestMapping("/setVisibility") // checkolini ?
@RequestMapping("/setVisibility") // check
public void setVisibility(@RequestParam(name="name", required=false, defaultValue="Stranger") String name,
@RequestParam("date") String workou,
@RequestParam("username") String athlet) throws Exception{
Expand All @@ -388,7 +388,7 @@ public void setVisibility(@RequestParam(name="name", required=false, defaultValu
}


@RequestMapping("/getAllActivities") // checkolini works
@RequestMapping("/getAllActivities") // check
public String getAllActivities(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

JSONObject obj = new JSONObject();
Expand All @@ -397,7 +397,7 @@ public String getAllActivities(@RequestParam(name="name", required=false, defaul
}


@RequestMapping("/getNrWorkoutsForAthlete") //checkolini works
@RequestMapping("/getNrWorkoutsForAthlete") //check
public String getNrWorkoutsForAthlete(@RequestParam(name="name", required=false, defaultValue="Stranger") String name,
@RequestParam("activity") String activity) throws Exception{

Expand All @@ -408,7 +408,7 @@ public String getNrWorkoutsForAthlete(@RequestParam(name="name", required=false,
}


@RequestMapping("/getAthletesForActivity") //checkolini works
@RequestMapping("/getAthletesForActivity") //check
public String getAthletesForActivity(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

List<Athlete> liste = db.getAthletesForActivity(name);
Expand All @@ -431,7 +431,7 @@ public String getAthletesForActivity(@RequestParam(name="name", required=false,
}


@RequestMapping("/getWorkoutsForActivity") //checkolini works
@RequestMapping("/getWorkoutsForActivity") //check
public String getWorkoutsForActivity(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

List<Workout> workouts = db.getWorkoutsForActivity(name);
Expand Down Expand Up @@ -474,7 +474,7 @@ public String getWorkoutsForActivity(@RequestParam(name="name", required=false,
}


@RequestMapping("/getCoachNotes") //checkolini works
@RequestMapping("/getCoachNotes") //check
public String getCoachNotes(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

List<String> liste = db.getCoachNotes(name);
Expand All @@ -489,22 +489,22 @@ public String getCoachNotes(@RequestParam(name="name", required=false, defaultVa
return feedback.toString();
}

@RequestMapping("/addCoachNotes") //checkolini fails
@RequestMapping("/addCoachNotes") //check
public void addCoachNotes(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

//DatabaseS db = new DatabaseS();
String[] str = name.split("_");
db.addCoachNotes(str[0], str[1]);
}

@RequestMapping("/updateCoachNotes") //checkolini ?
@RequestMapping("/updateCoachNotes") //check
public void updateCoachNotes(@RequestParam(name="name", required=false, defaultValue="Stranger") String name,
@RequestParam(name="note") String note) throws Exception{
db.updateCoachNotes(name, note);
}


@RequestMapping("/getQuotes") //checkolini works
@RequestMapping("/getQuotes") //check
public String getQuotes(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{
List<String> quotes = db.getQuotes();
JSONArray arr = new JSONArray();
Expand All @@ -519,7 +519,7 @@ public String getQuotes(@RequestParam(name="name", required=false, defaultValue=
}


@RequestMapping("/createCoach") // feil?
@RequestMapping("/createCoach")
public void createCoach(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) throws Exception{

// name on following form 0username_1password_2name_3Athletes(a,b,c,d,)_4Req(a,b,c,d)
Expand All @@ -532,7 +532,7 @@ public void createCoach(@RequestParam(name="name", required=false, defaultValue=
db.createCoach(coach);
}

@RequestMapping("/createAthlete") // noe feil?
@RequestMapping("/createAthlete")
public void createAthlete(@RequestParam(name="name", required=false, defaultValue="Stranger") String name,
@RequestParam(value="password") String pass,
@RequestParam(value="fName") String fName,
Expand Down

0 comments on commit b2f2867

Please sign in to comment.