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();
}
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);
}
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();
}
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);
}
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();
}
Aggregations