1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-25 14:27:33 +00:00

Restore test and ignore XMI.exporterVersion

This commit is contained in:
Arnaud Roques 2023-02-22 21:08:32 +01:00
parent c54983bb5e
commit 07f828770f
4 changed files with 292 additions and 2 deletions

View File

@ -27,7 +27,7 @@ public class XmiTest {
protected void checkXmlAndDescription(final String expectedDescription) protected void checkXmlAndDescription(final String expectedDescription)
throws IOException, UnsupportedEncodingException { throws IOException, UnsupportedEncodingException {
final String star = runPlantUML(expectedDescription, FileFormat.XMI_STAR); final String star = removeVersion(runPlantUML(expectedDescription, FileFormat.XMI_STAR));
final String starExpected = readStringFromSourceFile(getDiagramFile(), "{{{star", "}}}star"); final String starExpected = readStringFromSourceFile(getDiagramFile(), "{{{star", "}}}star");
// This is really a hack. Since XML generation does not guarantee the order of // This is really a hack. Since XML generation does not guarantee the order of
@ -39,7 +39,7 @@ public class XmiTest {
assertEquals(starExpected, star, "XmiStar: Generated GraphML is not ok"); assertEquals(starExpected, star, "XmiStar: Generated GraphML is not ok");
} }
final String argo = runPlantUML(expectedDescription, FileFormat.XMI_ARGO); final String argo = removeVersion(runPlantUML(expectedDescription, FileFormat.XMI_ARGO));
final String argoExpected = readStringFromSourceFile(getDiagramFile(), "{{{argo", "}}}argo"); final String argoExpected = readStringFromSourceFile(getDiagramFile(), "{{{argo", "}}}argo");
if (sortString(argo).equals(sortString(argoExpected)) == false) { if (sortString(argo).equals(sortString(argoExpected)) == false) {
@ -48,6 +48,10 @@ public class XmiTest {
} }
private String removeVersion(String xmi) {
return xmi.replaceFirst("\\<XMI.exporterVersion\\>.*\\</XMI.exporterVersion\\>", "");
}
private String sortString(String s) { private String sortString(String s) {
final Map<Character, AtomicInteger> map = new TreeMap<>(); final Map<Character, AtomicInteger> map = new TreeMap<>();
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {

View File

@ -0,0 +1,80 @@
package nonreg.xmi.clazz;
import java.io.IOException;
import org.junit.jupiter.api.Test;
import nonreg.xmi.XmiTest;
/*
https://forum.plantuml.net/12644/class-access-modifiers-not-in-xmi-export
Test diagram MUST be put between triple quotes
"""
@startuml
-class foo{
# field1 : type
}
@enduml
"""
Expected result MUST be put between triple brackets
{{{star
<?xml version="1.0" encoding="UTF-8"?><XMI xmlns:UML="href://org.omg/UML/1.3" xmi.version="1.1">
<XMI.header>
<XMI.documentation>
<XMI.exporter>PlantUML</XMI.exporter>
</XMI.documentation>
<XMI.metamodel xmi.name="UML" xmi.version="1.4"/>
</XMI.header>
<XMI.content>
<UML:Model name="PlantUML" xmi.id="model1">
<UML:Namespace.ownedElement>
<UML:Class name="foo" visibility="private" xmi.id="cl0002">
<UML:Classifier.feature>
<UML:Attribute name="field1 : type" visibility="protected" xmi.id="att3"/>
</UML:Classifier.feature>
</UML:Class>
</UML:Namespace.ownedElement>
</UML:Model>
</XMI.content>
</XMI>
}}}star
{{{argo
<?xml version="1.0" encoding="UTF-8"?><XMI xmlns:UML="href://org.omg/UML/1.3" xmi.version="1.1">
<XMI.header>
<XMI.documentation>
<XMI.exporter>PlantUML</XMI.exporter>
</XMI.documentation>
<XMI.metamodel xmi.name="UML" xmi.version="1.4"/>
</XMI.header>
<XMI.content>
<UML:Model name="PlantUML" xmi.id="model1">
<UML:Namespace.ownedElement>
<UML:Class name="foo" visibility="private" xmi.id="cl0002">
<UML:Classifier.feature>
<UML:Attribute name="field1 : type" visibility="protected" xmi.id="att3"/>
</UML:Classifier.feature>
</UML:Class>
</UML:Namespace.ownedElement>
</UML:Model>
</XMI.content>
</XMI>
}}}argo
*/
public class XMI0000_Test extends XmiTest {
@Test
void testSimple() throws IOException {
checkXmlAndDescription("(1 entities)");
}
}

View File

@ -0,0 +1,107 @@
package nonreg.xmi.clazz;
import java.io.IOException;
import org.junit.jupiter.api.Test;
import nonreg.xmi.XmiTest;
/*
https://forum.plantuml.net/12972/only-the-first-line-any-component-description-exported-file
Test diagram MUST be put between triple quotes
"""
@startuml
class A {
}
class B{
}
A -->B
@enduml
"""
Expected result MUST be put between triple brackets
{{{star
<?xml version="1.0" encoding="UTF-8"?><XMI xmlns:UML="href://org.omg/UML/1.3" xmi.version="1.1">
<XMI.header>
<XMI.documentation>
<XMI.exporter>PlantUML</XMI.exporter>
</XMI.documentation>
<XMI.metamodel xmi.name="UML" xmi.version="1.4"/>
</XMI.header>
<XMI.content>
<UML:Model name="PlantUML" xmi.id="model1">
<UML:Namespace.ownedElement>
<UML:Class name="A" xmi.id="cl0002">
<UML:Classifier.feature/>
</UML:Class>
<UML:Class name="B" xmi.id="cl0003">
<UML:Classifier.feature/>
</UML:Class>
<UML:Association namespace="model1" xmi.id="ass5">
<UML:Association.connection>
<UML:AssociationEnd association="ass5" type="cl0002" xmi.id="end6">
<UML:AssociationEnd.participant/>
</UML:AssociationEnd>
<UML:AssociationEnd association="ass5" type="cl0003" xmi.id="end7">
<UML:AssociationEnd.participant/>
</UML:AssociationEnd>
</UML:Association.connection>
</UML:Association>
</UML:Namespace.ownedElement>
</UML:Model>
</XMI.content>
</XMI>
}}}star
{{{argo
<?xml version="1.0" encoding="UTF-8"?><XMI xmlns:UML="href://org.omg/UML/1.3" xmi.version="1.1">
<XMI.header>
<XMI.documentation>
<XMI.exporter>PlantUML</XMI.exporter>
</XMI.documentation>
<XMI.metamodel xmi.name="UML" xmi.version="1.4"/>
</XMI.header>
<XMI.content>
<UML:Model name="PlantUML" xmi.id="model1">
<UML:Namespace.ownedElement>
<UML:Class name="A" xmi.id="cl0002">
<UML:Classifier.feature/>
</UML:Class>
<UML:Class name="B" xmi.id="cl0003">
<UML:Classifier.feature/>
</UML:Class>
<UML:Association xmi.id="ass5">
<UML:Association.connection>
<UML:AssociationEnd association="ass5" type="cl0002" xmi.id="end6">
<UML:AssociationEnd.participant/>
</UML:AssociationEnd>
<UML:AssociationEnd association="ass5" type="cl0003" xmi.id="end7">
<UML:AssociationEnd.participant/>
</UML:AssociationEnd>
</UML:Association.connection>
</UML:Association>
</UML:Namespace.ownedElement>
</UML:Model>
</XMI.content>
</XMI>
}}}argo
*/
public class XMI0002_Test extends XmiTest {
@Test
void testSimple() throws IOException {
checkXmlAndDescription("(2 entities)");
}
}

View File

@ -0,0 +1,99 @@
package nonreg.xmi.clazz;
import java.io.IOException;
import org.junit.jupiter.api.Test;
import nonreg.xmi.XmiTest;
/*
Test diagram MUST be put between triple quotes
"""
@startuml
class A {
{method}{abstract}{static} + method
}
abstract class B{
}
static class C{
}
@enduml
"""
Expected result MUST be put between triple brackets
{{{star
<?xml version="1.0" encoding="UTF-8"?><XMI xmlns:UML="href://org.omg/UML/1.3" xmi.version="1.1">
<XMI.header>
<XMI.documentation>
<XMI.exporter>PlantUML</XMI.exporter>
</XMI.documentation>
<XMI.metamodel xmi.name="UML" xmi.version="1.4"/>
</XMI.header>
<XMI.content>
<UML:Model name="PlantUML" xmi.id="model1">
<UML:Namespace.ownedElement>
<UML:Class name="A" xmi.id="cl0002">
<UML:Classifier.feature>
<UML:Operation isStatic="true" name="method" visibility="public" xmi.id="att7"/>
</UML:Classifier.feature>
</UML:Class>
<UML:Class isAbstract="true" name="B" xmi.id="cl0003">
<UML:Classifier.feature/>
</UML:Class>
<UML:Class isStatic="true" name="C" xmi.id="cl0004">
<UML:Classifier.feature/>
</UML:Class>
</UML:Namespace.ownedElement>
</UML:Model>
</XMI.content>
</XMI>
}}}star
{{{argo
<?xml version="1.0" encoding="UTF-8"?><XMI xmlns:UML="href://org.omg/UML/1.3" xmi.version="1.1">
<XMI.header>
<XMI.documentation>
<XMI.exporter>PlantUML</XMI.exporter>
</XMI.documentation>
<XMI.metamodel xmi.name="UML" xmi.version="1.4"/>
</XMI.header>
<XMI.content>
<UML:Model name="PlantUML" xmi.id="model1">
<UML:Namespace.ownedElement>
<UML:Class name="A" xmi.id="cl0002">
<UML:Classifier.feature>
<UML:Operation isStatic="true" name="method" visibility="public" xmi.id="att7"/>
</UML:Classifier.feature>
</UML:Class>
<UML:Class isAbstract="true" name="B" xmi.id="cl0003">
<UML:Classifier.feature/>
</UML:Class>
<UML:Class isStatic="true" name="C" xmi.id="cl0004">
<UML:Classifier.feature/>
</UML:Class>
</UML:Namespace.ownedElement>
</UML:Model>
</XMI.content>
</XMI>
}}}argo
*/
public class XMI0003_Test extends XmiTest {
@Test
void testSimple() throws IOException {
checkXmlAndDescription("(3 entities)");
}
}