Search in sources :

Example 1 with DbAuditPublisher

use of org.jenkins.plugins.audit2db.DbAuditPublisher 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());
}
Also used : BuildDetailsImpl(org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl) StringParameterDefinition(hudson.model.StringParameterDefinition) BooleanParameterDefinition(hudson.model.BooleanParameterDefinition) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) BuildDetailsRepository(org.jenkins.plugins.audit2db.data.BuildDetailsRepository) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) BooleanParameterDefinition(hudson.model.BooleanParameterDefinition) StringParameterDefinition(hudson.model.StringParameterDefinition) ParameterDefinition(hudson.model.ParameterDefinition) DbAuditPublisher(org.jenkins.plugins.audit2db.DbAuditPublisher) Test(org.junit.Test)

Example 2 with DbAuditPublisher

use of org.jenkins.plugins.audit2db.DbAuditPublisher in project selenium_java by sergueik.

the class WhenTestingDataSource method testInvalidJdbcDriverShouldFail.

@Test
public void testInvalidJdbcDriverShouldFail() throws Exception {
    final DbAuditPublisher publisher = new DbAuditPublisherImpl();
    final DbAuditPublisherDescriptor descriptor = (DbAuditPublisherDescriptor) publisher.getDescriptor();
    final FormValidation testResult = descriptor.doTestJdbcConnection("WrongDriver", jdbcUrl, jdbcUser, jdbcPassword);
    Assert.assertEquals("Unexpected successful connection.", FormValidation.Kind.ERROR, testResult.kind);
}
Also used : FormValidation(hudson.util.FormValidation) DbAuditPublisherImpl(org.jenkins.plugins.audit2db.internal.DbAuditPublisherImpl) DbAuditPublisher(org.jenkins.plugins.audit2db.DbAuditPublisher) DbAuditPublisherDescriptor(org.jenkins.plugins.audit2db.DbAuditPublisherDescriptor) Test(org.junit.Test)

Example 3 with DbAuditPublisher

use of org.jenkins.plugins.audit2db.DbAuditPublisher in project selenium_java by sergueik.

the class WhenSchedulingJob method getPlugin.

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;
}
Also used : DbAuditPublisherImpl(org.jenkins.plugins.audit2db.internal.DbAuditPublisherImpl) DbAuditPublisher(org.jenkins.plugins.audit2db.DbAuditPublisher) DbAuditPublisherDescriptor(org.jenkins.plugins.audit2db.DbAuditPublisherDescriptor)

Example 4 with DbAuditPublisher

use of org.jenkins.plugins.audit2db.DbAuditPublisher 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());
}
Also used : BuildDetailsImpl(org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) BuildDetailsRepository(org.jenkins.plugins.audit2db.data.BuildDetailsRepository) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) DbAuditPublisher(org.jenkins.plugins.audit2db.DbAuditPublisher) Test(org.junit.Test)

Example 5 with DbAuditPublisher

use of org.jenkins.plugins.audit2db.DbAuditPublisher in project selenium_java by sergueik.

the class WhenTestingDataSource method testGeneratingDdlWithValidJdbcDetailsShouldSucceed.

@Test
public void testGeneratingDdlWithValidJdbcDetailsShouldSucceed() throws Exception {
    final DbAuditPublisher publisher = new DbAuditPublisherImpl();
    final DbAuditPublisherDescriptor descriptor = (DbAuditPublisherDescriptor) publisher.getDescriptor();
    final FormValidation testResult = descriptor.doGenerateDdl(jdbcDriver, jdbcUrl, jdbcUser, jdbcPassword);
    Assert.assertEquals("Unexpected connection error.", FormValidation.Kind.OK, testResult.kind);
}
Also used : FormValidation(hudson.util.FormValidation) DbAuditPublisherImpl(org.jenkins.plugins.audit2db.internal.DbAuditPublisherImpl) DbAuditPublisher(org.jenkins.plugins.audit2db.DbAuditPublisher) DbAuditPublisherDescriptor(org.jenkins.plugins.audit2db.DbAuditPublisherDescriptor) Test(org.junit.Test)

Aggregations

DbAuditPublisher (org.jenkins.plugins.audit2db.DbAuditPublisher)6 Test (org.junit.Test)5 DbAuditPublisherDescriptor (org.jenkins.plugins.audit2db.DbAuditPublisherDescriptor)4 DbAuditPublisherImpl (org.jenkins.plugins.audit2db.internal.DbAuditPublisherImpl)4 FormValidation (hudson.util.FormValidation)3 FreeStyleBuild (hudson.model.FreeStyleBuild)2 FreeStyleProject (hudson.model.FreeStyleProject)2 BuildDetailsRepository (org.jenkins.plugins.audit2db.data.BuildDetailsRepository)2 BuildDetailsImpl (org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl)2 BuildDetails (org.jenkins.plugins.audit2db.model.BuildDetails)2 BooleanParameterDefinition (hudson.model.BooleanParameterDefinition)1 ParameterDefinition (hudson.model.ParameterDefinition)1 ParametersDefinitionProperty (hudson.model.ParametersDefinitionProperty)1 StringParameterDefinition (hudson.model.StringParameterDefinition)1