Search in sources :

Example 31 with UMLDiagram

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

the class UMLModelParserTest method buildModelFromJSON_activityDiagram_empty.

@Test
void buildModelFromJSON_activityDiagram_empty() throws Exception {
    JsonObject activityDiagramJson = loadFileFromResources("test-data/model-submission/empty-activity-diagram.json");
    UMLDiagram umlDiagram = UMLModelParser.buildModelFromJSON(activityDiagramJson, 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 32 with UMLDiagram

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

the class UMLModelParserTest method buildModelFromJSON_deploymentDiagram_empty.

@Test
void buildModelFromJSON_deploymentDiagram_empty() throws Exception {
    JsonObject deploymentDiagramJson = loadFileFromResources("test-data/model-submission/empty-deployment-diagram.json");
    UMLDiagram umlDiagram = UMLModelParser.buildModelFromJSON(deploymentDiagramJson, 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 33 with UMLDiagram

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

the class UMLModelParserTest method buildModelFromJSON_classDiagram_empty.

@Test
void buildModelFromJSON_classDiagram_empty() throws Exception {
    JsonObject classDiagramJson = loadFileFromResources("test-data/model-submission/empty-class-diagram.json");
    UMLDiagram umlDiagram = UMLModelParser.buildModelFromJSON(classDiagramJson, 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 34 with UMLDiagram

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

the class UMLObjectDiagramTest method parseObjectDiagramModelCorrectly.

@Test
void parseObjectDiagramModelCorrectly() throws IOException {
    UMLDiagram diagram = UMLModelParser.buildModelFromJSON(parseString(UMLObjectDiagrams.OBJECT_MODEL_2).getAsJsonObject(), 1L);
    assertThat(diagram).isInstanceOf(UMLObjectDiagram.class);
    UMLObjectDiagram communicationDiagram = (UMLObjectDiagram) diagram;
    assertThat(communicationDiagram.getObjectList()).hasSize(3);
    assertThat(communicationDiagram.getObjectLinkList()).hasSize(2);
    assertThat(communicationDiagram.getElementByJSONID("cf26446e-06ea-4e25-99c4-ded25948e856")).isInstanceOf(UMLObject.class);
    assertThat(communicationDiagram.getElementByJSONID("ea1a2901-eefd-4ffe-a64c-b8e84f977c48")).isInstanceOf(UMLObjectLink.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 35 with UMLDiagram

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

the class PetriNetTest method parsePetriNetModelCorrectly.

@Test
void parsePetriNetModelCorrectly() throws IOException {
    UMLDiagram diagram = UMLModelParser.buildModelFromJSON(parseString(PETRI_NET_MODEL_1B).getAsJsonObject(), 1L);
    assertThat(diagram).isInstanceOf(PetriNet.class);
    PetriNet petriNet = (PetriNet) diagram;
    assertThat(petriNet.getPlaces()).hasSize(2);
    assertThat(petriNet.getTransitions()).hasSize(2);
    assertThat(petriNet.getArcs()).hasSize(4);
    assertThat(petriNet.getElementByJSONID("f406d5df-9404-4914-8631-8588cd289566")).asInstanceOf(type(PetriNetTransition.class)).satisfies(transition -> {
        assertThat(transition.getName()).isEqualTo("t1");
    });
    assertThat(petriNet.getElementByJSONID("c67e50de-22a0-42df-8056-1cc65fc0f950")).asInstanceOf(type(PetriNetPlace.class)).satisfies(place -> {
        assertThat(place.getName()).isEqualTo("b");
        assertThat(place.getAmountOfTokens()).isEqualTo("0");
        assertThat(place.getCapacity()).isEqualTo("Infinity");
    });
    assertThat(petriNet.getElementByJSONID("818fd351-bf3e-48b8-b41b-d775b23c13e5")).asInstanceOf(type(PetriNetArc.class)).satisfies(arc -> {
        assertThat(arc.getMultiplicity()).isEqualTo("1");
        assertThat(arc.getSource()).isNotNull().isSameAs(petriNet.getElementByJSONID("a12c5ed0-56aa-4174-b64b-7aead67429fd"));
        assertThat(arc.getTarget()).isNotNull().isSameAs(petriNet.getElementByJSONID("9336eb67-ddfb-4622-8593-d640402a04fc"));
    });
}
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