use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class BuildDetailsHibernateRepositoryTests method retrievingMatchingProjectNamePatternShouldReturnValidDataset.
@Test
public void retrievingMatchingProjectNamePatternShouldReturnValidDataset() {
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();
// let's try to find projects by matching the first one in the set
final String projectName = dataset.keySet().iterator().next();
// find partial match
final String pattern = projectName.substring(0, projectName.length() / 2) + "%";
final List<String> projectNames = repository.getProjectNames(hostName, pattern, fromDate.getTime(), toDate.getTime());
txmgr.rollback(tx);
Assert.assertNotNull("Unexpected null list of project names", projectNames);
Assert.assertFalse("Unexpected empty list of project names", projectNames.isEmpty());
}
use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class BuildDetailsHibernateRepositoryTests method retrievingBuildNodeByValidUrlShouldSucceed.
@Test
public void retrievingBuildNodeByValidUrlShouldSucceed() {
final BuildDetails build = TestUtils.createRandomBuildDetails();
final Object buildId = repository.saveBuildDetails(build);
Assert.assertNotNull("Unexpected null build id", buildId);
final BuildNode expected = build.getNode();
final BuildNode actual = repository.getBuildNodeByUrl(expected.getUrl());
Assert.assertNotNull("Unexppected null build node", actual);
Assert.assertEquals("Unexpected build node", expected, actual);
}
use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class BuildDetailsHibernateRepositoryTests method retrievalByBlankParamNameShouldReturnNonEmptyList.
@Test
public void retrievalByBlankParamNameShouldReturnNonEmptyList() {
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 non-parameterised build details from the dataset
// this must appear in the returned list
BuildDetails expected = null;
for (final Entry<String, List<BuildDetails>> entry : dataset.entrySet()) {
expected = entry.getValue().get(0);
if (expected.getParameters().isEmpty()) {
break;
}
}
// get the first parameterised build details from the dataset
// this one should not appear in the returned list
BuildDetails unexpected = null;
for (final Entry<String, List<BuildDetails>> entry : dataset.entrySet()) {
unexpected = entry.getValue().get(0);
if (!unexpected.getParameters().isEmpty()) {
break;
}
}
final List<BuildDetails> buildDetails = repository.getBuildDetailsByParams(hostName, "", "", fromDate.getTime(), toDate.getTime());
txmgr.rollback(tx);
Assert.assertNotNull("Unexpected null list of build details", buildDetails);
Assert.assertFalse("Unexpected empty list of build details", buildDetails.isEmpty());
Assert.assertTrue("The expected build details was not returned", buildDetails.contains(expected));
Assert.assertTrue("The unexpected build details was returned", !buildDetails.contains(unexpected));
}
use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class BuildDetailsHibernateRepositoryTests method retrievingMatchingProjectNameShouldReturnValidDataset.
@Test
public void retrievingMatchingProjectNameShouldReturnValidDataset() {
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();
// let's try to find projects by matching the first one in the set
final String projectName = dataset.keySet().iterator().next();
// find exact match
final List<String> projectNames = repository.getProjectNames(hostName, projectName, fromDate.getTime(), toDate.getTime());
txmgr.rollback(tx);
Assert.assertNotNull("Unexpected null list of project names", projectNames);
Assert.assertFalse("Unexpected empty list of project names", projectNames.isEmpty());
Assert.assertEquals("Unexpected number of project names", 1, projectNames.size());
}
use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class BuildDetailsHibernateRepositoryTests method updatedBuildDetailsShouldBePersisted.
@Test
public void updatedBuildDetailsShouldBePersisted() {
final BuildDetails build = TestUtils.createRandomBuildDetails();
final Object buildId = repository.saveBuildDetails(build);
Assert.assertNotNull("Unexpected null build id", buildId);
final String oldName = build.getName();
final String newName = oldName + "UPDATED";
build.setName(newName);
repository.updateBuildDetails(build);
List<BuildDetails> builds = repository.getBuildDetailsByName(oldName);
Assert.assertNotNull("Unexpected null list of builds", builds);
Assert.assertTrue("Unexpected non-empty list of builds", builds.isEmpty());
builds = repository.getBuildDetailsByName(newName);
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));
}
Aggregations