Search in sources :

Example 11 with UMLDiagram

use of de.tum.in.www1.artemis.service.compass.umlmodel.UMLDiagram in project Artemis by ls1intum.

the class UMLModelParserTest method buildModelFromJSON_objectDiagram_empty.

@Test
void buildModelFromJSON_objectDiagram_empty() throws Exception {
    JsonObject objectDiagramJson = loadFileFromResources("test-data/model-submission/empty-object-diagram.json");
    UMLDiagram umlDiagram = UMLModelParser.buildModelFromJSON(objectDiagramJson, 123456789);
    assertThat(umlDiagram.getModelSubmissionId()).isEqualTo(123456789);
    assertThat(umlDiagram.getAllModelElements()).isEmpty();
}
Also used : UMLDiagram(de.tum.in.www1.artemis.service.compass.umlmodel.UMLDiagram) JsonObject(com.google.gson.JsonObject) Test(org.junit.jupiter.api.Test)

Example 12 with UMLDiagram

use of de.tum.in.www1.artemis.service.compass.umlmodel.UMLDiagram in project Artemis by ls1intum.

the class UMLModelParserTest method buildModelFromJSON_activityDiagram.

@Test
void buildModelFromJSON_activityDiagram() throws Exception {
    JsonObject activityDiagramJson = loadFileFromResources("test-data/model-submission/example-activity-diagram.json");
    List<UMLElement> expectedElements = createExampleActivityDiagramElements();
    UMLDiagram umlDiagram = UMLModelParser.buildModelFromJSON(activityDiagramJson, 123456789);
    assertThat(umlDiagram.getModelSubmissionId()).isEqualTo(123456789);
    assertThat(umlDiagram.getAllModelElements()).containsExactlyInAnyOrderElementsOf(expectedElements);
}
Also used : UMLDiagram(de.tum.in.www1.artemis.service.compass.umlmodel.UMLDiagram) UMLElement(de.tum.in.www1.artemis.service.compass.umlmodel.UMLElement) JsonObject(com.google.gson.JsonObject) Test(org.junit.jupiter.api.Test)

Example 13 with UMLDiagram

use of de.tum.in.www1.artemis.service.compass.umlmodel.UMLDiagram in project Artemis by ls1intum.

the class UMLModelParserTest method buildModelFromJSON_communicationDiagram_empty.

@Test
void buildModelFromJSON_communicationDiagram_empty() throws Exception {
    JsonObject communicationDiagramJson = loadFileFromResources("test-data/model-submission/empty-communication-diagram.json");
    UMLDiagram umlDiagram = UMLModelParser.buildModelFromJSON(communicationDiagramJson, 123456789);
    assertThat(umlDiagram.getModelSubmissionId()).isEqualTo(123456789);
    assertThat(umlDiagram.getAllModelElements()).isEmpty();
}
Also used : UMLDiagram(de.tum.in.www1.artemis.service.compass.umlmodel.UMLDiagram) JsonObject(com.google.gson.JsonObject) Test(org.junit.jupiter.api.Test)

Example 14 with UMLDiagram

use of de.tum.in.www1.artemis.service.compass.umlmodel.UMLDiagram in project Artemis by ls1intum.

the class UMLCommunicationDiagramTest method parseCommunicationDiagramModelCorrectly.

@Test
void parseCommunicationDiagramModelCorrectly() throws IOException {
    UMLDiagram diagram = UMLModelParser.buildModelFromJSON(parseString(UMLCommunicationDiagrams.COMMUNICATION_MODEL_2).getAsJsonObject(), 1L);
    assertThat(diagram).isInstanceOf(UMLCommunicationDiagram.class);
    UMLCommunicationDiagram communicationDiagram = (UMLCommunicationDiagram) diagram;
    assertThat(communicationDiagram.getObjectList()).hasSize(5);
    assertThat(communicationDiagram.getCommunicationLinkList()).hasSize(5);
    assertThat(communicationDiagram.getElementByJSONID("619ddf50-f2a6-4004-9fb3-db64ee10cd6e")).isInstanceOf(UMLObject.class);
    assertThat(communicationDiagram.getElementByJSONID("64040203-6e35-4b42-8ab5-71b544a70fa6")).isInstanceOf(UMLCommunicationLink.class);
}
Also used : UMLDiagram(de.tum.in.www1.artemis.service.compass.umlmodel.UMLDiagram) Test(org.junit.jupiter.api.Test) AbstractUMLDiagramTest(de.tum.in.www1.artemis.service.compass.umlmodel.AbstractUMLDiagramTest)

Example 15 with UMLDiagram

use of de.tum.in.www1.artemis.service.compass.umlmodel.UMLDiagram in project Artemis by ls1intum.

the class UMLComponentDiagramTest method parseComponentDiagramModelCorrectly.

@Test
void parseComponentDiagramModelCorrectly() throws IOException {
    UMLDiagram diagram = UMLModelParser.buildModelFromJSON(parseString(UMLComponentDiagrams.COMPONENT_MODEL_3).getAsJsonObject(), 1L);
    assertThat(diagram).isInstanceOf(UMLComponentDiagram.class);
    UMLComponentDiagram componentDiagram = (UMLComponentDiagram) diagram;
    // 4 Components A, B, C and D
    assertThat(componentDiagram.getComponentList()).hasSize(4);
    UMLComponent componentA = getComponent(componentDiagram, "A");
    UMLComponent componentB = getComponent(componentDiagram, "B");
    UMLComponent componentC = getComponent(componentDiagram, "C");
    UMLComponent componentD = getComponent(componentDiagram, "D");
    // 5 Interfaces: I1, I2, I3, I4, I5
    assertThat(componentDiagram.getComponentInterfaceList()).hasSize(5);
    UMLComponentInterface interfaceI1 = getInterface(componentDiagram, "I1");
    UMLComponentInterface interfaceI2 = getInterface(componentDiagram, "I2");
    UMLComponentInterface interfaceI3 = getInterface(componentDiagram, "I3");
    UMLComponentInterface interfaceI4 = getInterface(componentDiagram, "I4");
    UMLComponentInterface interfaceI5 = getInterface(componentDiagram, "I5");
    // 8 relationships: 3 ComponentInterfaceProvided, 3 ComponentInterfaceRequired, 2 Dependencies
    assertThat(componentDiagram.getComponentRelationshipList()).hasSize(8);
    UMLComponentRelationship relationship1 = getRelationship(componentDiagram, componentA, componentA);
    UMLComponentRelationship relationship2 = getRelationship(componentDiagram, interfaceI1, interfaceI2);
    UMLComponentRelationship relationship3 = getRelationship(componentDiagram, componentA, interfaceI5);
    UMLComponentRelationship relationship4 = getRelationship(componentDiagram, componentD, interfaceI5);
    UMLComponentRelationship relationship5 = getRelationship(componentDiagram, componentD, componentC);
    UMLComponentRelationship relationship6 = getRelationship(componentDiagram, componentD, componentA);
    UMLComponentRelationship relationship7 = getRelationship(componentDiagram, componentB, interfaceI3);
    UMLComponentRelationship relationship8 = getRelationship(componentDiagram, componentC, interfaceI3);
    assertThat(relationship1.getRelationshipType()).isEqualByComparingTo(COMPONENT_DEPENDENCY);
    assertThat(relationship2.getRelationshipType()).isEqualByComparingTo(COMPONENT_INTERFACE_PROVIDED);
    assertThat(relationship3.getRelationshipType()).isEqualByComparingTo(COMPONENT_INTERFACE_PROVIDED);
    assertThat(relationship4.getRelationshipType()).isEqualByComparingTo(COMPONENT_INTERFACE_REQUIRED);
    assertThat(relationship5.getRelationshipType()).isEqualByComparingTo(COMPONENT_DEPENDENCY);
    assertThat(relationship6.getRelationshipType()).isEqualByComparingTo(COMPONENT_INTERFACE_REQUIRED);
    assertThat(relationship7.getRelationshipType()).isEqualByComparingTo(COMPONENT_INTERFACE_REQUIRED);
    assertThat(relationship8.getRelationshipType()).isEqualByComparingTo(COMPONENT_INTERFACE_PROVIDED);
    // check owner relationships
    assertThat(componentA.getParentElement()).isNull();
    assertThat(componentB.getParentElement()).isEqualTo(componentA);
    assertThat(componentC.getParentElement()).isEqualTo(componentB);
    assertThat(componentD.getParentElement()).isNull();
    assertThat(interfaceI1.getParentElement()).isNull();
    assertThat(interfaceI2.getParentElement()).isEqualTo(componentA);
    assertThat(interfaceI3.getParentElement()).isEqualTo(componentB);
    assertThat(interfaceI4.getParentElement()).isEqualTo(componentC);
    assertThat(interfaceI5.getParentElement()).isNull();
}
Also used : UMLDiagram(de.tum.in.www1.artemis.service.compass.umlmodel.UMLDiagram) Test(org.junit.jupiter.api.Test) AbstractUMLDiagramTest(de.tum.in.www1.artemis.service.compass.umlmodel.AbstractUMLDiagramTest)

Aggregations

UMLDiagram (de.tum.in.www1.artemis.service.compass.umlmodel.UMLDiagram)38 Test (org.junit.jupiter.api.Test)36 JsonObject (com.google.gson.JsonObject)20 AbstractUMLDiagramTest (de.tum.in.www1.artemis.service.compass.umlmodel.AbstractUMLDiagramTest)16 UMLElement (de.tum.in.www1.artemis.service.compass.umlmodel.UMLElement)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JsonParser.parseString (com.google.gson.JsonParser.parseString)2 PlagiarismCheckState (de.tum.in.www1.artemis.domain.PlagiarismCheckState)2 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)2 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)2 Participation (de.tum.in.www1.artemis.domain.participation.Participation)2 PlagiarismComparison (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison)2 PlagiarismSubmission (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission)2 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)2 ModelingSubmissionElement (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingSubmissionElement)2 UMLModelParser (de.tum.in.www1.artemis.service.compass.umlmodel.parsers.UMLModelParser)2 IOException (java.io.IOException)2 java.util (java.util)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Collectors (java.util.stream.Collectors)2