Search in sources :

Example 6 with FileSpec

use of org.jfrog.filespecs.FileSpec 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"));
}
Also used : FileSpec(org.jfrog.filespecs.FileSpec) GetReleaseBundleStatusResponse(org.jfrog.build.extractor.clientConfiguration.client.distribution.response.GetReleaseBundleStatusResponse) Property(org.jfrog.filespecs.properties.Property) FilesGroup(org.jfrog.filespecs.entities.FilesGroup) CreateReleaseBundleRequest(org.jfrog.build.extractor.clientConfiguration.client.distribution.request.CreateReleaseBundleRequest) Test(org.testng.annotations.Test)

Example 7 with FileSpec

use of org.jfrog.filespecs.FileSpec 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);
    }
}
Also used : DeployDetails(org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails) FileSpec(org.jfrog.filespecs.FileSpec) Dependency(org.jfrog.build.extractor.ci.Dependency) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) FilesGroup(org.jfrog.filespecs.entities.FilesGroup)

Example 8 with FileSpec

use of org.jfrog.filespecs.FileSpec 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());
        }
    }
}
Also used : Path(java.nio.file.Path) FileSpec(org.jfrog.filespecs.FileSpec) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Module(org.jfrog.build.extractor.ci.Module) StringJoiner(java.util.StringJoiner) FilesGroup(org.jfrog.filespecs.entities.FilesGroup) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 9 with FileSpec

use of org.jfrog.filespecs.FileSpec in project build-info by JFrogDev.

the class DistributionManagerTest method createRequestBuilder.

CreateReleaseBundleRequest.Builder createRequestBuilder() throws IOException {
    FileSpec fileSpec = createSpec();
    ReleaseNotes releaseNotes = new ReleaseNotes();
    releaseNotes.setContent("Create content");
    releaseNotes.setSyntax(ReleaseNotes.Syntax.plain_text);
    return new CreateReleaseBundleRequest.Builder(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION).description("Create").releaseNotes(releaseNotes).spec(fileSpec);
}
Also used : FileSpec(org.jfrog.filespecs.FileSpec) ReleaseNotes(org.jfrog.build.extractor.clientConfiguration.client.distribution.types.ReleaseNotes) CreateReleaseBundleRequest(org.jfrog.build.extractor.clientConfiguration.client.distribution.request.CreateReleaseBundleRequest)

Example 10 with FileSpec

use of org.jfrog.filespecs.FileSpec in project build-info by JFrogDev.

the class DistributionManagerTest method updateRequestBuilder.

UpdateReleaseBundleRequest.Builder updateRequestBuilder() throws IOException {
    FileSpec fileSpec = createSpec();
    ReleaseNotes releaseNotes = new ReleaseNotes();
    releaseNotes.setContent("Update content");
    releaseNotes.setSyntax(ReleaseNotes.Syntax.plain_text);
    return new UpdateReleaseBundleRequest.Builder().description("Update").releaseNotes(releaseNotes).spec(fileSpec);
}
Also used : FileSpec(org.jfrog.filespecs.FileSpec) UpdateReleaseBundleRequest(org.jfrog.build.extractor.clientConfiguration.client.distribution.request.UpdateReleaseBundleRequest) ReleaseNotes(org.jfrog.build.extractor.clientConfiguration.client.distribution.types.ReleaseNotes)

Aggregations

FileSpec (org.jfrog.filespecs.FileSpec)10 FilesGroup (org.jfrog.filespecs.entities.FilesGroup)5 CreateReleaseBundleRequest (org.jfrog.build.extractor.clientConfiguration.client.distribution.request.CreateReleaseBundleRequest)3 Test (org.testng.annotations.Test)3 ReleaseNotes (org.jfrog.build.extractor.clientConfiguration.client.distribution.types.ReleaseNotes)2 DeployDetails (org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails)2 File (java.io.File)1 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1 Path (java.nio.file.Path)1 StringJoiner (java.util.StringJoiner)1 DownloadResponse (org.jfrog.build.client.DownloadResponse)1 BuildInfo (org.jfrog.build.extractor.ci.BuildInfo)1 Dependency (org.jfrog.build.extractor.ci.Dependency)1 Module (org.jfrog.build.extractor.ci.Module)1 ArtifactoryManager (org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager)1 UpdateReleaseBundleRequest (org.jfrog.build.extractor.clientConfiguration.client.distribution.request.UpdateReleaseBundleRequest)1 GetReleaseBundleStatusResponse (org.jfrog.build.extractor.clientConfiguration.client.distribution.response.GetReleaseBundleStatusResponse)1 DependenciesDownloaderHelper (org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper)1 EditPropertiesHelper (org.jfrog.build.extractor.clientConfiguration.util.EditPropertiesHelper)1