use of org.jenkins.plugins.audit2db.model.BuildParameter in project selenium_java by sergueik.
the class BuildDetailsHibernateRepositoryTests method retrievalByMatchingParamsShouldReturnNonEmptyList.
@Test
public void retrievalByMatchingParamsShouldReturnNonEmptyList() {
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(), fromDate.getTime(), toDate.getTime());
txmgr.rollback(tx);
Assert.assertNotNull("Unexpected null list of project names", buildDetails);
Assert.assertEquals("Unexpected number of build details retrieved", 1, buildDetails.size());
Assert.assertEquals("Unexpected build details retrieved", expected, buildDetails.get(0));
}
use of org.jenkins.plugins.audit2db.model.BuildParameter in project selenium_java by sergueik.
the class BuildDetailsImplTests method differentAttributesShouldPreserveEquality.
@Test
public void differentAttributesShouldPreserveEquality() {
final BuildDetails expected = getBuildDetails();
final BuildDetails actual = getBuildDetails();
Assert.assertEquals("Broken equality", expected, actual);
final Calendar spaceman = Calendar.getInstance();
spaceman.set(1961, 3, 12);
actual.setDuration(actual.getDuration() + 1000);
actual.setEndDate(spaceman.getTime());
actual.setFullName(actual.getFullName() + "CHANGED");
actual.setName(actual.getName() + "CHANGED");
actual.setParameters(new ArrayList<BuildParameter>());
actual.setStartDate(spaceman.getTime());
actual.setUserId(actual.getUserId() + "CHANGED");
actual.setUserName(actual.getUserName() + "CHANGED");
Assert.assertEquals("Broken equality", expected, actual);
}
use of org.jenkins.plugins.audit2db.model.BuildParameter in project selenium_java by sergueik.
the class BuildParameterImplTests method differentAttributesShouldPreserveEquality.
@Test
public void differentAttributesShouldPreserveEquality() {
final BuildParameter actual = new BuildParameterImpl(expected.getId(), expected.getName() + "DIFFERENT", expected.getValue() + "DIFFERENT", otherDetails);
Assert.assertEquals("Broken equality", expected, actual);
}
use of org.jenkins.plugins.audit2db.model.BuildParameter in project selenium_java by sergueik.
the class JobsByParamReportTests method paramValueWithWildcardShouldReturnNonEmptyResults.
@Test
public void paramValueWithWildcardShouldReturnNonEmptyResults() {
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().substring(0) + "%", 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 JobsByParamReportTests method matchingParametersShouldReturnNonEmptyResults.
@Test
public void matchingParametersShouldReturnNonEmptyResults() {
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(), TestUtils.NOW, TestUtils.NOW);
Assert.assertFalse("Unexpected empty results", results.isEmpty());
}
Aggregations