Cleanup Code

Pushed-by: Rene Pfeuffer<rene.pfeuffer@cloudogu.com>
Co-authored-by: René Pfeuffer<rene.pfeuffer@cloudogu.com>
This commit is contained in:
Laura Gorzitze
2024-02-06 14:54:00 +01:00
parent b34a989c57
commit d8e1f2d739
910 changed files with 2670 additions and 19707 deletions

View File

@@ -40,9 +40,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
/**
* @author Sebastian Sdorra
*/
@RunWith(MockitoJUnitRunner.Silent.class)
public class GitRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase {

View File

@@ -32,7 +32,6 @@ import static org.junit.Assert.assertTrue;
/**
* Unit tests for {@link GitRepositoryPathMatcher}.
*
* @author Sebastian Sdorra
* @since 1.54
*/
public class GitRepositoryPathMatcherTest {

View File

@@ -24,38 +24,25 @@
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import org.junit.Test;
import static org.junit.Assert.*;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
public class GitSubModuleParserTest
{
/** Field description */
public static final String GITMODULES_001 =
"/sonia/scm/repository/gitmodules-001";
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @throws IOException
*/
@Test
public void testParse() throws IOException
{
@@ -74,18 +61,8 @@ public class GitSubModuleParserTest
repository.getRepositoryUrl());
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param resource
*
* @return
*
* @throws IOException
*/
private String getContent(String resource) throws IOException
{
InputStream input =
@@ -97,16 +74,7 @@ public class GitSubModuleParserTest
return new String(buffer);
}
/**
* Method description
*
*
* @param resource
*
* @return
*
* @throws IOException
*/
private Map<String, SubRepository> getSubRepositories(String resource)
throws IOException
{

View File

@@ -24,7 +24,6 @@
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import jakarta.servlet.http.HttpServletRequest;
import org.assertj.core.api.Assertions;
@@ -54,7 +53,6 @@ import static org.mockito.Mockito.when;
/**
* Unit tests for {@link GitUtil}.
*
* @author Sebastian Sdorra
*/
public class GitUtilTest
{

View File

@@ -41,7 +41,6 @@ import org.mockito.junit.MockitoJUnitRunner;
/**
* Unit tests for {@link GitHookBranchProvider}.
*
* @author Sebastian Sdorra
*/
@RunWith(MockitoJUnitRunner.class)
public class GitHookBranchProviderTest {

View File

@@ -58,7 +58,6 @@ import static org.mockito.Mockito.when;
/**
* Unit tests for {@link GitHookTagProvider}.
*
* @author Sebastian Sdorra
*/
@RunWith(MockitoJUnitRunner.class)
public class GitHookTagProviderTest {

View File

@@ -24,45 +24,26 @@
package sonia.scm.repository.client.spi;
//~--- non-JDK imports --------------------------------------------------------
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import sonia.scm.repository.client.api.RepositoryClientException;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
/**
*
* @author Sebastian Sdorra
*/
public class GitAddCommand implements AddCommand
{
/**
* Constructs ...
*
*
* @param git
*/
GitAddCommand(Git git)
{
this.git = git;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param path
*
* @throws IOException
*/
@Override
public void add(String path) throws IOException
{
@@ -78,6 +59,5 @@ public class GitAddCommand implements AddCommand
//~--- fields ---------------------------------------------------------------
/** Field description */
private Git git;
}

View File

@@ -24,7 +24,6 @@
package sonia.scm.repository.client.spi;
//~--- non-JDK imports --------------------------------------------------------
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
@@ -32,31 +31,20 @@ import org.eclipse.jgit.api.errors.GitAPIException;
import sonia.scm.repository.Branch;
import sonia.scm.repository.client.api.RepositoryClientException;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import org.eclipse.jgit.lib.Ref;
import sonia.scm.repository.GitUtil;
/**
*
* @author Sebastian Sdorra
*/
public class GitBranchCommand implements BranchCommand
{
/**
* Constructs ...
*
*
* @param git
*/
GitBranchCommand(Git git)
{
this.git = git;
}
//~--- methods --------------------------------------------------------------
@Override
public Branch branch(String name) throws IOException
@@ -74,6 +62,5 @@ public class GitBranchCommand implements BranchCommand
//~--- fields ---------------------------------------------------------------
/** Field description */
private Git git;
}

View File

@@ -24,7 +24,6 @@
package sonia.scm.repository.client.spi;
//~--- non-JDK imports --------------------------------------------------------
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
@@ -36,40 +35,20 @@ import sonia.scm.repository.GitChangesetConverterFactory;
import sonia.scm.repository.GitTestHelper;
import sonia.scm.repository.client.api.RepositoryClientException;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
/**
*
* @author Sebastian Sdorra
*/
public class GitCommitCommand implements CommitCommand
{
/**
* Constructs ...
*
*
* @param git
*/
GitCommitCommand(Git git)
{
this.git = git;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param request
*
* @return
*
* @throws IOException
*/
@Override
public Changeset commit(CommitRequest request) throws IOException
{
@@ -89,6 +68,5 @@ public class GitCommitCommand implements CommitCommand
//~--- fields ---------------------------------------------------------------
/** Field description */
private final Git git;
}

View File

@@ -24,7 +24,6 @@
package sonia.scm.repository.client.spi;
//~--- non-JDK imports --------------------------------------------------------
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
@@ -34,36 +33,19 @@ import sonia.scm.repository.client.api.RepositoryClientException;
import java.io.IOException;
import java.util.function.Supplier;
//~--- JDK imports ------------------------------------------------------------
/**
*
* @author Sebastian Sdorra
*/
public class GitPushCommand implements PushCommand
{
/**
* Constructs ...
*
*
* @param git
* @param credentialsProvider
*/
public GitPushCommand(Git git, CredentialsProvider credentialsProvider)
{
this.git = git;
this.credentialsProvider = credentialsProvider;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @throws IOException
*/
@Override
public void push() throws IOException {
push(() -> git.push().setPushAll());
@@ -96,9 +78,7 @@ public class GitPushCommand implements PushCommand
//~--- fields ---------------------------------------------------------------
/** Field description */
private CredentialsProvider credentialsProvider;
/** Field description */
private Git git;
}

View File

@@ -24,45 +24,26 @@
package sonia.scm.repository.client.spi;
//~--- non-JDK imports --------------------------------------------------------
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import sonia.scm.repository.client.api.RepositoryClientException;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
/**
*
* @author Sebastian Sdorra
*/
public class GitRemoveCommand implements RemoveCommand
{
/**
* Constructs ...
*
*
* @param git
*/
GitRemoveCommand(Git git)
{
this.git = git;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param path
*
* @throws IOException
*/
@Override
public void remove(String path) throws IOException
{
@@ -78,6 +59,5 @@ public class GitRemoveCommand implements RemoveCommand
//~--- fields ---------------------------------------------------------------
/** Field description */
private Git git;
}

View File

@@ -24,7 +24,6 @@
package sonia.scm.repository.client.spi;
//~--- non-JDK imports --------------------------------------------------------
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
@@ -34,15 +33,10 @@ import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import sonia.scm.repository.GitRepositoryHandler;
import sonia.scm.repository.client.api.RepositoryClientException;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
import java.io.IOException;
/**
*
* @author Sebastian Sdorra
*/
public class GitRepositoryClientFactoryProvider
implements RepositoryClientFactoryProvider
{
@@ -118,14 +112,8 @@ public class GitRepositoryClientFactoryProvider
return new GitRepositoryClientProvider(git, credentialsProvider);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getType()
{

View File

@@ -24,7 +24,6 @@
package sonia.scm.repository.client.spi;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.collect.ImmutableSet;
import org.eclipse.jgit.api.Git;
@@ -36,82 +35,46 @@ import java.io.File;
import java.io.IOException;
import java.util.Set;
//~--- JDK imports ------------------------------------------------------------
/**
*
* @author Sebastian Sdorra
*/
public class GitRepositoryClientProvider extends RepositoryClientProvider
{
/** Field description */
private static final Set<ClientCommand> SUPPORTED_COMMANDS =
ImmutableSet.of(ClientCommand.ADD, ClientCommand.REMOVE,
ClientCommand.COMMIT, ClientCommand.TAG, ClientCommand.BRANCH,
ClientCommand.DELETE_REMOTE_BRANCH, ClientCommand.MERGE, ClientCommand.PUSH);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param git
* @param credentialsProvider
*/
GitRepositoryClientProvider(Git git)
{
this(git, null);
}
/**
* Constructs ...
*
*
* @param git
* @param credentialsProvider
*/
GitRepositoryClientProvider(Git git, CredentialsProvider credentialsProvider)
{
this.git = git;
this.credentialsProvider = credentialsProvider;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @throws IOException
*/
@Override
public void close() throws IOException
{
GitUtil.close(git.getRepository());
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public AddCommand getAddCommand()
{
return new GitAddCommand(git);
}
/**
* Method description
*
*
* @return
*/
@Override
public BranchCommand getBranchCommand()
{
@@ -128,60 +91,35 @@ public class GitRepositoryClientProvider extends RepositoryClientProvider
return new GitCheckoutCommand(git);
}
/**
* Method description
*
*
* @return
*/
@Override
public CommitCommand getCommitCommand()
{
return new GitCommitCommand(git);
}
/**
* Method description
*
*
* @return
*/
@Override
public PushCommand getPushCommand()
{
return new GitPushCommand(git, credentialsProvider);
}
/**
* Method description
*
*
* @return
*/
@Override
public RemoveCommand getRemoveCommand()
{
return new GitRemoveCommand(git);
}
/**
* Method description
*
*
* @return
*/
@Override
public Set<ClientCommand> getSupportedClientCommands()
{
return SUPPORTED_COMMANDS;
}
/**
* Method description
*
*
* @return
*/
@Override
public TagCommand getTagCommand()
{
@@ -200,9 +138,7 @@ public class GitRepositoryClientProvider extends RepositoryClientProvider
//~--- fields ---------------------------------------------------------------
/** Field description */
private CredentialsProvider credentialsProvider;
/** Field description */
private Git git;
}

View File

@@ -24,7 +24,6 @@
package sonia.scm.repository.client.spi;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Strings;
import org.eclipse.jgit.api.Git;
@@ -39,38 +38,18 @@ import sonia.scm.repository.client.api.RepositoryClientException;
import java.io.IOException;
//~--- JDK imports ------------------------------------------------------------
/**
*
* @author Sebastian Sdorra
*/
public class GitTagCommand implements TagCommand
{
/**
* Constructs ...
*
*
* @param git
*/
GitTagCommand(Git git)
{
this.git = git;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param request
*
* @return
*
* @throws IOException
*/
@Override
public Tag tag(TagRequest request) throws IOException
{
@@ -128,6 +107,5 @@ public class GitTagCommand implements TagCommand
//~--- fields ---------------------------------------------------------------
/** Field description */
private Git git;
}

View File

@@ -24,7 +24,6 @@
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import org.junit.After;
import sonia.scm.api.v2.resources.GitRepositoryConfigStoreProvider;
@@ -32,18 +31,11 @@ import sonia.scm.repository.GitConfig;
import sonia.scm.repository.GitRepositoryConfig;
import sonia.scm.store.InMemoryConfigurationStoreFactory;
/**
*
* @author Sebastian Sdorra
*/
public class AbstractGitCommandTestBase extends ZippedRepositoryTestBase
{
/**
* Method description
*
*/
@After
@After
public void close()
{
if (context != null) {
@@ -52,12 +44,7 @@ public class AbstractGitCommandTestBase extends ZippedRepositoryTestBase
}
}
/**
* Method description
*
*
* @return
*/
protected GitContext createContext()
{
if (context == null)
@@ -68,26 +55,15 @@ public class AbstractGitCommandTestBase extends ZippedRepositoryTestBase
return context;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
protected String getType()
{
return "git";
}
/**
* Method description
*
*
* @return
*/
@Override
protected String getZippedRepositoryResource()
{
@@ -96,6 +72,5 @@ public class AbstractGitCommandTestBase extends ZippedRepositoryTestBase
//~--- fields ---------------------------------------------------------------
/** Field description */
private GitContext context;
}

View File

@@ -24,7 +24,6 @@
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Charsets;
import com.google.common.io.Files;
@@ -53,11 +52,7 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
//~--- JDK imports ------------------------------------------------------------
/**
* @author Sebastian Sdorra
*/
public class AbstractRemoteCommandTestBase {
/**
@@ -97,7 +92,6 @@ public class AbstractRemoteCommandTestBase {
Transport.unregister(proto);
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
@@ -110,7 +104,6 @@ public class AbstractRemoteCommandTestBase {
Transport.register(proto);
}
//~--- methods --------------------------------------------------------------
/**
* Method description
@@ -127,14 +120,7 @@ public class AbstractRemoteCommandTestBase {
assertEquals(expected.getShortMessage(), actual.getDescription());
}
/**
* Method description
*
* @param git
* @param message
* @return
* @throws GitAPIException
*/
protected RevCommit commit(Git git, String message) throws GitAPIException {
User trillian = UserTestData.createTrillian();
CommitCommand cc = git.commit();
@@ -165,50 +151,32 @@ public class AbstractRemoteCommandTestBase {
//~--- fields ---------------------------------------------------------------
/**
* Field description
*/
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
/**
* Field description
*/
protected GitRepositoryHandler handler;
/**
* Field description
*/
protected Repository incomingRepository;
/**
* Field description
*/
protected Git incoming;
/**
* Field description
*/
protected File incomingDirectory;
/**
* Field description
*/
protected Git outgoing;
/**
* Field description
*/
protected File outgoingDirectory;
/**
* Field description
*/
protected Repository outgoingRepository;
/**
* Field description
*/
private ScmTransportProtocol proto;
protected ScmEventBus eventBus;

View File

@@ -24,7 +24,6 @@
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import org.junit.Test;
import sonia.scm.repository.BlameLine;
@@ -36,12 +35,9 @@ import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
//~--- JDK imports ------------------------------------------------------------
/**
* Unit tests for {@link GitBlameCommand}.
*
* @author Sebastian Sdorra
*/
public class GitBlameCommandTest extends AbstractGitCommandTestBase
{
@@ -72,12 +68,7 @@ public class GitBlameCommandTest extends AbstractGitCommandTestBase
assertEquals("3f76a12f08a6ba0dc988c68b7f0b2cd190efc3c4", result.getLine(0).getRevision());
}
/**
* Method description
*
*
* @throws IOException
*/
@Test
public void testGetBlameResult() throws IOException
{
@@ -105,12 +96,7 @@ public class GitBlameCommandTest extends AbstractGitCommandTestBase
line.getAuthor().getMail());
}
/**
* Method description
*
*
* @throws IOException
*/
@Test
public void testGetBlameResultWithRevision()
throws IOException
@@ -130,12 +116,7 @@ public class GitBlameCommandTest extends AbstractGitCommandTestBase
checkFirstLine(line);
}
/**
* Method description
*
*
* @param line
*/
private void checkFirstLine(BlameLine line)
{
assertEquals(1, line.getLineNumber());
@@ -148,12 +129,7 @@ public class GitBlameCommandTest extends AbstractGitCommandTestBase
assertEquals("douglas.adams@hitchhiker.com", line.getAuthor().getMail());
}
/**
* Method description
*
*
* @return
*/
private GitBlameCommand createCommand()
{
return new GitBlameCommand(createContext());

View File

@@ -52,7 +52,6 @@ import static sonia.scm.repository.spi.SyncAsyncExecutors.synchronousExecutor;
/**
* Unit tests for {@link GitBrowseCommand}.
*
* @author Sebastian Sdorra
*/
public class GitBrowseCommandTest extends AbstractGitCommandTestBase {

View File

@@ -38,7 +38,6 @@ import static sonia.scm.repository.spi.SyncAsyncExecutors.synchronousExecutor;
/**
* Unit tests for {@link GitBrowseCommand}.
*
* @author Sebastian Sdorra
*/
public class GitBrowseCommand_RecursiveDirectoryNameTest extends AbstractGitCommandTestBase {

View File

@@ -49,7 +49,6 @@ import static org.mockito.Mockito.when;
*
* TODO add not found test
*
* @author Sebastian Sdorra
*/
public class GitCatCommandTest extends AbstractGitCommandTestBase {

View File

@@ -41,9 +41,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
/**
* @author Sebastian Sdorra
*/
public class GitIncomingCommandTest
extends AbstractRemoteCommandTestBase {

View File

@@ -55,7 +55,6 @@ import static org.junit.Assert.assertNotNull;
* * 36b19e4 b
* * c2190a9 a
* </pre>
* @author Sebastian Sdorra
*/
public class GitLogCommandAncestorTest extends AbstractGitCommandTestBase
{

View File

@@ -55,7 +55,6 @@ import static org.mockito.Mockito.when;
/**
* Unit tests for {@link GitLogCommand}.
*
* @author Sebastian Sdorra
*/
@RunWith(MockitoJUnitRunner.class)
public class GitLogCommandTest extends AbstractGitCommandTestBase

View File

@@ -24,7 +24,6 @@
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -40,12 +39,9 @@ import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
//~--- JDK imports ------------------------------------------------------------
/**
* Unit tests for {@link OutgoingCommand}.
*
* @author Sebastian Sdorra
*/
public class GitOutgoingCommandTest extends AbstractRemoteCommandTestBase
{
@@ -123,12 +119,7 @@ public class GitOutgoingCommandTest extends AbstractRemoteCommandTestBase
assertCommitsEquals(c2, cpr.getChangesets().get(0));
}
/**
* Method description
*
*
* @throws IOException
*/
@Test
public void testGetOutgoingChangesetsWithEmptyRepository()
throws IOException
@@ -145,12 +136,7 @@ public class GitOutgoingCommandTest extends AbstractRemoteCommandTestBase
assertEquals(0, cpr.getTotal());
}
/**
* Method description
*
*
* @return
*/
private GitOutgoingCommand createCommand()
{
return new GitOutgoingCommand(

View File

@@ -24,7 +24,6 @@
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -41,12 +40,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
//~--- JDK imports ------------------------------------------------------------
/**
*
* @author Sebastian Sdorra
*/
public class GitPushCommandTest extends AbstractRemoteCommandTestBase
{
@@ -130,12 +124,7 @@ public class GitPushCommandTest extends AbstractRemoteCommandTestBase
assertThat(commits.hasNext()).isFalse();
}
/**
* Method description
*
*
* @return
*/
private GitPushCommand createCommand()
{
return new GitPushCommand(handler, new GitContext(outgoingDirectory, outgoingRepository, null, new GitConfig()));

View File

@@ -24,14 +24,11 @@
package sonia.scm.web;
//~--- non-JDK imports --------------------------------------------------------
import org.junit.Test;
import static org.junit.Assert.*;
//~--- JDK imports ------------------------------------------------------------
/**
* Unit tests for {@link GitUserAgentProvider}.
*

View File

@@ -42,7 +42,6 @@ import static org.mockito.Mockito.when;
/**
* Unit tests for {@link LfsBlobStoreFactory}.
*
* @author Sebastian Sdorra
*/
@RunWith(MockitoJUnitRunner.class)
public class LfsBlobStoreFactoryTest {