use of de.tum.in.www1.artemis.service.compass.controller.ModelClusterFactory in project Artemis by ls1intum.
the class AssessmentKnowledgeIntegrationTest method testSetModelAssessmentKnowledgeToModelElements.
/**
* Tests that a ModelAssessmentKnowledge is correctly set to model elements
* based on the ModelAssessmentKnowledge of the respective exercise
*
* @throws Exception might be thrown from Network Call to Artemis API
*/
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testSetModelAssessmentKnowledgeToModelElements() 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);
Course course = database.addEmptyCourse();
ModelingExercise exercise1 = modelingExerciseUtilService.createModelingExercise(course.getId());
ModelingExercise exercise2 = modelingExerciseUtilService.createModelingExercise(course.getId());
modelAssessmentKnowledgeService = new ModelAssessmentKnowledgeService(modelAssessmentKnowledgeRepository, modelingExerciseRepository);
exercise1.setKnowledge(modelAssessmentKnowledgeService.createNewKnowledge());
exercise2.setKnowledge(modelAssessmentKnowledgeService.createNewKnowledge());
ModelClusterFactory modelClusterFactory = new ModelClusterFactory();
List<ModelCluster> modelClusters1 = modelClusterFactory.buildClusters(List.of(submission1, submission2), exercise1);
List<ModelCluster> modelClusters2 = modelClusterFactory.buildClusters(List.of(submission3, submission4), exercise2);
ModelCluster modelCluster = modelClusters1.get(0);
for (ModelElement element : modelCluster.getModelElements()) {
assertThat(element.getKnowledge().getId()).isEqualTo(exercise1.getKnowledge().getId());
}
modelCluster = modelClusters2.get(0);
for (ModelElement element : modelCluster.getModelElements()) {
assertThat(element.getKnowledge().getId()).isEqualTo(exercise2.getKnowledge().getId());
}
assertThat(exercise1.getKnowledge().getId()).isNotEqualTo(exercise2.getKnowledge().getId());
}
Aggregations