use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.
the class AbstractStorageUtilTest method createTree.
protected StorageAsset createTree(int... levelElements) {
StorageAsset root = createRootAsset();
recurseSubTree(root, 0, levelElements);
return root;
}
use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.
the class AbstractStorageUtilTest method testWalkFromRootWithCondition.
@Test
void testWalkFromRootWithCondition() {
StorageAsset root = createTree();
StopVisitStatus status = new StopVisitStatus();
status.setStopCondition(a -> a.getName().equals("001002003"));
StorageUtil.walk(root, status);
Assertions.assertEquals("001002003", status.getLast().getName());
int expected = LEVEL2 * LEVEL3 + LEVEL2 + 2 * LEVEL3 + 1 + 1 + 1 + 4;
Assertions.assertEquals(expected, status.size());
}
use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.
the class AbstractStorageUtilTest method testStreamParallel.
@Test
void testStreamParallel() {
StorageAsset root = createTree();
List<StorageAsset> result;
try (Stream<StorageAsset> stream = StorageUtil.newAssetStream(root, true)) {
result = stream.filter(a -> a.getName().startsWith("001")).collect(Collectors.toList());
}
int expected = LEVEL2 * LEVEL3 + LEVEL2 + 1;
Assertions.assertEquals(expected, result.size());
}
use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.
the class AbstractStorageUtilTest method testCopyRecursive.
@Test
void testCopyRecursive() throws IOException {
StorageAsset root = createTree();
createStorage(root);
StorageAsset destinationRoot = createRootAsset();
RepositoryStorage destinationStorage = createStorage(destinationRoot);
StorageAsset destination = destinationStorage.getAsset("");
boolean result = StorageUtil.copyRecursively(root, destination, false);
Assertions.assertTrue(result);
Assertions.assertTrue(destination.exists());
Assertions.assertTrue(destination.resolve("000/000000/000000000").exists());
Assertions.assertTrue(destination.resolve("011/011000/011000000").exists());
Assertions.assertTrue(destination.resolve("010/010000/010000000").exists());
Assertions.assertTrue(destination.resolve("000/000000/000000000").exists());
}
use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.
the class AbstractStorageUtilTest method recurseSubTree.
private void recurseSubTree(StorageAsset parent, int level, int[] levelElements) {
if (level < levelElements.length) {
AssetType type = (level == levelElements.length - 1) ? AssetType.FILE : AssetType.CONTAINER;
for (int k = 0; k < levelElements[level]; k++) {
String name = parent.getName() + String.format("%03d", k);
StorageAsset asset = createAsset(parent, name, type);
recurseSubTree(asset, level + 1, levelElements);
}
}
}
Aggregations