use of org.apache.archiva.repository.content.Project in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method deleteItemNotFound.
@Test
public void deleteItemNotFound() throws IOException, URISyntaxException, ItemNotFoundException {
ManagedRepository repo = createManagedRepoWithContent("delete-repository");
ManagedRepositoryContent myRepoContent = repo.getContent();
Path repoRoot = repo.getRoot().getFilePath();
ArchivaItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.test2").build();
ContentItem item = myRepoContent.getItem(selector);
assertTrue(item instanceof Namespace);
try {
myRepoContent.deleteItem(item);
assertTrue("ItemNotFoundException expected for non existing namespace", false);
} catch (ItemNotFoundException e) {
}
selector = ArchivaItemSelector.builder().withNamespace("org.apache.test").withProjectId("samplejar2").build();
item = myRepoContent.getItem(selector);
assertTrue(item instanceof Project);
try {
myRepoContent.deleteItem(item);
assertTrue("ItemNotFoundException expected for non existing project", false);
} catch (ItemNotFoundException e) {
}
selector = ArchivaItemSelector.builder().withNamespace("org.apache.test").withProjectId("samplejar").withVersion("1.1").build();
item = myRepoContent.getItem(selector);
assertTrue(item instanceof Version);
try {
myRepoContent.deleteItem(item);
assertTrue("ItemNotFoundException expected for non existing version", false);
} catch (ItemNotFoundException e) {
}
selector = ArchivaItemSelector.builder().withNamespace("org.apache.test").withProjectId("samplejar").withVersion("1.0").withArtifactId("samplejar").withArtifactVersion("1.0").withExtension("jax").build();
item = myRepoContent.getItem(selector);
assertTrue(item instanceof Artifact);
try {
myRepoContent.deleteItem(item);
assertTrue("ItemNotFoundException expected for non existing artifact", false);
} catch (ItemNotFoundException e) {
}
}
use of org.apache.archiva.repository.content.Project in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method deleteProjectItem.
@Test
public void deleteProjectItem() throws IOException, URISyntaxException, ItemNotFoundException {
ManagedRepository repo = createManagedRepoWithContent("delete-repository");
ManagedRepositoryContent myRepoContent = repo.getContent();
Path repoRoot = repo.getRoot().getFilePath();
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/A")));
ArchivaItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("A").build();
ContentItem item = myRepoContent.getItem(selector);
assertTrue(item instanceof Project);
myRepoContent.deleteItem(item);
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/samplejar/1.0")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/maven/samplejar/2.0")));
assertFalse(Files.exists(repoRoot.resolve("org/apache/maven/A")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/samplejar")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/sub/samplejar")));
selector = ArchivaItemSelector.builder().withNamespace("org.apache.test").withProjectId("samplejar").build();
item = myRepoContent.getItem(selector);
assertTrue(item instanceof Project);
myRepoContent.deleteItem(item);
assertFalse(Files.exists(repoRoot.resolve("org/apache/test/samplejar")));
assertTrue(Files.exists(repoRoot.resolve("org/apache/test/sub/samplejar")));
}
use of org.apache.archiva.repository.content.Project in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testGetItemWithProjectSelector.
@Test
public void testGetItemWithProjectSelector() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("shared").build();
ContentItem item = repoContent.getItem(selector);
assertNotNull(item);
assertTrue(item instanceof Project);
}
use of org.apache.archiva.repository.content.Project in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testNewItemStreamWithNamespace1.
@Test
public void testNewItemStreamWithNamespace1() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.axis2").build();
Stream<? extends ContentItem> stream = repoContent.newItemStream(selector, false);
List<? extends ContentItem> result = stream.collect(Collectors.toList());
assertEquals(41, result.size());
ContentItem item = result.get(39);
Version version = item.adapt(Version.class);
assertNotNull(version);
assertEquals("1.3-SNAPSHOT", version.getId());
Project project = result.get(40).adapt(Project.class);
assertNotNull(project);
assertEquals("axis2", project.getId());
assertTrue(result.stream().anyMatch(a -> "axis2-1.3-20070725.210059-1.pom".equals(a.getAsset().getName())));
}
Aggregations