Search in sources :

Example 1 with BuildParameterImpl

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

the class BuildParameterImplTests method differentAttributesShouldPreserveEquality.

@Test
public void differentAttributesShouldPreserveEquality() {
    final BuildParameter actual = new BuildParameterImpl(expected.getId(), expected.getName() + "DIFFERENT", expected.getValue() + "DIFFERENT", otherDetails);
    Assert.assertEquals("Broken equality", expected, actual);
}
Also used : BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) BuildParameterImpl(org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl) Test(org.junit.Test)

Example 2 with BuildParameterImpl

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

the class BuildDetailsImplTests method getBuildDetails.

private BuildDetails getBuildDetails() {
    final BuildDetails build = new BuildDetailsImpl();
    build.setDuration(Long.valueOf(60));
    build.setEndDate(new Date(build.getStartDate().getTime() + (build.getDuration() * 1000)));
    build.setFullName("BUILD FULL NAME");
    build.setId("BUILD ID");
    build.setName("BUILD NAME");
    build.setUserId("BUILD USER ID");
    build.setUserName("BUILD USER NAME");
    final List<BuildParameter> params = new ArrayList<BuildParameter>();
    params.add(new BuildParameterImpl("PARAM_ID", "PARAM NAME", "PARAM VALUE", build));
    build.setParameters(params);
    return build;
}
Also used : BuildDetailsImpl(org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl) BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) ArrayList(java.util.ArrayList) BuildParameterImpl(org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl) Date(java.util.Date)

Example 3 with BuildParameterImpl

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

the class BuildParameterImplTests method differentIdShouldBreakEquality.

@Test
public void differentIdShouldBreakEquality() {
    final BuildParameter actual = new BuildParameterImpl(expected.getId() + "DIFFERENT", expected.getName(), expected.getValue(), expected.getBuildDetails());
    Assert.assertFalse("Broken inequality logic", actual.equals(expected));
}
Also used : BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) BuildParameterImpl(org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl) Test(org.junit.Test)

Example 4 with BuildParameterImpl

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

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

the class BuildDetailsResolver method addParametersFromContext.

private static void addParametersFromContext(BuildDetailsImpl details, Run<?, ?> run) throws IOException, InterruptedException {
    LOGGER.finest("resolving build parameters");
    List<BuildParameter> buildParameters = new ArrayList<BuildParameter>();
    for (Action action : run.getAllActions()) {
        if (!ParametersAction.class.isInstance(action)) {
            continue;
        }
        ParametersAction paramAction = (ParametersAction) action;
        for (ParameterValue param : paramAction.getParameters()) {
            LOGGER.finest("found parameter: " + param);
            String paramId = run.getId() + "-" + param.getName();
            buildParameters.add(new BuildParameterImpl(paramId, param.getName(), param.getValue().toString(), details));
        }
    }
    details.setParameters(buildParameters);
}
Also used : BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) Action(hudson.model.Action) ParametersAction(hudson.model.ParametersAction) ParameterValue(hudson.model.ParameterValue) ArrayList(java.util.ArrayList) BuildParameterImpl(org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl) ParametersAction(hudson.model.ParametersAction)

Aggregations

BuildParameterImpl (org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl)5 BuildParameter (org.jenkins.plugins.audit2db.model.BuildParameter)5 ArrayList (java.util.ArrayList)3 Date (java.util.Date)2 BuildDetailsImpl (org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl)2 BuildDetails (org.jenkins.plugins.audit2db.model.BuildDetails)2 Test (org.junit.Test)2 Action (hudson.model.Action)1 ParameterValue (hudson.model.ParameterValue)1 ParametersAction (hudson.model.ParametersAction)1 BuildNodeImpl (org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl)1 BuildNode (org.jenkins.plugins.audit2db.model.BuildNode)1