use of org.jenkins.plugins.audit2db.model.BuildNode 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.BuildNode in project selenium_java by sergueik.
the class BuildNodeImplTests method differentAttributesWithSameUrlShouldPreserveEquality.
@Test
public void differentAttributesWithSameUrlShouldPreserveEquality() {
final BuildNode actual = new BuildNodeImpl(expected.getMasterAddress() + "DIFFERENT", expected.getMasterHostName() + "DIFFERENT", expected.getDisplayName() + "DIFFERENT", expected.getUrl(), expected.getName() + "DIFFERENT", expected.getDescription() + "DIFFERENT", expected.getLabel() + "DIFFERENT");
Assert.assertEquals("Broken equality", expected, actual);
}
use of org.jenkins.plugins.audit2db.model.BuildNode in project selenium_java by sergueik.
the class BuildNodeImplTests method differentUrlShouldBreakEquality.
@Test
public void differentUrlShouldBreakEquality() {
final BuildNode actual = new BuildNodeImpl(expected.getMasterAddress(), expected.getMasterHostName(), expected.getDisplayName(), expected.getUrl() + "DIFFERENT", expected.getName(), expected.getDescription(), expected.getLabel());
Assert.assertFalse("Broken inequality logic", actual.equals(expected));
}
use of org.jenkins.plugins.audit2db.model.BuildNode in project selenium_java by sergueik.
the class BuildDetailsHibernateRepository method getBuildNodeByUrl.
/**
* @see org.jenkins.plugins.audit2db.data.BuildDetailsRepository#getBuildNodeByUrl(String)
*/
@Override
public BuildNode getBuildNodeByUrl(final String url) {
if (null == url) {
throw new IllegalArgumentException("Invalid url: cannot be null.");
}
BuildNode retval = null;
final DetachedCriteria criteria = DetachedCriteria.forClass(BuildNodeImpl.class);
criteria.add(Restrictions.eq("url", url).ignoreCase());
try {
@SuppressWarnings("unchecked") final List<BuildNode> nodes = getHibernateTemplate().findByCriteria(criteria);
if ((nodes != null) && !nodes.isEmpty()) {
retval = nodes.get(0);
}
} catch (final Throwable t) {
LOGGER.log(Level.SEVERE, t.getMessage(), t);
}
return retval;
}
use of org.jenkins.plugins.audit2db.model.BuildNode in project selenium_java by sergueik.
the class BuildDetailsHibernateRepository method saveBuildDetails.
/**
* @see org.jenkins.plugins.audit2db.data.BuildDetailsRepository#saveBuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails)
*/
@Override
public Object saveBuildDetails(final BuildDetails details) {
if (null == details) {
throw new IllegalArgumentException("Invalid build details: cannot be null.");
}
// check if the build node details are already persisted
final String url = details.getNode().getUrl();
final BuildNode node = getBuildNodeByUrl(url);
if (node != null) {
details.setNode(node);
}
return getHibernateTemplate().save(details);
}
Aggregations