Search in sources :

Example 1 with BuildNodeImpl

use of org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl 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 2 with BuildNodeImpl

use of org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl 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 3 with BuildNodeImpl

use of org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl in project selenium_java by sergueik.

the class TestUtils method createRandomBuildDetails.

public static BuildDetails createRandomBuildDetails(final boolean withParams) {
    final long salt = System.nanoTime();
    final BuildDetails build = new BuildDetailsImpl();
    build.setDuration(Long.valueOf(60 + (long) (Math.random() * 60)));
    build.setEndDate(new Date(build.getStartDate().getTime() + (build.getDuration() * 1000)));
    build.setFullName("BUILD FULL NAME " + salt);
    build.setId("BUILD ID " + salt);
    build.setName("BUILD NAME " + salt);
    build.setUserId("BUILD USER ID " + salt);
    build.setUserName("BUILD USER NAME " + salt);
    if (withParams) {
        final List<BuildParameter> params = new ArrayList<BuildParameter>();
        params.add(new BuildParameterImpl("PARAM_ID 1 " + salt, "PARAM NAME 1 " + salt, "PARAM VALUE 1 " + salt, build));
        params.add(new BuildParameterImpl("PARAM_ID 2 " + salt, "PARAM NAME 2 " + salt, "PARAM VALUE 2 " + salt, build));
        build.setParameters(params);
    }
    final BuildNode node = new BuildNodeImpl("NODE ADDRESS", "NODE HOSTNAME", "NODE DISPLAYNAME", "NODE URL", "NODE NAME", "NODE DESCRIPTION", "NODE LABEL");
    build.setNode(node);
    return build;
}
Also used : BuildDetailsImpl(org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl) BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) BuildNodeImpl(org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) ArrayList(java.util.ArrayList) BuildParameterImpl(org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl) Date(java.util.Date) BuildNode(org.jenkins.plugins.audit2db.model.BuildNode)

Example 4 with BuildNodeImpl

use of org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl in project selenium_java by sergueik.

the class BuildDetailsResolver method addBuildNodeFromContext.

private static void addBuildNodeFromContext(BuildDetailsImpl details, Run<?, ?> run, Computer computer) throws IOException, InterruptedException {
    LOGGER.finer("resolving build node");
    Jenkins jenkins = Jenkins.getInstance();
    LOGGER.finer("jenkins: " + jenkins);
    LOGGER.finer("computer: " + computer);
    Node node = computer.getNode();
    LOGGER.finer("node: " + node);
    String rootUrl = jenkins != null ? jenkins.getRootUrl() : "http://unconfigured-jenkins-server/";
    LOGGER.finer("rootUrl: " + rootUrl);
    URL url = new URL(rootUrl);
    String masterHostname = url.getHost();
    String urlString = String.format("%s/%s", rootUrl, computer.getUrl()).replaceAll("(\\w)(\\/{2,})(\\w)", "$1/$3");
    BuildNode buildNode = new BuildNodeImpl(resolveMasterIpAddress(computer), masterHostname, computer.getDisplayName(), // url
    urlString, node.getNodeName(), node.getNodeDescription(), node.getLabelString());
    LOGGER.finer("buildNode: " + buildNode);
    details.setNode(buildNode);
}
Also used : Jenkins(jenkins.model.Jenkins) BuildNodeImpl(org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl) Node(hudson.model.Node) BuildNode(org.jenkins.plugins.audit2db.model.BuildNode) URL(java.net.URL) BuildNode(org.jenkins.plugins.audit2db.model.BuildNode)

Aggregations

BuildNodeImpl (org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl)4 BuildNode (org.jenkins.plugins.audit2db.model.BuildNode)4 Test (org.junit.Test)2 Node (hudson.model.Node)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Jenkins (jenkins.model.Jenkins)1 BuildDetailsImpl (org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl)1 BuildParameterImpl (org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl)1 BuildDetails (org.jenkins.plugins.audit2db.model.BuildDetails)1 BuildParameter (org.jenkins.plugins.audit2db.model.BuildParameter)1