use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.
the class AssetSpliteratorTest method trySplit.
@Test
void trySplit() {
StorageAsset root = createTree();
AssetSpliterator spliterator = new AssetSpliterator(root);
final ConsumeVisitStatus status1 = new ConsumeVisitStatus();
final ConsumeVisitStatus status2 = new ConsumeVisitStatus();
Spliterator<StorageAsset> newSpliterator = spliterator.trySplit();
assertNotNull(newSpliterator);
newSpliterator.forEachRemaining(status1);
spliterator.forEachRemaining(status2);
int sum = LEVEL1 * LEVEL2 * LEVEL3 + LEVEL1 * LEVEL2 + LEVEL1 + 1;
int expected1 = sum / 2;
int expected2 = sum / 2 + 1;
assertEquals(expected1, status1.size());
assertEquals(expected2, status2.size());
}
use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.
the class FilesystemStorageTest method addAsset.
@Test
public void addAsset() {
StorageAsset newAsset = fsStorage.addAsset("dir2/test", false);
Assert.assertNotNull(newAsset);
Assert.assertFalse(newAsset.isContainer());
Assert.assertFalse(newAsset.exists());
StorageAsset newDirAsset = fsStorage.addAsset("/dir2/testdir2", true);
Assert.assertNotNull(newDirAsset);
Assert.assertTrue(newDirAsset.isContainer());
Assert.assertFalse(newDirAsset.exists());
}
use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.
the class AssetSpliterator method tryAdvance.
@Override
public boolean tryAdvance(Consumer<? super StorageAsset> action) {
try {
StorageAsset asset = workList.getLast();
consumeAsset(action, asset);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.
the class MockAsset method resolve.
@Override
public StorageAsset resolve(String toPath) {
if (children.containsKey(toPath)) {
return children.get(toPath);
} else {
if (toPath.startsWith("/")) {
toPath = StringUtils.removeStart(toPath, "/");
}
if ("".equals(toPath)) {
return this;
}
String[] destPath = toPath.split("/");
StringBuilder destPathStr = new StringBuilder();
MockAsset destParent = this;
for (int i = 0; i < destPath.length; i++) {
destPathStr.append("/").append(destPath[i]);
StorageAsset child = storage.getAsset(destPathStr.toString());
if (child != null) {
destParent = (MockAsset) child;
} else {
System.out.println("Resolve " + destParent.getPath() + " -- " + destPath[i]);
destParent = new MockAsset(destParent, destPath[i]);
}
}
return destParent;
}
}
use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.
the class AbstractStorageUtilTest method testWalkFromChild.
@Test
void testWalkFromChild() {
StorageAsset root = createTree();
ConsumeVisitStatus status = new ConsumeVisitStatus();
StorageAsset testRoot = root.list().get(3);
StorageUtil.walk(testRoot, status);
int expected = LEVEL2 * LEVEL3 + LEVEL2 + 1;
Assertions.assertEquals(expected, status.size());
StorageAsset first = root.list().get(3).list().get(0).list().get(0);
Assertions.assertEquals(first, status.getFirst());
Assertions.assertEquals(testRoot, status.getLast());
}
Aggregations