mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
Use more generic collection instead of list
This commit is contained in:
@@ -33,14 +33,12 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.Test;
|
||||
import sonia.scm.repository.BrowserResult;
|
||||
import sonia.scm.repository.FileObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -48,8 +46,6 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -68,7 +64,7 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase {
|
||||
|
||||
@Test
|
||||
public void testBrowse() throws IOException {
|
||||
List<FileObject> foList = getRootFromTip(new BrowseCommandRequest());
|
||||
Collection<FileObject> foList = getRootFromTip(new BrowseCommandRequest());
|
||||
FileObject a = getFileObject(foList, "a.txt");
|
||||
FileObject c = getFileObject(foList, "c");
|
||||
|
||||
@@ -96,7 +92,7 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase {
|
||||
|
||||
FileObject c = result.getFile();
|
||||
assertEquals("c", c.getName());
|
||||
List<FileObject> foList = c.getChildren();
|
||||
Collection<FileObject> foList = c.getChildren();
|
||||
|
||||
assertNotNull(foList);
|
||||
assertFalse(foList.isEmpty());
|
||||
@@ -139,7 +135,7 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase {
|
||||
|
||||
request.setDisableLastCommit(true);
|
||||
|
||||
List<FileObject> foList = getRootFromTip(request);
|
||||
Collection<FileObject> foList = getRootFromTip(request);
|
||||
|
||||
FileObject a = getFileObject(foList, "a.txt");
|
||||
|
||||
@@ -159,7 +155,7 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase {
|
||||
assertNotNull(result);
|
||||
|
||||
FileObject root = result.getFile();
|
||||
List<FileObject> foList = root.getChildren();
|
||||
Collection<FileObject> foList = root.getChildren();
|
||||
|
||||
assertNotNull(foList);
|
||||
assertFalse(foList.isEmpty());
|
||||
@@ -181,33 +177,22 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private FileObject getFileObject(List<FileObject> foList, String name)
|
||||
private FileObject getFileObject(Collection<FileObject> foList, String name)
|
||||
{
|
||||
FileObject a = null;
|
||||
|
||||
for (FileObject f : foList)
|
||||
{
|
||||
if (name.equals(f.getName()))
|
||||
{
|
||||
a = f;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assertNotNull(a);
|
||||
|
||||
return a;
|
||||
return foList.stream()
|
||||
.filter(f -> name.equals(f.getName()))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new AssertionError("file " + name + " not found"));
|
||||
}
|
||||
|
||||
private List<FileObject> getRootFromTip(BrowseCommandRequest request) throws IOException {
|
||||
private Collection<FileObject> getRootFromTip(BrowseCommandRequest request) throws IOException {
|
||||
BrowserResult result = new HgBrowseCommand(cmdContext,
|
||||
repository).getBrowserResult(request);
|
||||
|
||||
assertNotNull(result);
|
||||
|
||||
FileObject root = result.getFile();
|
||||
List<FileObject> foList = root.getChildren();
|
||||
Collection<FileObject> foList = root.getChildren();
|
||||
|
||||
assertNotNull(foList);
|
||||
assertFalse(foList.isEmpty());
|
||||
|
||||
Reference in New Issue
Block a user