diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b16933a668740d3045fad16ffe6661c15b2f08c4..5b21c0fef3af33baefb95dc0ddfb3330228c2ad8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,8 @@ image: openjdk:12-alpine before_script: - - export GRADLE_USER_HOME=`pwd`/.gradle - - chmod +x ./gradlew + - export GRADLE_USER_HOME=`pwd`/.gradle + - chmod +x ./gradlew stages: @@ -21,7 +21,7 @@ checkstyle_main: - cp build/reports/checkstyle/main.html ./checkstyleMain.html artifacts: paths: - - checkstyleMain.html + - checkstyleMain.html expire_in: 1 week checkstyle_test: @@ -31,7 +31,7 @@ checkstyle_test: - cp build/reports/checkstyle/test.html ./checkstyleTest.html artifacts: paths: - - checkstyleTest.html + - checkstyleTest.html expire_in: 1 week spotbugs_main: @@ -41,7 +41,7 @@ spotbugs_main: - cp build/reports/spotbugs/main.html ./spotbugsMain.html artifacts: paths: - - spotbugsMain.html + - spotbugsMain.html expire_in: 1 week spotbugs_test: @@ -51,5 +51,5 @@ spotbugs_test: - cp build/reports/spotbugs/test.html ./spotbugsTest.html artifacts: paths: - - spotbugsTest.html + - spotbugsTest.html expire_in: 1 week diff --git a/src/main/java/de/hda/fbi/db2/api/Lab01Data.java b/src/main/java/de/hda/fbi/db2/api/Lab01Data.java index 3673c617dbcf825f3cdf07d1a5e323877b4941bf..4893b5f32f6daf9cbfd39f5bbfc3a1c9b092bffa 100644 --- a/src/main/java/de/hda/fbi/db2/api/Lab01Data.java +++ b/src/main/java/de/hda/fbi/db2/api/Lab01Data.java @@ -3,32 +3,31 @@ package de.hda.fbi.db2.api; import java.util.List; /** - * API Class for lab01 - * Created by l.koehler on 05.08.2019. + * API Class for lab01 Created by l.koehler on 05.08.2019. */ public abstract class Lab01Data { - public void init() { - } + public void init() { + } - /** - * Return all questions. - * - * @return questions - */ - public abstract List<?> getQuestions(); + /** + * Return all questions. + * + * @return questions + */ + public abstract List<?> getQuestions(); - /** - * Return all categories. - * - * @return categories - */ - public abstract List<?> getCategories(); + /** + * Return all categories. + * + * @return categories + */ + public abstract List<?> getCategories(); - /** - * Save the csv data in appropriate objects. - * - * @param additionalCsvLines is the csv data - */ - public abstract void loadCsvFile(List<String[]> additionalCsvLines); + /** + * Save the csv data in appropriate objects. + * + * @param additionalCsvLines is the csv data + */ + public abstract void loadCsvFile(List<String[]> additionalCsvLines); } diff --git a/src/main/java/de/hda/fbi/db2/api/Lab02EntityManager.java b/src/main/java/de/hda/fbi/db2/api/Lab02EntityManager.java index 987ba2049516227bedb74445b9e63ce03f1bcbe6..990b54a68ce0292cd4051435c207eae3b4a004eb 100644 --- a/src/main/java/de/hda/fbi/db2/api/Lab02EntityManager.java +++ b/src/main/java/de/hda/fbi/db2/api/Lab02EntityManager.java @@ -3,36 +3,36 @@ package de.hda.fbi.db2.api; import javax.persistence.EntityManager; /** - * API Class for lab02 - * Created by l.koehler on 05.08.2019. + * API Class for lab02 Created by l.koehler on 05.08.2019. */ public abstract class Lab02EntityManager { - public void init() {} + public void init() { + } - /** - * You can use the data from lab01, this variable will be automatically set. - */ - protected Lab01Data lab01Data; + /** + * You can use the data from lab01, this variable will be automatically set. + */ + protected Lab01Data lab01Data; - /** - * Setter for Lab01Data; Don't overwrite, you will break the automation! - * - * @param lab01Data lab01Data - */ - public void setLab01Data(Lab01Data lab01Data) { - this.lab01Data = lab01Data; - } + /** + * Setter for Lab01Data; Don't overwrite, you will break the automation. + * + * @param lab01Data lab01Data + */ + public void setLab01Data(Lab01Data lab01Data) { + this.lab01Data = lab01Data; + } - /** - * There you have to persist the data in the database. - */ - public abstract void persistData(); + /** + * There you have to persist the data in the database. + */ + public abstract void persistData(); - /** - * Return a valid EntityManager. - * - * @return EntityManager - */ - public abstract EntityManager getEntityManager(); + /** + * Return a valid EntityManager. + * + * @return EntityManager + */ + public abstract EntityManager getEntityManager(); } diff --git a/src/main/java/de/hda/fbi/db2/api/Lab03Game.java b/src/main/java/de/hda/fbi/db2/api/Lab03Game.java index 8403ebb48d69b910c2b24ee6a9ca7738f7c9d130..f0431295bd08b16ac50a2d7682ca63f9fb173189 100644 --- a/src/main/java/de/hda/fbi/db2/api/Lab03Game.java +++ b/src/main/java/de/hda/fbi/db2/api/Lab03Game.java @@ -3,107 +3,105 @@ package de.hda.fbi.db2.api; import java.util.List; /** - * API Class for lab03 - * Created by l.koehler on 05.08.2019. + * API Class for lab03 Created by l.koehler on 05.08.2019. */ public abstract class Lab03Game { - public void init() {} + public void init() { + } - /** - * You can use the data from lab01, this variable will be automatically set. - */ - protected Lab01Data lab01Data; + /** + * You can use the data from lab01, this variable will be automatically set. + */ + protected Lab01Data lab01Data; - /** - * You can use the EntityManager or other stuff from lab02, - * this variable will be automatically set. - */ - protected Lab02EntityManager lab02EntityManager; + /** + * You can use the EntityManager or other stuff from lab02, this variable will be automatically + * set. + */ + protected Lab02EntityManager lab02EntityManager; - /** - * Setter for Lab01Data. - * - * @param lab01Data lab01Data - */ - public void setLab01Data(Lab01Data lab01Data) { - this.lab01Data = lab01Data; - } + /** + * Setter for Lab01Data. + * + * @param lab01Data lab01Data + */ + public void setLab01Data(Lab01Data lab01Data) { + this.lab01Data = lab01Data; + } - /** - * Setter fro Lab02EntityManager. - * - * @param lab02EntityManager lab02EntityManager - */ - public void setLab02EntityManager(Lab02EntityManager lab02EntityManager) { - this.lab02EntityManager = lab02EntityManager; - } + /** + * Setter fro Lab02EntityManager. + * + * @param lab02EntityManager lab02EntityManager + */ + public void setLab02EntityManager(Lab02EntityManager lab02EntityManager) { + this.lab02EntityManager = lab02EntityManager; + } - /** - * This method should create a game. For this you have to do the following things: - * - Ask for player - * - Ask for categories - * - Ask for maximum questions per category and choose questions - * <p> - * You do not have to play the game here. This should only create a game - * - * @return the game entity object. IMPORTANT: This has to be a entity. - */ - public abstract Object createGame(); + /** + * This method should create a game. For this you have to do the following things: - Ask for + * player - Ask for categories - Ask for maximum questions per category and choose questions + * + * <p>You do not have to play the game here. This should only create a game + * + * @return the game entity object. IMPORTANT: This has to be a entity. + */ + public abstract Object createGame(); - /** - * Here you have to play the game 'game'. - * - * @param game the game that should be played - */ - public abstract void playGame(Object game); + /** + * This should create a game with the given arguments. You do not have to read data from console. + * The game should be create only with the given arguments. You do not have to play the game + * here. + * + * @param playerName name of the player + * @param questions chosen questions + * @return a game object + */ + public abstract Object createGame(String playerName, List<Object> questions); - /** - * This should create a game with the given arguments. - * You do not have to read data from console. - * The game should be create only with the given arguments. - * You do not have to play the game here. - * - * @param playerName name of the player - * @param questions chosen questions - * @return a game object - */ - public abstract Object createGame(String playerName, List<Object> questions); + /** + * Here you have to play the game 'game'. + * + * @param game the game that should be played + */ + public abstract void playGame(Object game); - /** - * Simulate a game play. You do not have to read anything from console. - * - * @param game given game - */ - public abstract void simulateGame(Object game); + /** + * Simulate a game play. You do not have to read anything from console. + * + * @param game given game + */ + public abstract void simulateGame(Object game); - /** - * This should return the appropriate player for the given game. - * - * @param game given game for returning player - * @return player for given game - */ - public abstract Object getPlayer(Object game); + /** + * This should return the appropriate player for the given game. + * + * @param game given game for returning player + * @return player for given game + */ + public abstract Object getPlayer(Object game); - /** - * Return the player entity with given name. - * - * @param name name of the player - * @return the player entity - */ - public abstract Object getPlayer(String name); + /** + * Return the player entity with given name. + * + * @param name name of the player + * @return the player entity + */ + public abstract Object getPlayer(String name); - /** - * return the right answers of a played game. - * - * @param game given game - * @return number of right answers - */ - public abstract int getRightAnswers(Object game); + /** + * return the right answers of a played game. + * + * @param game given game + * @return number of right answers + */ + public abstract int getRightAnswers(Object game); - /** - * persist the game object in the database. - * @param game given game - */ - public abstract void persistGame(Object game); + /** + * persist the game object in the database. + * + * @param game given game + */ + public abstract void persistGame(Object game); } diff --git a/src/main/java/de/hda/fbi/db2/api/Lab04MassData.java b/src/main/java/de/hda/fbi/db2/api/Lab04MassData.java index 12a6c683c0be7b7993702d131835f53bc0a04a4b..7ec83528b7a2ff0e2265b111e6da714d4682d416 100644 --- a/src/main/java/de/hda/fbi/db2/api/Lab04MassData.java +++ b/src/main/java/de/hda/fbi/db2/api/Lab04MassData.java @@ -1,54 +1,55 @@ package de.hda.fbi.db2.api; /** - * + * Api for MassData. */ public abstract class Lab04MassData { - public void init() {} - - /** - * You can use the data from lab01, this variable will be automatically set. - */ - protected Lab01Data lab01Data; - - /** - * You can use the EntityManager or other stuff from lab02, - * this variable will be automatically set. - */ - protected Lab02EntityManager lab02EntityManager; - - /** - * You can use the Lab03Game, this variable will be automatically set. - */ - protected Lab03Game lab03Game; - - /** - * Setter for Lab01Data. - * - * @param lab01Data lab01Data - */ - public void setLab01Data(Lab01Data lab01Data) { - this.lab01Data = lab01Data; - } - - /** - * Setter fro Lab02EntityManager. - * - * @param lab02EntityManager lab02EntityManager - */ - public void setLab02EntityManager(Lab02EntityManager lab02EntityManager) { - this.lab02EntityManager = lab02EntityManager; - } - - /** - * Setter fro lab03Game. - * - * @param lab03Game lab03Game - */ - public void setLab03Game(Lab03Game lab03Game) { - this.lab03Game = lab03Game; - } - - public abstract void createMassData(); + public void init() { + } + + /** + * You can use the data from lab01, this variable will be automatically set. + */ + protected Lab01Data lab01Data; + + /** + * You can use the EntityManager or other stuff from lab02, this variable will be automatically + * set. + */ + protected Lab02EntityManager lab02EntityManager; + + /** + * You can use the Lab03Game, this variable will be automatically set. + */ + protected Lab03Game lab03Game; + + /** + * Setter for Lab01Data. + * + * @param lab01Data lab01Data + */ + public void setLab01Data(Lab01Data lab01Data) { + this.lab01Data = lab01Data; + } + + /** + * Setter fro Lab02EntityManager. + * + * @param lab02EntityManager lab02EntityManager + */ + public void setLab02EntityManager(Lab02EntityManager lab02EntityManager) { + this.lab02EntityManager = lab02EntityManager; + } + + /** + * Setter fro lab03Game. + * + * @param lab03Game lab03Game + */ + public void setLab03Game(Lab03Game lab03Game) { + this.lab03Game = lab03Game; + } + + public abstract void createMassData(); } diff --git a/src/main/java/de/hda/fbi/db2/controller/Controller.java b/src/main/java/de/hda/fbi/db2/controller/Controller.java index e72fe7281594d9b9c64d41079893a426aaec956f..a10654d1edb1eee911083b36169e59c7b67fd0c1 100644 --- a/src/main/java/de/hda/fbi/db2/controller/Controller.java +++ b/src/main/java/de/hda/fbi/db2/controller/Controller.java @@ -1,5 +1,9 @@ package de.hda.fbi.db2.controller; +import de.hda.fbi.db2.api.Lab01Data; +import de.hda.fbi.db2.api.Lab02EntityManager; +import de.hda.fbi.db2.api.Lab03Game; +import de.hda.fbi.db2.api.Lab04MassData; import java.io.File; import java.io.IOException; import java.net.URISyntaxException; @@ -7,10 +11,6 @@ import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; -import de.hda.fbi.db2.api.Lab01Data; -import de.hda.fbi.db2.api.Lab02EntityManager; -import de.hda.fbi.db2.api.Lab03Game; -import de.hda.fbi.db2.api.Lab04MassData; /** * Controller Created by l.koehler on 05.08.2019. @@ -19,6 +19,11 @@ public class Controller { private static Controller controller; + /** + * Singleton Pattern. + * + * @return a singleton Pattern instance + */ public static synchronized Controller getInstance() { if (controller == null) { controller = new Controller(); @@ -46,6 +51,7 @@ public class Controller { findImplementations(); } + @SuppressWarnings("deprecation") private void findImplementations() { try { Enumeration<URL> elements = Thread.currentThread().getContextClassLoader() @@ -123,6 +129,9 @@ public class Controller { return classes; } + /** + * reads the csv data. + */ public void readCsv() { if (lab01Data == null) { System.err.println("Could not find Lab01Data Implementation"); @@ -156,6 +165,9 @@ public class Controller { return lab04MassData; } + /** + * starts the main menu. + */ public void startMenu() { if (lab01Data == null) { System.err.println("Could not find Lab01Data Implementation"); @@ -178,6 +190,9 @@ public class Controller { menuController.showMenu(); } + /** + * persist data. + */ public void persistData() { if (lab01Data == null) { System.err.println("Could not find Lab01Data Implementation"); @@ -192,8 +207,7 @@ public class Controller { String schemaGeneration = (String) lab02EntityManager.getEntityManager().getProperties() .get("javax.persistence.schema-generation.database.action"); - if (schemaGeneration.equals("drop-and-create") || - schemaGeneration.equals("create")) { + if (schemaGeneration.equals("drop-and-create") || schemaGeneration.equals("create")) { lab02EntityManager.persistData(); } isPersisted = true; @@ -207,6 +221,9 @@ public class Controller { return isPersisted; } + /** + * creates massdata. + */ public void createMassData() { if (lab01Data == null) { System.err.println("Could not find Lab01Data Implementation"); diff --git a/src/main/java/de/hda/fbi/db2/controller/CsvDataReader.java b/src/main/java/de/hda/fbi/db2/controller/CsvDataReader.java index 7799e30d704e38d133d38bcdcb5ab66164e1aae9..e41ec7163b8e1836fac043fc7c1ff30fe6528675 100644 --- a/src/main/java/de/hda/fbi/db2/controller/CsvDataReader.java +++ b/src/main/java/de/hda/fbi/db2/controller/CsvDataReader.java @@ -16,86 +16,91 @@ import java.util.stream.Collectors; * Created by a.hofmann on 03.10.2016. */ public class CsvDataReader { - private static final String SPLIT_CHARACTER = ";"; - private static final Logger log = Logger.getLogger(CsvDataReader.class.getName()); - - private CsvDataReader() {} - /** - * Lists all available csv files in the resource folder. - * <strong>WARNING:</strong> May won't work on your machine - * @return list of csv filenames - * @throws IOException - * @throws URISyntaxException - */ - public static List<String> getAvailableFiles() throws IOException, URISyntaxException { - final Enumeration<URL> en = CsvDataReader.class.getClassLoader().getResources(""); - en.nextElement(); - File hackyFile = new File(en.nextElement().toURI()); - File[] filenames = hackyFile.listFiles(); - - List<String> fileList; - - if (filenames == null) { - fileList = new ArrayList<>(); - } else { - - fileList = Arrays.stream(filenames) - .filter(File::isFile) - .filter(file -> file.getName().endsWith(".csv")) - .map(File::getName) - .collect(Collectors.toList()); - } - - return fileList; + private static final String SPLIT_CHARACTER = ";"; + private static final Logger log = Logger.getLogger(CsvDataReader.class.getName()); + + private CsvDataReader() { + } + + /** + * Lists all available csv files in the resource folder. + * <strong>WARNING:</strong> May won't work on your machine + * + * @return list of csv filenames + * @throws IOException ioException + * @throws URISyntaxException uriSyntaxException + */ + public static List<String> getAvailableFiles() throws IOException, URISyntaxException { + final Enumeration<URL> en = CsvDataReader.class.getClassLoader().getResources(""); + en.nextElement(); + File hackyFile = new File(en.nextElement().toURI()); + File[] filenames = hackyFile.listFiles(); + + List<String> fileList; + + if (filenames == null) { + fileList = new ArrayList<>(); + } else { + + fileList = Arrays.stream(filenames) + .filter(File::isFile) + .filter(file -> file.getName().endsWith(".csv")) + .map(File::getName) + .collect(Collectors.toList()); } - - /** - * Reads the given embedded file and returns its content in an accessible form. - * @param otherFile filename of csv file in resource folder - * @return content of the related file as a list of split strings including - * the CSV-header at first position. - * @throws URISyntaxException - * @throws IOException - */ - public static List<String[]> read(String otherFile) throws IOException, URISyntaxException { - try { - if (!getAvailableFiles().contains(otherFile)){ - throw new IOException("File not found in Resources."); - } - } catch (IOException ioe){ - throw ioe; - } catch (Exception e){ - log.warning("CsvDataReader.getAvailableFiles() threw a exception." - + " Skipping file verification."); - } - final URL resource = CsvDataReader.class.getResource("/" + otherFile); - if (resource == null) { - throw new IllegalStateException("Unable to find the csv file."); - } - return readFile(new File(resource.toURI())); + + return fileList; + } + + /** + * Reads the given embedded file and returns its content in an accessible form. + * + * @param otherFile filename of csv file in resource folder + * @return content of the related file as a list of split strings including the CSV-header at + * first position. + * @throws URISyntaxException uRISyntaxException + * @throws IOException iOException + */ + public static List<String[]> read(String otherFile) throws IOException, URISyntaxException { + try { + if (!getAvailableFiles().contains(otherFile)) { + throw new IOException("File not found in Resources."); + } + } catch (IOException ioe) { + throw ioe; + } catch (Exception e) { + log.warning("CsvDataReader.getAvailableFiles() threw a exception." + + " Skipping file verification."); } - - /** - * Reads the embedded <code>Wissenstest_sample200.csv</code> file and - * returns its content in an accessible form. - * @return content of the related file as a list of split strings including - * the CSV-header at first position. - * @throws URISyntaxException - * @throws IOException - */ - public static List<String[]> read() throws URISyntaxException, IOException { - final URL resource = CsvDataReader.class.getResource("/Wissenstest_sample200.csv"); - if (resource == null) { - throw new IllegalStateException("Unable to find the csv file."); - } - return readFile(new File(resource.toURI())); + final URL resource = CsvDataReader.class.getResource("/" + otherFile); + if (resource == null) { + throw new IllegalStateException("Unable to find the csv file."); } + return readFile(new File(resource.toURI())); + } - private static List<String[]> readFile(File file) throws IOException { - final List<String> lines = Files.readAllLines(file.toPath()); - return lines.stream() - .map((line) -> line.split(SPLIT_CHARACTER)) - .collect(Collectors.toList()); + /** + * Reads the embedded <code>Wissenstest_sample200.csv</code> file and returns its content in an + * accessible form. + * + * @return content of the related file as a list of split strings including the CSV-header at + * first position. + * @throws URISyntaxException uRISyntaxException + * @throws IOException iOException + */ + public static List<String[]> read() throws URISyntaxException, IOException { + final URL resource = CsvDataReader.class.getResource("/Wissenstest_sample200.csv"); + if (resource == null) { + throw new IllegalStateException("Unable to find the csv file."); } + return readFile(new File(resource.toURI())); + } + + private static List<String[]> readFile(File file) throws IOException { + final List<String> lines = Files.readAllLines(file.toPath()); + return lines.stream() + .map((line) -> line.split(SPLIT_CHARACTER)) + .collect(Collectors.toList()); + } } diff --git a/src/main/java/de/hda/fbi/db2/controller/MenuController.java b/src/main/java/de/hda/fbi/db2/controller/MenuController.java index 897f4f1e231616a9fb3d97ac08c99fe9b6f2aa6c..cbfdf84866882098477eaedca9385194b0e9f802 100644 --- a/src/main/java/de/hda/fbi/db2/controller/MenuController.java +++ b/src/main/java/de/hda/fbi/db2/controller/MenuController.java @@ -1,85 +1,87 @@ package de.hda.fbi.db2.controller; +import de.hda.fbi.db2.api.Lab03Game; import java.io.BufferedReader; import java.io.InputStreamReader; -import de.hda.fbi.db2.api.Lab03Game; import java.nio.charset.StandardCharsets; /** - * MenuController - * Created by l.koehler on 05.08.2019. + * MenuController Created by l.koehler on 05.08.2019. */ public class MenuController { - private Controller controller; + private Controller controller; - public MenuController(Controller controller) { - this.controller = controller; - } + public MenuController(Controller controller) { + this.controller = controller; + } - public void showMenu() { - do { - System.out.println("Choose your Destiny?"); - System.out.println("--------------------------------------"); - System.out.println("1: Re-read csv"); - System.out.println("2: Play test"); - System.out.println("3: Create mass data"); - System.out.println("4: Analyze data"); - System.out.println("0: Quit"); - } while (readInput()); - } + /** + * shows the menu. + */ + public void showMenu() { + do { + System.out.println("Choose your Destiny?"); + System.out.println("--------------------------------------"); + System.out.println("1: Re-read csv"); + System.out.println("2: Play test"); + System.out.println("3: Create mass data"); + System.out.println("4: Analyze data"); + System.out.println("0: Quit"); + } while (readInput()); + } - private boolean readInput() { - try { - BufferedReader reader = - new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); - String input = reader.readLine(); - if (input == null) { - return true; - } - switch (input) { - case "0": - return false; - case "1": - readCsv(); - break; - case "2": - playTest(); - break; - case "3": - createMassData(); - break; - case "4": - analyzeData(); - break; - default: - System.out.println("Input Error"); - break; - } + private boolean readInput() { + try { + BufferedReader reader = + new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); + String input = reader.readLine(); + if (input == null) { + return true; + } + switch (input) { + case "0": + return false; + case "1": + readCsv(); + break; + case "2": + playTest(); + break; + case "3": + createMassData(); + break; + case "4": + analyzeData(); + break; + default: + System.out.println("Input Error"); + break; + } - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; } + } - private void analyzeData() { + private void analyzeData() { - } + } - private void createMassData() { - controller.createMassData(); - } + private void createMassData() { + controller.createMassData(); + } - private void playTest() { - Lab03Game gameController = controller.getLab03Game(); - Object game = gameController.createGame(); - gameController.playGame(game); - gameController.persistGame(game); - } + private void playTest() { + Lab03Game gameController = controller.getLab03Game(); + Object game = gameController.createGame(); + gameController.playGame(game); + gameController.persistGame(game); + } - private void readCsv() { - controller.readCsv(); - } + private void readCsv() { + controller.readCsv(); + } } diff --git a/src/test/java/de/hda/fbi/db2/test/Lab01Test.java b/src/test/java/de/hda/fbi/db2/test/Lab01Test.java index 796aa6da07b6bd6136a709c36229cc167421336b..0a9b63213d9b5de45891fa435bdd126de32c6471 100644 --- a/src/test/java/de/hda/fbi/db2/test/Lab01Test.java +++ b/src/test/java/de/hda/fbi/db2/test/Lab01Test.java @@ -2,12 +2,12 @@ package de.hda.fbi.db2.test; import static org.junit.Assert.assertEquals; +import de.hda.fbi.db2.controller.Controller; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; -import de.hda.fbi.db2.controller.Controller; /** * Created by l.koehler on 05.08.2019. @@ -17,6 +17,9 @@ public class Lab01Test { private static Controller controller; + /** + * Lab01Test init. + */ @BeforeClass public static void init() { controller = Controller.getInstance(); diff --git a/src/test/java/de/hda/fbi/db2/test/Lab02Test.java b/src/test/java/de/hda/fbi/db2/test/Lab02Test.java index 1ae4851819b22112e2e884a174d66b48a00b77f4..ae702933c1a697ed6667ace6206d02d0cad119ff 100644 --- a/src/test/java/de/hda/fbi/db2/test/Lab02Test.java +++ b/src/test/java/de/hda/fbi/db2/test/Lab02Test.java @@ -52,6 +52,9 @@ public class Lab02Test { Lab02Test.answerEntity = answerEntity; } + /** + * Lab02Test init. + */ @BeforeClass public static void init() { controller = Controller.getInstance(); @@ -181,7 +184,7 @@ public class Lab02Test { return; } } catch (Exception ignored) { - + //This is expected } } @@ -315,6 +318,7 @@ public class Lab02Test { } } } catch (Exception ignored) { + //This is expected } } Assert.fail("Could not find name in category"); diff --git a/src/test/java/de/hda/fbi/db2/test/Lab03Test.java b/src/test/java/de/hda/fbi/db2/test/Lab03Test.java index 7c75bebdb649e0ddb033b30dc2b77ed1dfa1ffa8..e39abc64248414a563d3c2218c0f28524289f02f 100644 --- a/src/test/java/de/hda/fbi/db2/test/Lab03Test.java +++ b/src/test/java/de/hda/fbi/db2/test/Lab03Test.java @@ -1,5 +1,8 @@ package de.hda.fbi.db2.test; +import de.hda.fbi.db2.api.Lab01Data; +import de.hda.fbi.db2.api.Lab03Game; +import de.hda.fbi.db2.controller.Controller; import java.util.ArrayList; import java.util.List; import javax.persistence.metamodel.Attribute; @@ -14,9 +17,6 @@ import org.junit.BeforeClass; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; -import de.hda.fbi.db2.api.Lab01Data; -import de.hda.fbi.db2.api.Lab03Game; -import de.hda.fbi.db2.controller.Controller; /** * Created by l.koehler on 05.08.2019. @@ -34,6 +34,9 @@ public class Lab03Test { Lab03Test.gameEntity = gameEntity; } + /** + * Lab03Test init. + */ @BeforeClass public static void init() { controller = Controller.getInstance(); @@ -164,8 +167,8 @@ public class Lab03Test { } for (EmbeddableType embeddable : metaData.getEmbeddables()) { - if (embeddable.getJavaType().getSimpleName().toLowerCase().equals("answer") || - embeddable.getJavaType().getSimpleName().toLowerCase().equals("answers")) { + if (embeddable.getJavaType().getSimpleName().toLowerCase().equals("answer") + || embeddable.getJavaType().getSimpleName().toLowerCase().equals("answers")) { answerEntity = embeddable; } } @@ -185,6 +188,7 @@ public class Lab03Test { correct = true; } } catch (Exception ignored) { + //This is expected } }