Commit 7671bc2c authored by Philipp Görick's avatar Philipp Görick

Move FlattenArchitecture out of AutomaticClusteringHelper into own class.

Add option to only flatten specified amount of levels. Do refactoring of
Flattenarchitecture class.
parent 6bf72679
Pipeline #97954 passed with stages
in 20 minutes and 45 seconds
......@@ -3,10 +3,7 @@ package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ConnectorSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol;
import de.monticore.lang.monticar.generator.middleware.clustering.AutomaticClusteringHelper;
import de.monticore.lang.monticar.generator.middleware.clustering.ClusteringAlgorithm;
import de.monticore.lang.monticar.generator.middleware.clustering.ClusteringAlgorithmFactory;
import de.monticore.lang.monticar.generator.middleware.clustering.ClusteringKind;
import de.monticore.lang.monticar.generator.middleware.clustering.*;
import de.monticore.lang.monticar.generator.middleware.clustering.algorithms.*;
import com.clust4j.algo.AffinityPropagation;
import com.clust4j.algo.AffinityPropagationParameters;
......@@ -109,7 +106,7 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
.<ExpandedComponentInstanceSymbol>resolve("lab.overallSystem", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = AutomaticClusteringHelper
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
.flattenArchitecture(componentInstanceSymbol);
assertNotNull(newComponentInstanceSymbol);
Collection<ExpandedComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
......@@ -126,7 +123,7 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
.<ExpandedComponentInstanceSymbol>resolve("lab.overallSystem", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = AutomaticClusteringHelper
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
.flattenArchitecture(componentInstanceSymbol, new HashMap<>());
assertNotNull(newComponentInstanceSymbol);
Collection<ExpandedComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
......@@ -143,7 +140,7 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
.<ExpandedComponentInstanceSymbol>resolve("lab.spanningSystem", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = AutomaticClusteringHelper
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
.flattenArchitecture(componentInstanceSymbol);
assertNotNull(newComponentInstanceSymbol);
Collection<ExpandedComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
......@@ -160,7 +157,7 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
.<ExpandedComponentInstanceSymbol>resolve("lab.spanningSystem", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = AutomaticClusteringHelper
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
.flattenArchitecture(componentInstanceSymbol, new HashMap<>());
assertNotNull(newComponentInstanceSymbol);
Collection<ExpandedComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
......@@ -169,6 +166,23 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
assertEquals(40, connectors.size());
}
@Test
public void testFlattenAlgorithmWithLevels() {
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver
.<ExpandedComponentInstanceSymbol>resolve("lab.spanningSystem", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
ExpandedComponentInstanceSymbol newComponentInstanceSymbol = FlattenArchitecture
.flattenArchitecture(componentInstanceSymbol, new HashMap<>(), 2);
assertNotNull(newComponentInstanceSymbol);
Collection<ExpandedComponentInstanceSymbol> subComponents = newComponentInstanceSymbol.getSubComponents();
Collection<ConnectorSymbol> connectors = newComponentInstanceSymbol.getConnectors();
assertEquals(4, subComponents.size());
assertEquals(24, connectors.size());
}
// todo: gotta move this thing later, just temporarily here for testing purposes
public static Dataset[] getClustering(Dataset data, SparseMatrix matrix) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment