Sona Markosyan
3 years ago
5 changed files with 110 additions and 6 deletions
-
18src/main/java/hs/fulda/de/ci/exam/project/Account.java
-
9src/main/java/hs/fulda/de/ci/exam/project/AccountRepository.java
-
42src/main/java/hs/fulda/de/ci/exam/project/Person.java
-
41src/test/java/hs/fulda/de/ci/exam/project/AccountTest.java
-
4src/test/java/hs/fulda/de/ci/exam/project/PersonTest.java
@ -0,0 +1,9 @@ |
|||||
|
package hs.fulda.de.ci.exam.project; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
|
||||
|
public interface AccountRepository { |
||||
|
ArrayList<Account> findAll(); |
||||
|
void save(Account account); |
||||
|
boolean addPersonalDetails(Person person); |
||||
|
} |
@ -1,20 +1,53 @@ |
|||||
package hs.fulda.de.ci.exam.project; |
package hs.fulda.de.ci.exam.project; |
||||
|
|
||||
import org.junit.jupiter.api.Test; |
|
||||
|
import org.junit.jupiter.api.*; |
||||
|
import org.junit.jupiter.api.extension.ExtendWith; |
||||
|
import org.mockito.InjectMocks; |
||||
|
import org.mockito.Mock; |
||||
|
import org.mockito.junit.jupiter.MockitoExtension; |
||||
|
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
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 { |
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 |
@Test |
||||
void test_resetPassword(){ |
void test_resetPassword(){ |
||||
Account account1 = new Account("123", "password", Account.AccountStatus.ACTIVE); |
|
||||
Account account2 = new Account("453", "notactive", Account.AccountStatus.CANCELED); |
|
||||
|
|
||||
account1.resetPassword("newpass"); |
account1.resetPassword("newpass"); |
||||
account2.resetPassword("notgood"); |
account2.resetPassword("notgood"); |
||||
|
|
||||
assertEquals("newpass", account1.getPassword(),"Password successfully changed."); |
assertEquals("newpass", account1.getPassword(),"Password successfully changed."); |
||||
assertEquals("notactive", account2.getPassword(),"Activate your account to change your password"); |
assertEquals("notactive", account2.getPassword(),"Activate your account to change your password"); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
@DisplayName("Should Not Create Itinerary when Starting Airport is null") |
||||
|
public void shouldThrowRuntimeExceptionWhenPersonNameIsNull(){ |
||||
|
assertThrows(RuntimeException.class, () -> { |
||||
|
account1.addAccountDetails(null, address1,"max.mustermann@gmail.com", "015147890206" ); |
||||
|
}); |
||||
} |
} |
||||
} |
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue