You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.3 KiB
57 lines
2.3 KiB
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);
|
|
}
|
|
|
|
|
|
|
|
}
|