Exemplo n.º 1
0
 @Test
 public void parseShouldRejectChecksumFailure() {
   try {
     IBAN.parse(INVALID_IBAN);
     fail("Invalid input should have been rejected for checksum mismatch.");
   } catch (WrongChecksumException e) {
     assertThat(e.getFailedInput(), is(INVALID_IBAN));
   }
 }
Exemplo n.º 2
0
 @Test
 public void testToPretty() throws Exception {
   assertEquals("", IBAN.toPretty(""));
   assertEquals("12", IBAN.toPretty("12"));
   assertEquals("12", IBAN.toPretty("1 2"));
   assertEquals("1234", IBAN.toPretty("1234"));
   assertEquals("1234", IBAN.toPretty("1 2 3 4"));
   assertEquals("1234 5", IBAN.toPretty("12345"));
   assertEquals("1234 5", IBAN.toPretty("1234 5"));
   assertEquals("1234 5678", IBAN.toPretty("12345678"));
   assertEquals("1234 5678", IBAN.toPretty("1234 5678"));
   assertEquals("1234 5678 9", IBAN.toPretty("123456789"));
   assertEquals("1234 5678 9", IBAN.toPretty("1234 5678 9"));
 }
Exemplo n.º 3
0
  @Test
  public void testEqualsContract() {
    IBAN x = IBAN.parse(VALID_IBAN);
    IBAN y = IBAN.parse(VALID_IBAN);
    IBAN z = IBAN.parse(VALID_IBAN);

    assertFalse("No object equals null", x.equals(null));
    assertTrue("An object equals itself", x.equals(x));
    assertTrue("Equality is symmetric", x.equals(y) && y.equals(x));
    assertTrue("Equality is transitive", x.equals(y) && y.equals(z) && x.equals(z));
    assertEquals("Equal objects have the same hash code", x.hashCode(), y.hashCode());
  }
Exemplo n.º 4
0
 @Test(expected = UnknownCountryCodeException.class)
 public void parseShouldRejectUnknownCountryCode() {
   IBAN.parse("UU345678345543234");
 }
Exemplo n.º 5
0
 @Test(expected = IllegalArgumentException.class)
 public void parseShouldRejectLeadingWhitespace() {
   IBAN.parse(" " + VALID_IBAN);
 }
Exemplo n.º 6
0
 @Test(expected = IllegalArgumentException.class)
 public void parseShouldRejectTrailingWhitespace() {
   IBAN.parse(VALID_IBAN + ' ');
 }
Exemplo n.º 7
0
 @Test(expected = IllegalArgumentException.class)
 public void parseShouldRejectInvalidInput() {
   IBAN.parse("Shenanigans!");
 }
Exemplo n.º 8
0
 @Test(expected = IllegalArgumentException.class)
 public void parseShouldRejectNull() {
   IBAN.parse(null);
 }
Exemplo n.º 9
0
 @Test
 public void valueOfNullIsNull() {
   assertThat(IBAN.valueOf(null), is(nullValue()));
 }
Exemplo n.º 10
0
 @Test
 public void getCheckDigitsShouldReturnTheCheckDigits() {
   assertThat(IBAN.parse(VALID_IBAN).getCheckDigits(), is("91"));
 }
Exemplo n.º 11
0
 @Test
 public void getCountryCodeShouldReturnTheCountryCode() {
   assertThat(IBAN.parse(VALID_IBAN).getCountryCode(), is("NL"));
 }