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);
}
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.");
}
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.");
}
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.");
}
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);
}
Aggregations