diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..7dffa91
Binary files /dev/null and b/.DS_Store differ
diff --git a/.idea/.gitignore b/.idea/.gitignore
index 02565d0..b64434e 100644
--- a/.idea/.gitignore
+++ b/.idea/.gitignore
@@ -6,7 +6,9 @@
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
+/target
target/
+target
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
@@ -15,10 +17,11 @@ release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
+# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
-.classpath
\ No newline at end of file
+.classpath
diff --git a/pom.xml b/pom.xml
index d3f05d5..1841d9b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,6 +50,12 @@
${mockito.version}
test
+
+ junit
+ junit
+ 4.8.2
+ test
+
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Account.java b/src/main/java/hs/fulda/de/ci/exam/project/Account.java
new file mode 100644
index 0000000..882db6a
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Account.java
@@ -0,0 +1,107 @@
+package hs.fulda.de.ci.exam.project;
+
+public class Account {
+ private AccountRepository accountRepository;
+
+ public Account(String id, String password, AccountStatus status) {
+ this.id = id;
+ this.password = password;
+ this.status = status;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public AccountStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(AccountStatus status) {
+ this.status = status;
+ }
+
+ public boolean isEnabled() {
+ if(status == AccountStatus.ACTIVE) return true;
+ return false;
+ }
+
+ public String getPasswordHash() {
+ return new PasswordEncoder().encode(password);
+ }
+
+ public enum AccountStatus {
+ ACTIVE,
+ CLOSED,
+ CANCELED,
+ BLACKLISTED,
+ BLOCKED
+ }
+
+ private String id;
+ private String password;
+ private AccountStatus status;
+
+ public boolean resetPassword(String new_password){
+ if(status == AccountStatus.ACTIVE){
+ this.password = new_password;
+ }
+ return false;
+ }
+
+ public void validatePersonDetails(Person person){
+ person.validateName();
+ person.validateAddress();
+ person.validateEmailAddress();
+ person.validatePhoneNumber();
+ }
+
+ public void addAccountDetails(String id, String name, Address address, String email, String phone){
+
+ Person person = new Person(name, address, email, phone);
+ validatePersonDetails(person);
+ accountRepository.addPersonalDetails(person, id);
+ }
+
+ public void validateId() {
+ if(this.id.isBlank())
+ throw new RuntimeException(("Id Cannot be null or empty"));
+ }
+
+ public void validatePassword(){
+ if(this.password.isBlank())
+ throw new RuntimeException(("Id Cannot be null or empty"));
+ }
+
+ public void validateAccountStatus(){
+ if(this.status.equals(null))
+ throw new RuntimeException(("Id Cannot be null or empty"));
+ }
+
+}
+class PasswordEncoder{
+ String encode(String password){
+ int p = 31;
+ int m = (int) Math.pow(10, 9) + 9;
+ int hash_value = 0;
+ int p_pow = 1;
+ for (char c : password.toCharArray()) {
+ hash_value = (hash_value + (c - 'a' + 1) * p_pow) % m;
+ p_pow = (p_pow * p) % m;
+ }
+ return Integer.toString(hash_value);
+ }
+}
+
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/AccountRepository.java b/src/main/java/hs/fulda/de/ci/exam/project/AccountRepository.java
new file mode 100644
index 0000000..6cec755
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/AccountRepository.java
@@ -0,0 +1,39 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class AccountRepository {
+ Map accountList = new ConcurrentHashMap();
+ Map personalInfo = new ConcurrentHashMap<>();
+
+ public boolean checkIfAccountAlreadyExist(Account account){
+ if(accountList.containsKey(generateKey(account))){
+ return true;
+ }
+ return false;
+ }
+ Account findById(String id){
+ Account account = accountList.get(id);
+ return account;
+ }
+
+ private String generateKey(Account account) {
+ return String.format("%s", account.getId());
+ }
+ public Collection findAll() {
+ return accountList.values();
+ }
+ public boolean save(Account account){
+ accountList.put(generateKey(account), account);
+ return true;
+ }
+ public void addPersonalDetails(Person person, String id){
+ personalInfo.put(accountList.get(id), person);
+ }
+
+ public void delete(Account account) {
+ accountList.remove(generateKey(account));
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/AccountService.java b/src/main/java/hs/fulda/de/ci/exam/project/AccountService.java
new file mode 100644
index 0000000..814d4c2
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/AccountService.java
@@ -0,0 +1,46 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.Date;
+
+public class AccountService {
+ private final AccountRepository accountRepository;
+ private final PasswordEncoder passwordEncoder;
+
+ public AccountService(AccountRepository accountRepository, PasswordEncoder passwordEncoder) {
+ this.accountRepository = accountRepository;
+ this.passwordEncoder = passwordEncoder;
+ }
+ public boolean isValidAccount(String id, String password){
+ Account account = accountRepository.findById(id);
+ return isEnabledAccount(account) && isValidPassword(account, password);
+ }
+
+ private boolean isEnabledAccount(Account account) {
+ return account!= null && account.isEnabled();
+ }
+
+ private boolean isValidPassword(Account account, String password) {
+ String encodedPassword = passwordEncoder.encode(password);
+ return encodedPassword.equals(account.getPasswordHash());
+ }
+ public void validateAccount(Account account){
+ account.validateAccountStatus();
+ account.validateId();
+ account.validatePassword();
+ }
+
+ public void checkIfAccountAlreadyExist(Account account){
+ if(accountRepository.checkIfAccountAlreadyExist(account)){
+ throw new RuntimeException("Account Already Exists");
+ }
+ }
+ public boolean createAccount(String id, String password, Account.AccountStatus accountStatus){
+ Account account = new Account(id, password, accountStatus);
+ validateAccount(account);
+ checkIfAccountAlreadyExist(account);
+ accountRepository.save(account);
+ return true;
+ }
+
+
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Address.java b/src/main/java/hs/fulda/de/ci/exam/project/Address.java
new file mode 100644
index 0000000..56f5d4d
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Address.java
@@ -0,0 +1,22 @@
+package hs.fulda.de.ci.exam.project;
+
+public class Address {
+ String streetAddress;
+ String city;
+ String state;
+ String zipCode;
+ String country;
+
+ public Address(String streetAddress, String city, String state, String zipCode, String country) {
+ this.streetAddress = streetAddress;
+ this.city = city;
+ this.state = state;
+ this.zipCode = zipCode;
+ this.country = country;
+ }
+
+ @Override
+ public String toString() {
+ return streetAddress + ", " + city + ", " + state + ", " + zipCode + ", " + country;
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Admin.java b/src/main/java/hs/fulda/de/ci/exam/project/Admin.java
new file mode 100644
index 0000000..236cd83
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Admin.java
@@ -0,0 +1,48 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.io.IOException;
+
+public class Admin extends Person{
+
+ AccountRepository accountRepository;
+ FlightRepository flightRepository;
+ AircraftRepository aircraftRepository;
+ public Admin(String name, Address address, String email, String phone) {
+ super(name, address, email, phone);
+ }
+
+ public Aircraft addAircraft(String name, String model, int manufacturerYear) throws IOException {
+ if(name.isBlank()) throw new RuntimeException("Name cannot be null or empty");
+ if(model.isBlank()) throw new RuntimeException("Model cannot be null or empty");
+ if(manufacturerYear < 0) throw new RuntimeException("Year cannot be zero");
+ Aircraft aircraft = new Aircraft(name, model, manufacturerYear);
+ aircraftRepository.save(aircraft);
+ return aircraft;
+ }
+
+ public String searchAircraft(String name){
+ String aircraftDetails = aircraftRepository.findAircraftByAircraftName(name);
+ if(aircraftDetails.isBlank()){
+ throw new RuntimeException("Aircraft does not exist.");
+ }
+ return aircraftDetails;
+ }
+
+ public Flight addFlight(String flightNumber, Airport departure, Airport arrival, int durationInMinutes ) throws IOException {
+ if(flightNumber.isBlank()) throw new RuntimeException("FlightNumber cannot be null or empty");
+ if(departure.equals(null)) throw new RuntimeException("Departure cannot be null or empty");
+ if(arrival.equals(null)) throw new RuntimeException("Arrival cannot be null or empty");
+ if(durationInMinutes < 0) throw new RuntimeException("Duration cannot be negative");
+ Flight flight = new Flight(flightNumber, departure, arrival, durationInMinutes );
+ flightRepository.save(flight);
+ return flight;
+ }
+
+ public boolean blockUser(Account user){
+ if(accountRepository.checkIfAccountAlreadyExist(user)){
+ user.setStatus(Account.AccountStatus.BLOCKED);
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Aircraft.java b/src/main/java/hs/fulda/de/ci/exam/project/Aircraft.java
new file mode 100644
index 0000000..64489d6
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Aircraft.java
@@ -0,0 +1,41 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.HashSet;
+
+public class Aircraft {
+ private String name;
+ private String model;
+ private int manYear;
+ private HashSet flights = new HashSet();
+
+ public Aircraft(String name, String model, int manufacturingYear) {
+ this.name = name;
+ this.model = model;
+ this.manYear = manufacturingYear;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getModel() {
+ return this.model;
+ }
+
+ public int getManYear() {
+ return this.manYear;
+ }
+
+ public HashSet getFlights() {
+ return this.flights;
+ }
+
+ public void addFlight(Flight flight) {
+ flights.add(flight);
+ }
+
+ @Override
+ public String toString() {
+ return "Aircraft = {" + "name=" + name + '\'' + ", model=" + model + ", manufacturingYear='" + manYear +'}';
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/AircraftRepository.java b/src/main/java/hs/fulda/de/ci/exam/project/AircraftRepository.java
new file mode 100644
index 0000000..29fec15
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/AircraftRepository.java
@@ -0,0 +1,31 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.io.*;
+import java.util.Scanner;
+
+public class AircraftRepository {
+
+ boolean save(Aircraft aircraft) throws IOException {
+ FileWriter fw = new FileWriter("aircraft_list.txt", true);
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write(aircraft.toString());
+ bw.newLine();
+ bw.close();
+ return true;
+ };
+ String findAircraftByAircraftName(String AircraftName){
+ File file = new File("aircraft_list.txt");
+ try {
+ Scanner scanner = new Scanner(file);
+ while (scanner.hasNextLine()) {
+ String line = scanner.nextLine();
+ if(line.matches("(.*)"+AircraftName+"(.*)")) {
+ return line;
+ }
+ }
+ } catch(FileNotFoundException e) {
+ System.out.println("There are no aircrafts added yet. Please add a aircraft first");
+ }
+ return "";
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Airline.java b/src/main/java/hs/fulda/de/ci/exam/project/Airline.java
new file mode 100644
index 0000000..1a85b40
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Airline.java
@@ -0,0 +1,39 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.HashSet;
+
+public class Airline {
+ private String name;
+ private String code;
+ private HashSet flights;
+
+ public Airline(String name, String code) {
+ this.name = name;
+ this.code = code;
+ this.flights = new HashSet<>();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public HashSet getFlights() {
+ return flights;
+ }
+
+ public void addFlight(Flight flight) {
+ flights.add(flight);
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Airport.java b/src/main/java/hs/fulda/de/ci/exam/project/Airport.java
new file mode 100644
index 0000000..5cf4bfd
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Airport.java
@@ -0,0 +1,42 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.HashSet;
+
+public class Airport {
+
+ protected String name;
+ public Address address;
+ protected String code;
+ public HashSet flights = new HashSet<>();
+
+ public Airport(String name, Address address, String code) {
+ this.name = name;
+ this.address = address;
+ this.code = code;
+ }
+
+ public Airport() {
+
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getCode() {
+ return this.code;
+ }
+
+ public Address getAddress() {
+ return this.address;
+ }
+
+ public HashSet getFlights() {
+ return this.flights;
+ }
+
+ @Override
+ public String toString() {
+ return "Airport{" + "name='" + name + '\'' + ", address=" + address + ", code='" + code + '\'' + '}';
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/BankTransaction.java b/src/main/java/hs/fulda/de/ci/exam/project/BankTransaction.java
new file mode 100644
index 0000000..26be339
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/BankTransaction.java
@@ -0,0 +1,36 @@
+package hs.fulda.de.ci.exam.project;
+
+public class BankTransaction extends Payment {
+ String bankName;
+ String iban;
+
+ public BankTransaction(int id, String amount, PaymentStatus status, String bankName, String iban) {
+ super(id, amount, status);
+ this.bankName = bankName;
+ this.iban = iban;
+ }
+
+ public String getBankName() {
+ return bankName;
+ }
+
+ public void setBankName(String bankName) {
+ this.bankName = bankName;
+ }
+
+ public String getIban() {
+ return iban;
+ }
+
+ public void setIban(String iban) {
+ this.iban = iban;
+ }
+
+ @Override
+ public boolean isValid() {
+ if (this.iban.length() != 22) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/CashTransaction.java b/src/main/java/hs/fulda/de/ci/exam/project/CashTransaction.java
new file mode 100644
index 0000000..7c17bde
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/CashTransaction.java
@@ -0,0 +1,12 @@
+package hs.fulda.de.ci.exam.project;
+
+public class CashTransaction extends Payment {
+ public CashTransaction(int id, String amount, PaymentStatus status) {
+ super(id, amount, status);
+ }
+
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/CreditCardTransaction.java b/src/main/java/hs/fulda/de/ci/exam/project/CreditCardTransaction.java
new file mode 100644
index 0000000..742bda6
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/CreditCardTransaction.java
@@ -0,0 +1,24 @@
+package hs.fulda.de.ci.exam.project;
+
+public class CreditCardTransaction extends Payment {
+ String cardNumber;
+
+ public CreditCardTransaction(int id, String amount, PaymentStatus status, String cardNumber) {
+ super(id, amount, status);
+ this.cardNumber = cardNumber;
+ }
+
+ public String getCardNumber() {
+ return cardNumber;
+ }
+
+ public void setCardNumber(String cardNumber) {
+ this.cardNumber = cardNumber;
+ }
+
+ @Override
+ public boolean isValid() {
+ if (this.cardNumber.length() != 20) return false;
+ return true;
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Customer.java b/src/main/java/hs/fulda/de/ci/exam/project/Customer.java
new file mode 100644
index 0000000..a092797
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Customer.java
@@ -0,0 +1,24 @@
+package hs.fulda.de.ci.exam.project;
+
+
+import java.util.ArrayList;
+
+public class Customer extends Person{
+
+ private String frequentFlyerNumber;
+
+
+
+ public Customer(String name, Address address, String email, String phone) {
+ super(name, address, email, phone);
+ }
+
+ public void setFrequentFlyerNumber(String frequentFlyerNumber) {
+ this.frequentFlyerNumber = frequentFlyerNumber;
+ }
+
+ public String getFrequentFlyerNumber() {
+ return frequentFlyerNumber;
+ }
+
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/EmailNotification.java b/src/main/java/hs/fulda/de/ci/exam/project/EmailNotification.java
new file mode 100644
index 0000000..0735a28
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/EmailNotification.java
@@ -0,0 +1,36 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.regex.Pattern;
+
+public class EmailNotification extends Notification {
+ String email;
+ String content;
+
+ public EmailNotification(String email, String content) {
+ super();
+ this.email = email;
+ this.content = content;
+ }
+
+ @Override
+ public boolean sendNotification() {
+ if (isValidEmail(email)) {
+ System.out.println("Email is sent to " + email);
+ return true;
+ }
+ System.out.println("Invalid Email Address");
+ return false;
+ }
+
+ private boolean isValidEmail(String email) {
+ String regexPattern = "^(?=.{1,64}@)[A-Za-z0-9_-]+(\\.[A-Za-z0-9_-]+)*@"
+ + "[^-][A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$";
+ return patternMatches(email, regexPattern);
+ }
+
+ public static boolean patternMatches(String emailAddress, String regexPattern) {
+ return Pattern.compile(regexPattern)
+ .matcher(emailAddress)
+ .matches();
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/ExampleClass.java b/src/main/java/hs/fulda/de/ci/exam/project/ExampleClass.java
deleted file mode 100644
index 0f6e89f..0000000
--- a/src/main/java/hs/fulda/de/ci/exam/project/ExampleClass.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package hs.fulda.de.ci.exam.project;
-
-public class ExampleClass {
- public static void main(String[] args) {
- System.out.println("Example Class Runs");
- }
-}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Flight.java b/src/main/java/hs/fulda/de/ci/exam/project/Flight.java
new file mode 100644
index 0000000..e41111a
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Flight.java
@@ -0,0 +1,84 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.HashSet;
+
+import static hs.fulda.de.ci.exam.project.FlightStatus.Cancelled;
+
+public class Flight {
+ String flightNumber;
+ Airport departure;
+ Airport arrival;
+ int durationInMinutes;
+ HashSet flightInstances = new HashSet<>();
+
+ public Flight(String flightNumber, Airport departure, Airport arrival, int durationInMinutes) {
+ this.flightNumber = flightNumber;
+ this.departure = departure;
+ this.arrival = arrival;
+ this.durationInMinutes = durationInMinutes;
+ }
+
+ public Flight() {
+
+ }
+
+ public HashSet getInstances() {
+ return this.flightInstances;
+ }
+
+ public FlightInstance getFlightInstance(FlightInstance fi) {
+ for (FlightInstance obj : flightInstances) {
+ if (obj.equals(fi))
+ return obj;
+ }
+ return null;
+ }
+
+ public boolean cancel(FlightInstance fInstance1) {
+ if (flightInstances.contains(fInstance1)) {
+ for (FlightInstance obj : flightInstances) {
+ if (obj.equals(fInstance1)) {
+ obj.status = Cancelled;
+ System.out.println("Flight intance is cancelled");
+ }
+ }
+ return true;
+ }
+ return false;
+
+ }
+
+ public boolean addFlightSchedule(FlightInstance fi) {
+ flightInstances.add(fi);
+ if (flightInstances.contains(fi)) {
+ System.out.println("Flight instance is added");
+ return true;
+ }
+ return false;
+ }
+
+ public String getFlightNumber() {
+ return flightNumber;
+ }
+
+ public Airport getDeparture() {
+ return departure;
+ }
+
+ public Airport getArrival() {
+ return arrival;
+ }
+
+ public int getDurationInMinutes() {
+ return durationInMinutes;
+ }
+
+ public void setFlightNumber(String flightNumber) {
+ this.flightNumber = flightNumber;
+ }
+
+ @Override
+ public String toString() {
+ return "Flight = {" + "flightNumber=" + flightNumber + '\'' + ", departure=" + departure + ", arrival='" + arrival + ", durationInMinutes=" + durationInMinutes + '}';
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/FlightInstance.java b/src/main/java/hs/fulda/de/ci/exam/project/FlightInstance.java
new file mode 100644
index 0000000..edbcaaf
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/FlightInstance.java
@@ -0,0 +1,43 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.sql.Time;
+
+public class FlightInstance {
+ Time departureTime;
+ String gate;
+ FlightStatus status;
+
+ public FlightInstance(Time departureTime, String gate, FlightStatus status) {
+ this.departureTime = departureTime;
+ this.gate = gate;
+ this.status = status;
+ }
+
+ public FlightInstance(){
+
+ }
+
+ public Time getDepartureTime() {
+ return departureTime;
+ }
+
+ public void setDepartureTime(Time departureTime) {
+ this.departureTime = departureTime;
+ }
+
+ public String getGate() {
+ return gate;
+ }
+
+ public void setGate(String gate) {
+ this.gate = gate;
+ }
+
+ public FlightStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(FlightStatus status) {
+ this.status = status;
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/FlightRepository.java b/src/main/java/hs/fulda/de/ci/exam/project/FlightRepository.java
new file mode 100644
index 0000000..e8b32ad
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/FlightRepository.java
@@ -0,0 +1,52 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Scanner;
+
+public class FlightRepository {
+ boolean save(Flight flight) throws IOException {
+ FileWriter fw = new FileWriter("flights.txt", true);
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write(flight.toString());
+ bw.newLine();
+ bw.close();
+ return true;
+ };
+ String findFlightByFlightNumber(String flightNumber){
+ File file = new File("flights.txt");
+
+ try {
+ Scanner scanner = new Scanner(file);
+
+ while (scanner.hasNextLine()) {
+ String line = scanner.nextLine();
+ if(line.matches("(.*)"+flightNumber+"(.*)")) {
+ return line;
+ }
+ }
+ } catch(FileNotFoundException e) {
+ System.out.println("There are no flights added yet. Please add a flight");
+ }
+ return "";
+ }
+
+ public ArrayList findbyDepartureArrival(Airport departure, Airport arrival) {
+ ArrayList flights = new ArrayList<>();
+ File file = new File("flights.txt");
+
+ try {
+ Scanner scanner = new Scanner(file);
+
+ while (scanner.hasNextLine()) {
+ String line = scanner.nextLine();
+ if(line.matches("(.*)"+departure+"(.*)") && line.matches("(.*)"+arrival+"(.*)")) {
+ flights.add(line);
+ }
+ }
+ } catch(FileNotFoundException e) {
+ System.out.println("There are no flights added yet. Please add a flight");
+ }
+ return flights;
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/FlightReservation.java b/src/main/java/hs/fulda/de/ci/exam/project/FlightReservation.java
new file mode 100644
index 0000000..d110357
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/FlightReservation.java
@@ -0,0 +1,84 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.HashMap;
+
+import static hs.fulda.de.ci.exam.project.PaymentStatus.Completed;
+import static hs.fulda.de.ci.exam.project.PaymentStatus.Failed;
+import static hs.fulda.de.ci.exam.project.ReservationStatus.Cancelled;
+import static hs.fulda.de.ci.exam.project.ReservationStatus.Confirmed;
+
+public class FlightReservation {
+ String reservationNumber;
+ FlightInstance flight;
+ HashMap seatMap;
+ ReservationStatus status;
+
+ public FlightReservation(String reservationNumber, FlightInstance flight, HashMap seatMap, ReservationStatus status) {
+ this.reservationNumber = reservationNumber;
+ this.flight = flight;
+ this.seatMap = seatMap;
+ this.status = status;
+ }
+
+ public FlightReservation(){
+
+ }
+
+ public String getReservationNumber() {
+ return reservationNumber;
+ }
+
+ public void setReservationNumber(String reservationNumber) {
+ this.reservationNumber = reservationNumber;
+ }
+
+ public FlightInstance getFlight() {
+ return flight;
+ }
+
+ public void setFlight(FlightInstance flight) {
+ this.flight = flight;
+ }
+
+ public HashMap getSeatMap() {
+ return seatMap;
+ }
+
+ public void setSeatMap(HashMap seatMap) {
+ this.seatMap = seatMap;
+ }
+
+ public ReservationStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(ReservationStatus status) {
+ this.status = status;
+ }
+
+ public void makePayment(Payment payment) {
+ System.out.println("processing payment");
+ if (payment.isValid()) {
+ payment.status = Completed;
+ setStatus(Confirmed);
+ } else {
+ payment.status = Failed;
+ setStatus(Cancelled);
+ }
+
+
+ }
+
+ public boolean notifyUser(String type, String to, String content) {
+ Notification notification = null;
+ switch (type) {
+ case "email":
+ notification = new EmailNotification(to, content);
+ break;
+ case "sms":
+ notification = new SmsNotification(to, content);
+ break;
+ }
+ return notification.sendNotification();
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/FlightReservationRepository.java b/src/main/java/hs/fulda/de/ci/exam/project/FlightReservationRepository.java
new file mode 100644
index 0000000..c169649
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/FlightReservationRepository.java
@@ -0,0 +1,36 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class FlightReservationRepository {
+ Map flightReservationList = new ConcurrentHashMap();
+
+ public boolean checkIfFlightAlreadyExist(FlightReservation flightReservation){
+ if(flightReservationList.containsKey(generateKey(flightReservation))){
+ return true;
+ }
+ return false;
+ }
+ FlightReservation findById(String id){
+ FlightReservation flightReservation = flightReservationList.get(id);
+ return flightReservation;
+ }
+
+ private String generateKey(FlightReservation flightReservation) {
+ return String.format("%s", flightReservation.getReservationNumber());
+ }
+ public Collection findAll() {
+ return flightReservationList.values();
+ }
+ public boolean save(FlightReservation flightReservation){
+ flightReservationList.put(generateKey(flightReservation), flightReservation);
+ return true;
+ }
+
+ public void delete(FlightReservation flightReservation) {
+ flightReservationList.remove(generateKey(flightReservation));
+ }
+
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/FlightSeat.java b/src/main/java/hs/fulda/de/ci/exam/project/FlightSeat.java
new file mode 100644
index 0000000..d84c60c
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/FlightSeat.java
@@ -0,0 +1,20 @@
+package hs.fulda.de.ci.exam.project;
+
+public class FlightSeat extends Seat {
+ private String reservationNumer;
+ private double fare;
+
+ public FlightSeat(double fare, String reservationNumer) {
+ super();
+ this.fare = fare;
+ this.reservationNumer = reservationNumer;
+ }
+
+ public double getFare() {
+ return this.fare;
+ }
+
+ public String getReservationNumber() {
+ return this.reservationNumer;
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/FlightStatus.java b/src/main/java/hs/fulda/de/ci/exam/project/FlightStatus.java
new file mode 100644
index 0000000..68aadf2
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/FlightStatus.java
@@ -0,0 +1,5 @@
+package hs.fulda.de.ci.exam.project;
+
+public enum FlightStatus {
+ Active, Scheduled, Delayed, Departed, Landed, InAir, Arrived, Cancelled, Diverted, Unknown
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/FrontDeskOfficer.java b/src/main/java/hs/fulda/de/ci/exam/project/FrontDeskOfficer.java
new file mode 100644
index 0000000..941be16
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/FrontDeskOfficer.java
@@ -0,0 +1,42 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class FrontDeskOfficer extends Person{
+
+ Map itineraryList = new ConcurrentHashMap();
+
+ public FrontDeskOfficer(String name, Address address, String email, String phone) {
+ super(name, address, email, phone);
+ }
+
+ public void createItinerary(Airport start_airport, Airport final_airport, Date date){
+ Itinerary itinerary = new Itinerary(start_airport, final_airport, date);
+ validateItinerary(itinerary);
+ checkIfItineraryAlreadyExist(itinerary);
+ itineraryList.put(generateKey(itinerary), itinerary);
+ }
+
+ public Collection getAllItineraries() {
+ return itineraryList.values();
+ }
+
+ private void checkIfItineraryAlreadyExist(Itinerary itinerary){
+ if(itineraryList.containsKey(generateKey(itinerary))){
+ throw new RuntimeException("Itinerary Already Exists");
+ }
+ }
+
+ private String generateKey(Itinerary itinerary) {
+ return String.format("%s-%s", itinerary.getStart_airport(), itinerary.getFinal_airport());
+ }
+
+ public void validateItinerary(Itinerary itinerary){
+ itinerary.validateStartAirport();
+ itinerary.validateFinalAirport();
+ itinerary.validateCreationDate();
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Itinerary.java b/src/main/java/hs/fulda/de/ci/exam/project/Itinerary.java
new file mode 100644
index 0000000..126aa8b
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Itinerary.java
@@ -0,0 +1,96 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+public class Itinerary {
+
+ private Airport start_airport;
+ private Airport final_airport;
+ private Date creationDate;
+ private FlightReservationRepository flightReservationRepository;
+
+ public Itinerary(Airport start_airport, Airport final_airport, Date creationDate) {
+ this.start_airport = start_airport;
+ this.final_airport = final_airport;
+ this.creationDate = creationDate;
+ }
+
+ public float makeDiscount(float fare, float discountRate){
+ fare = fare - (fare * discountRate/100);
+ return fare;
+ }
+
+ public boolean makePayment(FlightReservation flightReservation, String transactionType, Customer customer, float fare){
+ if(customer.getItineraries().size() >= 2) {
+ fare = makeDiscount(fare, 10);
+ if (transactionType == "Credit") {
+ fare = makeDiscount(fare, 15);
+ System.out.println("Your discount rate is 15%. The total amount of: " + fare + "Euro");
+ return true;
+ } else if (transactionType == "Cash" || transactionType == "Check") {
+ System.out.println("Your discount rate is 10%. The total amount of: " + fare + "Euro");
+ return true;
+ }
+ }
+ flightReservation.setStatus(ReservationStatus.Pending);
+ return false;
+ }
+
+ public FlightReservation makeReservation(FlightSeat flightSeat, Passenger passenger){
+ HashMap seatHashMap= new HashMap();
+ seatHashMap.put(passenger, flightSeat);
+ validatePassengerDetails(passenger);
+ FlightReservation flight = new FlightReservation();
+ flight.setSeatMap(seatHashMap);
+ flight.setStatus(ReservationStatus.Requested);
+ return flight;
+ }
+
+ public Airport getFinal_airport() {
+ return final_airport;
+ }
+
+ public Airport getStart_airport() {
+ return start_airport;
+ }
+
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public void setFinal_airport(Airport final_airport) {
+ this.final_airport = final_airport;
+ }
+
+ public void setStart_airport(Airport start_airport) {
+ this.start_airport = start_airport;
+ }
+
+ public void validateStartAirport() {
+ if(this.start_airport.getName().isBlank())
+ throw new RuntimeException(("Starting Airport Cannot be null or empty"));
+ }
+
+ public void validateFinalAirport() {
+ if(this.final_airport.getName().isBlank())
+ throw new RuntimeException(("Destination Airport Cannot be null or empty"));
+ }
+ public void validateCreationDate() {
+ if(this.creationDate.equals(null))
+ throw new RuntimeException(("Creation Date should not be null or empty"));
+ }
+
+ public void validatePassengerDetails(Passenger passenger){
+ passenger.validateName();
+ passenger.validatePassportNumber();
+ passenger.validateDate();
+ }
+
+
+}
+
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/ItineraryRepository.java b/src/main/java/hs/fulda/de/ci/exam/project/ItineraryRepository.java
new file mode 100644
index 0000000..8c4ea5f
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/ItineraryRepository.java
@@ -0,0 +1,8 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.ArrayList;
+
+public interface ItineraryRepository {
+ ArrayList findAll();
+ void save(Itinerary itinerary);
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Notification.java b/src/main/java/hs/fulda/de/ci/exam/project/Notification.java
new file mode 100644
index 0000000..4821060
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Notification.java
@@ -0,0 +1,5 @@
+package hs.fulda.de.ci.exam.project;
+
+public abstract class Notification {
+ public abstract boolean sendNotification();
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Passenger.java b/src/main/java/hs/fulda/de/ci/exam/project/Passenger.java
new file mode 100644
index 0000000..b7b9d89
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Passenger.java
@@ -0,0 +1,40 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.Date;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Passenger {
+ private String name;
+ private String passportNumber;
+ private Date dateOfBirth;
+
+ public Passenger(String name, String passportNumber, Date dateOfBirth) {
+ this.name = name;
+ this.passportNumber = passportNumber;
+ this.dateOfBirth = dateOfBirth;
+ }
+
+ public void validateName() {
+ if(name.isBlank()) {
+ throw new RuntimeException(("Name cannot be null or empty"));
+ }
+ }
+
+ public void validatePassportNumber() {
+ Pattern pattern = Pattern.compile("^(?!^0+$)[a-zA-Z0-9]{3,20}$");
+ Matcher matcher = pattern.matcher(this.passportNumber);
+ if(passportNumber.isBlank()){
+ throw new RuntimeException("Passport number cannot be blank");
+ }
+ if(!matcher.matches()){
+ throw new RuntimeException("Passport number cannot be null or empty");
+ }
+ }
+
+ public void validateDate() {
+ if(dateOfBirth.equals(null)) {
+ throw new RuntimeException("Birthdate cannot be null");
+ }
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Payment.java b/src/main/java/hs/fulda/de/ci/exam/project/Payment.java
new file mode 100644
index 0000000..21ece7c
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Payment.java
@@ -0,0 +1,39 @@
+package hs.fulda.de.ci.exam.project;
+
+public abstract class Payment {
+ int id;
+ String amount;
+ PaymentStatus status;
+
+ public Payment(int id, String amount, PaymentStatus status) {
+ this.id = id;
+ this.amount = amount;
+ this.status = status;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getAmount() {
+ return amount;
+ }
+
+ public void setAmount(String amount) {
+ this.amount = amount;
+ }
+
+ public PaymentStatus isStatus() {
+ return status;
+ }
+
+ public void setStatus(PaymentStatus status) {
+ this.status = status;
+ }
+
+ public abstract boolean isValid();
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/PaymentStatus.java b/src/main/java/hs/fulda/de/ci/exam/project/PaymentStatus.java
new file mode 100644
index 0000000..cad1ac7
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/PaymentStatus.java
@@ -0,0 +1,5 @@
+package hs.fulda.de.ci.exam.project;
+
+public enum PaymentStatus {
+ Unpaid, Pending, Completed, Failed, Declined, Cancelled, Abandoned, Settling, Settled, Refunded
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Person.java b/src/main/java/hs/fulda/de/ci/exam/project/Person.java
new file mode 100644
index 0000000..95b4c15
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Person.java
@@ -0,0 +1,93 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Person {
+ private String name;
+ private Address address;
+ private String email;
+ private String phone;
+ private FlightRepository flightRepository;
+ private ItineraryRepository itineraryRepository;
+
+ public Person(String name, Address address, String email, String phone) {
+ this.name = name;
+ this.address = address;
+ this.email = email;
+ this.phone = phone;
+ }
+ public String getName() {
+ return name;
+ }
+ public Address getAddress() {
+ return address;
+ }
+ public String getEmail() {
+ return email;
+ }
+ public String getPhone() {
+ return phone;
+ }
+
+ public void validateName() {
+ if(this.name.isBlank())
+ throw new RuntimeException(("Name Cannot be null or empty"));
+ }
+
+ public void validateAddress(){
+ if(this.address.equals(null))
+ throw new RuntimeException(("Address Cannot be null"));
+ }
+
+ public void validateEmailAddress(){
+ Pattern pattern = Pattern.compile("^(.+)@(.+)$");
+ Matcher matcher = pattern.matcher(this.email);
+ if(email.isBlank()){
+ throw new RuntimeException("Email cannot be blank");
+ }
+ if(!matcher.matches()){
+ throw new RuntimeException("Email address is not Valid");
+ }
+ }
+
+ public void validatePhoneNumber(){
+ if(this.phone.isBlank()) {
+ throw new RuntimeException("Phone Number Cannot be null or empty");
+ }
+ if(this.phone.length()>13) {
+ throw new RuntimeException("Phone Number is too long");
+ }
+ if(this.phone.length()<9) {
+ throw new RuntimeException("Phone Number is too short");
+ }
+ if(this.phone.matches("\\d")) {
+ throw new RuntimeException("Phone Number Contain only digits");
+ }
+ if(!this.phone.startsWith("0")) {
+ throw new RuntimeException("Phone Number should start with 0");
+ }
+ }
+
+ public String searchFlights(String flightNumber){
+ String flightDetails = flightRepository.findFlightByFlightNumber(flightNumber);
+ if(flightDetails.isBlank()){
+ throw new RuntimeException("Flight does not exist.");
+ }
+ return flightDetails;
+ }
+
+ public ArrayList searchAllFlightsByCriteria(Airport departure, Airport arrival){
+ ArrayList flights = flightRepository.findbyDepartureArrival(departure, arrival);
+ if(flights.isEmpty()){
+ throw new RuntimeException("Flights do not exist.");
+ }
+ return flights;
+ }
+
+ public ArrayList getItineraries() {
+ return itineraryRepository.findAll();
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/ReservationStatus.java b/src/main/java/hs/fulda/de/ci/exam/project/ReservationStatus.java
new file mode 100644
index 0000000..ed4005a
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/ReservationStatus.java
@@ -0,0 +1,5 @@
+package hs.fulda.de.ci.exam.project;
+
+public enum ReservationStatus {
+ Requested, Pending, Confirmed, CheckedIn, Cancelled, Abandoned
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Seat.java b/src/main/java/hs/fulda/de/ci/exam/project/Seat.java
new file mode 100644
index 0000000..1967565
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/Seat.java
@@ -0,0 +1,40 @@
+package hs.fulda.de.ci.exam.project;
+
+public class Seat {
+ private SeatClass seatClass;
+ private SeatType seatType;
+ private String seatNumber;
+
+ public Seat(String seatNumber, SeatType seatType, SeatClass seatClass) {
+ this.seatNumber = seatNumber;
+ this.seatType = seatType;
+ this.seatClass = seatClass;
+ }
+ public Seat(){
+
+ }
+
+ public SeatClass getSeatClass() {
+ return seatClass;
+ }
+
+ public void setSeatClass(SeatClass seatClass) {
+ this.seatClass = seatClass;
+ }
+
+ public SeatType getSeatType() {
+ return seatType;
+ }
+
+ public void setSeatType(SeatType seatType) {
+ this.seatType = seatType;
+ }
+
+ public String getSeatNumber() {
+ return seatNumber;
+ }
+
+ public void setSeatNumber(String seatNumber) {
+ this.seatNumber = seatNumber;
+ }
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/SeatClass.java b/src/main/java/hs/fulda/de/ci/exam/project/SeatClass.java
new file mode 100644
index 0000000..fec9a4a
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/SeatClass.java
@@ -0,0 +1,5 @@
+package hs.fulda.de.ci.exam.project;
+
+public enum SeatClass {
+ Economy, EconomyPlus, PreferredEconomy, Business, FirstClass
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/SeatType.java b/src/main/java/hs/fulda/de/ci/exam/project/SeatType.java
new file mode 100644
index 0000000..c5d76a0
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/SeatType.java
@@ -0,0 +1,5 @@
+package hs.fulda.de.ci.exam.project;
+
+public enum SeatType {
+ Regular, Accessible, EmergencyExit, ExtraLegRoom
+}
diff --git a/src/main/java/hs/fulda/de/ci/exam/project/SmsNotification.java b/src/main/java/hs/fulda/de/ci/exam/project/SmsNotification.java
new file mode 100644
index 0000000..73f5d50
--- /dev/null
+++ b/src/main/java/hs/fulda/de/ci/exam/project/SmsNotification.java
@@ -0,0 +1,37 @@
+package hs.fulda.de.ci.exam.project;
+
+import java.util.regex.Pattern;
+
+public class SmsNotification extends Notification {
+ String to;
+ String content;
+
+ public SmsNotification(String to, String content) {
+ super();
+ this.to = to;
+ this.content = content;
+ }
+
+ @Override
+ public boolean sendNotification() {
+ if (isValidEmail(to)) {
+ System.out.println("SMS is sent to " + to);
+ return true;
+ }
+ System.out.println("Invalid Number");
+ return false;
+ }
+
+ private boolean isValidEmail(String to) {
+ String regexPattern = "(\\(?([\\d \\-\\)\\–\\+\\/\\(]+){6,}\\)?([ .\\-–\\/]?)([\\d]+))";
+ return patternMatches(to, regexPattern);
+ }
+
+ public static boolean patternMatches(String emailAddress, String regexPattern) {
+ return Pattern.compile(regexPattern)
+ .matcher(emailAddress)
+ .matches();
+ }
+
+
+}
diff --git a/src/main/resources/img.png b/src/main/resources/img.png
new file mode 100644
index 0000000..edea587
Binary files /dev/null and b/src/main/resources/img.png differ
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/AccountServiceTest.java b/src/test/java/hs/fulda/de/ci/exam/project/AccountServiceTest.java
new file mode 100644
index 0000000..3d1d7dd
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/AccountServiceTest.java
@@ -0,0 +1,140 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.jupiter.api.DisplayName;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.*;
+
+public class AccountServiceTest {
+ private static final String PASSWORD = "password";
+
+ private static final Account ENABLED_USER =
+ new Account("user id", "hash", Account.AccountStatus.ACTIVE);
+
+ private static final Account DISABLED_USER =
+ new Account("disabled user id", "disabled user password hash", Account.AccountStatus.CLOSED);
+
+ private AccountRepository accountRepository;
+ private PasswordEncoder passwordEncoder;
+ private AccountService accountService;
+
+ @Before
+ public void setup() {
+ accountRepository = createAccountRepository();
+ passwordEncoder = createPasswordEncoder();
+ accountService = new AccountService(accountRepository, passwordEncoder);
+ }
+
+ @Test
+ public void shouldBeValidForValidCredentials(){
+ boolean accountIsValid = accountService.isValidAccount(ENABLED_USER.getId(), PASSWORD);
+ assertTrue(accountIsValid);
+
+ verify(accountRepository).findById(ENABLED_USER.getId());
+
+ verify(passwordEncoder).encode(PASSWORD);
+ }
+
+ @Test
+ public void shouldBEInvalidForInvalidId() {
+ boolean accountIsValid = accountService.isValidAccount("invalid id", PASSWORD);
+ assertFalse(accountIsValid);
+
+ InOrder inOrder = inOrder(accountRepository, passwordEncoder);
+ inOrder.verify(accountRepository).findById("invalid id");
+ inOrder.verify(passwordEncoder, never()).encode(anyString());
+ }
+
+ @Test
+ public void shouldBeInvalidForInvalid(){
+ boolean accountIsValid = accountService.isValidAccount("invalid id", PASSWORD);
+ assertFalse(accountIsValid);
+
+ InOrder inOrder = inOrder(accountRepository, passwordEncoder);
+ inOrder.verify(accountRepository).findById("invalid id");
+ inOrder.verify(passwordEncoder, never()).encode(anyString());
+ }
+
+ @Test
+ public void shouldBeInvalidForDisabledUser(){
+ boolean accountIsValid =
+ accountService.isValidAccount(DISABLED_USER.getId(), PASSWORD);
+ assertFalse(accountIsValid);
+
+ verify(accountRepository).findById(DISABLED_USER.getId());
+ verify(passwordEncoder, never()).encode(anyString());
+ }
+
+ @Test
+ public void shouldBeInvalidForInvalidPassword() {
+ boolean accountIsValid =
+ accountService.isValidAccount(ENABLED_USER.getId(), "invalid");
+ assertFalse(accountIsValid);
+
+ ArgumentCaptor passwordCaptor = ArgumentCaptor.forClass(String.class);
+
+ verify(passwordEncoder).encode(passwordCaptor.capture());
+ assertEquals("invalid", passwordCaptor.getValue());
+ }
+
+ private AccountRepository createAccountRepository() {
+ AccountRepository mock = mock(AccountRepository.class);
+ when(mock.findById(ENABLED_USER.getId())).thenReturn(ENABLED_USER);
+ when(mock.findById(DISABLED_USER.getId())).thenReturn(DISABLED_USER);
+ return mock;
+ }
+
+ private PasswordEncoder createPasswordEncoder() {
+ PasswordEncoder mock = mock(PasswordEncoder.class);
+ when(mock.encode(anyString())).thenReturn("any password hash");
+ when(mock.encode(PASSWORD)).thenReturn(ENABLED_USER.getPasswordHash());
+ return mock;
+ }
+
+ @Test
+ @DisplayName("Should Not Create Account when Id is null")
+ public void shouldThrowRuntimeExceptionWhenIdIsNull(){
+ assertThrows(RuntimeException.class, () -> {
+ accountService.createAccount(null, "pwd", Account.AccountStatus.ACTIVE);
+ });
+ }
+
+ @Test
+ @DisplayName("Should Not Create Account when password is blank")
+ public void shouldThrowRuntimeExceptionWhenPasswordIsNull(){
+ assertThrows(RuntimeException.class, () -> {
+ accountService.createAccount("John", "", Account.AccountStatus.ACTIVE);
+ });
+ }
+
+ @Test
+ @DisplayName("Should Not Create Account when status is null")
+ public void shouldThrowRuntimeExceptionWhenStatusIsNull(){
+ assertThrows(RuntimeException.class, () -> {
+ accountService.createAccount("John", "", null);
+ });
+ }
+
+ @Test
+ public void verifyCreateAccount() {
+
+ when(accountRepository.save(any(Account.class))).thenReturn(true);
+
+ assertTrue(accountService.createAccount("John", "pwd", Account.AccountStatus.ACTIVE));
+
+ verify(accountRepository).save(any(Account.class));
+ verify(accountRepository, times(1)).checkIfAccountAlreadyExist(any(Account.class));
+ verify(accountRepository, never()).delete(any(Account.class));
+ }
+
+}
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/AccountTest.java b/src/test/java/hs/fulda/de/ci/exam/project/AccountTest.java
new file mode 100644
index 0000000..8084b06
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/AccountTest.java
@@ -0,0 +1,108 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.jupiter.api.*;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.when;
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+public class AccountTest {
+
+ @BeforeAll
+ public void setupAll(){
+ System.out.println("Should Print Before All Tests");
+ }
+ Address address1;
+ Account account2;
+ Person person1;
+ Account account1;
+
+ @BeforeEach
+ public void setup() {
+ address1 = new Address("Fuldaer str", "Fulda", "Hessen", "36037", "Germany");
+ account2 = new Account("453", "notactive", Account.AccountStatus.CANCELED);
+ person1 = new Person("Max Mustermann", address1, "max.mustermann@gmail.com", "015147890206");
+ account1 = new Account("123", "password", Account.AccountStatus.ACTIVE);
+ }
+ @Test
+ void test_resetPassword(){
+
+ account1.resetPassword("newpass");
+ account2.resetPassword("notgood");
+
+ assertEquals("newpass", account1.getPassword(),"Password successfully changed.");
+ assertEquals("notactive", account2.getPassword(),"Activate your account to change your password");
+ }
+
+ @Test
+ @DisplayName("Should Not add Account details when Person Name is null")
+ public void shouldThrowRuntimeExceptionWhenPersonNameIsNull(){
+ assertThrows(RuntimeException.class, () -> {
+ account1.addAccountDetails("1",null, address1,"max.mustermann@gmail.com", "0151283290" );
+ });
+ }
+
+ @Test
+ @DisplayName("Should Not add Account details when Address is null")
+ public void shouldThrowRuntimeExceptionWhenPersonAddressIsNull(){
+ assertThrows(RuntimeException.class, () -> {
+ account1.addAccountDetails("1", "John", null,"max.mustermann@gmail.com", "0151283290" );
+ });
+ }
+
+ @DisplayName("Check if the Email is valid")
+ @ParameterizedTest
+ @MethodSource("phoneNumberList")
+ public void shouldThrowRuntimeExceptionWhenPhoneNumberIsNull(String phoneNumber){
+ assertThrows(RuntimeException.class, () -> {
+ account1.addAccountDetails("1","John", address1,"max.mustermann@gmail.com", phoneNumber);
+ });
+ }
+
+ private static List phoneNumberList() {
+ return Arrays.asList("1234567", "0123", "0125314622696456", "0abnajf");
+ }
+
+ @Test
+ @DisplayName("Should Not add Account details when Email is blank")
+ public void shouldThrowRuntimeExceptionWhenEmailIsNull(){
+ assertThrows(RuntimeException.class, () -> {
+ account1.addAccountDetails("1", "John", address1," ", "0151283290" );
+ });
+ assertThrows(RuntimeException.class, () -> {
+ account1.addAccountDetails("1", "John", address1,null, "0151283290" );
+ });
+ }
+
+ @ParameterizedTest
+ @MethodSource("EmailList")
+ @DisplayName("Should Not add Account details when Email Address is not valid")
+ public void shouldThrowRuntimeExceptionWhenEmailIsInvalid(String email){
+ try{
+ account1.addAccountDetails("1","John", address1, email, "0151283290");
+ }
+ catch(final RuntimeException e){
+ String msg2 = "Email address is not Valid";
+ assertEquals(msg2, e.getMessage());
+ }
+
+ }
+
+ private static List EmailList() {
+ return Arrays.asList("max.musterman", "12245.com");
+ }
+}
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/AddressTest.java b/src/test/java/hs/fulda/de/ci/exam/project/AddressTest.java
new file mode 100644
index 0000000..f1824d3
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/AddressTest.java
@@ -0,0 +1,13 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.jupiter.api.Test;
+import static org.assertj.core.api.Assertions.*;
+
+class AddressTest {
+
+ @Test
+ void testToString_Adress() {
+ Address address_fr = new Address("Frankfurt str 12", "Frankfurt", "Hessen", "63023", "Germany");
+ assertThat(address_fr.toString()).describedAs(" get address ").isEqualTo("Frankfurt str 12, Frankfurt, Hessen, 63023, Germany");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/AdminTest.java b/src/test/java/hs/fulda/de/ci/exam/project/AdminTest.java
new file mode 100644
index 0000000..2bf044f
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/AdminTest.java
@@ -0,0 +1,151 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+public class AdminTest {
+
+ Address address_fr;
+ Airport airport_fr;
+ Address address1_ist;
+ Airport airport1_ist;
+ Flight flight1;
+ Address address1;
+ Aircraft aircraft;
+
+ @BeforeEach
+ public void setup() {
+ aircraft = new Aircraft("Boeing", "787", 2003);
+ address_fr = new Address("Frankfurt str", "Frankfurt", "Hessen", "63023", "Germany");
+ airport_fr = new Airport("Fraport", address_fr, "1234");
+ address1_ist = new Address("Istanbul str", "Istanbul", "Fatih", "9019", "Turkey");
+ airport1_ist = new Airport("Istanbul", address1_ist, "5678");
+ flight1 = new Flight("1", airport_fr, airport1_ist, 140);
+ address1 = new Address("Fuldaer str", "Fulda", "Hessen", "36037", "Germany");
+ }
+ @InjectMocks
+ Admin admin = new Admin("Max Muster", address1, "example@gmail.com", "012345678" );
+
+ @Mock
+ private AccountRepository accountRepository;
+
+ @Test
+ public void test_blockUser() {
+ ArrayList users = new ArrayList<>();
+ Account user = new Account("john5", "password", Account.AccountStatus.ACTIVE);
+ when(accountRepository.checkIfAccountAlreadyExist(user)).thenReturn(true);
+
+ admin.blockUser(user);
+
+ assertEquals(Account.AccountStatus.BLOCKED, user.getStatus(), "Status successfully changed");
+ }
+
+ @Mock
+ private FlightRepository flightRepository;
+
+ @Test
+ public void test_addFlight_returnsNewFlight() throws IOException {
+
+ try {
+ when(flightRepository.save(any(Flight.class))).thenReturn(true);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ admin.addFlight("1", airport_fr, airport1_ist, 140);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertNotNull(admin.addFlight("1", airport_fr, airport1_ist, 140));
+ }
+ @Test
+ public void testAddFlight_throwsException() throws IOException {
+
+ when(flightRepository.save(any(Flight.class))).thenThrow(IOException.class);
+ assertThrows(IOException.class, () -> {
+ admin.addFlight("1", airport_fr, airport1_ist, 140);
+ });
+ }
+
+ @Test
+ public void shouldThrowRuntimeExceptionWhenNull(){
+
+ assertThrows(RuntimeException.class, () -> {
+ admin.addFlight(null, airport_fr, airport1_ist, 140);
+ });
+ assertThrows(RuntimeException.class, () -> {
+ admin.addFlight("1", null, airport1_ist, 140);
+ });
+ assertThrows(RuntimeException.class, () -> {
+ admin.addFlight("1", airport_fr, null, 140);
+ });
+ assertThrows(RuntimeException.class, () -> {
+ admin.addFlight("1", airport_fr, airport1_ist, -40);
+ });
+ }
+
+ @Test
+ public void test_searchFlightThrowsExceptionWhenBlank(){
+ when(flightRepository.findFlightByFlightNumber(any(String.class))).thenReturn("");
+ assertThrows(RuntimeException.class, () -> {
+ admin.searchFlights("1");
+ });
+ }
+
+ @Mock
+ private AircraftRepository aircraftRepository;
+
+ @Test
+ public void test_addAircraft_returnsNewAircraft() throws IOException {
+
+ try {
+ when(aircraftRepository.save(any(Aircraft.class))).thenReturn(true);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertNotNull(admin.addAircraft("Boeing", "787", 2003));
+ }
+
+ @Test
+ public void testAddAircraft_throwsException() throws IOException {
+
+ when(aircraftRepository.save(any(Aircraft.class))).thenThrow(IOException.class);
+ assertThrows(IOException.class, () -> {
+ admin.addAircraft("Boeing", "787", 2003);
+ });
+ }
+ @Test
+ public void addAircraftShouldThrowRuntimeExceptionWhenNull(){
+
+ assertThrows(RuntimeException.class, () -> {
+ admin.addAircraft(null, "787", 2003);
+ });
+ assertThrows(RuntimeException.class, () -> {
+ admin.addAircraft("Boeing", "", 2003);
+ });
+ assertThrows(RuntimeException.class, () -> {
+ admin.addAircraft("Boeing", "787", -2003);
+ });
+ }
+
+ @Test
+ public void test_searchAircraft(){
+ when(aircraftRepository.findAircraftByAircraftName(any(String.class))).thenReturn(aircraft.toString());
+ assertNotNull(admin.searchAircraft("Boeing"));
+ assertEquals(admin.searchAircraft("Boeing"), aircraft.toString());
+ }
+}
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/AircraftTest.java b/src/test/java/hs/fulda/de/ci/exam/project/AircraftTest.java
new file mode 100644
index 0000000..bb126b9
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/AircraftTest.java
@@ -0,0 +1,59 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.Test;
+
+import java.util.HashSet;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+
+public class AircraftTest {
+
+ Aircraft testAircraft = new Aircraft("Airbus", "Neo", 1990);
+ HashSet flights = new HashSet<>();
+ Flight flight1 = mock(Flight.class);
+ Flight flight2 = mock(Flight.class);
+
+ @Test
+ public void testClassAircraftConstructorName() {
+ assertThat(testAircraft.getName())
+ .describedAs("get the name of aircraft")
+ .isEqualTo("Airbus");
+ }
+
+ @Test
+ public void testClassAircraftConstructorModel() {
+ assertThat(testAircraft.getModel())
+ .describedAs("get the model of aircraft")
+ .isEqualTo("Neo");
+ }
+
+ @Test
+ public void testClassAircraftConstructorManifacturingYear() {
+ assertThat(testAircraft.getManYear())
+ .describedAs("get the manifacturing year of aircraft")
+ .isEqualTo(1990);
+ }
+
+ @Test
+ public void test_getFlightsEmptyList() {
+ assertThat(testAircraft.getFlights())
+ .describedAs("get the manifacturing year of aircraft")
+ .isEqualTo(flights);
+ }
+
+ @Test
+ public void test_getFlights_wiht_2_flights() {
+ flights.add(flight1);
+ flights.add(flight2);
+
+ testAircraft.addFlight(flight1);
+ testAircraft.addFlight(flight2);
+
+ assertThat(testAircraft.getFlights())
+ .describedAs("get flights of aircraft")
+ .isEqualTo(flights);
+ }
+
+
+}
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/AirlineTest.java b/src/test/java/hs/fulda/de/ci/exam/project/AirlineTest.java
new file mode 100644
index 0000000..4777567
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/AirlineTest.java
@@ -0,0 +1,51 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import java.util.HashSet;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AirlineTest {
+
+ Airline airline = new Airline("Pegasus", "1234");
+ Flight flight1 = mock(Flight.class);
+ HashSet flights = new HashSet<>();
+
+ @Test
+ void testConstructorSetsNameParameterCorrectly() {
+ assertThat(airline.getName())
+ .describedAs("name of airline")
+ .isEqualTo("Pegasus");
+ }
+
+ @Test
+ void testConstructorSetsCodeParameterCorrectly() {
+ assertThat(airline.getCode())
+ .describedAs("code of airline")
+ .isEqualTo("1234");
+ }
+
+ @Test
+ void getFlightsReturnsEmptyListOfFlights() {
+ assertThat(airline.getFlights())
+ .describedAs("flights of airline")
+ .isEqualTo(flights);
+ }
+
+ @Test
+ void addFlightAddsFlightToListOfFlights() {
+ flights.add(flight1);
+
+ airline.addFlight(flight1);
+
+ assertThat(airline.getFlights())
+ .describedAs("flights of airline")
+ .isEqualTo(flights);
+ }
+
+}
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/AirportTest.java b/src/test/java/hs/fulda/de/ci/exam/project/AirportTest.java
new file mode 100644
index 0000000..caa63ef
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/AirportTest.java
@@ -0,0 +1,56 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import java.util.HashSet;
+import static org.assertj.core.api.Assertions.*;
+
+@ExtendWith(MockitoExtension.class)
+public class AirportTest {
+
+
+ Address address_fr = new Address("Frankfurt str", "Frankfurt", "Hessen", "63023", "Germany");
+ Airport airport_fr = new Airport("Fraport", address_fr, "1234");
+
+
+ Address address1_ist = new Address("Istanbul str", "Istanbul", "Fatih", "9019", "Turkey");
+ Airport airport1_ist = new Airport("Istanbul", address1_ist, "5678");
+
+ Flight flight1 = new Flight("1", airport_fr, airport1_ist, 140);
+ Flight flight2 = new Flight("2", airport1_ist, airport_fr, 120);
+
+
+ @Test
+ void test_getName() {
+ assertThat(airport_fr.getName()).describedAs("get airport name").isEqualTo("Fraport");
+ }
+
+ @Test
+ void test_getCode() {
+ assertThat(airport_fr.getCode()).describedAs("get airport code").isEqualTo("1234");
+ }
+
+ @Test
+ void test_getAddress() {
+ assertThat(airport_fr.getAddress()).describedAs("get address of airport").isEqualTo(address_fr);
+ }
+
+ @Test
+ void test_getFlights() {
+ HashSet flist = new HashSet<>();
+ flist.add(flight1);
+ airport_fr.flights.add(flight1);
+ assertThat(airport_fr.getFlights()).describedAs("get all flights of the airport").isEqualTo(flist);
+ }
+
+ @Test
+ void test_getFlights_wiht_2_flights() {
+ HashSet flist = new HashSet<>();
+ flist.add(flight1);
+ flist.add(flight2);
+ airport_fr.flights.add(flight1);
+ airport_fr.flights.add(flight2);
+ assertThat(airport_fr.getFlights()).describedAs("get all flights of the airport").isEqualTo(flist);
+ }
+}
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/CustomerTest.java b/src/test/java/hs/fulda/de/ci/exam/project/CustomerTest.java
new file mode 100644
index 0000000..1c983ee
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/CustomerTest.java
@@ -0,0 +1,66 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import static org.mockito.Mockito.*;
+import org.mockito.junit.jupiter.MockitoExtension;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Date;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+@ExtendWith(MockitoExtension.class)
+public class CustomerTest {
+
+ final Address address1 = new Address("Fuldaer str", "Fulda", "Hessen", "36037", "Germany");
+
+ @InjectMocks
+ final Customer person1 = new Customer("Max Mustermann", address1, "max.mustermann@gmail.com", "015147890206");
+
+ @Test
+ public void test_setFlyingNumber() throws NoSuchFieldException, IllegalAccessException{
+
+ person1.setFrequentFlyerNumber("5");
+
+ final Field field = person1.getClass().getDeclaredField("frequentFlyerNumber");
+ field.setAccessible(true);
+ assertEquals(field.get(person1), "5","set frequent flying number of the customer");
+ }
+
+ @Test
+ public void test_getFlyingNumber() throws NoSuchFieldException, IllegalAccessException {
+
+ final Field field = person1.getClass().getDeclaredField("frequentFlyerNumber");
+ field.setAccessible(true);
+ field.set(person1, "10");
+
+ final String result = person1.getFrequentFlyerNumber();
+
+ assertEquals(result, "10","get frequent flying number of the customer");
+ }
+
+ @Mock
+ private ItineraryRepository itineraryRepo;
+
+ @Test
+ public void test_getItineraries() {
+ ArrayList itineraries = new ArrayList<>();
+
+ Airport airport_fr = new Airport("Fraport", address1, "1234");
+ Airport airport_be = new Airport("Berlin", address1, "5678");
+ Itinerary item1 = new Itinerary(airport_fr, airport_be, new Date());
+ Itinerary item2 = new Itinerary(airport_be, airport_fr, new Date());
+ itineraries.add(item1);
+ itineraries.add(item2);
+
+ when(itineraryRepo.findAll()).thenReturn(itineraries);
+
+ ArrayList new_itineraries = person1.getItineraries();
+
+ assertEquals(2, new_itineraries.size(), "Sizes are equal");
+ }
+
+}
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/ExampleClassTest.java b/src/test/java/hs/fulda/de/ci/exam/project/ExampleClassTest.java
deleted file mode 100644
index a90cba9..0000000
--- a/src/test/java/hs/fulda/de/ci/exam/project/ExampleClassTest.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package hs.fulda.de.ci.exam.project;
-
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
-
-public class ExampleClassTest {
- @Test
- void testExampleClass() {
- assertTrue(true);
- }
-}
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java b/src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java
new file mode 100644
index 0000000..17d0b9c
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java
@@ -0,0 +1,84 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.jupiter.api.Test;
+
+import java.sql.Time;
+import java.util.HashSet;
+
+import static hs.fulda.de.ci.exam.project.FlightStatus.Active;
+import static hs.fulda.de.ci.exam.project.FlightStatus.Cancelled;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class FlightTest {
+
+
+ Address address_fr = new Address("Frankfurt str", "Frankfurt", "Hessen", "63023", "Germany");
+ Airport airport_fr = new Airport("Fraport", address_fr, "1234");
+
+
+ Address address1_ist = new Address("Istanbul str", "Istanbul", "Fatih", "9019", "Turkey");
+ Airport airport1_ist = new Airport("Istanbul", address1_ist, "5678");
+
+ Flight flight1 = new Flight("1", airport_fr, airport1_ist, 140);
+ Flight flight2 = new Flight("2", airport1_ist, airport_fr, 120);
+
+ FlightInstance fInstance1 = new FlightInstance(new Time(12, 45, 00), "4E", Active);
+
+ @Test
+ void getInstances_no_instance_should_be_equal() {
+ HashSet empty_list = new HashSet<>();
+ assertThat(flight1.getInstances()).describedAs("get flight instances of the flight ").isEqualTo(empty_list);
+ }
+
+ @Test
+ void getInstances_not_empty_list_should_be_equal() {
+ HashSet list = new HashSet<>();
+ list.add(fInstance1);
+
+ flight1.flightInstances.add(fInstance1);
+ assertThat(flight1.getInstances()).describedAs("get flight instances of the flight ").isEqualTo(list);
+ }
+
+ @Test
+ void addFlightScheduleShoudlAddFlightInstanceWithActiveStatus() {
+ boolean addInstance = flight1.addFlightSchedule(fInstance1);
+ assertTrue(addInstance);
+ FlightStatus result = flight1.getFlightInstance(fInstance1).getStatus();
+ FlightStatus expected = Active;
+ assertThat(expected).isEqualTo(result);
+ }
+
+ @Test
+ void cancelingFlightShouldChangeActiveToCancelled() {
+ boolean addInstance = flight1.addFlightSchedule(fInstance1);
+ assertTrue(addInstance);
+ flight1.cancel(fInstance1);
+ FlightStatus result = flight1.getFlightInstance(fInstance1).getStatus();
+ FlightStatus expected = Cancelled;
+ assertThat(expected).isEqualTo(result);
+ }
+
+ @Test
+ void getFlightNumber() {
+ assertThat(flight1.getFlightNumber()).describedAs("get flight number of the flight").isEqualTo("1");
+ }
+
+ @Test
+ void getDeparture() {
+ assertThat(flight1.getDeparture()).describedAs("get departure of flight").isEqualTo(airport_fr);
+
+ }
+
+ @Test
+ void getArrival() {
+ assertThat(flight1.getArrival()).describedAs("get arrival of flight").isEqualTo(airport1_ist);
+
+ }
+
+ @Test
+ void getDurationInMinutes() {
+ assertThat(flight1.getDurationInMinutes()).describedAs("get duration of flight").isEqualTo(140);
+
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java b/src/test/java/hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java
new file mode 100644
index 0000000..cfb742c
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/FrontDeskOfficerTest.java
@@ -0,0 +1,53 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.Before;
+import org.junit.jupiter.api.*;
+import org.mockito.InjectMocks;
+
+import java.util.Date;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+public class FrontDeskOfficerTest {
+
+ Address address1;
+ Airport airport_fr;
+ Airport airport_be;
+ FrontDeskOfficer frontDeskOfficer;
+
+ @BeforeAll
+ public void setupAll(){
+ System.out.println("Should Print Before All Tests");
+ }
+ @BeforeEach
+ public void setup(){
+ address1 = new Address("Fuldaer str", "Fulda", "Hessen", "36037", "Germany");
+ airport_fr = new Airport("Fraport", address1, "1234");
+ airport_be = new Airport("Berlin", address1, "5678");
+ frontDeskOfficer = new FrontDeskOfficer("John", address1, "example@email.com", "0151238967");
+ }
+ @Test
+ public void shouldCreateItinerary() {
+ frontDeskOfficer.createItinerary(airport_fr, airport_be, new Date());
+ assertFalse(frontDeskOfficer.getAllItineraries().isEmpty());
+ assertEquals(1, frontDeskOfficer.getAllItineraries().size());
+ assertTrue(frontDeskOfficer.getAllItineraries().stream().filter(itinerary -> itinerary.getStart_airport().equals(airport_fr) &&
+ itinerary.getFinal_airport().equals(airport_be)).findAny().isPresent());
+ }
+ @Test
+ @DisplayName("Should Not Create Itinerary when Starting Airport is null")
+ public void shouldThrowRuntimeExceptionWhenStartAirportIsNull(){
+ assertThrows(RuntimeException.class, () -> {
+ frontDeskOfficer.createItinerary(null, airport_be, new Date());
+ });
+ }
+
+ @Test
+ @DisplayName("Should Not Create Itinerary when Destination Airport is null")
+ public void shouldThrowRuntimeExceptionWhenFinalAirportIsNull(){
+ assertThrows(RuntimeException.class, () -> {
+ frontDeskOfficer.createItinerary(airport_fr, airport_be, null);
+ });
+ }
+}
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/ItineraryTest.java b/src/test/java/hs/fulda/de/ci/exam/project/ItineraryTest.java
new file mode 100644
index 0000000..bf1e52f
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/ItineraryTest.java
@@ -0,0 +1,112 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.Assert;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.Mockito.*;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+@ExtendWith(MockitoExtension.class)
+public class ItineraryTest {
+
+ final Address address1 = new Address("Fuldaer str", "Fulda", "Hessen", "36037", "Germany");
+ final Airport airport_fr = new Airport("Fraport", address1, "1234");
+ final Airport airport_be = new Airport("Berlin", address1, "5678");
+ final Itinerary item2 = new Itinerary(airport_be, airport_fr, new Date());
+
+ @InjectMocks
+ final Customer person1 = new Customer("Max Mustermann", address1, "max.mustermann@gmail.com", "015147890206");
+ final Itinerary item1 = new Itinerary(airport_fr, airport_be, new Date());
+
+ @Mock
+ private ItineraryRepository itineraryRepo;
+ @Mock
+ private FlightReservationRepository flightReservationRepository;
+
+ @Test
+ public void test_makePayment() {
+ ArrayList itineraries = new ArrayList<>();
+
+ itineraries.add(item1);
+ itineraries.add(item2);
+
+ when(person1.getItineraries()).thenReturn(itineraries);
+
+ boolean actualWithCredit = item1.makePayment(new FlightReservation(),"Credit", person1, 450);
+ boolean actualWithCash = item1.makePayment(new FlightReservation(), "Cash", person1, 450);
+ boolean actualWithCheck = item1.makePayment(new FlightReservation(), "Check", person1, 450);
+ boolean actualEmpty = item1.makePayment(new FlightReservation(), " ", person1, 450);
+
+ assertEquals(true, actualWithCash, "The Payment method is successfully chosen");
+ assertEquals(true, actualWithCash, "The Payment method is successfully chosen");
+ assertEquals(true, actualWithCredit, "The Payment method is successfully chosen");
+ assertEquals(true, actualWithCheck, "The Payment method is successfully chosen");
+ assertEquals(false, actualEmpty, "The Payment method is wrong");
+ }
+
+ @Test
+ public void test_makePaymentStatus(){
+ FlightReservation flightReservation = new FlightReservation();
+ item1.makePayment(flightReservation,"Credit", person1, 450);
+ assertEquals(flightReservation.getStatus(), ReservationStatus.Pending);
+ }
+
+ @Test
+ @DisplayName("Should Not Make Reservation when Passenger name is null")
+ public void shouldThrowRuntimeExceptionWhenNameIsNull() {
+ String msg = null;
+ try {
+ item1.makeReservation(new FlightSeat(1000.0, "5"), new Passenger("", "Ab", new Date()));
+ } catch (Exception e) {
+ msg = e.getMessage();
+ }
+ assertEquals("Name cannot be null or empty", msg);
+ }
+
+ @DisplayName("Should Not Make Reservation when Passenger passport number is invalid")
+ @ParameterizedTest
+ @MethodSource("passportNumberList")
+ public void shouldThrowRuntimeExceptionWhenPhoneNumberIsNull(String passportNumber) {
+ String msg = null;
+ try {
+ item1.makeReservation(new FlightSeat(1000.0, "5"), new Passenger("John", passportNumber, new Date()));
+ } catch (Exception e) {
+ msg = e.getMessage();
+ }
+ assertEquals("Passport number cannot be null or empty", msg);
+ }
+
+ private static List passportNumberList() {
+ return Arrays.asList("A2", "000000", "AB231837%8");
+ }
+
+ @Test
+ @DisplayName("Should Not Make Reservation when Passenger Birthdate is null")
+ public void shouldThrowRuntimeExceptionWhenDateIsNull() {
+ assertThrows(RuntimeException.class, () -> {
+ item1.makeReservation(new FlightSeat(1000.0, "5"), new Passenger("John", "AB127389", null));
+ });
+ }
+
+ @Test
+ public void test_makeReservation() {
+ FlightReservation flightreservation = item2.makeReservation(new FlightSeat(1000.0, "5"), new Passenger("John", "AB2389", new Date()));
+ assertNotNull(flightreservation);
+ assertEquals(flightreservation.getStatus(), ReservationStatus.Requested);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/NotificationTest.java b/src/test/java/hs/fulda/de/ci/exam/project/NotificationTest.java
new file mode 100644
index 0000000..b1600f2
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/NotificationTest.java
@@ -0,0 +1,60 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.Test;
+
+import static hs.fulda.de.ci.exam.project.ReservationStatus.Confirmed;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class NotificationTest {
+
+ EmailNotification email = new EmailNotification("test@gmail.com", "HelloWorld");
+ EmailNotification emailInvalid = new EmailNotification("testgmail.com", "HelloWorld");
+ FlightReservation reservation = new FlightReservation();
+ SmsNotification sms = new SmsNotification("01788370107", "Reservation confirmed");
+ SmsNotification smsInvalid = new SmsNotification("123", "Some Wrong Number");
+
+
+ @Test
+ public void emailValidiationShouldReturnTrueForValidEmail() {
+ boolean result = email.sendNotification();
+ boolean expected = true;
+ assertThat(expected).isEqualTo(result);
+ }
+
+ @Test
+ public void emailValidiationShouldReturnFalseForInValidEmail() {
+ boolean result = emailInvalid.sendNotification();
+ boolean expected = false;
+ assertThat(expected).isEqualTo(result);
+ }
+
+ @Test
+ public void emailNotificationShouldBeSentWhenFlighReservationCompleted() {
+ reservation.setStatus(Confirmed);
+ boolean result = reservation.notifyUser("email", "test@gmail.com", "Reservation is Confirmed!");
+ boolean expected = true;
+ assertThat(expected).isEqualTo(result);
+ }
+
+ @Test
+ public void smsNotificationShouldBeSentWhenSmsTypeIsChosen() {
+ reservation.setStatus(Confirmed);
+ boolean result = reservation.notifyUser("sms", "01788370107", "Reservation is successfull");
+ boolean expected = true;
+ assertThat(expected).isEqualTo(result);
+ }
+
+ @Test
+ public void smsIsSentWhenNumberIsValid() {
+ boolean result = sms.sendNotification();
+ boolean expected = true;
+ assertThat(expected).isEqualTo(result);
+ }
+
+ @Test
+ public void smsShouldNotBeSentWhenNumberIsInvalid() {
+ boolean result = smsInvalid.sendNotification();
+ boolean expected = false;
+ assertThat(expected).isEqualTo(result);
+ }
+}
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/PaymentTest.java b/src/test/java/hs/fulda/de/ci/exam/project/PaymentTest.java
new file mode 100644
index 0000000..9e1a2b4
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/PaymentTest.java
@@ -0,0 +1,57 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.Test;
+
+import static hs.fulda.de.ci.exam.project.PaymentStatus.*;
+import static hs.fulda.de.ci.exam.project.ReservationStatus.Confirmed;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class PaymentTest {
+ @Test
+ public void should_be_possible_to_pay_with_credit_card(){
+ Payment credit_card_payment = new CreditCardTransaction(11, "139€", Unpaid, "01234567890123456789");
+ FlightReservation reservation = new FlightReservation();
+ reservation.makePayment(credit_card_payment);
+ assertEquals(Confirmed, reservation.getStatus());
+ assertEquals(Completed, credit_card_payment.status);
+ }
+
+ @Test
+ public void should_be_possible_to_pay_with_bank_account(){
+ FlightReservation reservation = new FlightReservation();
+ BankTransaction payment = new BankTransaction(11, "139€", Unpaid, "Sparkasse Fulda", "DE01234567890123456789");
+ reservation.makePayment(payment);
+ assertEquals(Confirmed, reservation.getStatus());
+ assertEquals(Completed, payment.status);
+ }
+
+ @Test
+ public void paymentShould_not_be_possible_if_credit_card_deatils_is_wrong(){
+ CreditCardTransaction credit_card_payment = new CreditCardTransaction(11, "139€", Unpaid, "123");
+ FlightReservation reservation = new FlightReservation();
+ reservation.makePayment(credit_card_payment);
+ assertEquals(ReservationStatus.Cancelled, reservation.getStatus());
+ assertEquals(Failed, credit_card_payment.status);
+ }
+
+ @Test
+ public void paymentShould_not_be_possible_if_iban_is_wrong(){
+ BankTransaction bank_payment = new BankTransaction(11, "139€", Unpaid, "Sparkasse Fulda", "DE012");
+ FlightReservation reservation = new FlightReservation();
+ reservation.makePayment(bank_payment);
+ assertEquals(ReservationStatus.Cancelled, reservation.getStatus());
+ assertEquals(Failed, bank_payment.status);
+ }
+
+ @Test
+ public void cashPaymentShouldBePossible(){
+ CashTransaction cash_payment = new CashTransaction(11, "139€", Unpaid);
+ FlightReservation reservation = new FlightReservation();
+ reservation.makePayment(cash_payment);
+ assertEquals(Confirmed, reservation.getStatus());
+ assertEquals(Completed, cash_payment.status);
+ }
+
+
+
+}
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/PersonTest.java b/src/test/java/hs/fulda/de/ci/exam/project/PersonTest.java
new file mode 100644
index 0000000..0d6157e
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/PersonTest.java
@@ -0,0 +1,70 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.util.ArrayList;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+public class PersonTest {
+ Address address_fr = new Address("Frankfurt str", "Frankfurt", "Hessen", "63023", "Germany");
+ Airport airport_fr = new Airport("Fraport", address_fr, "1234");
+
+
+ Address address1_ist = new Address("Istanbul str", "Istanbul", "Fatih", "9019", "Turkey");
+ Airport airport1_ist = new Airport("Istanbul", address1_ist, "5678");
+
+ Address address1 = new Address("Fuldaer str", "Fulda", "Hessen", "36037", "Germany");
+ @InjectMocks
+ Person person1 = new Person("Max Mustermann", address1, "max.mustermann@gmail.com", "015147890206");
+
+ @Mock
+ private FlightRepository flightRepository;
+
+ @Test
+ void test_getName() {
+ assertThat(person1.getName()).describedAs("get person name").isEqualTo("Max Mustermann");
+ }
+
+ @Test
+ void test_getAddress() {
+ assertThat(person1.getAddress()).describedAs("get address of person").isEqualTo(address1);
+ }
+
+ @Test
+ void test_getEmail() {
+ assertThat(person1.getEmail()).describedAs("get person email").isEqualTo("max.mustermann@gmail.com");
+ }
+ @Test
+ void test_getPhone() {
+ assertThat(person1.getPhone()).describedAs("get person phone").isEqualTo("015147890206");
+ }
+
+ @Test
+ public void test_searchAllFlightsByCriteria(){
+ ArrayList flights = new ArrayList<>();
+ flights.add("Flight1");
+ when(flightRepository.findbyDepartureArrival(airport_fr, airport1_ist)).thenReturn(flights);
+ assertNotNull(person1.searchAllFlightsByCriteria(airport_fr, airport1_ist));
+ }
+
+ @Test
+ public void test_searchFlight(){
+ Flight flight1 = new Flight("1", airport_fr, airport1_ist, 140);
+ when(flightRepository.findFlightByFlightNumber(any(String.class))).thenReturn(flight1.toString());
+ assertNotNull(person1.searchFlights("1"));
+ assertEquals(person1.searchFlights("1"), flight1.toString());
+ }
+}
diff --git a/src/test/java/hs/fulda/de/ci/exam/project/SeatTest.java b/src/test/java/hs/fulda/de/ci/exam/project/SeatTest.java
new file mode 100644
index 0000000..e9c4400
--- /dev/null
+++ b/src/test/java/hs/fulda/de/ci/exam/project/SeatTest.java
@@ -0,0 +1,29 @@
+package hs.fulda.de.ci.exam.project;
+
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class SeatTest {
+ @Test
+ public void testIfConstructorSetsValues() {
+ FlightSeat fSeat = new FlightSeat(100.0, "1234");
+ assertThat(fSeat.getFare()).isEqualTo(100.0);
+ assertThat(fSeat.getReservationNumber()).isEqualTo("1234");
+ }
+
+ @Test
+ public void testParentSeatClassConstructor() {
+ Seat seat = new Seat("14F", SeatType.Regular, SeatClass.Economy);
+ assertThat(seat.getSeatNumber()).isEqualTo("14F");
+ assertThat(seat.getSeatType()).isEqualTo(SeatType.Regular);
+ assertThat(seat.getSeatClass()).isEqualTo(SeatClass.Economy);
+ }
+
+ @Test
+ public void testMakingFlightTestParentClass(){
+ Seat seat = new FlightSeat(100.0, "1234");
+ assertThat(((FlightSeat) seat).getFare()).isEqualTo(100.0);
+ assertThat(((FlightSeat) seat).getReservationNumber()).isEqualTo("1234");
+ }
+}
diff --git a/target/AirlineManagementSystem-1.0-SNAPSHOT.jar b/target/AirlineManagementSystem-1.0-SNAPSHOT.jar
index 345bef8..f166720 100644
Binary files a/target/AirlineManagementSystem-1.0-SNAPSHOT.jar and b/target/AirlineManagementSystem-1.0-SNAPSHOT.jar differ
diff --git a/target/classes/hs/fulda/de/ci/exam/project/Address.class b/target/classes/hs/fulda/de/ci/exam/project/Address.class
new file mode 100644
index 0000000..4410a35
Binary files /dev/null and b/target/classes/hs/fulda/de/ci/exam/project/Address.class differ
diff --git a/target/classes/hs/fulda/de/ci/exam/project/Aircraft.class b/target/classes/hs/fulda/de/ci/exam/project/Aircraft.class
new file mode 100644
index 0000000..881facc
Binary files /dev/null and b/target/classes/hs/fulda/de/ci/exam/project/Aircraft.class differ
diff --git a/target/classes/hs/fulda/de/ci/exam/project/Airline.class b/target/classes/hs/fulda/de/ci/exam/project/Airline.class
new file mode 100644
index 0000000..3b3cb68
Binary files /dev/null and b/target/classes/hs/fulda/de/ci/exam/project/Airline.class differ
diff --git a/target/classes/hs/fulda/de/ci/exam/project/Airport.class b/target/classes/hs/fulda/de/ci/exam/project/Airport.class
new file mode 100644
index 0000000..e73f556
Binary files /dev/null and b/target/classes/hs/fulda/de/ci/exam/project/Airport.class differ
diff --git a/target/classes/hs/fulda/de/ci/exam/project/Customer.class b/target/classes/hs/fulda/de/ci/exam/project/Customer.class
new file mode 100644
index 0000000..f6e1080
Binary files /dev/null and b/target/classes/hs/fulda/de/ci/exam/project/Customer.class differ
diff --git a/target/classes/hs/fulda/de/ci/exam/project/ExampleClass.class b/target/classes/hs/fulda/de/ci/exam/project/ExampleClass.class
deleted file mode 100644
index 9cd9860..0000000
Binary files a/target/classes/hs/fulda/de/ci/exam/project/ExampleClass.class and /dev/null differ
diff --git a/target/classes/hs/fulda/de/ci/exam/project/Flight.class b/target/classes/hs/fulda/de/ci/exam/project/Flight.class
new file mode 100644
index 0000000..4e95dbf
Binary files /dev/null and b/target/classes/hs/fulda/de/ci/exam/project/Flight.class differ
diff --git a/target/classes/hs/fulda/de/ci/exam/project/FlightInstance.class b/target/classes/hs/fulda/de/ci/exam/project/FlightInstance.class
new file mode 100644
index 0000000..a6953eb
Binary files /dev/null and b/target/classes/hs/fulda/de/ci/exam/project/FlightInstance.class differ
diff --git a/target/classes/hs/fulda/de/ci/exam/project/Itinerary.class b/target/classes/hs/fulda/de/ci/exam/project/Itinerary.class
new file mode 100644
index 0000000..ee3c42e
Binary files /dev/null and b/target/classes/hs/fulda/de/ci/exam/project/Itinerary.class differ
diff --git a/target/classes/hs/fulda/de/ci/exam/project/ItineraryRepository.class b/target/classes/hs/fulda/de/ci/exam/project/ItineraryRepository.class
new file mode 100644
index 0000000..23fbe66
Binary files /dev/null and b/target/classes/hs/fulda/de/ci/exam/project/ItineraryRepository.class differ
diff --git a/target/classes/hs/fulda/de/ci/exam/project/Person.class b/target/classes/hs/fulda/de/ci/exam/project/Person.class
new file mode 100644
index 0000000..f688df2
Binary files /dev/null and b/target/classes/hs/fulda/de/ci/exam/project/Person.class differ
diff --git a/target/classes/img.png b/target/classes/img.png
new file mode 100644
index 0000000..edea587
Binary files /dev/null and b/target/classes/img.png differ
diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties
index 72e7601..ca0dfcb 100644
--- a/target/maven-archiver/pom.properties
+++ b/target/maven-archiver/pom.properties
@@ -1,5 +1,5 @@
#Generated by Maven
-#Mon Jan 24 12:13:24 CET 2022
+#Sat Jan 29 15:33:12 CET 2022
groupId=hs.fulda.de.ci.exam.project
artifactId=AirlineManagementSystem
version=1.0-SNAPSHOT
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
index 4146c73..e6d23e5 100644
--- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -1 +1,4 @@
-hs/fulda/de/ci/exam/project/ExampleClass.class
+hs/fulda/de/ci/exam/project/FlightInstance.class
+hs/fulda/de/ci/exam/project/Airport.class
+hs/fulda/de/ci/exam/project/Address.class
+hs/fulda/de/ci/exam/project/Flight.class
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
index 764d565..eadb9ed 100644
--- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -1 +1,4 @@
-/Users/imron/OneDrive - lt.hs-fulda.de/Desktop/Semester_7_HSF/CI/AirlineManagementSystem/src/main/java/hs/fulda/de/ci/exam/project/ExampleClass.java
+/Users/imron/Library/CloudStorage/OneDrive-lt.hs-fulda.de/Desktop/Semester_7_HSF/CI/AirlineManagementSystem/src/main/java/hs/fulda/de/ci/exam/project/Airport.java
+/Users/imron/Library/CloudStorage/OneDrive-lt.hs-fulda.de/Desktop/Semester_7_HSF/CI/AirlineManagementSystem/src/main/java/hs/fulda/de/ci/exam/project/Address.java
+/Users/imron/Library/CloudStorage/OneDrive-lt.hs-fulda.de/Desktop/Semester_7_HSF/CI/AirlineManagementSystem/src/main/java/hs/fulda/de/ci/exam/project/FlightInstance.java
+/Users/imron/Library/CloudStorage/OneDrive-lt.hs-fulda.de/Desktop/Semester_7_HSF/CI/AirlineManagementSystem/src/main/java/hs/fulda/de/ci/exam/project/Flight.java
diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
index 2a3e81d..c17a6a7 100644
--- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
+++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
@@ -1 +1,3 @@
-hs/fulda/de/ci/exam/project/ExampleClassTest.class
+hs/fulda/de/ci/exam/project/AddressTest.class
+hs/fulda/de/ci/exam/project/FlightTest.class
+hs/fulda/de/ci/exam/project/AirportTest.class
diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
index d0814c0..f230483 100644
--- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
+++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
@@ -1 +1,3 @@
-/Users/imron/OneDrive - lt.hs-fulda.de/Desktop/Semester_7_HSF/CI/AirlineManagementSystem/src/test/java/hs/fulda/de/ci/exam/project/ExampleClassTest.java
+/Users/imron/Library/CloudStorage/OneDrive-lt.hs-fulda.de/Desktop/Semester_7_HSF/CI/AirlineManagementSystem/src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java
+/Users/imron/Library/CloudStorage/OneDrive-lt.hs-fulda.de/Desktop/Semester_7_HSF/CI/AirlineManagementSystem/src/test/java/hs/fulda/de/ci/exam/project/AirportTest.java
+/Users/imron/Library/CloudStorage/OneDrive-lt.hs-fulda.de/Desktop/Semester_7_HSF/CI/AirlineManagementSystem/src/test/java/hs/fulda/de/ci/exam/project/AddressTest.java
diff --git a/target/surefire-reports/TEST-TestExample.xml b/target/surefire-reports/TEST-TestExample.xml
deleted file mode 100644
index 1ee3c16..0000000
--- a/target/surefire-reports/TEST-TestExample.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.AddressTest.xml b/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.AddressTest.xml
new file mode 100644
index 0000000..b461a41
--- /dev/null
+++ b/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.AddressTest.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.AirlineTest.xml b/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.AirlineTest.xml
new file mode 100644
index 0000000..3bfd7d0
--- /dev/null
+++ b/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.AirlineTest.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.AirportTest.xml b/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.AirportTest.xml
new file mode 100644
index 0000000..3705dfa
--- /dev/null
+++ b/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.AirportTest.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.ExampleClassTest.xml b/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.ExampleClassTest.xml
deleted file mode 100644
index d273299..0000000
--- a/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.ExampleClassTest.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.FlightTest.xml b/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.FlightTest.xml
new file mode 100644
index 0000000..62bc8f6
--- /dev/null
+++ b/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.FlightTest.xml
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.PersonTest.xml b/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.PersonTest.xml
new file mode 100644
index 0000000..28902a0
--- /dev/null
+++ b/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.PersonTest.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.TestExampleClass.xml b/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.TestExampleClass.xml
deleted file mode 100644
index 692684a..0000000
--- a/target/surefire-reports/TEST-hs.fulda.de.ci.exam.project.TestExampleClass.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/target/surefire-reports/TestExample.txt b/target/surefire-reports/hs.fulda.de.ci.exam.project.AddressTest.txt
similarity index 68%
rename from target/surefire-reports/TestExample.txt
rename to target/surefire-reports/hs.fulda.de.ci.exam.project.AddressTest.txt
index 0f318c5..bd33bb8 100644
--- a/target/surefire-reports/TestExample.txt
+++ b/target/surefire-reports/hs.fulda.de.ci.exam.project.AddressTest.txt
@@ -1,4 +1,4 @@
-------------------------------------------------------------------------------
-Test set: TestExample
+Test set: hs.fulda.de.ci.exam.project.AddressTest
-------------------------------------------------------------------------------
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 s - in TestExample
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 s - in hs.fulda.de.ci.exam.project.AddressTest
diff --git a/target/surefire-reports/hs.fulda.de.ci.exam.project.AirlineTest.txt b/target/surefire-reports/hs.fulda.de.ci.exam.project.AirlineTest.txt
new file mode 100644
index 0000000..f768d7c
--- /dev/null
+++ b/target/surefire-reports/hs.fulda.de.ci.exam.project.AirlineTest.txt
@@ -0,0 +1,4 @@
+-------------------------------------------------------------------------------
+Test set: hs.fulda.de.ci.exam.project.AirlineTest
+-------------------------------------------------------------------------------
+Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.096 s - in hs.fulda.de.ci.exam.project.AirlineTest
diff --git a/target/surefire-reports/hs.fulda.de.ci.exam.project.AirportTest.txt b/target/surefire-reports/hs.fulda.de.ci.exam.project.AirportTest.txt
new file mode 100644
index 0000000..8cf5feb
--- /dev/null
+++ b/target/surefire-reports/hs.fulda.de.ci.exam.project.AirportTest.txt
@@ -0,0 +1,4 @@
+-------------------------------------------------------------------------------
+Test set: hs.fulda.de.ci.exam.project.AirportTest
+-------------------------------------------------------------------------------
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.253 s - in hs.fulda.de.ci.exam.project.AirportTest
diff --git a/target/surefire-reports/hs.fulda.de.ci.exam.project.ExampleClassTest.txt b/target/surefire-reports/hs.fulda.de.ci.exam.project.ExampleClassTest.txt
deleted file mode 100644
index f790629..0000000
--- a/target/surefire-reports/hs.fulda.de.ci.exam.project.ExampleClassTest.txt
+++ /dev/null
@@ -1,4 +0,0 @@
--------------------------------------------------------------------------------
-Test set: hs.fulda.de.ci.exam.project.ExampleClassTest
--------------------------------------------------------------------------------
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.022 s - in hs.fulda.de.ci.exam.project.ExampleClassTest
diff --git a/target/surefire-reports/hs.fulda.de.ci.exam.project.FlightTest.txt b/target/surefire-reports/hs.fulda.de.ci.exam.project.FlightTest.txt
new file mode 100644
index 0000000..e30fffb
--- /dev/null
+++ b/target/surefire-reports/hs.fulda.de.ci.exam.project.FlightTest.txt
@@ -0,0 +1,4 @@
+-------------------------------------------------------------------------------
+Test set: hs.fulda.de.ci.exam.project.FlightTest
+-------------------------------------------------------------------------------
+Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.081 s - in hs.fulda.de.ci.exam.project.FlightTest
diff --git a/target/surefire-reports/hs.fulda.de.ci.exam.project.PersonTest.txt b/target/surefire-reports/hs.fulda.de.ci.exam.project.PersonTest.txt
new file mode 100644
index 0000000..d2b010e
--- /dev/null
+++ b/target/surefire-reports/hs.fulda.de.ci.exam.project.PersonTest.txt
@@ -0,0 +1,4 @@
+-------------------------------------------------------------------------------
+Test set: hs.fulda.de.ci.exam.project.PersonTest
+-------------------------------------------------------------------------------
+Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 s - in hs.fulda.de.ci.exam.project.PersonTest
diff --git a/target/surefire-reports/hs.fulda.de.ci.exam.project.TestExampleClass.txt b/target/surefire-reports/hs.fulda.de.ci.exam.project.TestExampleClass.txt
deleted file mode 100644
index b805685..0000000
--- a/target/surefire-reports/hs.fulda.de.ci.exam.project.TestExampleClass.txt
+++ /dev/null
@@ -1,4 +0,0 @@
--------------------------------------------------------------------------------
-Test set: hs.fulda.de.ci.exam.project.TestExampleClass
--------------------------------------------------------------------------------
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.023 s - in hs.fulda.de.ci.exam.project.TestExampleClass
diff --git a/target/test-classes/TestExample.class b/target/test-classes/TestExample.class
deleted file mode 100644
index 8a1c182..0000000
Binary files a/target/test-classes/TestExample.class and /dev/null differ
diff --git a/target/test-classes/hs/fulda/de/ci/exam/project/AddressTest.class b/target/test-classes/hs/fulda/de/ci/exam/project/AddressTest.class
new file mode 100644
index 0000000..a6d458a
Binary files /dev/null and b/target/test-classes/hs/fulda/de/ci/exam/project/AddressTest.class differ
diff --git a/target/test-classes/hs/fulda/de/ci/exam/project/AircraftTest.class b/target/test-classes/hs/fulda/de/ci/exam/project/AircraftTest.class
new file mode 100644
index 0000000..d7b5cb8
Binary files /dev/null and b/target/test-classes/hs/fulda/de/ci/exam/project/AircraftTest.class differ
diff --git a/target/test-classes/hs/fulda/de/ci/exam/project/AirlineTest.class b/target/test-classes/hs/fulda/de/ci/exam/project/AirlineTest.class
new file mode 100644
index 0000000..73baddb
Binary files /dev/null and b/target/test-classes/hs/fulda/de/ci/exam/project/AirlineTest.class differ
diff --git a/target/test-classes/hs/fulda/de/ci/exam/project/AirportTest.class b/target/test-classes/hs/fulda/de/ci/exam/project/AirportTest.class
new file mode 100644
index 0000000..2038134
Binary files /dev/null and b/target/test-classes/hs/fulda/de/ci/exam/project/AirportTest.class differ
diff --git a/target/test-classes/hs/fulda/de/ci/exam/project/CustomerTest.class b/target/test-classes/hs/fulda/de/ci/exam/project/CustomerTest.class
new file mode 100644
index 0000000..1b55663
Binary files /dev/null and b/target/test-classes/hs/fulda/de/ci/exam/project/CustomerTest.class differ
diff --git a/target/test-classes/hs/fulda/de/ci/exam/project/ExampleClassTest.class b/target/test-classes/hs/fulda/de/ci/exam/project/ExampleClassTest.class
deleted file mode 100644
index 5a0536d..0000000
Binary files a/target/test-classes/hs/fulda/de/ci/exam/project/ExampleClassTest.class and /dev/null differ
diff --git a/target/test-classes/hs/fulda/de/ci/exam/project/FlightTest.class b/target/test-classes/hs/fulda/de/ci/exam/project/FlightTest.class
new file mode 100644
index 0000000..dfb0f03
Binary files /dev/null and b/target/test-classes/hs/fulda/de/ci/exam/project/FlightTest.class differ
diff --git a/target/test-classes/hs/fulda/de/ci/exam/project/PersonTest.class b/target/test-classes/hs/fulda/de/ci/exam/project/PersonTest.class
new file mode 100644
index 0000000..5975c89
Binary files /dev/null and b/target/test-classes/hs/fulda/de/ci/exam/project/PersonTest.class differ