Skip to content

Commit 1cd92fd

Browse files
committed
Refactor
1 parent 125eaa4 commit 1cd92fd

File tree

6 files changed

+13
-33
lines changed

6 files changed

+13
-33
lines changed

.gitignore

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
1212
hs_err_pid*
13-
/.gradle/
14-
/.settings
15-
/.classpath
16-
/.project
17-
/build/
18-
/bin/
13+
/.*
14+
/build/
15+
/bin/
16+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Features:
6969

7070
# Functional testing
7171
- New local file-based Test Repository is created before each test and deletes automatically after each test
72-
- To execute tests just run GitVCSTest class as JUnit test. Tests from VCSAbstractTest class will be executed. See [pk-vcs-test](https://github.com/ProjectKaiser/pk-vcs-test) for details
72+
- To execute tests just run GitVCSTest class as JUnit test. Tests from VCSAbstractTest class will be executed. See [pk-vcs-test](https://github.com/ProjectKaiser/pk-vcs-test) for details
7373
- Run `gradle test` to execute tests
7474

7575
# Limitations

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ repositories {
1616

1717
dependencies {
1818
compile 'com.github.ProjectKaiser:master-SNAPSHOT'
19-
compile 'commons-logging:commons-logging:1.2'
2019
compile 'org.eclipse.jgit:org.eclipse.jgit:4.3.0.201604071810-r'
2120

2221
testCompile 'org.mockito:mockito-core:2.0.62-beta'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Apr 22 10:26:49 GMT+03:00 2016
1+
#Tue Mar 28 23:38:07 MSK 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
import java.net.SocketAddress;
1212
import java.net.URI;
1313
import java.nio.charset.StandardCharsets;
14-
import java.util.ArrayList;
15-
import java.util.Arrays;
16-
import java.util.HashSet;
17-
import java.util.List;
18-
import java.util.Set;
14+
import java.util.*;
1915

2016
import org.apache.commons.io.FileUtils;
2117
import org.apache.commons.io.IOUtils;
@@ -59,7 +55,7 @@ public class GitVCS implements IVCS {
5955
private static final String REFS_REMOTES_ORIGIN = Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/";
6056

6157
private CredentialsProvider credentials;
62-
private IVCSRepositoryWorkspace repo;
58+
private final IVCSRepositoryWorkspace repo;
6359

6460
public CredentialsProvider getCredentials() {
6561
return credentials;
@@ -269,10 +265,10 @@ public void setProxy(final String host, final int port, String proxyUser, String
269265
@Override
270266
public List<Proxy> select(URI uri) {
271267
if (uri.toString().toLowerCase().contains(repo.getRepoUrl().toLowerCase())) {
272-
return Arrays.asList(new Proxy(Type.HTTP, InetSocketAddress
273-
.createUnresolved(host, port)));
268+
return Collections.singletonList(new Proxy(Type.HTTP, InetSocketAddress
269+
.createUnresolved(host, port)));
274270
} else {
275-
return delegate == null ? Arrays.asList(Proxy.NO_PROXY)
271+
return delegate == null ? Collections.singletonList(Proxy.NO_PROXY)
276272
: delegate.select(uri);
277273
}
278274
}

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,10 @@
1818
import com.projectkaiser.scm.vcs.api.workingcopy.IVCSRepositoryWorkspace;
1919

2020
public class GitVCSTest extends VCSAbstractTest {
21-
22-
private static final String GITHUB_USER = System.getProperty("PK_VCS_TEST_GITHUB_USER") == null ?
23-
System.getenv("PK_VCS_TEST_GITHUB_USER") : System.getProperty("PK_VCS_TEST_GITHUB_USER");
24-
private static final String GITHUB_PASS = System.getProperty("PK_VCS_TEST_GITHUB_PASS") == null ?
25-
System.getenv("PK_VCS_TEST_GITHUB_PASS") : System.getProperty("PK_VCS_TEST_GITHUB_PASS");
2621

27-
private Git mockedGit;
2822
private Repository localGitRepo;
2923
private RuntimeException testGitResetException = new RuntimeException("test exeption on git.reset()");
3024

31-
@BeforeClass
32-
public static void setUpClass() {
33-
assertTrue("Set PK_VCS_TEST_GITHUB_USER enviroment variable as user name of a valid github account to execute tests.",
34-
GITHUB_USER != null);
35-
assertTrue("Set PK_VCS_TEST_GITHUB_PASS enviroment variable as user password of a valid github account to execute tests.",
36-
GITHUB_PASS != null);
37-
}
38-
3925
@Override
4026
public void setUp() throws Exception {
4127
super.setUp();
@@ -70,6 +56,7 @@ protected IVCS getVCS(IVCSRepositoryWorkspace mockedVCSRepo) {
7056

7157
@Override
7258
protected void setMakeFailureOnVCSReset(Boolean doMakeFailure) {
59+
Git mockedGit;
7360
if (doMakeFailure) {
7461
mockedGit = Mockito.spy(((GitVCS) vcs).getLocalGit(mockedLWC));
7562
Mockito.doReturn(mockedGit).when((GitVCS) vcs).getLocalGit(mockedLWC);

0 commit comments

Comments
 (0)