-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for the newly implemented code for Extension 2
- Loading branch information
1 parent
c17082d
commit 95b14b0
Showing
2 changed files
with
60 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package honours.ing.banq.card; | ||
|
||
import honours.ing.banq.BoilerplateTest; | ||
import honours.ing.banq.auth.CardBlockedError; | ||
import honours.ing.banq.auth.InvalidPINError; | ||
import honours.ing.banq.transaction.TransactionService; | ||
import org.junit.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* @author jeffrey | ||
* @since 3-8-17 | ||
*/ | ||
public class CardServiceTest extends BoilerplateTest { | ||
|
||
@Autowired | ||
private CardService service; | ||
|
||
@Autowired | ||
private TransactionService transactionService; | ||
|
||
@Test(expected = CardBlockedError.class) | ||
public void blockCard() throws Exception { | ||
for (int i = 0; i < 3; i++) { | ||
try { | ||
transactionService.depositIntoAccount(account1.iBan, account1.cardNumber, "0000", 10.0); | ||
} catch (InvalidPINError ignored) { } | ||
} | ||
|
||
transactionService.depositIntoAccount(account1.iBan, account1.cardNumber, account1.pin, 10.0); | ||
} | ||
|
||
@Test | ||
public void unblockCard() throws Exception { | ||
try { | ||
blockCard(); | ||
} catch (CardBlockedError ignored) { } | ||
|
||
service.unblockCard(account1.token, account1.iBan, account1.cardNumber); | ||
|
||
// Now test if the card is usable again | ||
transactionService.depositIntoAccount(account1.iBan, account1.cardNumber, account1.pin, 10.0); | ||
} | ||
|
||
} |