use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class BuildDetailsHibernateRepositoryTests method retrievalByMatchingNameShouldReturnNonEmptyList.
@Test
public void retrievalByMatchingNameShouldReturnNonEmptyList() {
final BuildDetails build = TestUtils.createRandomBuildDetails();
final Object buildId = repository.saveBuildDetails(build);
Assert.assertNotNull("Unexpected null build id", buildId);
final List<BuildDetails> builds = repository.getBuildDetailsByName(build.getName().toLowerCase());
Assert.assertNotNull("Unexpected null list of builds", builds);
Assert.assertFalse("Unexpected empty list of builds", builds.isEmpty());
Assert.assertEquals("Unexpected number of builds", 1, builds.size());
Assert.assertEquals("Mismatching build details found", build, builds.get(0));
}
use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class BuildDetailsHibernateRepositoryTests method retrievalByMatchingFullNameShouldReturnNonEmptyList.
@Test
public void retrievalByMatchingFullNameShouldReturnNonEmptyList() {
final BuildDetails build = TestUtils.createRandomBuildDetails();
final Object buildId = repository.saveBuildDetails(build);
Assert.assertNotNull("Unexpected null build id", buildId);
final List<BuildDetails> builds = repository.getBuildDetailsByFullName(build.getFullName().toLowerCase());
Assert.assertNotNull("Unexpected null list of builds", builds);
Assert.assertFalse("Unexpected empty list of builds", builds.isEmpty());
Assert.assertEquals("Unexpected number of builds", 1, builds.size());
Assert.assertEquals("Mismatching build details found", build, builds.get(0));
}
use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class BuildDetailsHibernateRepositoryTests method retrievalByNonMatchingUserNameShouldReturnEmptyList.
@Test
public void retrievalByNonMatchingUserNameShouldReturnEmptyList() {
final BuildDetails build = TestUtils.createRandomBuildDetails();
final Object buildId = repository.saveBuildDetails(build);
Assert.assertNotNull("Unexpected null build id", buildId);
final List<BuildDetails> builds = repository.getBuildDetailsByUserName(build.getUserName() + "NOMATCH");
Assert.assertNotNull("Unexpected null list of builds", builds);
Assert.assertTrue("Unexpected non-empty list of builds", builds.isEmpty());
}
use of org.jenkins.plugins.audit2db.model.BuildDetails 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.BuildDetails 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);
}
Aggregations