Skip to content

Commit

Permalink
Merge pull request #141 from kmwtechnology/LC-504
Browse files Browse the repository at this point in the history
LC-504: fixes issue of file creation
akul-sethi authored Jun 19, 2024
2 parents 44dd9bc + f6b903f commit 883d5ab
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
import org.junit.Test;
import org.mockito.MockedConstruction;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Set;

@@ -40,7 +41,8 @@ public void testGetLegalProperties() throws StageException {

@Test
public void testStop() throws Exception {
try (MockedConstruction<BufferedWriter> mockedConstruction = mockConstruction(BufferedWriter.class)) {
try (MockedConstruction<BufferedWriter> mockedConstruction = mockConstruction(BufferedWriter.class);
MockedConstruction<FileWriter> mockedWriter = mockConstruction(FileWriter.class)) {
Stage stage = factory.get("PrintTest/full.conf");
stage.stop();
verify(mockedConstruction.constructed().get(0)).close();
@@ -51,7 +53,7 @@ public void testStop() throws Exception {
public void testStopThrows() throws Exception {
try (MockedConstruction<BufferedWriter> mockedConstruction = mockConstruction(BufferedWriter.class, (mock, context) -> {
doThrow(IOException.class).when(mock).close();
})) {
}); MockedConstruction<FileWriter> mockedWriter = mockConstruction(FileWriter.class)) {
Stage stage = factory.get("PrintTest/full.conf");
assertThrows(StageException.class, () -> stage.stop());
}
@@ -61,7 +63,7 @@ public void testStopThrows() throws Exception {
public void testAppendThrows() throws StageException {
try (MockedConstruction<BufferedWriter> mockedConstruction = mockConstruction(BufferedWriter.class, (mock, context) -> {
doThrow(IOException.class).when(mock).append(any());
})) {
}); MockedConstruction<FileWriter> mockedWriter = mockConstruction(FileWriter.class)) {
Stage stage = factory.get("PrintTest/full.conf");
assertThrows(StageException.class, () -> stage.processDocument(Document.create("foo")));
}

0 comments on commit 883d5ab

Please sign in to comment.