Search in sources :

Example 1 with BuildNode

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);
}
Also used : BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) BuildNode(org.jenkins.plugins.audit2db.model.BuildNode) Test(org.junit.Test)

Example 2 with BuildNode

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);
}
Also used : BuildNodeImpl(org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl) BuildNode(org.jenkins.plugins.audit2db.model.BuildNode) Test(org.junit.Test)

Example 3 with BuildNode

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));
}
Also used : BuildNodeImpl(org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl) BuildNode(org.jenkins.plugins.audit2db.model.BuildNode) Test(org.junit.Test)

Example 4 with BuildNode

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;
}
Also used : DetachedCriteria(org.hibernate.criterion.DetachedCriteria) BuildNode(org.jenkins.plugins.audit2db.model.BuildNode)

Example 5 with BuildNode

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);
}
Also used : BuildNode(org.jenkins.plugins.audit2db.model.BuildNode)

Aggregations

BuildNode (org.jenkins.plugins.audit2db.model.BuildNode)10 Test (org.junit.Test)5 BuildNodeImpl (org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl)4 BuildDetails (org.jenkins.plugins.audit2db.model.BuildDetails)4 Computer (hudson.model.Computer)1 Node (hudson.model.Node)1 InetAddress (java.net.InetAddress)1 URL (java.net.URL)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Jenkins (jenkins.model.Jenkins)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1 BuildDetailsImpl (org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl)1 BuildParameterImpl (org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl)1 BuildParameter (org.jenkins.plugins.audit2db.model.BuildParameter)1 HibernateTemplate (org.springframework.orm.hibernate3.HibernateTemplate)1