Skip to content

Commit

Permalink
some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
hajk1 committed Feb 13, 2024
1 parent b0623d9 commit 8f914e7
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/test/java/org/iban4j/BicUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,21 @@
*/
package org.iban4j;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.iban4j.TestDataHelper.defaultExceptionMessage;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;


@DisplayName("BIC Util Test class")
public class BicUtilTest {

public static class InvalidBicValidationTest {


@Test
@DisplayName("validate BIC with null value")
public void bicValidationWithNullShouldThrowException() {
BicFormatException thrown = assertThrows(
BicFormatException.class,
Expand All @@ -41,6 +39,7 @@ public void bicValidationWithNullShouldThrowException() {
}

@Test
@DisplayName("validate BIC with empty value")
public void bicValidationWithEmptyStringShouldThrowException() {
BicFormatException thrown = assertThrows(
BicFormatException.class,
Expand All @@ -50,6 +49,7 @@ public void bicValidationWithEmptyStringShouldThrowException() {
}

@Test
@DisplayName("validate BIC with less characters")
public void bicValidationWithLessCharactersShouldThrowException() {
BicFormatException thrown = assertThrows(
BicFormatException.class,
Expand All @@ -59,6 +59,7 @@ public void bicValidationWithLessCharactersShouldThrowException() {
}

@Test
@DisplayName("validate BIC with more characters")
public void bicValidationWithMoreCharactersShouldThrowException() {
BicFormatException thrown = assertThrows(
BicFormatException.class,
Expand All @@ -68,6 +69,7 @@ public void bicValidationWithMoreCharactersShouldThrowException() {
}

@Test
@DisplayName("validate BIC with lowercase")
public void bicValidationWithLowercaseShouldThrowException() {
BicFormatException thrown = assertThrows(
BicFormatException.class,
Expand All @@ -77,6 +79,7 @@ public void bicValidationWithLowercaseShouldThrowException() {
}

@Test
@DisplayName("validate BIC with invalid bank code")
public void bicValidationWithInvalidBankCodeShouldThrowException() {
BicFormatException thrown = assertThrows(
BicFormatException.class,
Expand All @@ -86,6 +89,7 @@ public void bicValidationWithInvalidBankCodeShouldThrowException() {
}

@Test
@DisplayName("validate BIC with non existing country code")
public void bicValidationWithNonExistingCountryCodeShouldThrowException() {
UnsupportedCountryException thrown = assertThrows(
UnsupportedCountryException.class,
Expand All @@ -95,6 +99,7 @@ public void bicValidationWithNonExistingCountryCodeShouldThrowException() {
}

@Test
@DisplayName("validate BIC with invalid country code")
public void bicValidationWithInvalidCountryCodeShouldThrowException() {
BicFormatException thrown = assertThrows(
BicFormatException.class,
Expand All @@ -104,6 +109,7 @@ public void bicValidationWithInvalidCountryCodeShouldThrowException() {
}

@Test
@DisplayName("validate BIC with invalid location code")
public void bicValidationWithInvalidLocationCodeShouldThrowException() {
BicFormatException thrown = assertThrows(
BicFormatException.class,
Expand All @@ -113,6 +119,7 @@ public void bicValidationWithInvalidLocationCodeShouldThrowException() {
}

@Test
@DisplayName("validate BIC with invalid branch code")
public void bicValidationWithInvalidBranchCodeShouldThrowException() {
BicFormatException thrown = assertThrows(
BicFormatException.class,
Expand All @@ -121,9 +128,9 @@ public void bicValidationWithInvalidBranchCodeShouldThrowException() {
assertThat(thrown.getMessage(), containsString("Branch code must contain only letters or digits"));
}
@Test
@DisplayName("validate BIC with alphanumeric bank code")
public void bicValidationWithAlphanumericBankCode() {
BicUtil.validate("1234DEFFXXX");
}
}

}

0 comments on commit 8f914e7

Please sign in to comment.