use of org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl in project selenium_java by sergueik.
the class DbAuditPublisherImpl method prebuild.
@Override
public boolean prebuild(final AbstractBuild<?, ?> build, final BuildListener listener) {
LOGGER.log(Level.FINE, String.format("prebuild: %s;", build.getDisplayName()));
Object id = null;
final BuildDetails details = new BuildDetailsImpl(build);
try {
id = getRepository().saveBuildDetails(details);
LOGGER.log(Level.FINE, "Saved build details with id=" + id);
} catch (final Throwable t) {
LOGGER.log(Level.SEVERE, t.getMessage(), t);
}
return ((super.prebuild(build, listener)) && (id != null));
}
use of org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl in project selenium_java by sergueik.
the class WhenSchedulingJob method testParameterisedJobShouldSaveAllParameters.
@Test
public void testParameterisedJobShouldSaveAllParameters() throws Exception {
final FreeStyleProject project = createFreeStyleProject("ParameterisedJob");
// set parameters
final ParameterDefinition param1 = new StringParameterDefinition("myStringParam", "myStringValue", "My String Parameter");
final ParameterDefinition param2 = new BooleanParameterDefinition("myBooleanParam", false, "My Boolean Parameter");
project.addProperty(new ParametersDefinitionProperty(param1, param2));
// enable audit2db plugin
final DbAuditPublisher plugin = getPlugin();
project.getPublishersList().add((Publisher) plugin);
// build now
final Future<FreeStyleBuild> futureBuild = project.scheduleBuild2(0);
final FreeStyleBuild build = futureBuild.get();
Assert.assertNotNull(build);
Assert.assertEquals("Unexpected build result", Result.SUCCESS, build.getResult());
// check data persistence
final BuildDetailsRepository repository = plugin.getRepository();
final BuildDetails actual = repository.getBuildDetailsForBuild(build);
final BuildDetails expected = new BuildDetailsImpl(build);
Assert.assertEquals("Unexpected build details", expected, actual);
Assert.assertNotNull("Unexpected null end date", actual.getEndDate());
Assert.assertTrue("Unexpected duration", actual.getDuration() > 0L);
Assert.assertEquals("Unexpected number of params", 2, actual.getParameters().size());
}
use of org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl in project selenium_java by sergueik.
the class BuildDetailsImplTests method getBuildDetails.
private BuildDetails getBuildDetails() {
final BuildDetails build = new BuildDetailsImpl();
build.setDuration(Long.valueOf(60));
build.setEndDate(new Date(build.getStartDate().getTime() + (build.getDuration() * 1000)));
build.setFullName("BUILD FULL NAME");
build.setId("BUILD ID");
build.setName("BUILD NAME");
build.setUserId("BUILD USER ID");
build.setUserName("BUILD USER NAME");
final List<BuildParameter> params = new ArrayList<BuildParameter>();
params.add(new BuildParameterImpl("PARAM_ID", "PARAM NAME", "PARAM VALUE", build));
build.setParameters(params);
return build;
}
use of org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl in project selenium_java by sergueik.
the class TestUtils method createRandomBuildDetails.
public static BuildDetails createRandomBuildDetails(final boolean withParams) {
final long salt = System.nanoTime();
final BuildDetails build = new BuildDetailsImpl();
build.setDuration(Long.valueOf(60 + (long) (Math.random() * 60)));
build.setEndDate(new Date(build.getStartDate().getTime() + (build.getDuration() * 1000)));
build.setFullName("BUILD FULL NAME " + salt);
build.setId("BUILD ID " + salt);
build.setName("BUILD NAME " + salt);
build.setUserId("BUILD USER ID " + salt);
build.setUserName("BUILD USER NAME " + salt);
if (withParams) {
final List<BuildParameter> params = new ArrayList<BuildParameter>();
params.add(new BuildParameterImpl("PARAM_ID 1 " + salt, "PARAM NAME 1 " + salt, "PARAM VALUE 1 " + salt, build));
params.add(new BuildParameterImpl("PARAM_ID 2 " + salt, "PARAM NAME 2 " + salt, "PARAM VALUE 2 " + salt, build));
build.setParameters(params);
}
final BuildNode node = new BuildNodeImpl("NODE ADDRESS", "NODE HOSTNAME", "NODE DISPLAYNAME", "NODE URL", "NODE NAME", "NODE DESCRIPTION", "NODE LABEL");
build.setNode(node);
return build;
}
use of org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl in project selenium_java by sergueik.
the class WhenSchedulingJob method testPlainJobShouldSaveNoParameters.
@Test
public void testPlainJobShouldSaveNoParameters() throws Exception {
final FreeStyleProject project = createFreeStyleProject("PlainJob");
// enable audit2db plugin
final DbAuditPublisher plugin = getPlugin();
project.getPublishersList().add((Publisher) plugin);
// build now
final Future<FreeStyleBuild> futureBuild = project.scheduleBuild2(0);
final FreeStyleBuild build = futureBuild.get();
Assert.assertNotNull(build);
Assert.assertEquals("Unexpected build result", Result.SUCCESS, build.getResult());
// check data persistence
final BuildDetailsRepository repository = plugin.getRepository();
final BuildDetails actual = repository.getBuildDetailsForBuild(build);
final BuildDetails expected = new BuildDetailsImpl(build);
Assert.assertEquals("Unexpected build details", expected, actual);
Assert.assertNotNull("Unexpected null end date", actual.getEndDate());
Assert.assertTrue("Unexpected duration", actual.getDuration() > 0L);
Assert.assertEquals("Unexpected number of params", 0, actual.getParameters().size());
}
Aggregations