package net.dvt32.regexandvalidation.task6;

import static org.junit.Assert.*;

import org.junit.Test;

public class IbanValidatorTest {
	
	IbanValidator iv = new IbanValidator();
	private final String EXAMPLE_INPUT = 
		"<bankAccounts>\r\n" + 
		"<iban>GR16 0110 1050 0000 1054 7023 795</iban>\r\n" + 
		"<iban>GB35 MIBG 4025 3432 1446 70</iban>\r\n" + 
		"<iban>SA80 8000 0375 6080 1019 0160</iban>\r\n" + 
		"<iban>CH51 0868 6001 2565 1500 1</iban>\r\n" + 
		"<iban>BG80 BNBG 9661 1020 3456 7840</iban>\r\n" + 
		"<iban>IL30 01BG 0300 0009 6339 234</iban>\r\n" + 
		"<iban>AL47 2121 1009 0000 0002 3569 8741</iban>\r\n" + 
		"<iban>AZ21 NABZ 0000 0000 1370 1000 1944</iban>\r\n" + 
		"<iban>BG80 BNBG 9661 1020 3456 7843</iban>\r\n" + 
		"</bankAccounts>\r\n";
	
	@Test
	public void shouldCensorTwoBulgarianIbanNumbers() {
		String expectedOutput =
			"<bankAccounts>\r\n" + 
			"<iban>GR16 0110 1050 0000 1054 7023 795</iban>\r\n" + 
			"<iban>GB35 MIBG 4025 3432 1446 70</iban>\r\n" + 
			"<iban>SA80 8000 0375 6080 1019 0160</iban>\r\n" + 
			"<iban>CH51 0868 6001 2565 1500 1</iban>\r\n" + 
			"<iban>****7840</iban>\r\n" + 
			"<iban>IL30 01BG 0300 0009 6339 234</iban>\r\n" + 
			"<iban>AL47 2121 1009 0000 0002 3569 8741</iban>\r\n" + 
			"<iban>AZ21 NABZ 0000 0000 1370 1000 1944</iban>\r\n" + 
			"<iban>****7843</iban>\r\n" + 
			"</bankAccounts>\r\n";
		String actualOutput = iv.getStringWithCensoredIbanFirstPart(EXAMPLE_INPUT);
		assertEquals(expectedOutput, actualOutput);
	}
	
	@Test(expected = NullPointerException.class)
	public void shouldThrowNullPointerException() {
		iv.getStringWithCensoredIbanFirstPart(null);
	}
	
	@Test
	public void shouldNotCensorAnything() {
		String input =
			"<bankAccounts>\r\n" + 
			"<iban>GR16 0110 1050 0000 1054 7023 795</iban>\r\n" + 
			"<iban>GB35 MIBG 4025 3432 1446 70</iban>\r\n" + 
			"<iban>SA80 8000 0375 6080 1019 0160</iban>\r\n" + 
			"<iban>CH51 0868 6001 2565 1500 1</iban>\r\n" + 
			"<iban>****7840</iban>\r\n" + 
			"<iban>IL30 01BG 0300 0009 6339 234</iban>\r\n" + 
			"<iban>AL47 2121 1009 0000 0002 3569 8741</iban>\r\n" + 
			"<iban>AZ21 NABZ 0000 0000 1370 1000 1944</iban>\r\n" + 
			"<iban>****7843</iban>\r\n" + 
			"</bankAccounts>\r\n";
		String output = iv.getStringWithCensoredIbanFirstPart(input);
		assertEquals(input, output);
	}
	
}
@@ -860,21 +860,21 @@
 expected
-Outpu
+Resul
 t =%0D%0A%09%09%09
@@ -1410,21 +1410,21 @@
 g actual
-Outpu
+Resul
 t = iv.g
@@ -1497,21 +1497,21 @@
 expected
-Outpu
+Resul
 t, actua
@@ -1515,13 +1515,13 @@
 tual
-Outpu
+Resul
 t);%0D
@@ -2265,32 +2265,36 @@
 ccounts%3E%5Cr%5Cn%22;%0D%0A
+%09%09%0D%0A
 %09%09String output 
@@ -2286,21 +2286,61 @@
 %09String 
-outpu
+expectedResult = input;%0D%0A%09%09String actualResul
 t = iv.g
@@ -2401,20 +2401,35 @@
 als(
-input, outpu
+expectedResult, actualResul
 t);%0D
@@ -2436,9 +2436,11 @@
 %0A%09%7D%0D%0A%09%0D%0A
-
 %7D
+%0D%0A

Update IbanValidatorTest.java