use of org.jenkins.plugins.audit2db.model.BuildDetails 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());
}
use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class Audit2DbExecutionTests method testRunAddsListenerWithValidBuildDetailsToStepContext.
@Test
public void testRunAddsListenerWithValidBuildDetailsToStepContext() throws Exception {
Audit2DbStep step = new Audit2DbStep(JDBC_DRIVER, JDBC_URL, JDBC_USER, JDBC_PASS);
final List<Audit2DbGraphListener> listeners = new ArrayList<Audit2DbGraphListener>();
doReturn("/computer/(master)/").when(computer).getUrl();
doReturn(node).when(computer).getNode();
doReturn(computer).when(stepContext).get(Computer.class);
doReturn("Full Display Name # -99").when(run).getFullDisplayName();
doReturn(run).when(stepContext).get(Run.class);
doReturn(flowExecution).when(stepContext).get(FlowExecution.class);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
listeners.add((Audit2DbGraphListener) invocation.getArguments()[0]);
return null;
}
}).when(flowExecution).addListener(Mockito.any(GraphListener.class));
Audit2DbExecution execution = new Audit2DbExecution(step, stepContext);
execution.run();
Audit2DbGraphListener listener = listeners.get(0);
verify(flowExecution).addListener(listener);
assertThat("No BuildDetails", listener, hasProperty("details", Matchers.isA(BuildDetails.class)));
BuildDetails details = listener.getDetails();
assertNotNull("Null BuildDetails", details);
assertEquals("Mis-matched name", "Full Display Name # -99", details.getFullName());
assertNotNull("Null BuildDetails.node", details.getNode());
assertEquals("Mis-matched node url", "http://unconfigured-jenkins-server/computer/(master)/", details.getNode().getUrl());
}
Aggregations