Java Code Examples for hudson.matrix.AxisList#add()

The following examples show how to use hudson.matrix.AxisList#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitLabEnvironmentContributorTest.java    From gitlab-plugin with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void matrixProjectTest() throws IOException, InterruptedException, ExecutionException {
    EnvVars env;
    MatrixProject p = jenkins.jenkins.createProject(MatrixProject.class, "matrixbuild");
    GitLabWebHookCause cause = new GitLabWebHookCause(generateCauseData());
    // set up 2x2 matrix
    AxisList axes = new AxisList();
    axes.add(new TextAxis("db","mysql","oracle"));
    axes.add(new TextAxis("direction","north","south"));
    p.setAxes(axes);

    MatrixBuild build = p.scheduleBuild2(0, cause).get();
    List<MatrixRun> runs = build.getRuns();
    assertEquals(4,runs.size());
    for (MatrixRun run : runs) {
        env = run.getEnvironment(listener);
        assertNotNull(env.get("db"));
        assertEnv(env);
    }
}
 
Example 2
Source File: MatrixJobITest.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
/**
 * Build a matrix job with three configurations. For each configuration a different set of warnings will be parsed
 * with the same parser (GCC). After the successful build the total number of warnings at the root level should be
 * set to 12 (sum of all three configurations). Moreover, for each configuration the total number of warnings is
 * also verified (4, 6, and 2 warnings).
 *
 * @throws Exception in case of an error
 */
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
@Test
public void shouldCreateIndividualAxisResults() throws Exception {
    MatrixProject project = createProject(MatrixProject.class);
    copySingleFileToWorkspace(project, "matrix-warnings-one.txt", "user_axis/one/warnings.txt");
    copySingleFileToWorkspace(project, "matrix-warnings-two.txt", "user_axis/two/warnings.txt");
    copySingleFileToWorkspace(project, "matrix-warnings-three.txt", "user_axis/three/warnings.txt");
    IssuesRecorder publisher = new IssuesRecorder();
    Gcc4 tool = new Gcc4();
    tool.setPattern("**/*.txt");
    publisher.setTools(tool);
    project.getPublishersList().add(publisher);

    AxisList axis = new AxisList();
    TextAxis userAxis = new TextAxis("user_axis", "one two three");
    axis.add(userAxis);
    project.setAxes(axis);

    Map<String, Integer> warningsPerAxis = new HashMap<>();
    warningsPerAxis.put("one", 4);
    warningsPerAxis.put("two", 6);
    warningsPerAxis.put("three", 2);

    MatrixBuild build = project.scheduleBuild2(0).get();
    for (MatrixRun run : build.getRuns()) {
        getJenkins().assertBuildStatus(Result.SUCCESS, run);

        AnalysisResult result = getAnalysisResult(run);

        String currentAxis = run.getBuildVariables().values().iterator().next();
        assertThat(result.getTotalSize()).as("Result of axis " + currentAxis).isEqualTo(warningsPerAxis.get(currentAxis));
    }
    AnalysisResult aggregation = getAnalysisResult(build);
    assertThat(aggregation.getTotalSize()).isEqualTo(12);
}
 
Example 3
Source File: AxisListConverter.java    From DotCi with MIT License 5 votes vote down vote up
@Override
public Object decode(Class targetClass, Object fromDBObject, MappedField optionalExtraInfo) {
    if (fromDBObject == null) return null;

    BasicDBList rawList = (BasicDBList) fromDBObject;

    AxisList axisList = new AxisList();
    for (Object obj : rawList) {
        DBObject dbObj = (DBObject) obj;
        axisList.add((Axis) getMapper().fromDBObject(optionalExtraInfo.getSubClass(), dbObj, getMapper().createEntityCache()));
    }

    return axisList;
}