use of de.tum.in.www1.artemis.domain.modeling.ModelElement in project ArTEMiS by ls1intum.
the class FeedbackSelectorTest method testLongestFeedbackTextSelection.
@Test
public void testLongestFeedbackTextSelection() {
Feedback feedback1 = new Feedback().credits(1.0).reference("Class:6aba5764-d102-4740-9675-b2bd0a4f2123").text("feedback text");
Feedback feedback2 = new Feedback().credits(1.0).reference("Class:6aba5764-d102-4740-9675-b2bd0a4f2124").text("short");
Feedback feedback3 = new Feedback().credits(1.0).reference("Class:6aba5764-d102-4740-9675-b2bd0a4f2125").text("very long feedback text");
Result result = new Result();
ModelElement modelElement = new ModelElement();
modelElement.setModelElementType("Class");
modelElement.setModelElementId("6aba5764-d102-4740-9675-b2bd0a4f2127");
Feedback selectedFeedback = FeedbackSelector.selectFeedback(modelElement, List.of(feedback1, feedback2), result);
assertThat(selectedFeedback).as("feedback was selected").isNotNull();
assertThat(selectedFeedback.getReference()).as("feedback is assigned to the element").isEqualTo("Class:6aba5764-d102-4740-9675-b2bd0a4f2127");
assertThat(selectedFeedback.getText()).as("feedback text of element is correct").isEqualTo("feedback text");
selectedFeedback = FeedbackSelector.selectFeedback(modelElement, List.of(feedback1, feedback2, feedback3), result);
assertThat(selectedFeedback).as("feedback was selected").isNotNull();
assertThat(selectedFeedback.getReference()).as("feedback is assigned to the element").isEqualTo("Class:6aba5764-d102-4740-9675-b2bd0a4f2127");
assertThat(selectedFeedback.getText()).as("feedback text of element is correct").isEqualTo("very long feedback text");
}
use of de.tum.in.www1.artemis.domain.modeling.ModelElement in project Artemis by ls1intum.
the class ModelingSubmissionService method setNumberOfAffectedSubmissionsPerElement.
/**
* Sets number of potential automatic Feedback's for each model element belonging to the `Result`'s submission.
* This number determines how many other submissions would be affected if the user were to submit a certain element feedback.
* For each ModelElement of the submission, this method finds how many other ModelElements exist in the same cluster.
* This number is represented with the `numberOfAffectedSubmissions` field which is set here for each
* ModelElement of this submission
*
* @param submission Result for the Submission acting as a reference for the modeling submission to be searched.
*/
public void setNumberOfAffectedSubmissionsPerElement(@NotNull ModelingSubmission submission) {
List<ModelElementRepository.ModelElementCount> elementCounts = modelElementRepository.countOtherElementsInSameClusterForSubmissionId(submission.getId());
submission.setSimilarElements(elementCounts.stream().map(modelElementCount -> {
SimilarElementCount similarElementCount = new SimilarElementCount();
similarElementCount.setElementId(modelElementCount.getElementId());
similarElementCount.setNumberOfOtherElements(modelElementCount.getNumberOfOtherElements());
return similarElementCount;
}).collect(Collectors.toSet()));
}
use of de.tum.in.www1.artemis.domain.modeling.ModelElement in project Artemis by ls1intum.
the class FeedbackSelectorTest method testLongestFeedbackTextSelection.
@Test
public void testLongestFeedbackTextSelection() {
Feedback feedback1 = new Feedback().credits(1.0).reference("Class:6aba5764-d102-4740-9675-b2bd0a4f2123").text("feedback text");
Feedback feedback2 = new Feedback().credits(1.0).reference("Class:6aba5764-d102-4740-9675-b2bd0a4f2124").text("short");
Feedback feedback3 = new Feedback().credits(1.0).reference("Class:6aba5764-d102-4740-9675-b2bd0a4f2125").text("very long feedback text");
Result result = new Result();
ModelElement modelElement = new ModelElement();
modelElement.setModelElementType("Class");
modelElement.setModelElementId("6aba5764-d102-4740-9675-b2bd0a4f2127");
Feedback selectedFeedback = FeedbackSelector.selectFeedback(modelElement, List.of(feedback1, feedback2), result);
assertThat(selectedFeedback).as("feedback was selected").isNotNull();
assertThat(selectedFeedback.getReference()).as("feedback is assigned to the element").isEqualTo("Class:6aba5764-d102-4740-9675-b2bd0a4f2127");
assertThat(selectedFeedback.getText()).as("feedback text of element is correct").isEqualTo("feedback text");
selectedFeedback = FeedbackSelector.selectFeedback(modelElement, List.of(feedback1, feedback2, feedback3), result);
assertThat(selectedFeedback).as("feedback was selected").isNotNull();
assertThat(selectedFeedback.getReference()).as("feedback is assigned to the element").isEqualTo("Class:6aba5764-d102-4740-9675-b2bd0a4f2127");
assertThat(selectedFeedback.getText()).as("feedback text of element is correct").isEqualTo("very long feedback text");
}
use of de.tum.in.www1.artemis.domain.modeling.ModelElement in project Artemis by ls1intum.
the class ModelClusterFactoryTest method testBuildingClustersWithSimilarElements.
@Test
public void testBuildingClustersWithSimilarElements() throws Exception {
ModelingSubmission submission1 = ModelFactory.generateModelingSubmission(FileUtils.loadFileFromResources("test-data/model-submission/model.54727.json"), true);
submission1.setId(1L);
ModelingSubmission submission2 = ModelFactory.generateModelingSubmission(FileUtils.loadFileFromResources("test-data/model-submission/model.54727.cpy.json"), true);
submission2.setId(2L);
ModelingSubmission submission3 = ModelFactory.generateModelingSubmission(FileUtils.loadFileFromResources("test-data/model-submission/model.54727.cpy.json"), true);
submission3.setId(3L);
ModelingSubmission submission4 = ModelFactory.generateModelingSubmission(FileUtils.loadFileFromResources("test-data/model-submission/model.54727.cpy.json"), true);
submission4.setId(4L);
ModelingSubmission submission5 = ModelFactory.generateModelingSubmission(FileUtils.loadFileFromResources("test-data/model-submission/model.one-element.json"), true);
submission5.setId(5L);
ModelingExercise exercise = new ModelingExercise();
List<ModelCluster> modelClusters = modelClusterFactory.buildClusters(List.of(submission1, submission2, submission3, submission4, submission5), exercise);
assertThat(modelClusters).as("model clusters created").hasSize(10);
ModelCluster modelCluster = modelClusters.get(0);
assertThat(modelCluster.getModelElements()).as("all elements are created").hasSize(4);
for (ModelElement element : modelCluster.getModelElements()) {
assertThat(element.getCluster()).as("created elements keeps the cluster").isEqualTo(modelCluster);
}
}
Aggregations