Compare commits
59 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfb65131e2 | ||
|
|
6faa5edd57 | ||
|
|
2f2a9ba9fc | ||
|
|
533a5e9631 | ||
|
|
f31449508e | ||
|
|
b266160e93 | ||
|
|
a44907865c | ||
|
|
2f1d07f008 | ||
|
|
af65142bf4 | ||
|
|
e2be018816 | ||
|
|
36fbcfedb8 | ||
|
|
2b985344dc | ||
|
|
c030bf3a8e | ||
|
|
8150537aa5 | ||
|
|
694d58924c | ||
|
|
2ed6192090 | ||
|
|
5ef716330c | ||
|
|
facebc1334 | ||
|
|
84793dc924 | ||
|
|
dd184a1398 | ||
|
|
b959484185 | ||
|
|
69d80b1f7c | ||
|
|
f8799c06fb | ||
|
|
f20f010cb8 | ||
|
|
048253a9d3 | ||
|
|
8d029fe21c | ||
|
|
60f8b2a9d9 | ||
|
|
66c2b44be6 | ||
|
|
f0d6b04e30 | ||
|
|
6084338525 | ||
|
|
9006588eed | ||
|
|
367daa1eff | ||
|
|
a2af22facb | ||
|
|
abdaa14679 | ||
|
|
8c5f177704 | ||
|
|
00718a1cf2 | ||
|
|
e73c419c55 | ||
|
|
f4cc37a34b | ||
|
|
461b3bd329 | ||
|
|
f56a959720 | ||
|
|
796deadb8c | ||
|
|
2b1c6cf780 | ||
|
|
eed4f7903d | ||
|
|
377db10f13 | ||
|
|
50fb2078b0 | ||
|
|
123a767a75 | ||
|
|
e0e6744c95 | ||
|
|
cfc238af73 | ||
|
|
78e050751f | ||
|
|
81f48ca0b6 | ||
|
|
d97ae9b53a | ||
|
|
2a136b6a07 | ||
|
|
080053765c | ||
|
|
21ab3d5b79 | ||
|
|
8e747e54be | ||
|
|
99899dfc88 | ||
|
|
867eae66f4 | ||
|
|
37d43c8247 | ||
|
|
a704522a63 |
19
README.md
@@ -1,26 +1,17 @@
|
||||
# Greenify
|
||||
The easiest way to save CO2 and help the environment! Enter your activities and find out your carbon footprint.
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## Badges
|
||||
[](https://gitlab.ewi.tudelft.nl/cse1105/2018-2019/oopp-group-43/template)
|
||||
|
||||
## Getting started
|
||||
You can run greenify with gradle. To start the server, run:
|
||||
To start Greenify:
|
||||
|
||||
```
|
||||
cd <FILE-LOCATION>/greenify/src/server
|
||||
gradle build
|
||||
gradle bootrun
|
||||
```
|
||||
|
||||
With the following you can start the application
|
||||
|
||||
```
|
||||
cd <FILE-LOCATION>/greenify/src/client
|
||||
gradle build
|
||||
gradle bootrun
|
||||
cd <FILE-LOCATION>/greenify/src/Client/build/libs
|
||||
java -Dserver.address="https://greenify43.herokuapp.com" -jar greenify-1.0.0.jar
|
||||
```
|
||||
|
||||
## Running the tests
|
||||
|
||||
@@ -46,7 +46,6 @@ dependencies {
|
||||
testCompile("junit:junit")
|
||||
compileOnly 'org.projectlombok:lombok:1.18.6'
|
||||
compile("org.springframework.boot:spring-boot-starter-data-jpa")
|
||||
compile("com.h2database:h2")
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.6'
|
||||
testCompile(
|
||||
'junit:junit:4.12',
|
||||
|
||||
43
doc/meetings/week9/20190408_agenda.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# Meeting 8
|
||||
|
||||
## Opening
|
||||
> Check if everyone is present:
|
||||
- ~~Nivard Jansen~~
|
||||
- ~~Kristin Peneva~~
|
||||
- ~~Daan Sneep~~
|
||||
- [x] Merel SteenBergen
|
||||
- [x] Ceren Ugurlu
|
||||
- [x] Mika Wauben
|
||||
- [x] Sem van der Hoeven
|
||||
|
||||
- Chair: Merel Steenbergen
|
||||
- Secretary: Sem van der Hoeven
|
||||
|
||||
## Points of action
|
||||
|
||||
- First of all, discuss problems we have faced and if somebody is halted because of a problem
|
||||
- if so, try to work out the problem
|
||||
|
||||
### pre/during meeting
|
||||
- Discuss what we did last week (see scrumboard)
|
||||
- Does anyone have blocking issues?
|
||||
- Coverage reports
|
||||
- Checkstyle reports
|
||||
- Show demo to the TA, since Mitchell isn't here, a different TA will visit us, so we'll show him the entire application.
|
||||
- Discuss about the presentation
|
||||
- Discuss about final things that need to be done
|
||||
|
||||
### post meeting
|
||||
- Focus on the presentation
|
||||
- Focus on the final report
|
||||
- Focus on things we get points for according to the rubric
|
||||
|
||||
## Any other business
|
||||
> If anybody has something that should be discussed but came up with that after the agenda was finalized, he/she should bring that up now so that it can be discussed after all.
|
||||
|
||||
## Question round
|
||||
- Questions for the TA
|
||||
- How to get the code coverage badge, since we use Gradle and we've got the Maven code.
|
||||
|
||||
## Closing
|
||||
> We're almost finished!
|
||||
BIN
doc/reports/checkstyle/20190415_checkstyle.jpg
Normal file
|
After Width: | Height: | Size: 793 KiB |
BIN
doc/reports/coverage/20190415_coverage.jpg
Normal file
|
After Width: | Height: | Size: 189 KiB |
BIN
doc/reports/final-report/20190411_final_report.pdf
Normal file
13
doc/reports/sprint-reviews/20190415_sprint_review.md
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
# Sprint Review
|
||||
|
||||
## Main problems Encountered
|
||||
|
||||
### Problem 1:
|
||||
|
||||
## Adjustments from previous sprints
|
||||
Our project is completely finished and we're very happy with the result.
|
||||
|
||||
## Adjustments for next sprint
|
||||
This is the last sprint for this project!
|
||||
|
||||
BIN
doc/sprints/sprint7/20190415_scrumboard.png
Normal file
|
After Width: | Height: | Size: 107 KiB |
BIN
doc/sprints/sprint7/retrospective_sprint7.pdf
Normal file
@@ -39,8 +39,8 @@ test {
|
||||
}
|
||||
|
||||
bootJar {
|
||||
baseName = 'gs-consuming-rest'
|
||||
version = '0.1.0'
|
||||
baseName = 'greenify'
|
||||
version = '1.0.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -48,6 +48,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.bouncycastle:bcprov-jdk16:1.46", "org.bouncycastle:bcpg-jdk16:1.46", "org.bouncycastle:bcmail-jdk16:1.46", "org.bouncycastle:bctsp-jdk16:1.46"
|
||||
compile("org.springframework.boot:spring-boot-starter")
|
||||
compile("org.springframework:spring-web")
|
||||
compile("com.fasterxml.jackson.core:jackson-databind")
|
||||
|
||||
@@ -400,7 +400,7 @@ public class CalculatorController {
|
||||
}
|
||||
try {
|
||||
extraActivityController.updateExtras();
|
||||
} catch (Exception ex) {
|
||||
} catch (NullPointerException ex) {
|
||||
System.out.println("continue");
|
||||
}
|
||||
Float footprint = userService.saveFootprint(userService.currentUser.getName());
|
||||
|
||||
@@ -2,8 +2,8 @@ package greenify.client.controller;
|
||||
|
||||
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
||||
import greenify.client.Application;
|
||||
import greenify.client.Friend;
|
||||
import greenify.client.Hints;
|
||||
import greenify.client.features.Friend;
|
||||
import greenify.client.features.Hints;
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.KeyFrame;
|
||||
@@ -93,6 +93,10 @@ public class DashBoardController {
|
||||
@FXML
|
||||
private Button addFriendButton;
|
||||
@FXML
|
||||
private Button addFriend;
|
||||
@FXML
|
||||
private Button removeFriend;
|
||||
@FXML
|
||||
private Button addExtraActivityButton;
|
||||
@FXML
|
||||
private Button addExtraActivityButton2;
|
||||
@@ -105,18 +109,24 @@ public class DashBoardController {
|
||||
@FXML
|
||||
private TableView<Friend> globalLeaderboard;
|
||||
@FXML
|
||||
private TableColumn<Friend, Integer> globalPlace;
|
||||
@FXML
|
||||
private TableColumn<Friend, String> globalUser;
|
||||
@FXML
|
||||
private TableColumn<Friend, Float> globalScore;
|
||||
@FXML
|
||||
private TableView<Friend> developmentLeaderboard;
|
||||
@FXML
|
||||
private TableColumn<Friend, Integer> developmentPlace;
|
||||
@FXML
|
||||
private TableColumn<Friend, String> developmentUser;
|
||||
@FXML
|
||||
private TableColumn<Friend, Float> developmentScore;
|
||||
@FXML
|
||||
private TableView<Friend> friendLeaderboard;
|
||||
@FXML
|
||||
private TableColumn<Friend, Integer> friendPlace;
|
||||
@FXML
|
||||
private TableColumn<Friend, String> friendUser;
|
||||
@FXML
|
||||
private TableColumn<Friend, Float> friendScore;
|
||||
@@ -185,14 +195,18 @@ public class DashBoardController {
|
||||
@FXML
|
||||
private Label hintText;
|
||||
@FXML
|
||||
private Label solarPanels;
|
||||
private Label veganMeal;
|
||||
@FXML
|
||||
private Label localProduce;
|
||||
@FXML
|
||||
private Label bike;
|
||||
@FXML
|
||||
private Label publicTrans;
|
||||
@FXML
|
||||
private Label loweringTemp;
|
||||
@FXML
|
||||
private Label solarPanels;
|
||||
@FXML
|
||||
private Button achiev1Tip;
|
||||
@FXML
|
||||
private Button achiev2Tip;
|
||||
@@ -231,15 +245,18 @@ public class DashBoardController {
|
||||
logOutButton.setSkin(new MyButtonSkin(logOutButton));
|
||||
friendsColumn.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||
scoreColumn.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||
globalPlace.setCellValueFactory(new PropertyValueFactory<>("Place"));
|
||||
globalUser.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||
globalScore.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||
developmentUser.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||
developmentPlace.setCellValueFactory(new PropertyValueFactory<>("Place"));
|
||||
developmentScore.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||
friendPlace.setCellValueFactory(new PropertyValueFactory<>("Place"));
|
||||
friendUser.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||
friendScore.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||
List<String> friendList = userService.getFriendNames(userService.currentUser.getName());
|
||||
for (int i = 0; i < friendList.size(); i++) {
|
||||
Friend friend = new Friend(friendList.get(i),
|
||||
Friend friend = new Friend(i, friendList.get(i),
|
||||
userService.getFootprint(friendList.get(i)));
|
||||
data.add(friend);
|
||||
}
|
||||
@@ -251,6 +268,8 @@ public class DashBoardController {
|
||||
addFriendButton.setSkin(new ClickButtonSkin(addFriendButton));
|
||||
addExtraActivityButton.setSkin(new ClickButtonSkin(addExtraActivityButton));
|
||||
addExtraActivityButton2.setSkin(new ClickButtonSkin(addExtraActivityButton2));
|
||||
addFriend.setSkin(new ClickButtonSkin(addFriend));
|
||||
removeFriend.setSkin(new ClickButtonSkin(removeFriend));
|
||||
addRandomHints();
|
||||
|
||||
Tooltip tooltip = new Tooltip("tip");
|
||||
@@ -417,10 +436,12 @@ public class DashBoardController {
|
||||
snacks.setText(inputMap.get("input_footprint_shopping_food_otherfood"));
|
||||
Map<String, String> extraMap = userService
|
||||
.getExtraInputs(userService.currentUser.getName());
|
||||
veganMeal.setText(extraMap.get("vegan"));
|
||||
localProduce.setText(extraMap.get("local_produce"));
|
||||
bike.setText(extraMap.get("bike"));
|
||||
solarPanels.setText(extraMap.get("solar_panels"));
|
||||
publicTrans.setText(extraMap.get("public_transport"));
|
||||
loweringTemp.setText(extraMap.get("temperature"));
|
||||
solarPanels.setText(extraMap.get("solar_panels"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -460,6 +481,7 @@ public class DashBoardController {
|
||||
updateFriends();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Logs out the user.
|
||||
* @param event the event (clicking the button)
|
||||
@@ -479,6 +501,9 @@ public class DashBoardController {
|
||||
//development leaderboard
|
||||
developmentLeaderboard.getItems().clear();
|
||||
developmentData.removeAll();
|
||||
//friends leaderboard
|
||||
friendLeaderboard.getItems().clear();
|
||||
friendLeaderData.removeAll();
|
||||
|
||||
//load the fxml file
|
||||
Parent dash = Application.load(this.getClass().getClassLoader()
|
||||
@@ -564,6 +589,20 @@ public class DashBoardController {
|
||||
calcStage.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* method opens removeFriend scene.
|
||||
* @throws IOException when file is not found
|
||||
*/
|
||||
public void openRemoveFriend() throws IOException {
|
||||
Parent calc = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/RemoveFriend.fxml"));
|
||||
Scene scene = new Scene(calc);
|
||||
Stage calcStage = new Stage();
|
||||
calcStage.setScene(scene);
|
||||
calcStage.setTitle("Remove your friend - " + userService.currentUser.getName());
|
||||
calcStage.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Leaderboard is updating.
|
||||
* @throws InterruptedException throws exception
|
||||
@@ -579,14 +618,15 @@ public class DashBoardController {
|
||||
List<String> userList = userService.getAllUsers();
|
||||
sortScores(userList);
|
||||
for (int i = userList.size() - 1; i >= 0; i--) {
|
||||
Friend user = new Friend(userList.get(i), userService.getFootprint(userList.get(i)));
|
||||
Friend user = new Friend(userList.size() - i, userList.get(i),
|
||||
userService.getFootprint(userList.get(i)));
|
||||
globalLeaderData.add(user);
|
||||
}
|
||||
List<String> secondList = sortDiffScores(userList);
|
||||
for (int j = 0; j < userList.size(); j++) {
|
||||
double diff = Math.round((userService.getFirstFootprint(secondList.get(j))
|
||||
- userService.getFootprint(secondList.get(j))) * 10) / 10.0;
|
||||
Friend diffUser = new Friend(secondList.get(j), diff);
|
||||
Friend diffUser = new Friend(j + 1, secondList.get(j), diff);
|
||||
developmentData.add(diffUser);
|
||||
}
|
||||
globalLeaderboard.setItems(globalLeaderData);
|
||||
@@ -637,14 +677,14 @@ public class DashBoardController {
|
||||
friendLeaderData.removeAll();
|
||||
sortDiffScores(wholeList);
|
||||
for (int i = friendList.size() - 1; i >= 0 ; i--) {
|
||||
Friend user = new Friend(friendList.get(i), userService
|
||||
Friend user = new Friend(i, friendList.get(i), userService
|
||||
.getFootprint(friendList.get(i)));
|
||||
data.add(user);
|
||||
}
|
||||
for (int j = 0; j < wholeList.size(); j++) {
|
||||
double diff = Math.round((userService.getFirstFootprint(wholeList.get(j))
|
||||
- userService.getFootprint(wholeList.get(j))) * 10) / 10.0;
|
||||
Friend diffUser = new Friend(wholeList.get(j), diff);
|
||||
Friend diffUser = new Friend(j + 1, wholeList.get(j), diff);
|
||||
friendLeaderData.add(diffUser);
|
||||
}
|
||||
friendsTable.setItems(data);
|
||||
|
||||
@@ -2,12 +2,15 @@ package greenify.client.controller;
|
||||
|
||||
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.ScaleTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Slider;
|
||||
@@ -129,12 +132,30 @@ public class ExtraActivityController {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* add transition animation.
|
||||
* @param node adding animation
|
||||
*/
|
||||
public void addFadeTransAnimation(Node node) {
|
||||
FadeTransition fade = new FadeTransition(Duration.millis(350), node);
|
||||
fade.setFromValue(0);
|
||||
fade.setToValue(1.0);
|
||||
TranslateTransition trans = new TranslateTransition(Duration.millis(350), node);
|
||||
trans.setFromX(-800);
|
||||
trans.setToX(0);
|
||||
ParallelTransition par = new ParallelTransition();
|
||||
par.setNode(node);
|
||||
par.getChildren().addAll(fade, trans);
|
||||
par.play();
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the vegetarian meal section.
|
||||
* @param event the click of the designated button
|
||||
*/
|
||||
public void displayVeganMeal(ActionEvent event) {
|
||||
// System.out.println("display vm");
|
||||
addFadeTransAnimation(veganMealPane);
|
||||
veganMealPane.setVisible(true);
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(false);
|
||||
@@ -149,6 +170,7 @@ public class ExtraActivityController {
|
||||
*/
|
||||
public void displayBike(ActionEvent event) {
|
||||
// System.out.println("display b");
|
||||
addFadeTransAnimation(bikePane);
|
||||
veganMealPane.setVisible(false);
|
||||
bikePane.setVisible(true);
|
||||
temperaturePane.setVisible(false);
|
||||
@@ -163,6 +185,7 @@ public class ExtraActivityController {
|
||||
*/
|
||||
public void displayTemperature(ActionEvent event) {
|
||||
// System.out.println("display t");
|
||||
addFadeTransAnimation(temperaturePane);
|
||||
veganMealPane.setVisible(false);
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(true);
|
||||
@@ -177,6 +200,7 @@ public class ExtraActivityController {
|
||||
*/
|
||||
public void displaySolarPanel(ActionEvent event) {
|
||||
// System.out.println("display sp");
|
||||
addFadeTransAnimation(solarPanelPane);
|
||||
veganMealPane.setVisible(false);
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(false);
|
||||
@@ -190,6 +214,7 @@ public class ExtraActivityController {
|
||||
* @param event the click of the designated button
|
||||
*/
|
||||
public void displayLocalProduce(ActionEvent event) {
|
||||
addFadeTransAnimation(localProducePane);
|
||||
veganMealPane.setVisible(false);
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(false);
|
||||
@@ -203,6 +228,7 @@ public class ExtraActivityController {
|
||||
* @param event the click of the designated button
|
||||
*/
|
||||
public void displayPublicTransport(ActionEvent event) {
|
||||
addFadeTransAnimation(publicTransportPane);
|
||||
veganMealPane.setVisible(false);
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(false);
|
||||
|
||||
@@ -23,9 +23,13 @@ public class FriendController {
|
||||
private Button addButton;
|
||||
@FXML
|
||||
private TextField userNameText;
|
||||
@FXML
|
||||
private Button removeButton;
|
||||
@FXML
|
||||
private TextField removeUserNameText;
|
||||
|
||||
/**
|
||||
* Signs up the user.
|
||||
* Add a new friend.
|
||||
* @param event the click of the sign up button
|
||||
*/
|
||||
@FXML
|
||||
@@ -58,8 +62,48 @@ public class FriendController {
|
||||
String friendName = userNameText.getText();
|
||||
Stage current = (Stage) owner;
|
||||
dashBoardController.updateAchievements();
|
||||
dashBoardController.updateFriends();
|
||||
current.close();
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner, "Friend added!",
|
||||
userNameText.getText() + " is now your friend!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes one of the friends of the user.
|
||||
* @param event the click of the sign up button
|
||||
*/
|
||||
@FXML
|
||||
public void removeFriend(ActionEvent event) throws InterruptedException {
|
||||
//set the window to the current window (for displaying the alerts)
|
||||
Window owner = removeButton.getScene().getWindow();
|
||||
//check if the username field is empty
|
||||
if (removeUserNameText.getText().isEmpty()) {
|
||||
//if so, display an alert
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!",
|
||||
"Please enter a username!");
|
||||
return;
|
||||
} else if (removeUserNameText.getText().equals(userService.currentUser.getName())) {
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
|
||||
"You are not your friend!");
|
||||
return;
|
||||
} else if (!userService.getFriendNames(userService.currentUser.getName())
|
||||
.contains(removeUserNameText.getText())) {
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
|
||||
"You do not have a friend with this username!");
|
||||
return;
|
||||
} else if (!userService.getAllUsers().contains(removeUserNameText.getText())) {
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
|
||||
"The user does not exist!");
|
||||
return;
|
||||
}
|
||||
//add friend to the current user
|
||||
userService.removeFriend(userService.currentUser.getName(), removeUserNameText.getText());
|
||||
//close the register window after the user has entered all the credentials
|
||||
Stage current = (Stage) owner;
|
||||
dashBoardController.updateFriends();
|
||||
dashBoardController.updateAchievements();
|
||||
current.close();
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner, "Friend removed!",
|
||||
removeUserNameText.getText() + " is not your friend anymore!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package greenify.client.controller;
|
||||
|
||||
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
||||
import greenify.client.Application;
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.animation.FadeTransition;
|
||||
@@ -7,8 +8,10 @@ import javafx.animation.Interpolator;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.KeyValue;
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.ScaleTransition;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.animation.TranslateTransition;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.ActionEvent;
|
||||
@@ -33,6 +36,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -47,6 +51,8 @@ public class RegisterWindowController {
|
||||
@Autowired
|
||||
ExtraActivityController extraActivityController;
|
||||
|
||||
@FXML
|
||||
private Text explainText;
|
||||
//navigation panes
|
||||
@FXML
|
||||
private AnchorPane getStartedPane;
|
||||
@@ -160,6 +166,8 @@ public class RegisterWindowController {
|
||||
private PasswordField passwordField2;
|
||||
@FXML
|
||||
private Button signUpButton;
|
||||
|
||||
|
||||
//@FXML
|
||||
//private Line uNamePathLine;
|
||||
|
||||
@@ -172,6 +180,8 @@ public class RegisterWindowController {
|
||||
addSlideAnimation(1100, passwordField, 300);
|
||||
TimeUnit.MILLISECONDS.sleep(300);
|
||||
addSlideAnimation(1100, passwordField2, -420);
|
||||
|
||||
signUpButton.setSkin(new RegisterButtonSkin(signUpButton));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,12 +197,24 @@ public class RegisterWindowController {
|
||||
slideIn.play();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows an explanation of the application.
|
||||
* @param event the click of the question mark button
|
||||
*/
|
||||
public void showExplanation(ActionEvent event) {
|
||||
if (explainText.isVisible()) {
|
||||
explainText.setVisible(false);
|
||||
} else {
|
||||
explainText.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs up the user.
|
||||
* @param event the click of the sign up button
|
||||
*/
|
||||
@FXML
|
||||
public void handleSignUpButton(ActionEvent event) throws IOException {
|
||||
public void handleSignUpButton(ActionEvent event) throws IOException, NoSuchAlgorithmException {
|
||||
//set the window to the current window (for displaying the alerts)
|
||||
Window owner = signUpButton.getScene().getWindow();
|
||||
//check if the username field is empty
|
||||
@@ -230,7 +252,7 @@ public class RegisterWindowController {
|
||||
//close the register window after the user has entered all the credentials
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
|
||||
|
||||
Parent calc = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/FirstCalculator.fxml"));
|
||||
Scene scene = new Scene(calc);
|
||||
@@ -613,4 +635,41 @@ public class RegisterWindowController {
|
||||
carTravelElectricLabel.getText().replace(" km/Le", ""));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
public class RegisterButtonSkin extends ButtonSkin {
|
||||
/**
|
||||
* registers button skins.
|
||||
* @param button clicking
|
||||
*/
|
||||
public RegisterButtonSkin(Button button) {
|
||||
super(button);
|
||||
|
||||
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(140));
|
||||
scaleUp.setToX(1.2);
|
||||
scaleUp.setToY(1.2);
|
||||
scaleUp.setNode(button);
|
||||
button.setOnMouseEntered(e -> scaleUp.playFromStart());
|
||||
|
||||
ScaleTransition scaleMiddleDown = new ScaleTransition(Duration.millis(50));
|
||||
|
||||
scaleMiddleDown.setToX(1.1);
|
||||
scaleMiddleDown.setToY(1.1);
|
||||
scaleMiddleDown.setNode(button);
|
||||
button.setOnMousePressed(e -> scaleMiddleDown.playFromStart());
|
||||
|
||||
ScaleTransition scaleMiddleUp = new ScaleTransition(Duration.millis(50));
|
||||
|
||||
scaleMiddleUp.setToX(1.2);
|
||||
scaleMiddleUp.setToY(1.2);
|
||||
scaleMiddleUp.setNode(button);
|
||||
button.setOnMouseReleased(e -> scaleMiddleUp.playFromStart());
|
||||
|
||||
ScaleTransition scaleDown = new ScaleTransition(Duration.millis(200));
|
||||
scaleDown.setToX(1.0);
|
||||
scaleDown.setToY(1.0);
|
||||
scaleDown.setNode(button);
|
||||
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package greenify.client.controller;
|
||||
|
||||
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
||||
import greenify.client.Application;
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.animation.ScaleTransition;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Parent;
|
||||
@@ -12,11 +14,13 @@ import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import javafx.util.Duration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -36,6 +40,11 @@ public class UserController {
|
||||
@FXML
|
||||
private Button signUpButton;
|
||||
|
||||
public void initialize() {
|
||||
loginButton.setSkin(new LoginButtonSkin(loginButton));
|
||||
signUpButton.setSkin(new LoginButtonSkin(signUpButton));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles when the user clicks on the login button.
|
||||
* it checks if the username and password fields are filled
|
||||
@@ -44,8 +53,8 @@ public class UserController {
|
||||
* @throws IOException an exception for logging in the user
|
||||
*/
|
||||
@FXML
|
||||
protected void handleLoginButtonAction(ActionEvent event) throws IOException {
|
||||
|
||||
protected void handleLoginButtonAction(ActionEvent event)
|
||||
throws IOException, NoSuchAlgorithmException {
|
||||
Window owner = loginButton.getScene().getWindow(); //get the current window
|
||||
if (usernameField.getText().isEmpty()) {
|
||||
AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!",
|
||||
@@ -136,11 +145,51 @@ public class UserController {
|
||||
Parent registerWindow = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/RegisterWindow.fxml"));
|
||||
Scene registerScene = new Scene(registerWindow);
|
||||
registerScene.getStylesheets().add(this.getClass().getClassLoader()
|
||||
.getResource("stylesheets/registerWindowStyle.css").toExternalForm());
|
||||
Stage registerStage = new Stage();
|
||||
registerStage.setScene(registerScene);
|
||||
registerStage.setTitle("Enter register credentials");
|
||||
registerStage.show();
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
public class LoginButtonSkin extends ButtonSkin {
|
||||
/**
|
||||
* method for the skin of login button.
|
||||
* @param button clicking
|
||||
*/
|
||||
public LoginButtonSkin(Button button) {
|
||||
super(button);
|
||||
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(140));
|
||||
scaleUp.setToX(1.1);
|
||||
scaleUp.setToY(1.1);
|
||||
scaleUp.setNode(button);
|
||||
button.setOnMouseEntered(e -> scaleUp.playFromStart());
|
||||
|
||||
ScaleTransition scaleMiddleDown = new ScaleTransition(Duration.millis(50));
|
||||
scaleMiddleDown.setFromX(1.1);
|
||||
scaleMiddleDown.setFromY(1.1);
|
||||
scaleMiddleDown.setToX(1.05);
|
||||
scaleMiddleDown.setToY(1.05);
|
||||
scaleMiddleDown.setNode(button);
|
||||
button.setOnMousePressed(e -> scaleMiddleDown.playFromStart());
|
||||
|
||||
ScaleTransition scaleMiddleUp = new ScaleTransition(Duration.millis(50));
|
||||
scaleMiddleUp.setFromX(1.05);
|
||||
scaleMiddleUp.setFromY(1.05);
|
||||
scaleMiddleUp.setToX(1.1);
|
||||
scaleMiddleUp.setToY(1.1);
|
||||
scaleMiddleUp.setNode(button);
|
||||
button.setOnMouseReleased(e -> scaleMiddleUp.playFromStart());
|
||||
|
||||
ScaleTransition scaleDown = new ScaleTransition(Duration.millis(200));
|
||||
scaleDown.setToX(1.0);
|
||||
scaleDown.setToY(1.0);
|
||||
scaleDown.setNode(button);
|
||||
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,34 @@
|
||||
package greenify.client;
|
||||
package greenify.client.features;
|
||||
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
public class Friend {
|
||||
|
||||
private SimpleIntegerProperty place;
|
||||
private SimpleStringProperty friend;
|
||||
private SimpleDoubleProperty score;
|
||||
|
||||
public Friend(String friend, Double friendScore) {
|
||||
/**
|
||||
* Constructor for a friend.
|
||||
* @param place place in the leaderboard
|
||||
* @param friend name of the user
|
||||
* @param friendScore score of the user
|
||||
*/
|
||||
public Friend(Integer place, String friend, Double friendScore) {
|
||||
this.place = new SimpleIntegerProperty(place);
|
||||
this.friend = new SimpleStringProperty(friend);
|
||||
this.score = new SimpleDoubleProperty(friendScore);
|
||||
}
|
||||
|
||||
public Integer getPlace() {
|
||||
return place.get();
|
||||
}
|
||||
|
||||
public void setPlace(Integer place) {
|
||||
this.place = new SimpleIntegerProperty(place);
|
||||
}
|
||||
|
||||
public String getFriend() {
|
||||
return friend.get();
|
||||
@@ -1,4 +1,4 @@
|
||||
package greenify.client;
|
||||
package greenify.client.features;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
@@ -2,6 +2,7 @@ package greenify.client.rest;
|
||||
|
||||
import greenify.common.UserDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.HttpEntity;
|
||||
@@ -12,6 +13,9 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -19,6 +23,9 @@ import java.util.Map;
|
||||
public class UserService {
|
||||
public UserDto currentUser;
|
||||
|
||||
@Value( "${server.address:http://localhost:8080}" )
|
||||
String serverAddress = "http://localhost:8080";
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
|
||||
@@ -36,16 +43,17 @@ public class UserService {
|
||||
@SuppressWarnings("Duplicates")
|
||||
//this suppressWarnings is to get rid of the errors of duplicate code
|
||||
//because the methods are very similar
|
||||
public UserDto registerUser(String name, String password) {
|
||||
public UserDto registerUser(String name, String password) throws NoSuchAlgorithmException {
|
||||
//headers for http
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
//set the accept header in JSON value
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
//connect to the server with the needed url
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/registerUser")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/registerUser")
|
||||
.queryParam("name", name)
|
||||
//getting the name from the database
|
||||
.queryParam("password", password);
|
||||
.queryParam("password", hashPassword(password));
|
||||
//getting the password from the database
|
||||
|
||||
//create a http entity to be sent
|
||||
@@ -67,13 +75,14 @@ public class UserService {
|
||||
* @return a userDTO
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public UserDto loginUser(String name, String password) {
|
||||
public UserDto loginUser(String name, String password) throws NoSuchAlgorithmException {
|
||||
//this method is almost the same as the registerUser one, but with a different link
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/loginUser")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/loginUser")
|
||||
.queryParam("name", name)
|
||||
.queryParam("password", password);
|
||||
.queryParam("password", hashPassword(password));
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
UserDto result = this.restTemplate.getForObject(builder.build()
|
||||
@@ -92,7 +101,7 @@ public class UserService {
|
||||
public void updateInput(String name, String inputName, String value) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/setInput")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(serverAddress + "/setInput")
|
||||
.queryParam("name", name)
|
||||
.queryParam("inputName", inputName)
|
||||
.queryParam("value",value);
|
||||
@@ -112,7 +121,8 @@ public class UserService {
|
||||
public void updateExtraInput(String name, String inputName, String value) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/setExtraInput")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/setExtraInput")
|
||||
.queryParam("name", name)
|
||||
.queryParam("inputName", inputName)
|
||||
.queryParam("value", value);
|
||||
@@ -131,7 +141,8 @@ public class UserService {
|
||||
public double getFootprint(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getFootprint")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getFootprint")
|
||||
.queryParam("name", name);
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
@@ -149,7 +160,7 @@ public class UserService {
|
||||
public double getFirstFootprint(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getFirst")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(serverAddress + "/getFirst")
|
||||
.queryParam("name", name);
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
@@ -168,7 +179,8 @@ public class UserService {
|
||||
public Float saveFootprint(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/saveFootprint")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/saveFootprint")
|
||||
.queryParam("name", name);
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
@@ -187,7 +199,8 @@ public class UserService {
|
||||
public Float saveFirstFootprint(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/saveFirstFootprint")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/saveFirstFootprint")
|
||||
.queryParam("name", name);
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
@@ -205,7 +218,8 @@ public class UserService {
|
||||
public List<String> getFriendNames(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getFriends")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getFriends")
|
||||
.queryParam("name", name);
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
@@ -223,7 +237,8 @@ public class UserService {
|
||||
public void addFriend(String name, String friend) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/addFriend")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/addFriend")
|
||||
.queryParam("name", name)
|
||||
.queryParam("friend",friend);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
@@ -241,7 +256,8 @@ public class UserService {
|
||||
public void removeFriend(String name, String friend) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/removeFriend")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/removeFriend")
|
||||
.queryParam("name", name)
|
||||
.queryParam("friend",friend);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
@@ -258,7 +274,8 @@ public class UserService {
|
||||
public Map<String, String> getInputs(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getInputs")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getInputs")
|
||||
.queryParam("name", name);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
@@ -275,7 +292,8 @@ public class UserService {
|
||||
public Map<String, String> getExtraInputs(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getExtraInputs")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getExtraInputs")
|
||||
.queryParam("name", name);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
@@ -293,7 +311,8 @@ public class UserService {
|
||||
public Map getAchievements(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getAchievements")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getAchievements")
|
||||
.queryParam("name", name);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
@@ -310,7 +329,8 @@ public class UserService {
|
||||
public Map<String, String> getResults(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getResults")
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getResults")
|
||||
.queryParam("name", name);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
@@ -325,11 +345,50 @@ public class UserService {
|
||||
public List<String> getAllUsers() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getAllUsers");
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getAllUsers");
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
List<String> result = this.restTemplate.getForObject(builder
|
||||
.build().encode().toUri(), List.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a user from the database.
|
||||
* @param name the username of the current user.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void deleteAccount(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/deleteAccount")
|
||||
.queryParam("name", name);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
ResponseEntity<String> authenticateResponse = this.restTemplate.getForEntity(builder.build()
|
||||
.encode().toUri(), String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hashes the password of a user.
|
||||
* @param password password of the user
|
||||
* @return hashed password
|
||||
* @throws NoSuchAlgorithmException when there is no such algorithm
|
||||
*/
|
||||
public String hashPassword(String password)
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
byte[] encodedHash = digest.digest(password.getBytes(StandardCharsets.UTF_8));
|
||||
StringBuffer hexString = new StringBuffer();
|
||||
for (int i = 0; i < encodedHash.length; i++) {
|
||||
String hex = Integer.toHexString(0xff & encodedHash[i]);
|
||||
if (hex.length() == 1) {
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
return hexString.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.shape.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.shape.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.control.Slider?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.shape.Line?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<AnchorPane prefHeight="703.0" prefWidth="820.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.RegisterWindowController">
|
||||
<children>
|
||||
@@ -146,6 +161,24 @@
|
||||
</Label>
|
||||
<Button fx:id="getStartedNextButton" layoutX="383.0" layoutY="406.0" mnemonicParsing="false" onAction="#displayTravel" styleClass="nextButton" text="Next" />
|
||||
<Line endX="79.0" layoutX="147.0" layoutY="14.0" stroke="#545b54" />
|
||||
<Text layoutX="296.0" layoutY="51.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Welcome to Greenify!">
|
||||
<font>
|
||||
<Font name="System Bold" size="22.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Text fx:id="explainText" layoutX="52.0" layoutY="456.0" strokeType="OUTSIDE" strokeWidth="0.0" text="This application will help you decrease your CO2-footprint. In the next screen, you will be asked to fill in certain things, like your yearly energy costs. These values will help us calculate your CO2-footprint. Warning: If you don't fill anything in, the calculator will use a default value based on averages, so if you want a value to be zero, please fill in zero. After that, you'll be able to see your score and compare your footprint to those of your friends. Let's go green and save the planet!" textAlignment="CENTER" visible="false" wrappingWidth="714.0">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font></Text>
|
||||
<Button fx:id="showExplanation" layoutX="31.0" layoutY="534.0" mnemonicParsing="false" onAction="#showExplanation" prefHeight="63.0" prefWidth="52.0" style="-fx-background-color: transparent; -fx-padding: 0 0 0 0;">
|
||||
<graphic>
|
||||
<ImageView fitHeight="62.0" fitWidth="83.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/questionmark.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
</children></AnchorPane>
|
||||
<AnchorPane fx:id="travelPane" layoutY="85.0" prefHeight="618.0" prefWidth="820.0" visible="false">
|
||||
<children>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
@@ -24,7 +25,7 @@
|
||||
<Font size="13.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<Button fx:id="signUpButton" layoutX="115.0" layoutY="229.0" mnemonicParsing="false" onAction="#handleSignUpButton" style="-fx-background-color: #005e07;" text="Sign up!" textFill="#c4eec9">
|
||||
<Button fx:id="signUpButton" layoutX="115.0" layoutY="229.0" mnemonicParsing="false" onAction="#handleSignUpButton" text="Sign up!" textFill="#c4eec9">
|
||||
<font>
|
||||
<Font name="Corbel Bold" size="14.0" />
|
||||
</font>
|
||||
|
||||
39
src/Client/src/main/resources/fxml/RemoveFriend.fxml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<AnchorPane prefHeight="287.0" prefWidth="187.0" style="-fx-background-color: #e2f0c8;" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.FriendController">
|
||||
<children>
|
||||
<Text fill="#00650d" layoutX="114.0" layoutY="64.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Remove Friend" textAlignment="CENTER" wrappingWidth="234.96600341796875">
|
||||
<font>
|
||||
<Font size="30.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<TextField fx:id="removeUserNameText" layoutX="140.0" layoutY="100.0" prefHeight="35.0" prefWidth="183.0" promptText="Username">
|
||||
<font>
|
||||
<Font size="13.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<Button fx:id="removeButton" layoutX="206.0" layoutY="154.0" mnemonicParsing="false" onAction="#removeFriend" style="-fx-background-color: #005e07;" text="Remove!" textFill="#c4eec9">
|
||||
<font>
|
||||
<Font name="Corbel Bold" size="14.0" />
|
||||
</font>
|
||||
</Button>
|
||||
<ImageView fitHeight="80.0" fitWidth="349.0" layoutY="211.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/grass.png"/>
|
||||
</image>
|
||||
</ImageView>
|
||||
<ImageView fitHeight="150.0" fitWidth="200.0" layoutY="43.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/friends.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
@@ -1,12 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.chart.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.shape.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.scene.chart.PieChart?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
@@ -23,9 +16,8 @@
|
||||
<?import javafx.scene.shape.Line?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
<?import javafx.scene.control.Tooltip?>
|
||||
|
||||
<AnchorPane prefHeight="702.0" prefWidth="1032.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.DashBoardController">
|
||||
<AnchorPane prefHeight="702.0" prefWidth="1032.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.DashBoardController">
|
||||
<children>
|
||||
<AnchorPane fx:id="menuBar" prefHeight="703.0" prefWidth="216.0" style="-fx-background-color: #5a635c;">
|
||||
<children>
|
||||
@@ -241,71 +233,83 @@
|
||||
<Font name="System Bold Italic" size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Pane layoutX="545.0" layoutY="130.0" prefHeight="342.0" prefWidth="255.0" style="-fx-background-color: #f4fff4;">
|
||||
<Pane layoutX="545.0" layoutY="130.0" prefHeight="255.0" prefWidth="255.0" style="-fx-background-color: #f4fff4;">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="26.0" prefHeight="46.0" prefWidth="115.0" text="Meat fish eggs">
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="14.0" prefHeight="46.0" prefWidth="115.0" text="Meat fish eggs">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="90.0" prefHeight="46.0" prefWidth="115.0" text="Grains/baked foods" textAlignment="CENTER">
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="60.0" prefHeight="46.0" prefWidth="115.0" text="Grains/baked foods" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="154.0" prefHeight="46.0" prefWidth="115.0" text="Dairy">
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="106.0" prefHeight="46.0" prefWidth="115.0" text="Dairy">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="218.0" prefHeight="46.0" prefWidth="115.0" text="Fruits vegetables">
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="152.0" prefHeight="46.0" prefWidth="115.0" text="Fruits vegetables">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="282.0" prefHeight="46.0" prefWidth="115.0" text="Snacks drinks">
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="198.0" prefHeight="46.0" prefWidth="115.0" text="Snacks drinks">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="meat" layoutX="171.0" layoutY="41.0" styleClass="activityField" text="Label" />
|
||||
<Label fx:id="grains" layoutX="171.0" layoutY="105.0" styleClass="activityField" text="Label" />
|
||||
<Label fx:id="dairy" layoutX="171.0" layoutY="169.0" styleClass="activityField" text="Label" />
|
||||
<Label fx:id="fruits" layoutX="171.0" layoutY="233.0" styleClass="activityField" text="Label" />
|
||||
<Label fx:id="snacks" layoutX="171.0" layoutY="297.0" styleClass="activityField" text="Label" />
|
||||
<Label fx:id="meat" layoutX="171.0" layoutY="29.0" styleClass="activityField" text="Label" />
|
||||
<Label fx:id="grains" layoutX="171.0" layoutY="75.0" styleClass="activityField" text="Label" />
|
||||
<Label fx:id="dairy" layoutX="171.0" layoutY="121.0" styleClass="activityField" text="Label" />
|
||||
<Label fx:id="fruits" layoutX="171.0" layoutY="167.0" styleClass="activityField" text="Label" />
|
||||
<Label fx:id="snacks" layoutX="171.0" layoutY="213.0" styleClass="activityField" text="Label" />
|
||||
</children>
|
||||
</Pane>
|
||||
<Label alignment="CENTER" layoutX="545.0" layoutY="488.0" prefHeight="32.0" prefWidth="255.0" text="Extras!" textAlignment="CENTER" textFill="#107222">
|
||||
<Label alignment="CENTER" layoutX="545.0" layoutY="385.0" prefHeight="32.0" prefWidth="255.0" text="Extras!" textAlignment="CENTER" textFill="#107222">
|
||||
<font>
|
||||
<Font name="System Bold Italic" size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Pane layoutX="545.0" layoutY="520.0" prefHeight="129.0" prefWidth="255.0" style="-fx-background-color: #f4fff4;">
|
||||
<Pane layoutX="545.0" layoutY="412.0" prefHeight="238.0" prefWidth="255.0" style="-fx-background-color: #f4fff4;">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="7.0" prefHeight="27.0" prefWidth="183.0" text="Buying local produce">
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="12.0" layoutY="56.0" prefHeight="27.0" prefWidth="183.0" text="Buying local produce">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="localProduce" layoutX="195.0" layoutY="7.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="39.0" prefHeight="27.0" prefWidth="183.0" text="Using bike">
|
||||
<Label fx:id="localProduce" layoutX="189.0" layoutY="56.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="12.0" layoutY="92.0" prefHeight="27.0" prefWidth="183.0" text="Using bike">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="bike" layoutX="195.0" layoutY="39.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="20.0" layoutY="71.0" prefHeight="27.0" prefWidth="183.0" text="Lowering the temperature">
|
||||
<Label fx:id="bike" layoutX="189.0" layoutY="92.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="13.0" layoutY="164.0" prefHeight="27.0" prefWidth="183.0" text="Lowering the temperature">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="loweringTemp" layoutX="195.0" layoutY="71.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="20.0" layoutY="103.0" prefHeight="27.0" prefWidth="183.0" text="Installing solar panels">
|
||||
<Label fx:id="loweringTemp" layoutX="188.0" layoutY="164.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="13.0" layoutY="200.0" prefHeight="27.0" prefWidth="183.0" text="Installing solar panels">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="solarPanels" layoutX="195.0" layoutY="103.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
|
||||
<Label fx:id="solarPanels" layoutX="188.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="13.0" layoutY="128.0" prefHeight="27.0" prefWidth="183.0" text="Using public transport">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="publicTrans" layoutX="188.0" layoutY="128.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="11.0" layoutY="20.0" prefHeight="27.0" prefWidth="183.0" text="Eating vegetarian meal">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="veganMeal" layoutX="188.0" layoutY="20.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
|
||||
</children>
|
||||
</Pane>
|
||||
<Button fx:id="addExtraActivityButton2" contentDisplay="RIGHT" layoutX="545.0" layoutY="14.0" mnemonicParsing="false" onAction="#openExtraActivities" style="-fx-background-color: transparent;" text="Add extra activity!" textFill="#147219">
|
||||
@@ -447,16 +451,11 @@
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<TableView fx:id="globalLeaderboard" layoutX="56.0" layoutY="220.0" prefHeight="333.0" prefWidth="200.0">
|
||||
<TableView fx:id="globalLeaderboard" layoutX="53.0" layoutY="220.0" prefHeight="334.0" prefWidth="207.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="globalPlace" prefWidth="30.0" text="#" />
|
||||
<TableColumn fx:id="globalUser" prefWidth="75.0" text="User" />
|
||||
<TableColumn fx:id="globalScore" prefWidth="124.0" text="Score" />
|
||||
</columns>
|
||||
</TableView>
|
||||
<TableView fx:id="developmentLeaderboard" layoutX="302.0" layoutY="220.0" prefHeight="333.0" prefWidth="200.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="developmentUser" prefWidth="75.0" text="User" />
|
||||
<TableColumn fx:id="developmentScore" prefWidth="124.0" text="Score" />
|
||||
<TableColumn fx:id="globalScore" prefWidth="100.0" text="Score" />
|
||||
</columns>
|
||||
</TableView>
|
||||
<Label layoutX="69.0" layoutY="177.0" prefHeight="46.0" prefWidth="187.0" text="Global Leaderboard" textAlignment="CENTER" textFill="#5f1616">
|
||||
@@ -558,6 +557,13 @@
|
||||
</Button>
|
||||
</children>
|
||||
</GridPane>
|
||||
<TableView fx:id="developmentLeaderboard" layoutX="292.0" layoutY="220.0" prefHeight="334.0" prefWidth="207.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="developmentPlace" prefWidth="30.0" text="#" />
|
||||
<TableColumn fx:id="developmentUser" prefWidth="75.0" text="User" />
|
||||
<TableColumn fx:id="developmentScore" prefWidth="100.0" text="Score" />
|
||||
</columns>
|
||||
</TableView>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane fx:id="friendsPane" layoutX="216.0" prefHeight="703.0" prefWidth="820.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="214.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
@@ -572,7 +578,7 @@
|
||||
<Font size="20.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<TableView fx:id="friendsTable" layoutX="60.0" layoutY="170.0" prefHeight="426.0" prefWidth="216.0" style="-fx-background-color: #e1fcd9;">
|
||||
<TableView fx:id="friendsTable" layoutX="60.0" layoutY="170.0" prefHeight="426.0" prefWidth="214.0" style="-fx-background-color: #e1fcd9;">
|
||||
<columns>
|
||||
<TableColumn fx:id="friendsColumn" prefWidth="107.0" text="Friend" />
|
||||
<TableColumn fx:id="scoreColumn" prefWidth="108.0" text="Score" />
|
||||
@@ -586,15 +592,40 @@
|
||||
<Font size="20.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<TableView fx:id="friendLeaderboard" layoutX="300.0" layoutY="170.0" prefHeight="426.0" prefWidth="216.0" style="-fx-background-color: #e1fcd9;">
|
||||
<TableView fx:id="friendLeaderboard" layoutX="300.0" layoutY="170.0" prefHeight="426.0" prefWidth="232.0" style="-fx-background-color: #e1fcd9;">
|
||||
<columns>
|
||||
<TableColumn fx:id="friendUser" prefWidth="107.0" text="Friend" />
|
||||
<TableColumn fx:id="friendScore" prefWidth="108.0" text="Score" />
|
||||
<TableColumn fx:id="friendPlace" prefWidth="30.0" resizable="false" text="#" />
|
||||
<TableColumn fx:id="friendUser" minWidth="30.0" prefWidth="100.0" resizable="false" text="Friend" />
|
||||
<TableColumn fx:id="friendScore" minWidth="30.0" prefWidth="100.0" resizable="false" text="Score" />
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
<Button fx:id="addFriend" contentDisplay="RIGHT" layoutX="575.0" layoutY="75.0" mnemonicParsing="false" onAction="#openAddFriend" prefHeight="74.0" prefWidth="200.0" style="-fx-border-radius: 20px; -fx-padding: 0px 0px 0px 0px; -fx-background-color: transparent;" text="Add friend" textFill="#29721a">
|
||||
<font>
|
||||
<Font name="Corbel Bold" size="14.0" />
|
||||
</font>
|
||||
<graphic>
|
||||
<ImageView fitHeight="74.0" fitWidth="64.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/friend2.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="removeFriend" contentDisplay="RIGHT" layoutX="560.0" layoutY="150.0" mnemonicParsing="false" onAction="#openRemoveFriend" prefHeight="74.0" prefWidth="200.0" style="-fx-border-radius: 20px; -fx-padding: 0px 0px 0px 0px; -fx-background-color: transparent;" text="Remove friend" textFill="#29721a">
|
||||
<font>
|
||||
<Font name="Corbel Bold" size="14.0" />
|
||||
</font>
|
||||
<graphic>
|
||||
<ImageView fitHeight="70.0" fitWidth="60.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/remove_friend.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
@@ -8,63 +9,6 @@
|
||||
|
||||
<AnchorPane prefHeight="611.0" prefWidth="820.0" stylesheets="@../stylesheets/extraActivitiesStyle.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.ExtraActivityController">
|
||||
<children>
|
||||
<AnchorPane prefHeight="611.0" prefWidth="107.0">
|
||||
<children>
|
||||
<Button fx:id="displayVeganMealButton" contentDisplay="TOP" layoutX="14.0" layoutY="62.0" mnemonicParsing="false" onAction="#displayVeganMeal" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="45.0" pickOnBounds="true" preserveRatio="true" styleClass="navButton">
|
||||
<image>
|
||||
<Image url="@../icons/icons8-vegan-food-100.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="displayLocalProduceButton" contentDisplay="TOP" layoutX="14.0" layoutY="143.0" mnemonicParsing="false" onAction="#displayLocalProduce" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="45.0" pickOnBounds="true" preserveRatio="true" styleClass="navButton">
|
||||
<image>
|
||||
<Image url="@../icons/localProduce.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="displayBikeButton" contentDisplay="TOP" layoutX="14.0" layoutY="224.0" mnemonicParsing="false" onAction="#displayBike" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="48.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/icons8-bicycle-filled-100.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic></Button>
|
||||
<Button fx:id="displaySolarPanelButton" contentDisplay="TOP" layoutX="14.0" layoutY="467.0" mnemonicParsing="false" onAction="#displaySolarPanel" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="48.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/icons8-solar-panel-filled-100.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="displayTemperatureButton" contentDisplay="TOP" layoutX="14.0" layoutY="386.0" mnemonicParsing="false" onAction="#displayTemperature" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="48.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/icons8-temperature-inside-64.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="displayPublicTransportButton" contentDisplay="TOP" layoutX="14.0" layoutY="305.0" mnemonicParsing="false" onAction="#displayPublicTransport" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="45.0" pickOnBounds="true" preserveRatio="true" styleClass="navButton">
|
||||
<image>
|
||||
<Image url="@../icons/publicTransport.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane fx:id="veganMealPane" layoutX="107.0" prefHeight="611.0" prefWidth="713.0">
|
||||
<children>
|
||||
<Line fx:id="line1" endX="79.0" layoutX="465.0" layoutY="7.0" stroke="#545b54" />
|
||||
@@ -223,7 +167,7 @@
|
||||
<AnchorPane fx:id="publicTransportPane" layoutX="107.0" prefHeight="611.0" prefWidth="713.0" visible="false">
|
||||
<children>
|
||||
<Line fx:id="line21" endX="79.0" layoutX="465.0" layoutY="7.0" stroke="#545b54" />
|
||||
<Text layoutX="153.0" layoutY="56.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Using your public transport instead of your car">
|
||||
<Text layoutX="153.0" layoutY="56.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Using public transport instead of your car">
|
||||
<font>
|
||||
<Font size="20.0" />
|
||||
</font>
|
||||
@@ -257,5 +201,62 @@
|
||||
</HBox>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane prefHeight="611.0" prefWidth="107.0">
|
||||
<children>
|
||||
<Button fx:id="displayVeganMealButton" contentDisplay="TOP" layoutX="14.0" layoutY="62.0" mnemonicParsing="false" onAction="#displayVeganMeal" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="45.0" pickOnBounds="true" preserveRatio="true" styleClass="navButton">
|
||||
<image>
|
||||
<Image url="@../icons/icons8-vegan-food-100.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="displayLocalProduceButton" contentDisplay="TOP" layoutX="14.0" layoutY="143.0" mnemonicParsing="false" onAction="#displayLocalProduce" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="45.0" pickOnBounds="true" preserveRatio="true" styleClass="navButton">
|
||||
<image>
|
||||
<Image url="@../icons/localProduce.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="displayBikeButton" contentDisplay="TOP" layoutX="14.0" layoutY="224.0" mnemonicParsing="false" onAction="#displayBike" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="48.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/icons8-bicycle-filled-100.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic></Button>
|
||||
<Button fx:id="displaySolarPanelButton" contentDisplay="TOP" layoutX="14.0" layoutY="467.0" mnemonicParsing="false" onAction="#displaySolarPanel" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="48.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/icons8-solar-panel-filled-100.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="displayTemperatureButton" contentDisplay="TOP" layoutX="14.0" layoutY="386.0" mnemonicParsing="false" onAction="#displayTemperature" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="48.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/icons8-temperature-inside-64.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="displayPublicTransportButton" contentDisplay="TOP" layoutX="14.0" layoutY="305.0" mnemonicParsing="false" onAction="#displayPublicTransport" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
|
||||
<graphic>
|
||||
<ImageView fitHeight="45.0" fitWidth="45.0" pickOnBounds="true" preserveRatio="true" styleClass="navButton">
|
||||
<image>
|
||||
<Image url="@../icons/publicTransport.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
||||
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 26 KiB |
BIN
src/Client/src/main/resources/icons/questionmark.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
src/Client/src/main/resources/icons/remove_friend.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
@@ -2,4 +2,12 @@
|
||||
-fx-background-color: #005e07;
|
||||
-fx-text-fill: #c4eec9;
|
||||
-fx-font-weight: bold;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
-fx-background-color: #027009;
|
||||
}
|
||||
|
||||
.button:pressed {
|
||||
-fx-background-color: #1ba023;
|
||||
}
|
||||
@@ -1,15 +1,17 @@
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import greenify.client.Friend;
|
||||
import greenify.client.features.Friend;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
||||
public class FriendTest {
|
||||
@Test
|
||||
public void setAndGetTest() {
|
||||
Friend test = new Friend("ceren", 10.0);
|
||||
Friend test = new Friend(1,"ceren", 10.0);
|
||||
test.setPlace(1);
|
||||
test.setFriend("greenify");
|
||||
test.setScore(15.0);
|
||||
Assertions.assertEquals(test.getPlace(), 1);
|
||||
assertEquals(test.getFriend(), "greenify");
|
||||
Assertions.assertEquals(test.getScore(), 15.0);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import greenify.client.Hints;
|
||||
import greenify.client.features.Hints;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HintsTest {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class UserServiceTest {
|
||||
@Test
|
||||
public void userRegisterTest() throws Exception {
|
||||
UserDto testUser = new UserDto(1L, "Eric");
|
||||
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/registerUser?name=Eric&password=password"),
|
||||
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/registerUser?name=Eric&password=5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"),
|
||||
UserDto.class))
|
||||
.thenReturn(testUser);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class UserServiceTest {
|
||||
@Test
|
||||
public void userLoginTest() throws Exception {
|
||||
UserDto testUser = new UserDto(1L, "Eric");
|
||||
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/loginUser?name=Eric&password=password"),
|
||||
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/loginUser?name=Eric&password=5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"),
|
||||
UserDto.class))
|
||||
.thenReturn(testUser);
|
||||
UserDto user = userService.loginUser("Eric", "password");
|
||||
@@ -152,8 +152,6 @@ public class UserServiceTest {
|
||||
|
||||
@Test
|
||||
public void removeFriendTest() throws Exception {
|
||||
userService.addFriend("Eric", "Ceren");
|
||||
Mockito.verify(userService).addFriend("Eric", "Ceren");
|
||||
userService.removeFriend("Eric", "Ceren");
|
||||
Mockito.verify(userService).removeFriend("Eric", "Ceren");
|
||||
}
|
||||
@@ -169,6 +167,12 @@ public class UserServiceTest {
|
||||
userService.getResults("mika");
|
||||
Mockito.verify(userService).getResults("mika");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteAccountTest() throws Exception {
|
||||
userService.deleteAccount("merel");
|
||||
Mockito.verify(userService).deleteAccount("merel");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
21
src/Common/src/test/java/ApplicationExceptionTest.java
Normal file
@@ -0,0 +1,21 @@
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import greenify.common.ApplicationException;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ApplicationExceptionTest {
|
||||
|
||||
@Test
|
||||
public void setAndGetTest() {
|
||||
ApplicationException ex = new ApplicationException("This is an exception");
|
||||
assertEquals(ex.getMessage(), "This is an exception");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsTest() {
|
||||
ApplicationException ex = new ApplicationException("This is an exception");
|
||||
ApplicationException test = new ApplicationException("This is an exception");
|
||||
assertEquals(ex.getMessage(), test.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,19 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "com.heroku.sdk.heroku-gradle" version "1.0.4"
|
||||
}
|
||||
|
||||
heroku {
|
||||
appName = "greenify43"
|
||||
includes = ["${buildDir}/libs/greenify-server-1.0.0.jar"]
|
||||
includeBuildDir = false
|
||||
processTypes(
|
||||
web: "java -Dserver.port=\$PORT -jar src/Server/build/libs/greenify-server-1.0.0.jar"
|
||||
)
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
@@ -16,8 +29,8 @@ apply plugin: 'jacoco'
|
||||
apply plugin: 'checkstyle'
|
||||
|
||||
bootJar {
|
||||
baseName = 'gs-rest-service'
|
||||
version = '0.1.0'
|
||||
baseName = 'greenify-server'
|
||||
version = '1.0.0'
|
||||
}
|
||||
|
||||
test {
|
||||
|
||||
@@ -209,7 +209,6 @@ public class User {
|
||||
throw new ApplicationException("Cannot add yourself as a friend");
|
||||
} else {
|
||||
friends.add(user);
|
||||
System.out.print("Friend added!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +221,6 @@ public class User {
|
||||
throw new ApplicationException("This user is not your friend!");
|
||||
} else {
|
||||
friends.remove(user);
|
||||
System.out.print("Friend removed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,6 @@ public class UserController {
|
||||
*/
|
||||
@RequestMapping("/getFirst")
|
||||
public Float getFirstFootprint(@RequestParam(value = "name") String name) {
|
||||
System.out.println("hello");
|
||||
Float footprint = userService.getFirstFootprint(name);
|
||||
return footprint;
|
||||
}
|
||||
@@ -195,5 +194,14 @@ public class UserController {
|
||||
public Map<String, String> getResults(@RequestParam(value = "name") String name) {
|
||||
return userService.getResults(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a user from the database.
|
||||
* @param name name of the user
|
||||
*/
|
||||
@RequestMapping("/deleteAccount")
|
||||
public void deleteAccount(@RequestParam(value = "name") String name) {
|
||||
userService.deleteAccount(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ public class AchievementService {
|
||||
public void achieveSocialButterfly(User user) {
|
||||
if (user.getFriends().size() >= 3) {
|
||||
userService.setAchievement(user.getName(), "Social butterfly", true);
|
||||
} else {
|
||||
userService.setAchievement(user.getName(), "Social butterfly", false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +50,8 @@ public class AchievementService {
|
||||
public void achieveGreenSaver(User user) {
|
||||
if (20 > user.getFootPrint()) {
|
||||
userService.setAchievement(user.getName(), "Green saver", true);
|
||||
} else {
|
||||
userService.setAchievement(user.getName(), "Green saver", false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +63,8 @@ public class AchievementService {
|
||||
int vegan = Integer.parseInt(user.getExtraInputs().get("vegan"));
|
||||
if (vegan > 10) {
|
||||
userService.setAchievement(user.getName(), "Animal friend", true);
|
||||
} else {
|
||||
userService.setAchievement(user.getName(), "Animal friend", false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +76,8 @@ public class AchievementService {
|
||||
int bike = Integer.parseInt(user.getExtraInputs().get("bike"));
|
||||
if (bike > 15) {
|
||||
userService.setAchievement(user.getName(), "Tom Dumoulin", true);
|
||||
} else {
|
||||
userService.setAchievement(user.getName(), "Tom Dumoulin", false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +86,11 @@ public class AchievementService {
|
||||
* @param user user for whom achiev6 changes
|
||||
*/
|
||||
public void achieveLetItShine(User user) {
|
||||
int solar_panels = Integer.parseInt(user.getExtraInputs().get("solar_panels"));
|
||||
if (solar_panels >= 2) {
|
||||
int solarPanels = Integer.parseInt(user.getExtraInputs().get("solar_panels"));
|
||||
if (solarPanels >= 2) {
|
||||
userService.setAchievement(user.getName(), "Let it shine", true);
|
||||
} else {
|
||||
userService.setAchievement(user.getName(), "Let it shine", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ public class CalculatorService {
|
||||
.indexOf("<result_grand_total>")
|
||||
+ 20, response.getBody().indexOf("</result_grand_total>"));
|
||||
// to do: in not HTTP 200 or exception case throws exception
|
||||
System.out.println(Float.parseFloat(result));
|
||||
return Float.parseFloat(result);
|
||||
}
|
||||
|
||||
@@ -110,6 +109,11 @@ public class CalculatorService {
|
||||
user.setFootPrintInputs(inputs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the result of the CO2-calculation from the CoolClimate website
|
||||
* @param map results that the user filled in
|
||||
* @return the results from the website.
|
||||
*/
|
||||
public Map<String, String> getResults(Map<String, String> map) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
|
||||
@@ -303,4 +303,15 @@ public class UserService {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets the list of all users.
|
||||
*/
|
||||
public void deleteAccount(String name) {
|
||||
User user = userRepository.findByName(name);
|
||||
if (user == null) {
|
||||
throw new ApplicationException("User doesn't exist");
|
||||
}
|
||||
userRepository.delete(user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,4 +262,16 @@ public class UserControllerTest {
|
||||
assertEquals("mika", arg1Captor.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteAccountTest() throws Exception {
|
||||
ArgumentCaptor<String> arg1Captor = ArgumentCaptor.forClass(String.class);
|
||||
mvc.perform(get("/deleteAccount")
|
||||
.param("name", "merel")
|
||||
.accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(print())
|
||||
.andExpect(status().isOk());
|
||||
verify(userService, times(1)).deleteAccount(arg1Captor.capture());
|
||||
assertEquals("merel", arg1Captor.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ package greenify.server.service;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import greenify.common.ApplicationException;
|
||||
@@ -326,4 +329,17 @@ public class UserServiceTest {
|
||||
public void getAchievementsTest() {
|
||||
assertEquals(AllAchievements.getDefaults(), userService.getAchievements("alex"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteAccountException() {
|
||||
assertThrows(ApplicationException.class, () -> userService.deleteAccount("merel"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteAccount() {
|
||||
User alex = new User(1L, "alex", "password");
|
||||
doNothing().when(userRepository).delete(alex);
|
||||
userService.deleteAccount("alex");
|
||||
verify(userRepository, times(1)).delete(alex);
|
||||
}
|
||||
}
|
||||