Skip to content

Commit ba6b4e3

Browse files
committed
Update Gradle version and fix tests
1 parent ccf2130 commit ba6b4e3

2 files changed

Lines changed: 7 additions & 49 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/test/java/net/explorviz/code/analysis/git/GitRepositoryHandlerTest.java

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
import net.explorviz.code.analysis.types.RemoteRepositoryObject;
1515
import org.eclipse.jgit.api.errors.GitAPIException;
1616
import org.eclipse.jgit.api.errors.InvalidRemoteException;
17-
import org.eclipse.jgit.api.errors.TransportException;
1817
import org.eclipse.jgit.lib.ObjectId;
1918
import org.eclipse.jgit.lib.Repository;
2019
import org.eclipse.jgit.revwalk.RevCommit;
2120
import org.eclipse.jgit.revwalk.RevTree;
2221
import org.eclipse.jgit.revwalk.RevWalk;
23-
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
2422
import org.eclipse.jgit.treewalk.TreeWalk;
2523
import org.junit.jupiter.api.AfterEach;
2624
import org.junit.jupiter.api.Assertions;
@@ -34,13 +32,11 @@
3432
public class GitRepositoryHandlerTest {
3533

3634
private static final String MASTER = "master";
37-
private static final String MAIN = "main";
3835
private final String sshUrl = "git@gitlab.com:0xhexdec/busydoingnothing.git";
3936
private final String httpsUrl = "https://gitlab.com/0xhexdec/busydoingnothing.git";
40-
private final String gitlabUserName = "privateTestConnector";
41-
private final String gitlabUserPassword = "_QGDgx@2!sD/y!Y";
37+
4238
@Inject
43-
GitRepositoryHandler gitRepositoryHandler; // NOCS
39+
GitRepositoryHandler gitRepositoryHandler; // NOCS
4440
private File tempGitLocation;
4541

4642
@BeforeEach
@@ -58,7 +54,6 @@ void tearDown() {
5854
}
5955
}
6056

61-
6257
@Test()
6358
void testInvalidRemote() {
6459
String url = "%%%%";
@@ -113,40 +108,6 @@ void openRepository() throws GitAPIException, IOException {
113108

114109
}
115110

116-
117-
@Test()
118-
void testPrivateRemote() {
119-
final String url = "https://gitlab.com/0xhexdec/privaterepotest.git";
120-
121-
// try cloning without permission
122-
Assertions.assertThrows(TransportException.class, () -> {
123-
this.gitRepositoryHandler.getGitRepository("",
124-
new RemoteRepositoryObject(url, tempGitLocation.getAbsolutePath(), MASTER));
125-
});
126-
Assertions.assertThrows(TransportException.class, () -> {
127-
this.gitRepositoryHandler.getGitRepository("",
128-
new RemoteRepositoryObject(url, tempGitLocation.getAbsolutePath(),
129-
new UsernamePasswordCredentialsProvider(
130-
gitlabUserName, gitlabUserPassword), MASTER));
131-
});
132-
Assertions.assertThrows(TransportException.class, () -> {
133-
this.gitRepositoryHandler.getGitRepository("",
134-
new RemoteRepositoryObject(url, tempGitLocation.getAbsolutePath(),
135-
new UsernamePasswordCredentialsProvider(
136-
"username", "password"), MAIN));
137-
});
138-
139-
try (Repository repository = this.gitRepositoryHandler.getGitRepository("",
140-
new RemoteRepositoryObject(url, tempGitLocation.getAbsolutePath(),
141-
new UsernamePasswordCredentialsProvider(
142-
gitlabUserName, gitlabUserPassword), MAIN))) {
143-
repository.getBranch();
144-
} catch (Exception e) {
145-
Assertions.fail();
146-
}
147-
148-
}
149-
150111
@Test()
151112
void testSsh() {
152113
try (Repository repository = this.gitRepositoryHandler.getGitRepository("",
@@ -176,7 +137,6 @@ void testSshConversion() {
176137
Assertions.assertEquals(Map.entry(true, httpsUrl),
177138
GitRepositoryHandler.convertSshToHttps(httpsUrl));
178139

179-
180140
Assertions.assertEquals(Map.entry(true, httpsUrl),
181141
GitRepositoryHandler.convertSshToHttps(sshUrl));
182142

@@ -197,7 +157,6 @@ void testSshConversion() {
197157

198158
}
199159

200-
201160
@Test
202161
void testRemoteLookup() throws GitAPIException, IOException {
203162
try (Repository repository = this.gitRepositoryHandler.getGitRepository("",
@@ -229,11 +188,10 @@ void testGetStringifiedFileInCommit()
229188
while (treeWalk.next()) {
230189
final String actual = GitRepositoryHandler.getContent(treeWalk.getObjectId(0),
231190
repository);
232-
final String expected =
233-
"package testgit.my.test.pckg;\n" + "\n" + "public class TestGitClass {\n" + "\n"
234-
+ " private final String testVariable;\n" + "\n"
235-
+ " public TestGitClass(final String testVariable) {\n"
236-
+ " this.testVariable = testVariable;\n" + " }\n" + "\n" + "}";
191+
final String expected = "package testgit.my.test.pckg;\n" + "\n" + "public class TestGitClass {\n" + "\n"
192+
+ " private final String testVariable;\n" + "\n"
193+
+ " public TestGitClass(final String testVariable) {\n"
194+
+ " this.testVariable = testVariable;\n" + " }\n" + "\n" + "}";
237195

238196
Assertions.assertEquals(expected.replace(" ", "").replace("\n", "").replace("\r", ""),
239197
actual.replace(" ", "").replace("\n", "").replace("\r", ""));

0 commit comments

Comments
 (0)