Merge branch 'tests'
This commit is contained in:
@ -27,7 +27,7 @@ public class Exporter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Führt den Export aus -> Holt daten, erstellt file
|
||||
* Führt den Export aus: Holt daten, erstellt file
|
||||
* @throws IOException Fehler beim File erstellen
|
||||
*/
|
||||
public void doExport() throws IOException {
|
||||
@ -46,8 +46,7 @@ public class Exporter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Führt den Imput aus -> File holen, Daten in db erstellen
|
||||
* @throws IOException Fehler beim File öffnen
|
||||
* Führt den Imput aus: File holen, Daten in db erstellen
|
||||
*/
|
||||
public void doImport() {
|
||||
ProgressBar progressBar = new ProgressBar("Import...");
|
||||
|
@ -35,7 +35,7 @@ public class FileHelper {
|
||||
* @param img Das zu speichernde Bild
|
||||
* @param type Dateityp z.b. jpg
|
||||
* @param file Wo die datei zu speichern ist
|
||||
* @throws IOException
|
||||
* @throws IOException Fehler beim speichern des Images
|
||||
*/
|
||||
public static void saveImage(Image img, String type, File file) throws IOException {
|
||||
ImageIO.write(ImgHelper.toBufferedImage(img), type, file);
|
||||
|
@ -38,6 +38,7 @@ public class TourPlaner{
|
||||
* @param oldname Alter Tourname
|
||||
* @param tour Neuer Tourname
|
||||
* @return false bei error
|
||||
* @throws IOException Fehler beim editieren der Tour
|
||||
*/
|
||||
public static boolean editTour(String oldname, Tour tour) throws IOException {
|
||||
ProgressBar progressBar = new ProgressBar("Edit...");
|
||||
@ -73,7 +74,9 @@ public class TourPlaner{
|
||||
/**
|
||||
* Fügt eine Tour hinzu
|
||||
* @param newTour Neue Tour
|
||||
* @param progressBar Aktuelle Progressbar
|
||||
* @return false bei error
|
||||
* @throws IOException Fehler beim hinzufügen der Tour
|
||||
*/
|
||||
public static boolean addTour(Tour newTour, ProgressBar progressBar) throws IOException {
|
||||
int step = progressBar.getProgressSize(2, 100);
|
||||
|
40
src/tourplaner/tests/EinheitenAdderTest.java
Normal file
40
src/tourplaner/tests/EinheitenAdderTest.java
Normal file
@ -0,0 +1,40 @@
|
||||
package tourplaner.tests;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import tourplaner.business.ConfigHelper;
|
||||
import tourplaner.business.EinheitenAdder;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class EinheitenAdderTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void addMeter() {
|
||||
assertEquals(EinheitenAdder.addMeter("1"), "1"+ " " + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "einheiten", "meter"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void addSpeed() {
|
||||
assertEquals(EinheitenAdder.addSpeed("1"), "1"+ " " + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "einheiten", "speed"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void addKm() {
|
||||
assertEquals(EinheitenAdder.addKm("1"), "1"+ " " + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "einheiten", "strecke"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void addMinuten() {
|
||||
assertEquals(EinheitenAdder.addMinuten("1"), "1"+ " " + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "einheiten", "zeit"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void addJson() {
|
||||
assertEquals(EinheitenAdder.addJson("1"), "1" + ".json");
|
||||
}
|
||||
}
|
73
src/tourplaner/tests/LogTest.java
Normal file
73
src/tourplaner/tests/LogTest.java
Normal file
@ -0,0 +1,73 @@
|
||||
package tourplaner.tests;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import tourplaner.object.Log;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
|
||||
class LogTest {
|
||||
|
||||
private Log log;
|
||||
private final LocalDate date = LocalDate.now();
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
this.log = new Log("1", 2, this.date, 3, "4", 5, 6, "7");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getRating() {
|
||||
assertEquals(this.log.getRating(), "7");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getBemerkung() {
|
||||
assertEquals(this.log.getBemerkung(), "4");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAvgspeed() {
|
||||
double act = -45;
|
||||
assertEquals(this.log.getAvgspeed(), act);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void getHightmeter() {
|
||||
assertEquals(this.log.getHightmeter(), 5);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getPause() {
|
||||
assertEquals(this.log.getPause(), 6);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getGegangen() {
|
||||
assertEquals(this.log.getGegangen(), 2-6);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getId() {
|
||||
assertEquals(this.log.getId(), "1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDauer() {
|
||||
assertEquals(this.log.getDauer(), 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDatum() {
|
||||
assertEquals(this.log.getDatum(), this.date);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getStrecke() {
|
||||
assertEquals(this.log.getStrecke(), 3);
|
||||
}
|
||||
}
|
76
src/tourplaner/tests/TourTest.java
Normal file
76
src/tourplaner/tests/TourTest.java
Normal file
@ -0,0 +1,76 @@
|
||||
package tourplaner.tests;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import tourplaner.object.Log;
|
||||
import tourplaner.object.Tour;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class TourTest {
|
||||
|
||||
private Log log1, log2, log3;
|
||||
private Tour tour;
|
||||
private final LocalDate date = LocalDate.now();
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
this.tour = new Tour("String name", "String dauer", "String mapJson", 2, "String start", "String ziel");
|
||||
this.log1 = new Log("1", 2, this.date, 3, "4", 5, 6, "7");;
|
||||
this.log2 = new Log("2", 2, this.date, 3, "4", 5, 6, "7");;
|
||||
this.log3 = new Log("3", 2, this.date, 3, "4", 5, 6, "7");;
|
||||
}
|
||||
|
||||
@Test
|
||||
void setGetLogs() {
|
||||
ArrayList<Log> logs = new ArrayList<>();
|
||||
logs.add(log1);
|
||||
logs.add(log2);
|
||||
logs.add(log3);
|
||||
|
||||
tour.setLog(logs);
|
||||
assertEquals(this.tour.getLogs(), logs);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void addLog() {
|
||||
this.tour.addLog(this.log1);
|
||||
assertEquals(this.tour.getLog("1"), this.log1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void delLog() {
|
||||
this.tour.addLog(this.log1);
|
||||
this.tour.delLog("1");
|
||||
assertEquals(this.tour.getLogs(), new ArrayList<>());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDauer() {
|
||||
assertEquals(this.tour.getDauer(), "String dauer");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getStrecke() {
|
||||
assertEquals(this.tour.getStrecke(), 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getName() {
|
||||
assertEquals(this.tour.getName(), "String name");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getStart() {
|
||||
assertEquals(this.tour.getStart(), "String start");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getZiel() {
|
||||
assertEquals(this.tour.getZiel(), "String ziel");
|
||||
}
|
||||
}
|
@ -119,6 +119,7 @@ public class AlertHelper {
|
||||
* @param title Title des Dialogs
|
||||
* @param header Header des Dialogs
|
||||
* @param msg Nachricht des Dialogs
|
||||
* @param content Inhalt des Input Felds
|
||||
* @return Null bei keiner eingabe
|
||||
*/
|
||||
public static String inputText(String title, String header, String msg, String content){
|
||||
@ -131,6 +132,7 @@ public class AlertHelper {
|
||||
* @param header Header des Dialogs
|
||||
* @param msg Nachricht des Dialogs
|
||||
* @param notNull true wenn der input nicht leer sein darf
|
||||
* @param content Inhalt des Input Felds
|
||||
* @return Null bei keiner eingabe
|
||||
*/
|
||||
public static String inputTextNotNull(String title, String header, String msg, String content, boolean notNull) {
|
||||
@ -177,10 +179,11 @@ public class AlertHelper {
|
||||
|
||||
|
||||
/**
|
||||
* Positive Nummer eingabe. Wenn Convertierung zu int nicht klappt -> -1
|
||||
* Positive Nummer eingabe. Wenn Convertierung zu int nicht klappt, dann -1
|
||||
* @param title Title des Dialogs
|
||||
* @param header Header des Dialogs
|
||||
* @param msg Nachricht des Dialogs
|
||||
* @param content Inhalt des Input Felds
|
||||
* @return -1.0 bei error sonst ein double
|
||||
*/
|
||||
public static double inputNumber(String title, String header, String msg, String content) {
|
||||
|
@ -237,8 +237,8 @@ public class TourplanerController implements Initializable {
|
||||
|
||||
/**
|
||||
* Wird beim Start ausgeführt
|
||||
* @param url
|
||||
* @param resourceBundle
|
||||
* @param url Url
|
||||
* @param resourceBundle Resource Bundle
|
||||
*/
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
|
@ -39,6 +39,7 @@ public class ViewModel {
|
||||
/**
|
||||
* Bearbeitet eine bereits bestehende Tour
|
||||
* prüft ob eine tour ausgewählt ist
|
||||
* @throws IOException Fehler beim editieren der Tour
|
||||
*/
|
||||
public void editTour() throws IOException {
|
||||
if (this.selectedTour == null){
|
||||
@ -152,6 +153,7 @@ public class ViewModel {
|
||||
|
||||
/**
|
||||
* Fügt eine neue Tour hinzu
|
||||
* @return false bei error
|
||||
*/
|
||||
public boolean addTour(){
|
||||
if(tourNameInput()) {
|
||||
|
Reference in New Issue
Block a user