Skip to content

Commit a89aa02

Browse files
author
Denis
committed
EVCSFileNotFound is used in tests
1 parent e1e888d commit a89aa02

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main/java/com/projectkaiser/scm/vcs/GitVCS.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.projectkaiser.scm.vcs.api.VCSWorkspace;
3333
import com.projectkaiser.scm.vcs.api.exceptions.EVCSBranchExists;
3434
import com.projectkaiser.scm.vcs.api.exceptions.EVCSException;
35+
import com.projectkaiser.scm.vcs.api.exceptions.EVCSFileNotFound;
3536

3637
public class GitVCS extends AbstractVCS implements IVCS {
3738

@@ -307,6 +308,8 @@ public String getFileContent(String branchName, String filePath, String encoding
307308
}
308309
} catch (GitAPIException e) {
309310
throw new EVCSException(e);
311+
} catch (IOException e) {
312+
throw new EVCSFileNotFound(String.format("File %s is not found", filePath));
310313
} catch (Exception e) {
311314
throw new RuntimeException(e);
312315
}

src/test/java/com/projectkaiser/scm/vcs/GitVCSTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
import com.projectkaiser.scm.vcs.api.IVCS;
2727
import com.projectkaiser.scm.vcs.api.PKVCSMergeResult;
2828
import com.projectkaiser.scm.vcs.api.VCSWorkspace;
29+
import com.projectkaiser.scm.vcs.api.VCSWorkspaceState;
2930
import com.projectkaiser.scm.vcs.api.exceptions.EVCSBranchExists;
31+
import com.projectkaiser.scm.vcs.api.exceptions.EVCSFileNotFound;
3032

3133
public class GitVCSTest {
3234

@@ -184,7 +186,12 @@ public void testGetSetFileContent() throws NoFilepatternException, GitAPIExcepti
184186

185187
assertEquals(vcs.getFileContent("master", "folder/file1.txt"), LINE_2);
186188
assertEquals(vcs.getFileContent("master", "folder/file1.txt", "UTF-8"), LINE_2);
187-
189+
try {
190+
vcs.getFileContent("master", "sdfsdf1.txt");
191+
fail("EVCSFileNotFound is not thrown");
192+
} catch (EVCSFileNotFound e) {
193+
w.unlock();
194+
}
188195
}
189196
} finally {
190197
w.unlock();

0 commit comments

Comments
 (0)