Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
dimanyfantakis committed Apr 6, 2024
1 parent c104c8c commit cb1953c
Show file tree
Hide file tree
Showing 24 changed files with 683 additions and 963 deletions.
11 changes: 3 additions & 8 deletions src/test/java/model/GraphClassDiagramConverterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import model.graph.ClassifierVertex;
import org.junit.jupiter.api.Test;
import utils.PathConstructor;
import utils.PathTemplate;
import utils.PathTemplate.LatexEditor;

import java.io.File;
import java.nio.file.Paths;
Expand All @@ -30,14 +32,7 @@ void convertGraphToClassDiagramTest()
List<String> chosenFiles = Arrays.asList("MainWindow",
"LatexEditorView",
"OpeningWindow");
classDiagramManager.createSourceProject(Paths.get(String.format("%s%s%s",
PathConstructor.getCurrentPath(),
File.separator,
PathConstructor.constructPath("src",
"test",
"resources",
"LatexEditor",
"src"))));
classDiagramManager.createSourceProject(LatexEditor.SRC.path);
classDiagramManager.convertTreeToDiagram(chosenFiles);
Set<ClassifierVertex> graphNodes = classDiagramManager.getClassDiagram().getGraphNodes().keySet();
Map<ClassifierVertex, Set<Arc<ClassifierVertex>>> diagram = classDiagramManager.getClassDiagram().getDiagram();
Expand Down
11 changes: 3 additions & 8 deletions src/test/java/model/GraphPackageDiagramConverterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import model.graph.PackageVertex;
import org.junit.jupiter.api.Test;
import utils.PathConstructor;
import utils.PathTemplate;
import utils.PathTemplate.LatexEditor;

import java.io.File;
import java.nio.file.Paths;
Expand All @@ -25,14 +27,7 @@ public class GraphPackageDiagramConverterTest
void convertGraphToPackageDiagramTest()
{
PackageDiagramManager packageDiagramManager = new PackageDiagramManager();
packageDiagramManager.createSourceProject(Paths.get(String.format("%s%s%s",
PathConstructor.getCurrentPath(),
File.separator,
PathConstructor.constructPath("src",
"test",
"resources",
"LatexEditor",
"src"))));
packageDiagramManager.createSourceProject(LatexEditor.SRC.path);
packageDiagramManager.convertTreeToDiagram(List.of("src.view",
"src.model",
"src.model.strategies",
Expand Down
42 changes: 18 additions & 24 deletions src/test/java/model/ShadowCleanerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import utils.PathConstructor;
import utils.PathTemplate;
import utils.PathTemplate.LatexEditor;

import java.io.File;
import java.nio.file.Paths;
Expand All @@ -34,14 +36,7 @@ void shadowWeakRelationshipsTest()
"VersionsManager",
"DocumentManager",
"Document");
classDiagramManager.createSourceProject(Paths.get(String.format("%s%s%s",
PathConstructor.getCurrentPath(),
File.separator,
PathConstructor.constructPath("src",
"test",
"resources",
"LatexEditor",
"src"))));
classDiagramManager.createSourceProject(LatexEditor.SRC.path);
classDiagramManager.convertTreeToDiagram(chosenFiles);
Map<ClassifierVertex, Integer> graphNodes = classDiagramManager.getClassDiagram().getGraphNodes();

Expand All @@ -65,32 +60,32 @@ void shadowWeakRelationshipsTest()
ClassifierVertex chooseTemplate = diagram.keySet().stream().filter(sinkVertex -> sinkVertex.getName().equals("ChooseTemplate")).findFirst().orElseGet(Assertions::fail);
List<Arc<ClassifierVertex>> chooseTemplateLatexEditorViewArc = diagram.get(chooseTemplate)
.stream()
.filter(sinkVertexArc ->
sinkVertexArc.targetVertex().getName().equals("LatexEditorView"))
.filter(it -> it.targetVertex().getName().equals("LatexEditorView"))
.toList();

assertEquals(1, chooseTemplateLatexEditorViewArc.size());
assertEquals(ArcType.ASSOCIATION, chooseTemplateLatexEditorViewArc.get(0).arcType());

ClassifierVertex latexEditorView = diagram
.keySet()
.stream()
.filter(sinkVertex ->
sinkVertex.getName().equals("LatexEditorView"))
.filter(it -> it.getName().equals("LatexEditorView"))
.findFirst()
.orElseGet(Assertions::fail);

List<Arc<ClassifierVertex>> latexEditorViewVersionsManagerArc = diagram.get(latexEditorView)
.stream()
.filter(sinkVertexArc ->
sinkVertexArc.targetVertex().getName().equals("VersionsManager"))
.filter(it -> it.targetVertex().getName().equals("VersionsManager"))
.toList();

assertEquals(1, latexEditorViewVersionsManagerArc.size());
assertEquals(ArcType.ASSOCIATION, latexEditorViewVersionsManagerArc.get(0).arcType());

List<Arc<ClassifierVertex>> LatexEditorViewLatexEditorControllerArc = diagram.get(latexEditorView)
.stream()
.filter(sinkVertexArc ->
sinkVertexArc.targetVertex().getName().equals("LatexEditorController"))
.filter(it -> it.targetVertex().getName().equals("LatexEditorController"))
.toList();

assertEquals(1, LatexEditorViewLatexEditorControllerArc.size());
assertEquals(ArcType.ASSOCIATION, LatexEditorViewLatexEditorControllerArc.get(0).arcType());

Expand All @@ -108,32 +103,31 @@ void shadowWeakRelationshipsTest()
ClassifierVertex mainWindow = diagram
.keySet()
.stream()
.filter(sinkVertex ->
sinkVertex.getName().equals("MainWindow"))
.filter(it -> it.getName().equals("MainWindow"))
.findFirst()
.orElseGet(Assertions::fail);

List<Arc<ClassifierVertex>> mainWindowLatexEditorViewArc = diagram
.get(mainWindow)
.stream()
.filter(sinkVertexArc ->
sinkVertexArc.targetVertex().getName().equals("LatexEditorView"))
.filter(it -> it.targetVertex().getName().equals("LatexEditorView"))
.toList();
assertEquals(1, mainWindowLatexEditorViewArc.size());
assertEquals(ArcType.ASSOCIATION, mainWindowLatexEditorViewArc.get(0).arcType());

ClassifierVertex versionsManager = diagram
.keySet()
.stream()
.filter(sinkVertex ->
sinkVertex.getName().equals("VersionsManager"))
.filter(it -> it.getName().equals("VersionsManager"))
.findFirst()
.orElseGet(Assertions::fail);

List<Arc<ClassifierVertex>> versionsManagerLatexEditorViewArc = diagram
.get(versionsManager)
.stream()
.filter(sinkVertexArc ->
sinkVertexArc.targetVertex().getName().equals("LatexEditorView"))
.filter(it -> it.targetVertex().getName().equals("LatexEditorView"))
.toList();

assertEquals(1, versionsManagerLatexEditorViewArc.size());
assertEquals(ArcType.ASSOCIATION, versionsManagerLatexEditorViewArc.get(0).arcType());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.javatuples.Pair;
import org.junit.jupiter.api.Test;
import utils.PathConstructor;
import utils.PathTemplate;
import utils.PathTemplate.LatexEditor;

import java.io.File;
import java.io.IOException;
Expand All @@ -36,14 +38,7 @@ void exportDiagramTest()
List<String> chosenFiles = Arrays.asList("MainWindow",
"LatexEditorView",
"OpeningWindow");
classDiagramManager.createSourceProject(Paths.get(String.format("%s%s%s",
PathConstructor.getCurrentPath(),
File.separator,
PathConstructor.constructPath("src",
"test",
"resources",
"LatexEditor",
"src"))));
classDiagramManager.createSourceProject(LatexEditor.SRC.path);
classDiagramManager.convertTreeToDiagram(chosenFiles);
classDiagramManager.arrangeDiagram();
DiagramArrangementManagerInterface classDiagramArrangement = new ClassDiagramArrangementManager(classDiagramManager.getClassDiagram());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import model.diagram.exportation.JavaFXClassDiagramExporter;
import org.junit.jupiter.api.Test;
import utils.PathConstructor;
import utils.PathTemplate;
import utils.PathTemplate.LatexEditor;

import java.io.File;
import java.io.IOException;
Expand All @@ -33,14 +35,7 @@ void exportDiagramTest()
List<String> chosenFiles = Arrays.asList("MainWindow",
"LatexEditorView",
"OpeningWindow");
classDiagramManager.createSourceProject(Paths.get(String.format("%s%s%s",
PathConstructor.getCurrentPath(),
File.separator,
PathConstructor.constructPath("src",
"test",
"resources",
"LatexEditor",
"src"))));
classDiagramManager.createSourceProject(LatexEditor.SRC.path);
classDiagramManager.convertTreeToDiagram(chosenFiles);
DiagramExporter javaFXExporter = new JavaFXClassDiagramExporter(classDiagramManager.getClassDiagram());
File actualFile = javaFXExporter.exportDiagram(Path.of(String.format("%s%s%s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import utils.PathConstructor;
import utils.PathTemplate;
import utils.PathTemplate.LatexEditor;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -46,18 +48,17 @@ void exportDiagramTest()
try
{
PackageDiagramManager packageDiagramManager = new PackageDiagramManager();
packageDiagramManager.createSourceProject(Paths.get(PathConstructor.getCurrentPath() + File.separator + PathConstructor.constructPath("src",
"test",
"resources",
"LatexEditor",
"src")));
packageDiagramManager.createSourceProject(LatexEditor.SRC.path);
packageDiagramManager.convertTreeToDiagram(getPackages());

DiagramExporter javaFXExporter = new JavaFXPackageDiagramExporter(packageDiagramManager.getPackageDiagram());
File actualFile = javaFXExporter.exportDiagram(Path.of(PathConstructor.getCurrentPath() + File.separator + PathConstructor.constructPath("src",
"test",
"resources",
"testingExportedFile.txt")));
File actualFile = javaFXExporter.exportDiagram(Path.of(String.format("%s%s%s",
PathConstructor.getCurrentPath(),
File.separator,
PathConstructor.constructPath("src",
"test",
"resources",
"testingExportedFile.txt"))));

JsonArray expectedJsonArray = getJsonArray();
JsonArray actualJsonArray = JsonParser.parseString(Files.readAllLines(actualFile.toPath()).get(0)).getAsJsonArray();
Expand Down Expand Up @@ -94,37 +95,31 @@ void exportDiagramTest()
}
for (ClassifierVertex classifierVertex : expSinkVertices)
{
Optional<ClassifierVertex> optionalSinkVertex = actSinkVertices.stream().filter(sinkVertex1 ->
sinkVertex1.getName().equals(classifierVertex.getName()) &&
sinkVertex1.getVertexType().equals(classifierVertex.getVertexType()) &&
sinkVertex1.getArcs().size() == classifierVertex.getArcs().size() &&
sinkVertex1.getMethods().size() == classifierVertex.getMethods().size() &&
sinkVertex1.getFields().size() == classifierVertex.getFields().size())
Optional<ClassifierVertex> optionalSinkVertex = actSinkVertices.stream()
.filter(it -> it.getName().equals(classifierVertex.getName()) &&
it.getVertexType().equals(classifierVertex.getVertexType()) &&
it.getArcs().size() == classifierVertex.getArcs().size() &&
it.getMethods().size() == classifierVertex.getMethods().size() &&
it.getFields().size() == classifierVertex.getFields().size())
.findFirst();
assertTrue(optionalSinkVertex.isPresent());

List<ClassifierVertex.Field> fields = optionalSinkVertex.get().getFields();
for (ClassifierVertex.Field field : classifierVertex.getFields())
{
assertTrue(fields.stream()
.anyMatch(field1 ->
field1.name().equals(field.name()) &&
field1.type().equals(field.type()) &&
field1.modifier().equals(field.modifier())
)
);
.anyMatch(it -> it.name().equals(field.name()) &&
it.type().equals(field.type()) &&
it.modifier().equals(field.modifier())));
}

List<ClassifierVertex.Method> methods = optionalSinkVertex.get().getMethods();
for (ClassifierVertex.Method method : classifierVertex.getMethods())
{
assertTrue(methods.stream()
.anyMatch(method1 ->
method1.name().equals(method.name()) &&
method1.returnType().equals(method.returnType()) &&
method1.parameters().equals(method.parameters())
)
);
.anyMatch(it -> it.name().equals(method.name()) &&
it.returnType().equals(method.returnType()) &&
it.parameters().equals(method.parameters())));
}

List<Arc<ClassifierVertex>> arcs = optionalSinkVertex.get().getArcs();
Expand Down
Loading

0 comments on commit cb1953c

Please sign in to comment.