Commit e6051fd8 authored by Manuel Schrick's avatar Manuel Schrick
Browse files

removed tests that used normal montiarc models

parent 737a1617
package de.monticore.lang.montiarc.svggenerator;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.montiarc.svggenerator.calculators.MainCalculator;
import de.monticore.symboltable.Scope;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
/**
* Created by MatlabEclipseVM on 27.06.2016.
*/
public class SVGDrawingTest {
private MainCalculator cal = new MainCalculator();
private SVGGenerator svgGenerator = new SVGGenerator();
@BeforeClass
public static void init(){
LogConfig.init();
}
/**
* MAIN
*/
@Test
public void main() throws Exception {
System.out.println("Start Test");
Scope symTab = TestingUtilities.createSymTab("src/test/resources/tags");
ExpandedComponentInstanceSymbol inst1 = symTab.<ExpandedComponentInstanceSymbol>resolve("industry4.turbineController", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(inst1);
// Calculate Layout information for the given input
cal.calculateLayout(inst1, MainCalculator.Mode.NORMAL);
// Draw the layout (create output SVG file)
svgGenerator.drawLayouts(inst1);
}
}
\ No newline at end of file
package de.monticore.lang.montiarc.svggenerator;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.montiarc.svggenerator.calculators.MainCalculator;
import de.monticore.symboltable.Scope;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
/**
* Created by Till, Kate und Hanna on 15.03.2017.
*/
public class SVGVerticalTest {
private MainCalculator cal = new MainCalculator();
private SVGGenerator svgGenerator = new SVGGenerator();
@BeforeClass
public static void init(){
LogConfig.init();
}
@Test
public void testCaseKatharina1() {
helpSVGBuild("testKatharinaWWithTags.firstExample");
}
@Test
public void testCaseKatharina2() {
helpSVGBuild("testKatharinaWWithTags.secondExample");
}
@Test
public void testCaseKatharina3() {
helpSVGBuild("testKatharinaWWithTags.thirdExample");
}
@Test
public void testCaseKatharina4() {
helpSVGBuild("testKatharinaWWithTags.fourthExample");
}
@Test
public void testCaseKatharina5() {
helpSVGBuild("testKatharinaWWithTags.fifthExample");
}
/**
* build the first example of Till Sieverts
*/
@Test
public void testCaseTill1() {
helpSVGBuild("testTillSievertsWithTags.firstExample");
}
/**
* build the second example of Till Sieverts
*/
@Test
public void testCaseTill2() {
helpSVGBuild("testTillSievertsWithTags.secondExample");
}
/**
* build the third example of Till Sieverts
*/
@Test
public void testCaseTill3() {
helpSVGBuild("testTillSievertsWithTags.thirdExample");
}
/**
* build the fourth example of Till Sieverts
*/
@Test
public void testCaseTill4() {
helpSVGBuild("testTillSievertsWithTags.fourthExample");
}
/**
* build the fifth example of Till Sieverts
*/
@Test
public void testCaseTill5() {
helpSVGBuild("testTillSievertsWithTags.fifthExample");
}
/**
* build the first example of Hanna Franzen
*/
@Test
public void testCaseHanna1() {
helpSVGBuild("testHannaFranzenWithTags.firstExample");
}
/**
* build the second example of Hanna Franzen
*/
@Test
public void testCaseHanna2() {
helpSVGBuild("testHannaFranzenWithTags.secondExample");
}
/**
* build the third example of Hanna Franzen
*/
@Test
public void testCaseHanna3() {
helpSVGBuild("testHannaFranzenWithTags.thirdExample");
}
/**
* build the fourth example of Hanna Franzen
*/
@Test
public void testCaseHanna4() {
helpSVGBuild("testHannaFranzenWithTags.fourthExample");
}
/**
* build the fifth example of Hanna Franzen
*/
@Test
public void testCaseHanna5() {
helpSVGBuild("testHannaFranzenWithTags.fifthExample");
}
/**
* build the sixth example of Hanna Franzen
*/
@Test
public void testCaseHanna6() {
helpSVGBuild("testHannaFranzenWithTags.sixthExample");
}
@Test
public void testIndustry() {
helpSVGBuild("industry.turbineController");
}
/**
* Help method to build the test cases
*/
public void helpSVGBuild(String testCase) {
try {
System.out.println("Start Building SVG File: " + testCase);
Scope symTab = TestingUtilities.createSymTab("src/test/resources/tags");
ExpandedComponentInstanceSymbol inst1 = symTab.<ExpandedComponentInstanceSymbol>resolve(testCase, ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(inst1);
// Calculate Layout information for the given input
cal.calculateLayout(inst1, MainCalculator.Mode.NORMAL);
// Draw the layout (create output SVG file)
svgGenerator.drawLayouts(inst1);
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main() throws Exception {
SVGVerticalTest test = new SVGVerticalTest();
test.testCaseKatharina1();
test.testCaseKatharina2();
test.testCaseKatharina3();
test.testCaseKatharina4();
test.testCaseKatharina5();
test.testCaseTill1();
test.testCaseTill2();
test.testCaseTill3();
test.testCaseTill4();
test.testCaseTill5();
test.testCaseHanna1();
test.testCaseHanna2();
test.testCaseHanna3();
test.testCaseHanna4();
test.testCaseHanna5();
test.testCaseHanna6();
}
}
\ No newline at end of file
package de.monticore.lang.montiarc.svggenerator.calculators;
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.montiarc.svggenerator.LogConfig;
import de.monticore.lang.montiarc.svggenerator.TestingUtilities;
import de.monticore.lang.montiarc.svggenerator.calculators.symbols.ComponentLayoutSymbol;
import de.monticore.lang.montiarc.svggenerator.calculators.symbols.LayoutPosition;
import de.monticore.lang.montiarc.svggenerator.calculators.symbols.ConnectorLayoutSymbol;
import de.monticore.lang.montiarc.svggenerator.calculators.symbols.PortLayoutSymbol;
import de.monticore.symboltable.Scope;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.Collection;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
// de.monticore.lang.montiarc.svggenerator
// montiarc-core-features
//
// Created by Sven Titgemeyer on 11/8/16.
// Copyright (c) 2016 Sven Titgemeyer. All rights reserved.
//
public class CalculatorTest {
public static final String FAS_MONTI_ARC = "src/test/resources/tags/FAS_MontiArc";
@BeforeClass
public static void init(){
LogConfig.init();
}
@Test
public void testCanvasCalculator() throws NoHorizontalLayoutInformationException {
ExpandedComponentInstanceSymbol inst1 = componentFrom(FAS_MONTI_ARC, "basicLibary.and");
assertNotNull(inst1);
CanvasCalculator calculator = new CanvasCalculator();
calculator.calculateLayout(inst1);
ComponentLayoutSymbol layoutSymbol = inst1.<ComponentLayoutSymbol>getTags
(ComponentLayoutSymbol.KIND).iterator().next();
assertEquals(layoutSymbol.getLayoutPosition(), LayoutPosition.UNDEFINED);
assertEquals(layoutSymbol.getWidth(), 285);
assertEquals(layoutSymbol.getHeight(), -2147483569);
assertEquals(layoutSymbol.getX(), 80);
assertEquals(layoutSymbol.getY(), 80);
}
@Test
public void testCanvasPorts() throws NoHorizontalLayoutInformationException {
ExpandedComponentInstanceSymbol inst1 = componentFrom
(FAS_MONTI_ARC, "basicLibary.and");
assertNotNull(inst1);
CanvasCalculator canvasCalculator = new CanvasCalculator();
canvasCalculator.calculateLayout(inst1);
PortCalculator portCalculator = new PortCalculator();
portCalculator.calculateLayout(inst1);
int numberOfPorts = inst1.getPorts().size();
assertEquals(numberOfPorts, 3);
PortSymbol[] port = inst1.getPorts().toArray(new PortSymbol[numberOfPorts]);
PortLayoutSymbol port0 = port[0].<PortLayoutSymbol>getTags(PortLayoutSymbol.KIND)
.iterator().next();
assertEquals(port0.getX(), 70);
assertEquals(port0.getY(), -1073741754);
assertEquals(port0.isInternal(), true);
PortLayoutSymbol port1 = port[1].<PortLayoutSymbol>getTags(PortLayoutSymbol
.KIND).iterator().next();
assertEquals(port1.getX(), 70);
assertEquals(port1.getY(), -1073741714);
assertEquals(port1.isInternal(), true);
PortLayoutSymbol port2 = port[2].<PortLayoutSymbol>getTags(PortLayoutSymbol
.KIND).iterator().next();
assertEquals(port2.getX(), 355);
assertEquals(port2.getY(), -1073741714);
assertEquals(port2.isInternal(), false);
}
@Test(expected = NoHorizontalLayoutInformationException.class)
public void testConnector() throws NoHorizontalLayoutInformationException {
ExpandedComponentInstanceSymbol inst1 = componentFrom(FAS_MONTI_ARC, "advancedLibary.nand");
assertNotNull(inst1);
MainCalculator mainCalculator = new MainCalculator();
mainCalculator.calculateLayout(inst1, MainCalculator.Mode.NORMAL);
String[] assertArray = {
"connectorLayout { start=(710, 260), end=(440, 520), mid=(730, 260), mid2=(430, 490) }",
"connectorLayout { start=(400, 90), end=(190, 260), mid=(400, 120), mid2=(170, 200) }",
"connectorLayout { start=(440, 90), end=(190, 290), mid=(440, 130), mid2=(160, 220) }",
"connectorLayout { start=(410, 260), end=(490, 260), mid=(430, 260), mid2=(490, 240) }",
};
Collection<ConnectorSymbol> connectors = inst1.getConnectors();
assertEquals(4, connectors.size());
int arrayIndex = 0;
for (ConnectorSymbol connector : connectors) {
ConnectorLayoutSymbol tags = connector.<ConnectorLayoutSymbol>getTags(ConnectorLayoutSymbol.KIND).iterator().next();
assertEquals(assertArray[arrayIndex], tags.toString());
arrayIndex++;
}
}
public ExpandedComponentInstanceSymbol componentFrom(String tabName, String instanceName) {
Scope scope = TestingUtilities.createSymTab
(tabName);
ExpandedComponentInstanceSymbol inst1 =
scope.<ExpandedComponentInstanceSymbol>resolve(instanceName,
ExpandedComponentInstanceSymbol.KIND).orElse(null);
return inst1;
}
}
......@@ -244,27 +244,4 @@ public class TemplateTest {
viewModel.isEnd = isEnd;
return viewModel;
}
@Test
public void testCanvas() {
// setup canvas view model
CanvasViewModel viewModel = new CanvasViewModel();
viewModel.x = 0;
viewModel.y = 1;
viewModel.id = 2;
viewModel.height = 200;
viewModel.width = 300;
viewModel.name = "testCanvas";
// load expected string from file
String expected = TestingUtilities.readFile(expectedFiles + "canvas.svg");
// Build line using template builder
TemplateBuilder templateBuilder = new TemplateBuilder();
String canvas = templateBuilder.build("canvas.ftl", viewModel.hashMap());
// compare results
assertEquals(canvas, expected);
}
}
Supports Markdown
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