From 06db1d5d4590a3709dd96a441e6f1b00567d10e5 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Thu, 7 Jan 2021 11:24:11 -0500 Subject: [PATCH] updated command test; ready for more tests in the future --- .../com/inteligr8/git/CommandUnitTest.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/inteligr8/git/CommandUnitTest.java b/src/test/java/com/inteligr8/git/CommandUnitTest.java index 565e69c..84be925 100644 --- a/src/test/java/com/inteligr8/git/CommandUnitTest.java +++ b/src/test/java/com/inteligr8/git/CommandUnitTest.java @@ -2,6 +2,7 @@ package com.inteligr8.git; import java.io.File; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.UUID; @@ -10,8 +11,6 @@ import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.ListBranchCommand.ListMode; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Ref; -import org.eclipse.jgit.transport.CredentialsProvider; -import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; import org.eclipse.jgit.util.FileUtils; import org.junit.AfterClass; import org.junit.Assert; @@ -19,9 +18,6 @@ import org.junit.BeforeClass; import org.junit.Test; public class CommandUnitTest { - - private final static CredentialsProvider gitCreds = new UsernamePasswordCredentialsProvider( - System.getProperty("git.username"), System.getProperty("git.token")); private static File tmpdir; private static Git git; @@ -31,8 +27,7 @@ public class CommandUnitTest { tmpdir = new File(System.getProperty("java.io.tmpdir"), "git-" + UUID.randomUUID().toString() + ".tmp"); git = new CloneCommand() - .setURI("git@github.com:bmlong137/env-docker-adbp.git") - .setCredentialsProvider(gitCreds) + .setURI("git@bitbucket.org:inteligr8/git-utils.git") .setDirectory(tmpdir) .call(); } @@ -45,10 +40,17 @@ public class CommandUnitTest { } @Test - public void lotsOfBranches() throws GitAPIException { + public void listOfBranches() throws GitAPIException, IOException { List remoteBranches = git.branchList().setListMode(ListMode.REMOTE).call(); Assert.assertNotNull(remoteBranches); - Assert.assertTrue(remoteBranches.size() > 5); + Assert.assertTrue(remoteBranches.contains(git.getRepository().findRef("origin/develop"))); + Assert.assertTrue(remoteBranches.contains(git.getRepository().findRef("origin/stable"))); + + List localBranches = git.branchList().call(); + Assert.assertNotNull(localBranches); + Assert.assertEquals(1, localBranches.size()); + + Assert.assertTrue(Collections.disjoint(remoteBranches, localBranches)); } }