Search in sources :

Example 1 with InsightsConfigFilesDAL

use of com.cognizant.devops.platformdal.filemanagement.InsightsConfigFilesDAL in project Insights by CognizantOneDevOps.

the class AssessmentReportsTestData method preparePanelJson.

public JsonObject preparePanelJson(String vType, String vQuery, String title, int id) throws InsightsCustomException {
    JsonObject panelTemplateJson = null;
    try {
        InsightsConfigFilesDAL configFilesDAL = new InsightsConfigFilesDAL();
        byte[] panelTemplateByte = configFilesDAL.getConfigurationFile(vType).getFileData();
        String template = new String(panelTemplateByte);
        panelTemplateJson = JsonUtils.parseStringAsJsonObject(template);
        panelTemplateJson.addProperty("title", title);
        panelTemplateJson.addProperty("id", id);
        panelTemplateJson.addProperty("datasource", "Neo4j Data Source");
        panelTemplateJson.getAsJsonArray(AssessmentReportAndWorkflowConstants.TARGETS).get(0).getAsJsonObject().addProperty(AssessmentReportAndWorkflowConstants.QUERYTEXT, vQuery);
    } catch (Exception e) {
        log.error("Error while preparing panel JSON ====", e);
        throw new InsightsCustomException(e.getMessage());
    }
    return panelTemplateJson;
}
Also used : InsightsConfigFilesDAL(com.cognizant.devops.platformdal.filemanagement.InsightsConfigFilesDAL) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException) JsonObject(com.google.gson.JsonObject) SkipException(org.testng.SkipException) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException) JsonIOException(com.google.gson.JsonIOException) JsonSyntaxException(com.google.gson.JsonSyntaxException) IOException(java.io.IOException)

Example 2 with InsightsConfigFilesDAL

use of com.cognizant.devops.platformdal.filemanagement.InsightsConfigFilesDAL in project Insights by CognizantOneDevOps.

the class AssessmentReportsTest method onInit.

@BeforeClass
public void onInit() throws Exception {
    reportTypeId = saveWorkflowType("Report");
    // save multiple Kpi definition in db
    readKpiFileAndSave("KPIDefination.json");
    InsightsConfigFilesDAL configFilesDAL = new InsightsConfigFilesDAL();
    configFilesDAL.saveConfigurationFile(AssessmentReportsTestData.createConfigFileData());
    // save multiple content definition in db
    readContentFileAndSave("ContentsConfiguration.json");
    getData();
    generateGrafanaToken();
    // save report template in db
    readReportTempFileAndSave("REPORT_SONAR_JENKINS_PROD_RT.json", reportIdProdRT);
    readReportTempFileAndSave("REPORT_SONAR_RT.json", reportIdSonarRT);
    saveReportTemplate(reportTemplatekpi, reportIdkpiRT);
    saveReportTemplate(reportTemplatekpis, reportIdkpisRT);
    // save report template design files in db
    uploadReportTemplateDesignFiles(reportIdProdRT);
    typeId = saveWorkflowType("SYSTEM");
    // save workflow task in db
    saveWorkflowTask(taskKpiExecution);
    saveWorkflowTask(taskPDFExecution);
    saveWorkflowTask(taskEmailExecution);
    saveWorkflowTask(taskSystemHealthNotificationExecution);
    saveWorkflowTask(taskSystemEmailNotificationExecution);
    // save assessment report
    saveAssessmentReport(workflowIdProd, assessmentReport, 2);
    saveAssessmentReport(workflowIdWithEmail, assessmentReportWithEmail, 3);
    saveAssessmentReport(workflowIdWithoutEmail, assessmentReportWithoutEmail, 2);
    saveAssessmentReport(workflowIdWrongkpi, assessmentReportWrongkpi, 2);
    saveAssessmentReport(workflowIdWrongkpis, assessmentReportWrongkpis, 2);
    saveAssessmentReport(workflowIdFail, assessmentReportFail, 1);
    saveHealthNotificationWorkflowConfig();
    grafanaPDFExportUrl = ApplicationConfigProvider.getInstance().getGrafana().getGrafanaEndpoint();
    smtpHostServer = ApplicationConfigProvider.getInstance().getEmailConfiguration().getSmtpHostServer();
    ApplicationConfigProvider.getInstance().getAssessmentReport().setMaxWorkflowRetries(3);
    initializeTask();
    // run workflow executor
    WorkflowExecutor executor = new WorkflowExecutor();
    executor.executeWorkflow();
    Thread.sleep(40000);
    WorkflowImmediateJobExecutor immediateJobExecutor = new WorkflowImmediateJobExecutor();
    immediateJobExecutor.executeImmediateWorkflow();
    Thread.sleep(40000);
}
Also used : InsightsConfigFilesDAL(com.cognizant.devops.platformdal.filemanagement.InsightsConfigFilesDAL) WorkflowImmediateJobExecutor(com.cognizant.devops.platformworkflow.workflowtask.core.WorkflowImmediateJobExecutor) WorkflowExecutor(com.cognizant.devops.platformworkflow.workflowtask.core.WorkflowExecutor) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

InsightsConfigFilesDAL (com.cognizant.devops.platformdal.filemanagement.InsightsConfigFilesDAL)2 InsightsCustomException (com.cognizant.devops.platformcommons.exception.InsightsCustomException)1 WorkflowExecutor (com.cognizant.devops.platformworkflow.workflowtask.core.WorkflowExecutor)1 WorkflowImmediateJobExecutor (com.cognizant.devops.platformworkflow.workflowtask.core.WorkflowImmediateJobExecutor)1 JsonIOException (com.google.gson.JsonIOException)1 JsonObject (com.google.gson.JsonObject)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 IOException (java.io.IOException)1 SkipException (org.testng.SkipException)1 BeforeClass (org.testng.annotations.BeforeClass)1