Search in sources :

Example 1 with AbstractBuildResultNotificationDTO

use of de.tum.in.www1.artemis.service.dto.AbstractBuildResultNotificationDTO in project Artemis by ls1intum.

the class JenkinsService method addFeedbackToResult.

@Override
protected void addFeedbackToResult(Result result, AbstractBuildResultNotificationDTO buildResult) {
    final ProgrammingExercise programmingExercise = (ProgrammingExercise) result.getParticipation().getExercise();
    final ProgrammingLanguage programmingLanguage = programmingExercise.getProgrammingLanguage();
    final var jobs = ((TestResultsDTO) buildResult).getResults();
    // Extract test case feedback
    for (final var job : jobs) {
        for (final var testCase : job.getTestCases()) {
            var feedbackMessages = extractMessageFromTestCase(testCase).map(List::of).orElse(List.of());
            var feedback = feedbackRepository.createFeedbackFromTestCase(testCase.getName(), feedbackMessages, testCase.isSuccessful(), programmingLanguage);
            result.addFeedback(feedback);
        }
    }
    // Extract static code analysis feedback if option was enabled
    var staticCodeAnalysisReports = ((TestResultsDTO) buildResult).getStaticCodeAnalysisReports();
    if (Boolean.TRUE.equals(programmingExercise.isStaticCodeAnalysisEnabled()) && staticCodeAnalysisReports != null && !staticCodeAnalysisReports.isEmpty()) {
        var scaFeedback = feedbackRepository.createFeedbackFromStaticCodeAnalysisReports(staticCodeAnalysisReports);
        result.addFeedbacks(scaFeedback);
    }
    // Relevant feedback is negative, or positive with a message
    result.setHasFeedback(result.getFeedbacks().stream().anyMatch(fb -> !fb.isPositive() || fb.getDetailText() != null));
}
Also used : ContinuousIntegrationException(de.tum.in.www1.artemis.exception.ContinuousIntegrationException) ProgrammingLanguage(de.tum.in.www1.artemis.domain.enumeration.ProgrammingLanguage) ProgrammingSubmissionRepository(de.tum.in.www1.artemis.repository.ProgrammingSubmissionRepository) ExerciseDateService(de.tum.in.www1.artemis.service.ExerciseDateService) LoggerFactory(org.slf4j.LoggerFactory) AbstractContinuousIntegrationService(de.tum.in.www1.artemis.service.connectors.AbstractContinuousIntegrationService) TestResultsDTO(de.tum.in.www1.artemis.service.connectors.jenkins.dto.TestResultsDTO) Value(org.springframework.beans.factory.annotation.Value) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) RepositoryType(de.tum.in.www1.artemis.domain.enumeration.RepositoryType) ProgrammingExerciseParticipation(de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseParticipation) JenkinsJobService(de.tum.in.www1.artemis.service.connectors.jenkins.jobs.JenkinsJobService) Map(java.util.Map) Qualifier(org.springframework.beans.factory.annotation.Qualifier) RestTemplate(org.springframework.web.client.RestTemplate) FeedbackRepository(de.tum.in.www1.artemis.repository.FeedbackRepository) Logger(org.slf4j.Logger) BuildPlanType(de.tum.in.www1.artemis.domain.enumeration.BuildPlanType) TestCaseDTO(de.tum.in.www1.artemis.service.connectors.jenkins.dto.TestCaseDTO) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Profile(org.springframework.context.annotation.Profile) JenkinsServer(com.offbytwo.jenkins.JenkinsServer) JenkinsException(de.tum.in.www1.artemis.exception.JenkinsException) AbstractBuildResultNotificationDTO(de.tum.in.www1.artemis.service.dto.AbstractBuildResultNotificationDTO) List(java.util.List) Stream(java.util.stream.Stream) de.tum.in.www1.artemis.domain(de.tum.in.www1.artemis.domain) CIPermission(de.tum.in.www1.artemis.service.connectors.CIPermission) BuildLogEntryService(de.tum.in.www1.artemis.service.BuildLogEntryService) ConnectorHealth(de.tum.in.www1.artemis.service.connectors.ConnectorHealth) Optional(java.util.Optional) ResponseEntity(org.springframework.http.ResponseEntity) Jsoup(org.jsoup.Jsoup) TestResultsDTO(de.tum.in.www1.artemis.service.connectors.jenkins.dto.TestResultsDTO) ProgrammingLanguage(de.tum.in.www1.artemis.domain.enumeration.ProgrammingLanguage)

Example 2 with AbstractBuildResultNotificationDTO

use of de.tum.in.www1.artemis.service.dto.AbstractBuildResultNotificationDTO in project ArTEMiS by ls1intum.

the class JenkinsService method addFeedbackToResult.

@Override
protected void addFeedbackToResult(Result result, AbstractBuildResultNotificationDTO buildResult) {
    final ProgrammingExercise programmingExercise = (ProgrammingExercise) result.getParticipation().getExercise();
    final ProgrammingLanguage programmingLanguage = programmingExercise.getProgrammingLanguage();
    final var jobs = ((TestResultsDTO) buildResult).getResults();
    // Extract test case feedback
    for (final var job : jobs) {
        for (final var testCase : job.getTestCases()) {
            var feedbackMessages = extractMessageFromTestCase(testCase).map(List::of).orElse(List.of());
            var feedback = feedbackRepository.createFeedbackFromTestCase(testCase.getName(), feedbackMessages, testCase.isSuccessful(), programmingLanguage);
            result.addFeedback(feedback);
        }
    }
    // Extract static code analysis feedback if option was enabled
    var staticCodeAnalysisReports = ((TestResultsDTO) buildResult).getStaticCodeAnalysisReports();
    if (Boolean.TRUE.equals(programmingExercise.isStaticCodeAnalysisEnabled()) && staticCodeAnalysisReports != null && !staticCodeAnalysisReports.isEmpty()) {
        var scaFeedback = feedbackRepository.createFeedbackFromStaticCodeAnalysisReports(staticCodeAnalysisReports);
        result.addFeedbacks(scaFeedback);
    }
    // Relevant feedback is negative, or positive with a message
    result.setHasFeedback(result.getFeedbacks().stream().anyMatch(fb -> !fb.isPositive() || fb.getDetailText() != null));
}
Also used : ContinuousIntegrationException(de.tum.in.www1.artemis.exception.ContinuousIntegrationException) ProgrammingLanguage(de.tum.in.www1.artemis.domain.enumeration.ProgrammingLanguage) ProgrammingSubmissionRepository(de.tum.in.www1.artemis.repository.ProgrammingSubmissionRepository) ExerciseDateService(de.tum.in.www1.artemis.service.ExerciseDateService) LoggerFactory(org.slf4j.LoggerFactory) AbstractContinuousIntegrationService(de.tum.in.www1.artemis.service.connectors.AbstractContinuousIntegrationService) TestResultsDTO(de.tum.in.www1.artemis.service.connectors.jenkins.dto.TestResultsDTO) Value(org.springframework.beans.factory.annotation.Value) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) RepositoryType(de.tum.in.www1.artemis.domain.enumeration.RepositoryType) ProgrammingExerciseParticipation(de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseParticipation) JenkinsJobService(de.tum.in.www1.artemis.service.connectors.jenkins.jobs.JenkinsJobService) Map(java.util.Map) Qualifier(org.springframework.beans.factory.annotation.Qualifier) RestTemplate(org.springframework.web.client.RestTemplate) FeedbackRepository(de.tum.in.www1.artemis.repository.FeedbackRepository) Logger(org.slf4j.Logger) BuildPlanType(de.tum.in.www1.artemis.domain.enumeration.BuildPlanType) TestCaseDTO(de.tum.in.www1.artemis.service.connectors.jenkins.dto.TestCaseDTO) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Profile(org.springframework.context.annotation.Profile) JenkinsServer(com.offbytwo.jenkins.JenkinsServer) JenkinsException(de.tum.in.www1.artemis.exception.JenkinsException) AbstractBuildResultNotificationDTO(de.tum.in.www1.artemis.service.dto.AbstractBuildResultNotificationDTO) List(java.util.List) Stream(java.util.stream.Stream) de.tum.in.www1.artemis.domain(de.tum.in.www1.artemis.domain) CIPermission(de.tum.in.www1.artemis.service.connectors.CIPermission) BuildLogEntryService(de.tum.in.www1.artemis.service.BuildLogEntryService) ConnectorHealth(de.tum.in.www1.artemis.service.connectors.ConnectorHealth) Optional(java.util.Optional) ResponseEntity(org.springframework.http.ResponseEntity) Jsoup(org.jsoup.Jsoup) TestResultsDTO(de.tum.in.www1.artemis.service.connectors.jenkins.dto.TestResultsDTO) ProgrammingLanguage(de.tum.in.www1.artemis.domain.enumeration.ProgrammingLanguage)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 JenkinsServer (com.offbytwo.jenkins.JenkinsServer)2 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)2 BuildPlanType (de.tum.in.www1.artemis.domain.enumeration.BuildPlanType)2 ProgrammingLanguage (de.tum.in.www1.artemis.domain.enumeration.ProgrammingLanguage)2 RepositoryType (de.tum.in.www1.artemis.domain.enumeration.RepositoryType)2 ProgrammingExerciseParticipation (de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseParticipation)2 ContinuousIntegrationException (de.tum.in.www1.artemis.exception.ContinuousIntegrationException)2 JenkinsException (de.tum.in.www1.artemis.exception.JenkinsException)2 FeedbackRepository (de.tum.in.www1.artemis.repository.FeedbackRepository)2 ProgrammingSubmissionRepository (de.tum.in.www1.artemis.repository.ProgrammingSubmissionRepository)2 BuildLogEntryService (de.tum.in.www1.artemis.service.BuildLogEntryService)2 ExerciseDateService (de.tum.in.www1.artemis.service.ExerciseDateService)2 AbstractContinuousIntegrationService (de.tum.in.www1.artemis.service.connectors.AbstractContinuousIntegrationService)2 CIPermission (de.tum.in.www1.artemis.service.connectors.CIPermission)2 ConnectorHealth (de.tum.in.www1.artemis.service.connectors.ConnectorHealth)2 TestCaseDTO (de.tum.in.www1.artemis.service.connectors.jenkins.dto.TestCaseDTO)2 TestResultsDTO (de.tum.in.www1.artemis.service.connectors.jenkins.dto.TestResultsDTO)2 JenkinsJobService (de.tum.in.www1.artemis.service.connectors.jenkins.jobs.JenkinsJobService)2 AbstractBuildResultNotificationDTO (de.tum.in.www1.artemis.service.dto.AbstractBuildResultNotificationDTO)2