use of de.tum.in.www1.artemis.domain.participation.SolutionProgrammingExerciseParticipation in project ArTEMiS by ls1intum.
the class UrlServiceTest method testUserIndependentRepositoryUrl.
@Test
public void testUserIndependentRepositoryUrl() {
var solutionProgrammingExerciseParticipation = new SolutionProgrammingExerciseParticipation();
solutionProgrammingExerciseParticipation.setRepositoryUrl(repositoryUrl1.toString());
assertThat(solutionProgrammingExerciseParticipation.getUserIndependentRepositoryUrl()).isEqualTo("https://bitbucket.ase.in.tum.de/scm/EIST2016RME/RMEXERCISE-ab123cd");
var templateProgrammingExerciseParticipation = new TemplateProgrammingExerciseParticipation();
templateProgrammingExerciseParticipation.setRepositoryUrl(repositoryUrl2.toString());
assertThat(templateProgrammingExerciseParticipation.getUserIndependentRepositoryUrl()).isEqualTo("https://repobruegge.in.tum.de/scm/EIST2016RME/RMEXERCISE-ab123cd.git");
var studentParticipation1 = new ProgrammingExerciseStudentParticipation();
studentParticipation1.setRepositoryUrl(repositoryUrl3.toString());
assertThat(studentParticipation1.getUserIndependentRepositoryUrl()).isEqualTo("https://artemistest2gitlab.ase.in.tum.de/TESTADAPTER/testadapter-exercise.git");
var studentParticipation2 = new ProgrammingExerciseStudentParticipation();
studentParticipation2.setRepositoryUrl(repositoryUrl4.toString());
assertThat(studentParticipation2.getUserIndependentRepositoryUrl()).isEqualTo("https://artemistest2gitlab.ase.in.tum.de/FTCSCAGRADING1/ftcscagrading1-username");
assertThat(new ProgrammingExerciseStudentParticipation().getUserIndependentRepositoryUrl()).isNull();
var studentParticipation3 = new ProgrammingExerciseStudentParticipation();
studentParticipation3.setRepositoryUrl("http://localhost:8080/Assignment/rest/words/{name}/protection");
assertThat(studentParticipation3.getUserIndependentRepositoryUrl()).isNull();
}
use of de.tum.in.www1.artemis.domain.participation.SolutionProgrammingExerciseParticipation in project Artemis by ls1intum.
the class ProgrammingExerciseSimulationService method setupInitialSubmissionsAndResults.
/**
* This method creates the template and solution submissions and results for the new exercise
* These submissions and results are SIMULATIONS for the testing of programming exercises without a connection to
* the VCS and Continuous Integration server
* @param programmingExercise the new exercise
* This functionality is only for testing purposes (noVersionControlAndContinuousIntegrationAvailable)
*/
public void setupInitialSubmissionsAndResults(ProgrammingExercise programmingExercise) {
var templateProgrammingExerciseParticipation = this.templateProgrammingExerciseParticipationRepository.findByProgrammingExerciseId(programmingExercise.getId()).orElseThrow(() -> new EntityNotFoundException("TemplateProgrammingExerciseParticipation with programming exercise with " + programmingExercise.getId() + " does not exist"));
var solutionProgrammingExerciseParticipation = this.solutionProgrammingExerciseParticipationRepository.findByProgrammingExerciseId(programmingExercise.getId()).orElseThrow(() -> new EntityNotFoundException("SolutionProgrammingExerciseParticipation with programming exercise with " + programmingExercise.getId() + " does not exist"));
String commitHashBase = VCSSimulationUtils.simulateCommitHash();
Result templateResult = createSubmissionAndResult(templateProgrammingExerciseParticipation, commitHashBase);
templateResult.setResultString("0 of 13 passed");
templateResult.setScore(0D);
resultRepository.save(templateResult);
String commitHashSolution = VCSSimulationUtils.simulateCommitHash();
Result solutionResult = createSubmissionAndResult(solutionProgrammingExerciseParticipation, commitHashSolution);
solutionResult.setResultString("13 of 13 passed");
solutionResult.setScore(100D);
resultRepository.save(solutionResult);
}
use of de.tum.in.www1.artemis.domain.participation.SolutionProgrammingExerciseParticipation in project ArTEMiS by ls1intum.
the class TestwiseCoverageService method getLineCountByFilePath.
/**
* Returns the line count by file name for all files in the solution repository for the last submission.
* @return line count by file name of files in the last submission's solution repository
*/
private Map<String, Integer> getLineCountByFilePath(ProgrammingSubmission submission) {
try {
var solutionParticipation = (SolutionProgrammingExerciseParticipation) submission.getParticipation();
var solutionRepo = gitService.getOrCheckoutRepository(solutionParticipation.getVcsRepositoryUrl(), true);
gitService.resetToOriginHead(solutionRepo);
gitService.pullIgnoreConflicts(solutionRepo);
var solutionFiles = repositoryService.getFilesWithContent(solutionRepo);
var result = new HashMap<String, Integer>();
solutionFiles.forEach((filePath, value) -> {
// do not count lines for non-java files
if (!filePath.endsWith(".java")) {
return;
}
var lineCount = value.split("\n").length + 1;
result.put(filePath, lineCount);
});
return result;
} catch (GitAPIException e) {
log.error("Exception while generating testwise coverage report", e);
throw new InternalServerErrorException("Error while generating testwise coverage report: " + e.getMessage());
}
}
use of de.tum.in.www1.artemis.domain.participation.SolutionProgrammingExerciseParticipation in project ArTEMiS by ls1intum.
the class ProgrammingExerciseSimulationService method setupInitialSubmissionsAndResults.
/**
* This method creates the template and solution submissions and results for the new exercise
* These submissions and results are SIMULATIONS for the testing of programming exercises without a connection to
* the VCS and Continuous Integration server
* @param programmingExercise the new exercise
* This functionality is only for testing purposes (noVersionControlAndContinuousIntegrationAvailable)
*/
public void setupInitialSubmissionsAndResults(ProgrammingExercise programmingExercise) {
var templateProgrammingExerciseParticipation = this.templateProgrammingExerciseParticipationRepository.findByProgrammingExerciseId(programmingExercise.getId()).orElseThrow(() -> new EntityNotFoundException("TemplateProgrammingExerciseParticipation with programming exercise with " + programmingExercise.getId() + " does not exist"));
var solutionProgrammingExerciseParticipation = this.solutionProgrammingExerciseParticipationRepository.findByProgrammingExerciseId(programmingExercise.getId()).orElseThrow(() -> new EntityNotFoundException("SolutionProgrammingExerciseParticipation with programming exercise with " + programmingExercise.getId() + " does not exist"));
String commitHashBase = VCSSimulationUtils.simulateCommitHash();
Result templateResult = createSubmissionAndResult(templateProgrammingExerciseParticipation, commitHashBase);
templateResult.setResultString("0 of 13 passed");
templateResult.setScore(0D);
resultRepository.save(templateResult);
String commitHashSolution = VCSSimulationUtils.simulateCommitHash();
Result solutionResult = createSubmissionAndResult(solutionProgrammingExerciseParticipation, commitHashSolution);
solutionResult.setResultString("13 of 13 passed");
solutionResult.setScore(100D);
resultRepository.save(solutionResult);
}
use of de.tum.in.www1.artemis.domain.participation.SolutionProgrammingExerciseParticipation in project Artemis by ls1intum.
the class TestwiseCoverageService method getLineCountByFilePath.
/**
* Returns the line count by file name for all files in the solution repository for the last submission.
* @return line count by file name of files in the last submission's solution repository
*/
private Map<String, Integer> getLineCountByFilePath(ProgrammingSubmission submission) {
try {
var solutionParticipation = (SolutionProgrammingExerciseParticipation) submission.getParticipation();
var solutionRepo = gitService.getOrCheckoutRepository(solutionParticipation.getVcsRepositoryUrl(), true);
gitService.resetToOriginHead(solutionRepo);
gitService.pullIgnoreConflicts(solutionRepo);
var solutionFiles = repositoryService.getFilesWithContent(solutionRepo);
var result = new HashMap<String, Integer>();
solutionFiles.forEach((filePath, value) -> {
// do not count lines for non-java files
if (!filePath.endsWith(".java")) {
return;
}
var lineCount = value.split("\n").length + 1;
result.put(filePath, lineCount);
});
return result;
} catch (GitAPIException e) {
log.error("Exception while generating testwise coverage report", e);
throw new InternalServerErrorException("Error while generating testwise coverage report: " + e.getMessage());
}
}
Aggregations