use of org.jenkins.plugins.audit2db.model.BuildParameter in project selenium_java by sergueik.
the class JobsByParamReportTests method invalidParamNameShouldReturnEmptyResults.
@Test
public void invalidParamNameShouldReturnEmptyResults() {
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() + " INVALID", param.getValue(), 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 BuildDetailsHibernateRepositoryTests method retrievalByNonMatchingParamNameShouldReturnEmptyList.
@Test
public void retrievalByNonMatchingParamNameShouldReturnEmptyList() {
final Map<String, List<BuildDetails>> dataset = TestUtils.createRandomDataset(hostName);
// ideally we should persist dataset in a transaction and roll it back
// at the end of the test
final TransactionStatus tx = txmgr.getTransaction(null);
tx.setRollbackOnly();
for (final List<BuildDetails> detailsList : dataset.values()) {
repository.saveBuildDetailsList(detailsList);
}
final Calendar fromDate = Calendar.getInstance();
fromDate.add(Calendar.YEAR, -1);
final Calendar toDate = Calendar.getInstance();
// get the first parameterised build details from the dataset
BuildDetails expected = null;
while (dataset.entrySet().iterator().hasNext()) {
expected = dataset.entrySet().iterator().next().getValue().get(0);
if (!expected.getParameters().isEmpty()) {
break;
}
}
final BuildParameter param = expected.getParameters().get(0);
final List<BuildDetails> buildDetails = repository.getBuildDetailsByParams(hostName, param.getName() + "-WRONGNAME", param.getValue(), fromDate.getTime(), toDate.getTime());
txmgr.rollback(tx);
Assert.assertNotNull("Unexpected null list of project names", buildDetails);
Assert.assertEquals("Unexpected non-empty list retrieved", 0, buildDetails.size());
}
use of org.jenkins.plugins.audit2db.model.BuildParameter in project selenium_java by sergueik.
the class BuildDetailsHibernateRepositoryTests method retrievalByNonMatchingParamValueShouldReturnEmptyList.
@Test
public void retrievalByNonMatchingParamValueShouldReturnEmptyList() {
final Map<String, List<BuildDetails>> dataset = TestUtils.createRandomDataset(hostName);
// ideally we should persist dataset in a transaction and roll it back
// at the end of the test
final TransactionStatus tx = txmgr.getTransaction(null);
tx.setRollbackOnly();
for (final List<BuildDetails> detailsList : dataset.values()) {
repository.saveBuildDetailsList(detailsList);
}
final Calendar fromDate = Calendar.getInstance();
fromDate.add(Calendar.YEAR, -1);
final Calendar toDate = Calendar.getInstance();
// get the first parameterised build details from the dataset
BuildDetails expected = null;
while (dataset.entrySet().iterator().hasNext()) {
expected = dataset.entrySet().iterator().next().getValue().get(0);
if (!expected.getParameters().isEmpty()) {
break;
}
}
final BuildParameter param = expected.getParameters().get(0);
final List<BuildDetails> buildDetails = repository.getBuildDetailsByParams(hostName, param.getName(), param.getValue() + "-WRONGVALUE", fromDate.getTime(), toDate.getTime());
txmgr.rollback(tx);
Assert.assertNotNull("Unexpected null list of project names", buildDetails);
Assert.assertEquals("Unexpected non-empty list retrieved", 0, buildDetails.size());
}
use of org.jenkins.plugins.audit2db.model.BuildParameter 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.model.BuildParameter in project selenium_java by sergueik.
the class BuildParameterImplTests method differentIdShouldBreakEquality.
@Test
public void differentIdShouldBreakEquality() {
final BuildParameter actual = new BuildParameterImpl(expected.getId() + "DIFFERENT", expected.getName(), expected.getValue(), expected.getBuildDetails());
Assert.assertFalse("Broken inequality logic", actual.equals(expected));
}
Aggregations