mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
Replace model object exception with generic ones and migrate guice
This commit is contained in:
@@ -36,17 +36,16 @@ package sonia.scm.repository.spi;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.BlameLine;
|
||||
import sonia.scm.repository.BlameResult;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -54,16 +53,8 @@ import java.io.IOException;
|
||||
public class HgBlameCommandTest extends AbstractHgCommandTestBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetBlameResult() throws IOException, RepositoryException
|
||||
{
|
||||
public void testGetBlameResult() throws IOException {
|
||||
BlameCommandRequest request = new BlameCommandRequest();
|
||||
|
||||
request.setPath("a.txt");
|
||||
@@ -87,17 +78,8 @@ public class HgBlameCommandTest extends AbstractHgCommandTestBase
|
||||
line.getAuthor().getMail());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetBlameResultWithRevision()
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
public void testGetBlameResultWithRevision() throws IOException {
|
||||
BlameCommandRequest request = new BlameCommandRequest();
|
||||
|
||||
request.setPath("a.txt");
|
||||
|
||||
@@ -36,19 +36,20 @@ package sonia.scm.repository.spi;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.BrowserResult;
|
||||
import sonia.scm.repository.FileObject;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -56,16 +57,8 @@ import java.util.List;
|
||||
public class HgBrowseCommandTest extends AbstractHgCommandTestBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testBrowse() throws IOException, RepositoryException
|
||||
{
|
||||
public void testBrowse() throws IOException {
|
||||
List<FileObject> foList = getRootFromTip(new BrowseCommandRequest());
|
||||
FileObject a = getFileObject(foList, "a.txt");
|
||||
FileObject c = getFileObject(foList, "c");
|
||||
@@ -81,16 +74,8 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase
|
||||
assertEquals("c", c.getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testBrowseSubDirectory() throws IOException, RepositoryException
|
||||
{
|
||||
public void testBrowseSubDirectory() throws IOException {
|
||||
BrowseCommandRequest request = new BrowseCommandRequest();
|
||||
|
||||
request.setPath("c");
|
||||
@@ -137,16 +122,8 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase
|
||||
checkDate(e.getLastModified());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testDisableLastCommit() throws IOException, RepositoryException
|
||||
{
|
||||
public void testDisableLastCommit() throws IOException {
|
||||
BrowseCommandRequest request = new BrowseCommandRequest();
|
||||
|
||||
request.setDisableLastCommit(true);
|
||||
@@ -159,16 +136,8 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase
|
||||
assertNull(a.getLastModified());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testRecursive() throws IOException, RepositoryException
|
||||
{
|
||||
public void testRecursive() throws IOException {
|
||||
BrowseCommandRequest request = new BrowseCommandRequest();
|
||||
|
||||
request.setRecursive(true);
|
||||
@@ -215,20 +184,7 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
private List<FileObject> getRootFromTip(BrowseCommandRequest request)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
private List<FileObject> getRootFromTip(BrowseCommandRequest request) throws IOException {
|
||||
BrowserResult result = new HgBrowseCommand(cmdContext,
|
||||
repository).getBrowserResult(request);
|
||||
|
||||
|
||||
@@ -33,8 +33,10 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.NotFoundException;
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -45,7 +47,7 @@ import static org.junit.Assert.assertEquals;
|
||||
public class HgCatCommandTest extends AbstractHgCommandTestBase {
|
||||
|
||||
@Test
|
||||
public void testCat() throws IOException, RepositoryException {
|
||||
public void testCat() throws IOException {
|
||||
CatCommandRequest request = new CatCommandRequest();
|
||||
|
||||
request.setPath("a.txt");
|
||||
@@ -54,23 +56,24 @@ public class HgCatCommandTest extends AbstractHgCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleCat() throws IOException, RepositoryException {
|
||||
public void testSimpleCat() throws IOException {
|
||||
CatCommandRequest request = new CatCommandRequest();
|
||||
|
||||
request.setPath("b.txt");
|
||||
assertEquals("b", execute(request));
|
||||
}
|
||||
|
||||
@Test(expected = RepositoryException.class)
|
||||
public void testUnknownFile() throws IOException, RepositoryException {
|
||||
@Test(expected = InternalRepositoryException.class)
|
||||
public void testUnknownFile() throws IOException {
|
||||
CatCommandRequest request = new CatCommandRequest();
|
||||
|
||||
request.setPath("unknown");
|
||||
execute(request);
|
||||
}
|
||||
|
||||
@Test(expected = RepositoryException.class)
|
||||
public void testUnknownRevision() throws IOException, RepositoryException {
|
||||
@Test(expected = NotFoundException.class)
|
||||
@Ignore("detection of unknown revision in hg not yet implemented")
|
||||
public void testUnknownRevision() throws IOException {
|
||||
CatCommandRequest request = new CatCommandRequest();
|
||||
|
||||
request.setRevision("abc");
|
||||
@@ -79,7 +82,7 @@ public class HgCatCommandTest extends AbstractHgCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleStream() throws IOException, RepositoryException {
|
||||
public void testSimpleStream() throws IOException {
|
||||
CatCommandRequest request = new CatCommandRequest();
|
||||
request.setPath("b.txt");
|
||||
|
||||
@@ -92,7 +95,7 @@ public class HgCatCommandTest extends AbstractHgCommandTestBase {
|
||||
catResultStream.close();
|
||||
}
|
||||
|
||||
private String execute(CatCommandRequest request) throws IOException, RepositoryException {
|
||||
private String execute(CatCommandRequest request) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
new HgCatCommand(cmdContext, repository).getCatResult(request, baos);
|
||||
return baos.toString().trim();
|
||||
|
||||
@@ -35,19 +35,18 @@ package sonia.scm.repository.spi;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.aragost.javahg.Changeset;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.HgTestUtil;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -60,12 +59,9 @@ public class HgIncomingCommandTest extends IncomingOutgoingTestBase
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetIncomingChangesets()
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
public void testGetIncomingChangesets() throws IOException {
|
||||
writeNewFile(outgoing, outgoingDirectory, "a.txt", "Content of file a.txt");
|
||||
writeNewFile(outgoing, outgoingDirectory, "b.txt", "Content of file b.txt");
|
||||
|
||||
@@ -89,16 +85,8 @@ public class HgIncomingCommandTest extends IncomingOutgoingTestBase
|
||||
assertChangesetsEqual(c2, cpr.getChangesets().get(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetIncomingChangesetsWithEmptyRepository()
|
||||
throws RepositoryException
|
||||
{
|
||||
public void testGetIncomingChangesetsWithEmptyRepository() {
|
||||
HgIncomingCommand cmd = createIncomingCommand();
|
||||
IncomingCommandRequest request = new IncomingCommandRequest();
|
||||
|
||||
@@ -110,17 +98,8 @@ public class HgIncomingCommandTest extends IncomingOutgoingTestBase
|
||||
assertEquals(0, cpr.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test(expected = RepositoryException.class)
|
||||
public void testGetIncomingChangesetsWithUnrelatedRepository()
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
@Test(expected = InternalRepositoryException.class)
|
||||
public void testGetIncomingChangesetsWithUnrelatedRepository() throws IOException {
|
||||
writeNewFile(outgoing, outgoingDirectory, "a.txt", "Content of file a.txt");
|
||||
writeNewFile(outgoing, outgoingDirectory, "b.txt", "Content of file b.txt");
|
||||
|
||||
|
||||
@@ -36,20 +36,19 @@ package sonia.scm.repository.spi;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.Modifications;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -57,16 +56,8 @@ import java.io.IOException;
|
||||
public class HgLogCommandTest extends AbstractHgCommandTestBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetAll() throws IOException, RepositoryException
|
||||
{
|
||||
public void testGetAll() {
|
||||
ChangesetPagingResult result =
|
||||
createComamnd().getChangesets(new LogCommandRequest());
|
||||
|
||||
@@ -75,16 +66,8 @@ public class HgLogCommandTest extends AbstractHgCommandTestBase
|
||||
assertEquals(5, result.getChangesets().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetAllByPath() throws IOException, RepositoryException
|
||||
{
|
||||
public void testGetAllByPath() {
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
request.setPath("a.txt");
|
||||
@@ -102,16 +85,8 @@ public class HgLogCommandTest extends AbstractHgCommandTestBase
|
||||
result.getChangesets().get(2).getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetAllWithLimit() throws IOException, RepositoryException
|
||||
{
|
||||
public void testGetAllWithLimit() {
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
request.setPagingLimit(2);
|
||||
@@ -133,16 +108,8 @@ public class HgLogCommandTest extends AbstractHgCommandTestBase
|
||||
assertEquals("542bf4893dd2ff58a0eb719551d75ddeb919608b", c2.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetAllWithPaging() throws IOException, RepositoryException
|
||||
{
|
||||
public void testGetAllWithPaging() {
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
request.setPagingStart(1);
|
||||
@@ -165,16 +132,8 @@ public class HgLogCommandTest extends AbstractHgCommandTestBase
|
||||
assertEquals("79b6baf49711ae675568e0698d730b97ef13e84a", c2.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetCommit() throws IOException, RepositoryException
|
||||
{
|
||||
public void testGetCommit() {
|
||||
HgLogCommand command = createComamnd();
|
||||
Changeset c =
|
||||
command.getChangeset("a9bacaf1b7fa0cebfca71fed4e59ed69a6319427");
|
||||
@@ -197,16 +156,8 @@ public class HgLogCommandTest extends AbstractHgCommandTestBase
|
||||
assertThat(mods.getAdded(), contains("a.txt", "b.txt"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetRange() throws IOException, RepositoryException
|
||||
{
|
||||
public void testGetRange() {
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
request.setStartChangeset("3049df33fdbb");
|
||||
|
||||
@@ -35,20 +35,18 @@ package sonia.scm.repository.spi;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.aragost.javahg.Changeset;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.HgTestUtil;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -56,17 +54,8 @@ import java.io.IOException;
|
||||
public class HgOutgoingCommandTest extends IncomingOutgoingTestBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetOutgoingChangesets()
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
public void testGetOutgoingChangesets() throws IOException {
|
||||
writeNewFile(outgoing, outgoingDirectory, "a.txt", "Content of file a.txt");
|
||||
writeNewFile(outgoing, outgoingDirectory, "b.txt", "Content of file b.txt");
|
||||
|
||||
@@ -90,16 +79,8 @@ public class HgOutgoingCommandTest extends IncomingOutgoingTestBase
|
||||
assertChangesetsEqual(c2, cpr.getChangesets().get(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testGetOutgoingChangesetsWithEmptyRepository()
|
||||
throws RepositoryException
|
||||
{
|
||||
public void testGetOutgoingChangesetsWithEmptyRepository() {
|
||||
HgOutgoingCommand cmd = createOutgoingCommand();
|
||||
OutgoingCommandRequest request = new OutgoingCommandRequest();
|
||||
|
||||
@@ -111,17 +92,8 @@ public class HgOutgoingCommandTest extends IncomingOutgoingTestBase
|
||||
assertEquals(0, cpr.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test(expected = RepositoryException.class)
|
||||
public void testGetOutgoingChangesetsWithUnrelatedRepository()
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
@Test(expected = InternalRepositoryException.class)
|
||||
public void testGetOutgoingChangesetsWithUnrelatedRepository() throws IOException {
|
||||
writeNewFile(outgoing, outgoingDirectory, "a.txt", "Content of file a.txt");
|
||||
writeNewFile(outgoing, outgoingDirectory, "b.txt", "Content of file b.txt");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user