Browse Source

updated Itinerary

feature-pr-Itinerary
Sona Markosyan 3 years ago
parent
commit
9845780898
  1. 4
      src/main/java/hs/fulda/de/ci/exam/project/FlightReservation.java
  2. 8
      src/main/java/hs/fulda/de/ci/exam/project/FlightReservationRepository.java
  3. 13
      src/main/java/hs/fulda/de/ci/exam/project/Itinerary.java
  4. 4
      src/main/java/hs/fulda/de/ci/exam/project/Passenger.java
  5. 8
      src/test/java/hs/fulda/de/ci/exam/project/ItineraryTest.java

4
src/main/java/hs/fulda/de/ci/exam/project/FlightReservation.java

@ -0,0 +1,4 @@
package hs.fulda.de.ci.exam.project;
public class FlightReservation {
}

8
src/main/java/hs/fulda/de/ci/exam/project/FlightReservationRepository.java

@ -0,0 +1,8 @@
package hs.fulda.de.ci.exam.project;
import java.util.ArrayList;
public interface FlightReservationRepository {
ArrayList<FlightReservation> findAll();
void save(FlightReservation flightReservation);
}

13
src/main/java/hs/fulda/de/ci/exam/project/Itinerary.java

@ -7,6 +7,7 @@ public class Itinerary {
private Airport start_airport; private Airport start_airport;
private Airport final_airport; private Airport final_airport;
private Date creationDate; private Date creationDate;
private FlightReservationRepository flightReservationRepository;
public Itinerary(Airport start_airport, Airport final_airport, Date creationDate) { public Itinerary(Airport start_airport, Airport final_airport, Date creationDate) {
this.start_airport = start_airport; this.start_airport = start_airport;
@ -14,8 +15,8 @@ public class Itinerary {
this.creationDate = creationDate; this.creationDate = creationDate;
} }
public List<String> getReservations(){
return null;
public List<FlightReservation> getReservations(){
return flightReservationRepository.findAll();
} }
public float makeDiscount(float fare, float discountRate){ public float makeDiscount(float fare, float discountRate){
@ -40,6 +41,14 @@ public class Itinerary {
return false; return false;
} }
public boolean makeReservation(Passenger passenger){
List<FlightReservation> flightReservations = getReservations();
FlightReservation flight = new FlightReservation();
flightReservationRepository.save(flight);
return false;
}
public Airport getFinal_airport() { public Airport getFinal_airport() {
return final_airport; return final_airport;
} }

4
src/main/java/hs/fulda/de/ci/exam/project/Passenger.java

@ -0,0 +1,4 @@
package hs.fulda.de.ci.exam.project;
public class Passenger {
}

8
src/test/java/hs/fulda/de/ci/exam/project/ItineraryTest.java

@ -15,9 +15,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
public class ItineraryTest { public class ItineraryTest {
final Address address1 = new Address("Fuldaer str", "Fulda", "Hessen", "36037", "Germany"); 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");
@InjectMocks @InjectMocks
final Customer person1 = new Customer("Max Mustermann", address1, "max.mustermann@gmail.com", "015147890206"); final Customer person1 = new Customer("Max Mustermann", address1, "max.mustermann@gmail.com", "015147890206");
final Itinerary item1 = new Itinerary(airport_fr, airport_be, new Date());
final Itinerary item2 = new Itinerary(airport_be, airport_fr, new Date());
@Mock @Mock
private ItineraryRepository itineraryRepo; private ItineraryRepository itineraryRepo;
@ -26,10 +30,6 @@ public class ItineraryTest {
public void test_makePayment() { public void test_makePayment() {
ArrayList<Itinerary> itineraries = new ArrayList<>(); ArrayList<Itinerary> 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(item1);
itineraries.add(item2); itineraries.add(item2);

Loading…
Cancel
Save