-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
104 additions
and
18 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
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
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
56 changes: 56 additions & 0 deletions
56
src/test/java/com/qoomon/banking/swift/message/block/SwiftBlockReaderTest.java
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,56 @@ | ||
package com.qoomon.banking.swift.message.block; | ||
|
||
import com.qoomon.banking.TestUtils; | ||
import com.qoomon.banking.swift.message.block.exception.BlockParseException; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.Test; | ||
|
||
import java.io.StringReader; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
/** | ||
* Created by qoomon on 26/07/16. | ||
*/ | ||
public class SwiftBlockReaderTest { | ||
|
||
@Test | ||
public void readBlock_SHOULD_read_valid_blocks() throws Exception { | ||
// Given | ||
|
||
String blockText = "{1:a}{2:b}{3:c}"; | ||
|
||
SwiftBlockReader subjectUnderTest = new SwiftBlockReader(new StringReader(blockText)); | ||
|
||
// When | ||
List<GeneralBlock> blockList = TestUtils.collectUntilNull(subjectUnderTest::readBlock); | ||
|
||
// Then | ||
|
||
assertThat(blockList).hasSize(3); | ||
assertThat(blockList.get(0).getId()).isEqualTo("1"); | ||
assertThat(blockList.get(0).getContent()).isEqualTo("a"); | ||
assertThat(blockList.get(1).getId()).isEqualTo("2"); | ||
assertThat(blockList.get(1).getContent()).isEqualTo("b"); | ||
assertThat(blockList.get(2).getId()).isEqualTo("3"); | ||
assertThat(blockList.get(2).getContent()).isEqualTo("c"); | ||
|
||
} | ||
|
||
@Test | ||
public void readBlock_WHEN_unfinished_block_detected_THROW_exception() throws Exception { | ||
// Given | ||
|
||
String blockText = "{1:a}{2:b}{3:c"; | ||
|
||
SwiftBlockReader subjectUnderTest = new SwiftBlockReader(new StringReader(blockText)); | ||
|
||
// When | ||
Throwable exception = catchThrowable(() -> TestUtils.collectUntilNull(subjectUnderTest::readBlock)); | ||
|
||
// Then | ||
assertThat(exception).isInstanceOf(BlockParseException.class); | ||
} | ||
|
||
} |
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