use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class FoloRecordCacheTest method clearRecordDeletesRecord.
@Test
public void clearRecordDeletesRecord() throws Exception {
final TrackingKey key = newKey();
assertThat(cache.hasRecord(key), equalTo(false));
cache.recordArtifact(new TrackedContentEntry(key, new StoreKey(StoreType.remote, "foo"), AccessChannel.MAVEN_REPO, "", "/path", StoreEffect.DOWNLOAD, 127L, "", "", ""));
TrackedContent record = cache.seal(key);
assertThat(record, notNullValue());
assertThat(cache.hasRecord(key), equalTo(true));
cache.delete(key);
assertThat(cache.hasRecord(key), equalTo(false));
assertThat(cache.get(key), nullValue());
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class GroupDataManagerTCK method createTwoGroupsAndAffectedByForOneLevel.
@Test
public void createTwoGroupsAndAffectedByForOneLevel() throws Exception {
final StoreDataManager manager = getFixtureProvider().getDataManager();
final StoreKey central = new StoreKey(StoreType.remote, "central");
final StoreKey repo2 = new StoreKey(StoreType.remote, "repo2");
Group g1 = new Group("g1", central);
Group g2 = new Group("g2", repo2);
store(g1, g2);
List<StoreKey> keys = Arrays.asList(central, repo2);
Set<StoreKey> gKeys = manager.query().getGroupsAffectedBy(keys).stream().map(Group::getKey).collect(Collectors.toSet());
assertThat(gKeys.contains(g1.getKey()), equalTo(Boolean.TRUE));
assertThat(gKeys.contains(g2.getKey()), equalTo(Boolean.TRUE));
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class PackageMetadataMerger method merge.
public byte[] merge(final Collection<Transfer> sources, final Group group, final String path) {
Logger logger = LoggerFactory.getLogger(getClass());
logger.debug("Generating merged metadata in: {}:{}", group.getKey(), path);
InputStream stream = null;
boolean merged = false;
final PackageMetadata packageMetadata = new PackageMetadata();
final IndyObjectMapper mapper = new IndyObjectMapper(true);
for (final Transfer src : sources) {
if (!src.exists()) {
continue;
}
try {
stream = src.openInputStream();
String content = IOUtils.toString(stream);
logger.debug("Adding in metadata content from: {}\n\n{}\n\n", src, content);
PackageMetadata md = mapper.readValue(content, PackageMetadata.class);
merged = packageMetadata.merge(md) || merged;
} catch (final IOException e) {
final StoreKey key = getKey(src);
logger.error(String.format("Cannot read metadata: %s from artifact-store: %s. Reason: %s", src.getPath(), key, e.getMessage()), e);
} finally {
closeQuietly(stream);
}
}
if (metadataProviders != null) {
for (PackageMetadataProvider provider : metadataProviders) {
try {
PackageMetadata toMerge = provider.getMetadata(group.getKey(), path);
if (toMerge != null) {
merged = packageMetadata.merge(toMerge) || merged;
}
} catch (IndyWorkflowException e) {
logger.error(String.format("Cannot read metadata: %s from metadata provider: %s. Reason: %s", path, provider.getClass().getSimpleName(), e.getMessage()), e);
}
}
}
if (merged) {
String output = null;
try {
output = mapper.writeValueAsString(packageMetadata);
} catch (JsonProcessingException e) {
logger.error(String.format("Cannot convert from metadata: %s to String. Reason: %s", packageMetadata, e.getMessage()), e);
}
return output.getBytes();
}
return null;
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class KojiMavenMetadataProviderTest method excludeBinaryImportsFromVersionMetadata.
@Test
public void excludeBinaryImportsFromVersionMetadata() throws Exception {
initKojiClient("metadata-with-import-generate", false);
Metadata metadata = provider.getMetadata(new StoreKey(MAVEN_PKG_KEY, group, "public"), "commons-io/commons-io/maven-metadata.xml");
assertThat(metadata, notNullValue());
StringWriter sw = new StringWriter();
new MetadataXpp3Writer().write(sw, metadata);
System.out.println(sw.toString());
Versioning versioning = metadata.getVersioning();
assertThat(versioning, notNullValue());
assertThat(versioning.getLatest(), equalTo("2.4.0.redhat-1"));
assertThat(versioning.getRelease(), equalTo("2.4.0.redhat-1"));
List<String> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(1));
int idx = 0;
assertThat(versions.get(idx), equalTo("2.4.0.redhat-1"));
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class KojiMavenMetadataProviderTest method metadataNullWhenNoVersionsFound.
@Test
public void metadataNullWhenNoVersionsFound() throws Exception {
initKojiClient("no-metadata-generate", false);
Metadata metadata = provider.getMetadata(new StoreKey(MAVEN_PKG_KEY, group, "public"), "commons-io/commons-io/maven-metadata.xml");
assertThat(metadata, nullValue());
}
Aggregations