use of org.jfrog.filespecs.entities.FilesGroup in project build-info by JFrogDev.
the class LocalDistributionManagerTest method addedPropsTest.
@Test
public void addedPropsTest() throws IOException {
// Create a release bundle with added props
String fileName = uploadFile();
FileSpec fileSpec = new FileSpec();
FilesGroup filesGroup = new FilesGroup().setTargetProps("key1=value1,value2").setPattern(localRepo1 + "/data/" + fileName);
fileSpec.addFilesGroup(filesGroup);
CreateReleaseBundleRequest request = new CreateReleaseBundleRequest.Builder(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION).spec(fileSpec).build();
distributionManager.createReleaseBundle(request);
// Assert added props
GetReleaseBundleStatusResponse bundleInfo = distributionManager.getReleaseBundleStatus(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION);
assertNotNull(bundleInfo);
List<Property> addedProps = bundleInfo.getSpec().getQueries().get(0).getAddedProps();
assertFalse(addedProps.isEmpty());
Property property = addedProps.get(0);
assertEquals(property.getKey(), "key1");
assertEquals(property.getValues(), Sets.newHashSet("value1", "value2"));
}
use of org.jfrog.filespecs.entities.FilesGroup in project build-info by JFrogDev.
the class DownloadTest method testDownloadArtifactFromDifferentPath.
public void testDownloadArtifactFromDifferentPath() throws IOException {
String targetDirPath = tempWorkspace.getPath() + File.separatorChar + "testDownloadDupArtifactFromDifferentPath" + File.separatorChar;
FileSpec fileSpec = new FileSpec();
// Upload one file to different locations in Artifactory.
try {
File file = createRandomFile(tempWorkspace.getPath() + File.pathSeparatorChar + "file", 1);
for (int i = 0; i < 3; i++) {
String filePath = TEST_REPO_PATH + "/" + i + "/file";
DeployDetails deployDetails = new DeployDetails.Builder().file(file).artifactPath(filePath).targetRepository(localRepo1).explode(false).packageType(DeployDetails.PackageType.GENERIC).build();
FilesGroup fg = new FilesGroup();
fg.setPattern(localRepo1 + "/" + filePath);
fg.setTarget(targetDirPath);
fileSpec.addFilesGroup(fg);
// Upload artifact
artifactoryManager.upload(deployDetails);
}
DependenciesDownloaderHelper helper = new DependenciesDownloaderHelper(artifactoryManager, tempWorkspace.getPath(), log);
List<Dependency> dependencies = helper.downloadDependencies(fileSpec);
Assert.assertEquals(dependencies.size(), 3);
} finally {
FileUtils.deleteDirectory(tempWorkspace);
}
}
use of org.jfrog.filespecs.entities.FilesGroup in project build-info by JFrogDev.
the class NpmExtractorTest method npmPublishTest.
@SuppressWarnings("unused")
@Test(dataProvider = "npmPublishProvider")
public void npmPublishTest(Project project, ArrayListMultimap<String, String> props, String targetPath, String packageName) {
Path projectDir = null;
try {
// Run npm publish
projectDir = createProjectDir(project);
Path path = StringUtils.isNotBlank(packageName) ? projectDir.resolve(packageName) : projectDir;
NpmPublish npmPublish = new NpmPublish(artifactoryManagerBuilder, props, path, localRepo1, log, null, null);
BuildInfo buildInfo = npmPublish.execute();
assertEquals(buildInfo.getModules().size(), 1);
Module module = buildInfo.getModules().get(0);
// Check correctness of the module and the artifact
assertEquals(module.getType(), "npm");
assertEquals(module.getId(), project.getModuleId());
assertEquals(module.getRepository(), localRepo1);
assertEquals(module.getArtifacts().size(), 1);
assertEquals(module.getArtifacts().get(0).getName(), project.getModuleId());
assertEquals(module.getArtifacts().get(0).getRemotePath(), project.getRemotePath());
// DownloadBase the artifact and check for its properties
StringJoiner propertiesBuilder = new StringJoiner(";");
props.entries().forEach(property -> propertiesBuilder.add(property.getKey() + "=" + property.getValue()));
FilesGroup fileSpec = new FilesGroup();
fileSpec.setProps(propertiesBuilder.toString());
fileSpec.setPattern(localRepo1 + "/" + targetPath);
fileSpec.setTarget(projectDir.toString());
FileSpec spec = new FileSpec();
spec.addFilesGroup(fileSpec);
assertEquals(downloaderHelper.downloadDependencies(spec).size(), 1);
} catch (Exception e) {
fail(ExceptionUtils.getStackTrace(e));
} finally {
if (projectDir != null) {
FileUtils.deleteQuietly(projectDir.toFile());
}
}
}
Aggregations