From d643a384ecb0bd95858c294fd7946e32c5dbb197 Mon Sep 17 00:00:00 2001 From: Denis Gribanov Date: Fri, 5 Jan 2018 21:32:33 +0300 Subject: [PATCH] test update, ENoVersionFile is thrown if version file is missing in develop branch --- .../org/scm4j/releaser/branch/DevelopBranch.java | 4 ++-- .../scm4j/releaser/exceptions/ENoVersionFile.java | 11 +++++++++++ .../org/scm4j/releaser/branch/DevelopBranchTest.java | 12 ++++++------ 3 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 src/main/java/org/scm4j/releaser/exceptions/ENoVersionFile.java diff --git a/src/main/java/org/scm4j/releaser/branch/DevelopBranch.java b/src/main/java/org/scm4j/releaser/branch/DevelopBranch.java index a15269a1..e041467a 100644 --- a/src/main/java/org/scm4j/releaser/branch/DevelopBranch.java +++ b/src/main/java/org/scm4j/releaser/branch/DevelopBranch.java @@ -5,7 +5,7 @@ import org.scm4j.releaser.Utils; import org.scm4j.releaser.conf.Component; import org.scm4j.releaser.conf.VCSRepository; -import org.scm4j.releaser.exceptions.EComponentConfigNoUrl; +import org.scm4j.releaser.exceptions.ENoVersionFile; import org.scm4j.vcs.api.VCSCommit; import org.scm4j.vcs.api.exceptions.EVCSFileNotFound; @@ -35,7 +35,7 @@ public Version getVersion() { String verFileContent = repo.getVCS().getFileContent(repo.getDevelopBranch(), Utils.VER_FILE_NAME, null); return new Version(verFileContent.trim()); } catch (EVCSFileNotFound e) { - throw new EComponentConfigNoUrl(Utils.VER_FILE_NAME + " file is missing in develop branch of " + comp); + throw new ENoVersionFile(comp); } } } diff --git a/src/main/java/org/scm4j/releaser/exceptions/ENoVersionFile.java b/src/main/java/org/scm4j/releaser/exceptions/ENoVersionFile.java new file mode 100644 index 00000000..b924a147 --- /dev/null +++ b/src/main/java/org/scm4j/releaser/exceptions/ENoVersionFile.java @@ -0,0 +1,11 @@ +package org.scm4j.releaser.exceptions; + +import org.scm4j.releaser.Utils; +import org.scm4j.releaser.conf.Component; + +public class ENoVersionFile extends EReleaserException { + + public ENoVersionFile(Component comp) { + super(Utils.VER_FILE_NAME + " file is missing in develop branch of " + comp); + } +} diff --git a/src/test/java/org/scm4j/releaser/branch/DevelopBranchTest.java b/src/test/java/org/scm4j/releaser/branch/DevelopBranchTest.java index 37dbb2c8..17105301 100644 --- a/src/test/java/org/scm4j/releaser/branch/DevelopBranchTest.java +++ b/src/test/java/org/scm4j/releaser/branch/DevelopBranchTest.java @@ -1,11 +1,11 @@ package org.scm4j.releaser.branch; import org.junit.Test; -import org.scm4j.releaser.testutils.TestEnvironment; import org.scm4j.releaser.Utils; import org.scm4j.releaser.conf.Component; import org.scm4j.releaser.conf.VCSRepository; -import org.scm4j.releaser.exceptions.EComponentConfigNoUrl; +import org.scm4j.releaser.exceptions.ENoVersionFile; +import org.scm4j.releaser.testutils.TestEnvironment; import org.scm4j.vcs.api.IVCS; import java.util.ArrayList; @@ -13,7 +13,8 @@ import static org.junit.Assert.*; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; public class DevelopBranchTest { @@ -32,7 +33,7 @@ public void testIsNotModifiedIfNoCommits() throws Exception { } @Test - public void testGetVersionIfNoVersionFile() throws Exception { + public void testNoVersionFileExcetpion() throws Exception { try (TestEnvironment env = new TestEnvironment()) { env.generateTestEnvironment(); Component comp = new Component(TestEnvironment.PRODUCT_UNTILL); @@ -42,8 +43,7 @@ public void testGetVersionIfNoVersionFile() throws Exception { try { db.getVersion(); fail(); - } catch (EComponentConfigNoUrl e) { - + } catch (ENoVersionFile e) { } } }