Search in sources :

Example 6 with BuildInfoBuilder

use of org.jfrog.build.extractor.builder.BuildInfoBuilder in project build-info by JFrogDev.

the class BuildExtractorUtilsTest method testBuildToJson.

public void testBuildToJson() throws IOException {
    String[] requestedByA = new String[] { "parentA", "b", "moduleId" };
    String[] requestedByB = new String[] { "parentB", "d", "moduleId" };
    Dependency dependencyA = new DependencyBuilder().id("depA").addRequestedBy(requestedByA).addRequestedBy(requestedByB).build();
    Module module = new ModuleBuilder().id("moduleId").addDependency(dependencyA).build();
    BuildInfo buildInfo = new BuildInfoBuilder("buildId").number("12").started("34").addModule(module).build();
    // Serialize and deserialize again
    BuildInfo actualBuildInfo = jsonStringToBuildInfo(buildInfoToJsonString(buildInfo));
    // Check buildInfo
    assertEquals(actualBuildInfo.getName(), buildInfo.getName());
    assertEquals(actualBuildInfo.getNumber(), buildInfo.getNumber());
    assertEquals(actualBuildInfo.getStarted(), buildInfo.getStarted());
    // Check module
    Module actualModule = actualBuildInfo.getModule(module.getId());
    assertNotNull(actualModule);
    // Check dependency
    assertEquals(actualModule.getDependencies().size(), 1);
    Dependency actualDependency = actualModule.getDependencies().get(0);
    assertEquals(actualDependency.getId(), dependencyA.getId());
    // Check requestedBy
    String[][] requestedBy = actualDependency.getRequestedBy();
    assertEquals(ArrayUtils.getLength(requestedBy), 2);
    assertEquals(requestedBy[0], requestedByA);
    assertEquals(requestedBy[1], requestedByB);
}
Also used : BuildInfoBuilder(org.jfrog.build.extractor.builder.BuildInfoBuilder) DependencyBuilder(org.jfrog.build.extractor.builder.DependencyBuilder) ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder)

Example 7 with BuildInfoBuilder

use of org.jfrog.build.extractor.builder.BuildInfoBuilder in project build-info by JFrogDev.

the class BuildInfoMavenBuilderTest method testStartedSetters.

/**
 * Validates the build start time values after using the builder setters
 */
public void testStartedSetters() {
    String started = "192-1212-1";
    BuildInfo buildInfo = new BuildInfoBuilder("test").number("4").started(started).build();
    assertEquals(buildInfo.getStarted(), started, "Unexpected buildInfo started.");
    Date startedDate = new Date();
    buildInfo = new BuildInfoBuilder("test").number("4").startedDate(startedDate).build();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Build.STARTED_FORMAT);
    assertEquals(buildInfo.getStarted(), simpleDateFormat.format(startedDate), "Unexpected buildInfo started.");
}
Also used : BuildInfoBuilder(org.jfrog.build.extractor.builder.BuildInfoBuilder) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 8 with BuildInfoBuilder

use of org.jfrog.build.extractor.builder.BuildInfoBuilder in project build-info by JFrogDev.

the class BuildInfoMavenBuilderTest method testBuilderAddMethod.

/**
 * Validates the build values after using the builder add methods
 */
public void testBuilderAddMethod() {
    Module module = new Module();
    module.setId("module-id");
    String propertyKey = "key";
    String propertyValue = "value";
    PromotionStatus promotionStatus = new PromotionStatusBuilder("momo").timestampDate(new Date()).build();
    BuildInfo buildInfo = new BuildInfoBuilder("test").number("4").started("test").addModule(module).addProperty(propertyKey, propertyValue).addStatus(promotionStatus).build();
    List<Module> modules = buildInfo.getModules();
    assertFalse(modules.isEmpty(), "A buildInfo module should have been added.");
    assertEquals(modules.get(0), module, "Unexpected buildInfo module.");
    assertTrue(buildInfo.getProperties().containsKey(propertyKey), "A buildInfo property should have been added.");
    assertEquals(buildInfo.getProperties().get(propertyKey), propertyValue, "Unexpected buildInfo property value.");
    List<PromotionStatus> statuses = buildInfo.getStatuses();
    assertFalse(statuses.isEmpty(), "Expected a status to be added.");
    assertEquals(statuses.get(0), promotionStatus, "Unexpected added status.");
}
Also used : BuildInfoBuilder(org.jfrog.build.extractor.builder.BuildInfoBuilder) PromotionStatusBuilder(org.jfrog.build.api.builder.PromotionStatusBuilder) PromotionStatus(org.jfrog.build.api.release.PromotionStatus) Date(java.util.Date)

Example 9 with BuildInfoBuilder

use of org.jfrog.build.extractor.builder.BuildInfoBuilder in project build-info by JFrogDev.

the class BuildInfoMavenBuilderTest method testDefaultBuild.

/**
 * Validates the build values when using the defaults
 */
public void testDefaultBuild() {
    BuildInfo buildInfo = new BuildInfoBuilder("test").number("4").started("test").build();
    assertEquals(buildInfo.getVersion(), "1.0.1", "Unexpected default build version.");
    assertEquals(buildInfo.getNumber(), "4", "Unexpected default build number.");
    assertNull(buildInfo.getAgent(), "Default build agent should be null.");
    assertEquals(buildInfo.getDurationMillis(), 0, "Default build duration millis should be zero.");
    assertNull(buildInfo.getPrincipal(), "Default build principal should be null.");
    assertNull(buildInfo.getArtifactoryPrincipal(), "Default build artifactory principal should be null.");
    assertNull(buildInfo.getArtifactoryPluginVersion(), "Default build ArtifactoryPluginVersion should be null.");
    assertNull(buildInfo.getUrl(), "Default build URL should be null.");
    assertNull(buildInfo.getParentName(), "Default build parent build name should be null.");
    assertNull(buildInfo.getParentNumber(), "Default build parent build number should be null.");
    assertNull(buildInfo.getModules(), "Default build modules should be null.");
    assertNull(buildInfo.getProperties(), "Default properties should be null.");
    assertEquals(buildInfo.getVcs(), new ArrayList<Vcs>(), "Default vcs revision should be null.");
}
Also used : BuildInfoBuilder(org.jfrog.build.extractor.builder.BuildInfoBuilder)

Example 10 with BuildInfoBuilder

use of org.jfrog.build.extractor.builder.BuildInfoBuilder in project build-info by JFrogDev.

the class IssuesCollectorTest method publishBuildInfoWithVcs.

private void publishBuildInfoWithVcs(List<Vcs> vcsList) throws IOException {
    BuildInfoBuilder buildInfoBuilder = new BuildInfoBuilder(BUILD_NAME).number(BUILD_NUMBER).startedDate(new Date()).url(getArtifactoryUrl()).vcs(vcsList);
    BuildInfo buildInfoToSend = buildInfoBuilder.build();
    // Publish build info
    artifactoryManager.publishBuildInfo(buildInfoToSend, null);
}
Also used : BuildInfoBuilder(org.jfrog.build.extractor.builder.BuildInfoBuilder) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) Date(java.util.Date)

Aggregations

BuildInfoBuilder (org.jfrog.build.extractor.builder.BuildInfoBuilder)10 Date (java.util.Date)6 SimpleDateFormat (java.text.SimpleDateFormat)3 BuildInfo (org.jfrog.build.extractor.ci.BuildInfo)3 IOException (java.io.IOException)2 Map (java.util.Map)2 PromotionStatusBuilder (org.jfrog.build.api.builder.PromotionStatusBuilder)2 PromotionStatus (org.jfrog.build.api.release.PromotionStatus)2 ModuleBuilder (org.jfrog.build.extractor.builder.ModuleBuilder)2 Agent (org.jfrog.build.extractor.ci.Agent)2 BuildAgent (org.jfrog.build.extractor.ci.BuildAgent)2 Issue (org.jfrog.build.extractor.ci.Issue)2 IssueTracker (org.jfrog.build.extractor.ci.IssueTracker)2 Issues (org.jfrog.build.extractor.ci.Issues)2 MatrixParameter (org.jfrog.build.extractor.ci.MatrixParameter)2 Vcs (org.jfrog.build.extractor.ci.Vcs)2 ArtifactoryClientConfiguration (org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration)2 File (java.io.File)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1