All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clarolab.bamboo.client.BambooResultClient Maven / Gradle / Ivy

package com.clarolab.bamboo.client;

import com.clarolab.bamboo.entities.BambooMain;
import com.clarolab.bamboo.entities.BambooResult;
import com.clarolab.bamboo.utils.Constants;
import lombok.Builder;
import lombok.Data;

import java.util.List;

@Data
public class BambooResultClient extends BambooClient {

    @Builder
    public BambooResultClient(BambooApiClient bambooApiClient, int limitResults) {
        super(bambooApiClient, limitResults);
    }

    public List getResultsForPlan(String planKey) throws Exception {
        return getResults(Constants.BAMBOO_RESULT_ENDPOINT, planKey);
    }

    public List getResultsForPlanFromStages(String projectKeyPlanKey) throws Exception {
        return getResults(Constants.BAMBOO_RESULT_WITH_STAGES_ENDPOINT, projectKeyPlanKey);
    }

    private List getResults(String endPoint, String key) throws Exception {
        List bambooResults =  perform(String.format(endPoint, key, 0, getLimitResults()), BambooMain.class).getResults();
        bambooResults.forEach(bambooResult -> {
            if(bambooResult.getArtifacts() != null && !bambooResult.getArtifacts().isEmpty())
                bambooResult.getArtifacts().forEach(bambooArtifact -> bambooArtifact.setBambooApiClient(getBambooApiClient()));

            if(bambooResult.getStages() != null && !bambooResult.getStages().isEmpty()){
                bambooResult.getStages().forEach(stage -> {
                    if(stage.getResults() != null && !stage.getResults().isEmpty()){
                        stage.getResults().forEach(bambooResultOnstage -> {
                            if(bambooResultOnstage.getArtifacts() != null || !bambooResultOnstage.getArtifacts().isEmpty())
                                bambooResultOnstage.getArtifacts().forEach(bambooArtifact -> bambooArtifact.setBambooApiClient(getBambooApiClient()));
                        });
                    }
                });
            }

        });
        return bambooResults;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy