use of org.jenkins.plugins.audit2db.model.BuildParameter in project selenium_java by sergueik.
the class JobsByParamReportTests method invalidParamValueShouldReturnEmptyResults.
@Test
public void invalidParamValueShouldReturnEmptyResults() {
final JobsByParamReport report = new JobsByParamReportImpl();
report.setRepository(TestUtils.getTestRepository());
final Map<String, List<BuildDetails>> dataset = TestUtils.createRandomDataset(DbAuditUtil.getHostName());
// after each test run
for (final List<BuildDetails> detailsList : dataset.values()) {
TestUtils.getTestRepository().saveBuildDetailsList(detailsList);
}
final BuildParameter param = dataset.values().iterator().next().get(0).getParameters().get(0);
final Map<String, List<BuildDetails>> results = report.getProjectExecutions(param.getName(), param.getValue() + " INVALID", TestUtils.NOW, TestUtils.NOW);
Assert.assertTrue("Unexpected results collection", results.isEmpty());
}
use of org.jenkins.plugins.audit2db.model.BuildParameter in project selenium_java by sergueik.
the class JobsByParamReportTests method paramNameWithWildcardShouldReturnNonEmptyResults.
@Test
public void paramNameWithWildcardShouldReturnNonEmptyResults() {
final JobsByParamReport report = new JobsByParamReportImpl();
report.setRepository(TestUtils.getTestRepository());
final Map<String, List<BuildDetails>> dataset = TestUtils.createRandomDataset(DbAuditUtil.getHostName());
// after each test run
for (final List<BuildDetails> detailsList : dataset.values()) {
TestUtils.getTestRepository().saveBuildDetailsList(detailsList);
}
final BuildParameter param = dataset.values().iterator().next().get(0).getParameters().get(0);
final Map<String, List<BuildDetails>> results = report.getProjectExecutions(param.getName().substring(0) + "%", param.getValue(), TestUtils.NOW, TestUtils.NOW);
Assert.assertFalse("Unexpected empty results", results.isEmpty());
}
use of org.jenkins.plugins.audit2db.model.BuildParameter 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.model.BuildParameter in project selenium_java by sergueik.
the class BuildDetailsResolver method addParametersFromContext.
private static void addParametersFromContext(BuildDetailsImpl details, Run<?, ?> run) throws IOException, InterruptedException {
LOGGER.finest("resolving build parameters");
List<BuildParameter> buildParameters = new ArrayList<BuildParameter>();
for (Action action : run.getAllActions()) {
if (!ParametersAction.class.isInstance(action)) {
continue;
}
ParametersAction paramAction = (ParametersAction) action;
for (ParameterValue param : paramAction.getParameters()) {
LOGGER.finest("found parameter: " + param);
String paramId = run.getId() + "-" + param.getName();
buildParameters.add(new BuildParameterImpl(paramId, param.getName(), param.getValue().toString(), details));
}
}
details.setParameters(buildParameters);
}
Aggregations