@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()); }
private DbAuditPublisher getPlugin() { final DbAuditPublisher publisher = new DbAuditPublisherImpl(); final DbAuditPublisherDescriptor descriptor = (DbAuditPublisherDescriptor) publisher.getDescriptor(); descriptor.setJdbcDriver(jdbcDriver); descriptor.setJdbcUrl(jdbcUrl); descriptor.setJdbcUser(jdbcUser); descriptor.setJdbcPassword(jdbcPassword); return publisher; }
@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()); }