Search in sources :

Example 1 with ModelAssessmentKnowledgeService

use of de.tum.in.www1.artemis.service.ModelAssessmentKnowledgeService 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());
}
Also used : ModelClusterFactory(de.tum.in.www1.artemis.service.compass.controller.ModelClusterFactory) ModelElement(de.tum.in.www1.artemis.domain.modeling.ModelElement) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) ModelAssessmentKnowledgeService(de.tum.in.www1.artemis.service.ModelAssessmentKnowledgeService) ModelCluster(de.tum.in.www1.artemis.domain.modeling.ModelCluster) Course(de.tum.in.www1.artemis.domain.Course) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 2 with ModelAssessmentKnowledgeService

use of de.tum.in.www1.artemis.service.ModelAssessmentKnowledgeService 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());
}
Also used : ModelClusterFactory(de.tum.in.www1.artemis.service.compass.controller.ModelClusterFactory) ModelElement(de.tum.in.www1.artemis.domain.modeling.ModelElement) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) ModelAssessmentKnowledgeService(de.tum.in.www1.artemis.service.ModelAssessmentKnowledgeService) ModelCluster(de.tum.in.www1.artemis.domain.modeling.ModelCluster) Course(de.tum.in.www1.artemis.domain.Course) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Aggregations

Course (de.tum.in.www1.artemis.domain.Course)2 ModelCluster (de.tum.in.www1.artemis.domain.modeling.ModelCluster)2 ModelElement (de.tum.in.www1.artemis.domain.modeling.ModelElement)2 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)2 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)2 ModelAssessmentKnowledgeService (de.tum.in.www1.artemis.service.ModelAssessmentKnowledgeService)2 ModelClusterFactory (de.tum.in.www1.artemis.service.compass.controller.ModelClusterFactory)2 Test (org.junit.jupiter.api.Test)2 WithMockUser (org.springframework.security.test.context.support.WithMockUser)2