mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 06:07:57 +01:00
Fix tests.
This commit is contained in:
parent
9517f06902
commit
5ace7f5259
@ -73,7 +73,7 @@ public class FreemindExporter
|
|||||||
|
|
||||||
final List<TopicType> topics = mindmapMap.getTopic();
|
final List<TopicType> topics = mindmapMap.getTopic();
|
||||||
|
|
||||||
// Insolated Topic doesn´t exists in Freemind only take the center topic
|
// Isolated Topic does not exist in Freemind only take the center topic
|
||||||
TopicType centerTopic = null;
|
TopicType centerTopic = null;
|
||||||
if (topics.size() > 1) {
|
if (topics.size() > 1) {
|
||||||
for (TopicType topic : topics) {
|
for (TopicType topic : topics) {
|
||||||
|
@ -24,16 +24,13 @@ import com.wisemapping.model.IconFamily;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
final public class FreemindIconConverter {
|
final public class FreemindIconConverter {
|
||||||
|
|
||||||
|
|
||||||
private final static Map<String, MindmapIcon> freeIdToIcon = new HashMap<String, MindmapIcon>();
|
private final static Map<String, MindmapIcon> freeIdToIcon = new TreeMap<String, MindmapIcon>();
|
||||||
private final static Map<MindmapIcon, String> iconToFreeId = new HashMap<MindmapIcon, String>();
|
private final static Map<MindmapIcon, String> iconToFreeId = new TreeMap<MindmapIcon, String>();
|
||||||
|
|
||||||
private FreemindIconConverter() {
|
private FreemindIconConverter() {
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ public class FreemindImporter
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MindMap importMap(String mapName, String description, InputStream input) throws ImporterException {
|
public MindMap importMap(@NotNull String mapName, @NotNull String description, @NotNull InputStream input) throws ImporterException {
|
||||||
|
|
||||||
final MindMap result = new MindMap();
|
final MindMap result = new MindMap();
|
||||||
nodesMap = new HashMap<String, TopicType>();
|
nodesMap = new HashMap<String, TopicType>();
|
||||||
|
@ -29,6 +29,7 @@ package com.wisemapping.model;
|
|||||||
|
|
||||||
import com.wisemapping.util.ZipUtils;
|
import com.wisemapping.util.ZipUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@ -189,7 +190,7 @@ public class MindMap {
|
|||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNativeXml(String nativeXml)
|
public void setNativeXml(@NotNull String nativeXml)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
this.xml = ZipUtils.stringToZip(nativeXml);
|
this.xml = ZipUtils.stringToZip(nativeXml);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package com.wisemapping.model;
|
package com.wisemapping.model;
|
||||||
|
|
||||||
public class MindmapIcon {
|
public class MindmapIcon implements Comparable{
|
||||||
private String name;
|
private String name;
|
||||||
private IconFamily family;
|
private IconFamily family;
|
||||||
|
|
||||||
@ -38,4 +38,8 @@ public class MindmapIcon {
|
|||||||
public String getId() {
|
public String getId() {
|
||||||
return family.name().toLowerCase() + "_" + name;
|
return family.name().toLowerCase() + "_" + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int compareTo(Object o) {
|
||||||
|
return ((MindmapIcon)o).getId().compareTo(this.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ public class MindmapIcons {
|
|||||||
private static void load() {
|
private static void load() {
|
||||||
try {
|
try {
|
||||||
if (iconsByFamily == null) {
|
if (iconsByFamily == null) {
|
||||||
iconsByFamily = new HashMap<IconFamily, List<MindmapIcon>>();
|
iconsByFamily = new TreeMap<IconFamily, List<MindmapIcon>>();
|
||||||
|
|
||||||
Field[] fields = MindmapIcons.class.getDeclaredFields();
|
Field[] fields = MindmapIcons.class.getDeclaredFields();
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
|
@ -54,9 +54,9 @@ public class JAXBUtils {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveMap(@NotNull Object obj, @NotNull OutputStream out, String pachage) throws JAXBException {
|
public static void saveMap(@NotNull Object obj, @NotNull OutputStream out, String packag) throws JAXBException {
|
||||||
|
|
||||||
final JAXBContext context = getInstance(pachage);
|
final JAXBContext context = getInstance(packag);
|
||||||
final Marshaller marshaller = context.createMarshaller();
|
final Marshaller marshaller = context.createMarshaller();
|
||||||
|
|
||||||
marshaller.marshal(obj, out);
|
marshaller.marshal(obj, out);
|
||||||
|
@ -40,7 +40,7 @@ public class ZipUtils {
|
|||||||
byte[] buffer = new byte[512];
|
byte[] buffer = new byte[512];
|
||||||
|
|
||||||
int len;
|
int len;
|
||||||
StringBuffer sb_result = new StringBuffer();
|
StringBuilder sb_result = new StringBuilder();
|
||||||
|
|
||||||
while ((len = zipIn.read(buffer)) > 0) {
|
while ((len = zipIn.read(buffer)) > 0) {
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,3 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="0.9.0"><node wCOORDS="0,0" TEXT="eeeeeeeeeee" ID="ID_0" COLOR="#000000"><font SIZE="10" NAME="Arial"/><hook NAME="accessories/plugins/NodeNote.properties"><text>
|
|
||||||
</text></hook><node wORDER="7" wCOORDS="200,-200" TEXT="interne" POSITION="right" ID="ID_1" COLOR="#cc0000"><font SIZE="12" NAME="Arial" ITALIC="true" BOLD="true"/><node wORDER="0" wCOORDS="290,-225" TEXT="faiblesses" POSITION="right" ID="ID_2" COLOR="#330033"><font SIZE="12" NAME="Arial" ITALIC="true" BOLD="true"/></node></node><node wORDER="3" wCOORDS="200,-100" TEXT="www.luxuo.com" POSITION="right" LINK="www.luxuo.com" ID="ID_3"><arrowlink ENDARROW="Default" DESTINATION="ID_6"/></node><node wORDER="0" wCOORDS="200,0" TEXT="" POSITION="right" ID="ID_4"/><node wORDER="4" wCOORDS="200,100" TEXT="forces" POSITION="right" ID="ID_5" COLOR="#003333"><font SIZE="12" NAME="Arial" ITALIC="true" BOLD="true"/></node><node wORDER="8" wCOORDS="200,200" TEXT="" POSITION="right" ID="ID_6"><hook NAME="accessories/plugins/NodeNote.properties"><text>%5El%3A%5El%3A%5El
|
|
||||||
</text></hook></node><node wORDER="12" wCOORDS="200,300" TEXT="" POSITION="right" ID="ID_7"><node wORDER="0" wCOORDS="290,275" TEXT="externe" POSITION="right" ID="ID_8" COLOR="#000066"><font SIZE="12" NAME="Arial" ITALIC="true" BOLD="true"/><node wORDER="0" wCOORDS="380,250" TEXT="opportunit?s" POSITION="right" ID="ID_9" COLOR="#ff3300"><font SIZE="12" NAME="Arial" ITALIC="true" BOLD="true"/></node><node wORDER="1" wCOORDS="380,275" TEXT="menaces" POSITION="right" ID="ID_10" COLOR="#333300"><font SIZE="12" NAME="Arial" ITALIC="true" BOLD="true"/><arrowlink ENDARROW="Default" DESTINATION="ID_0"/></node></node><arrowlink ENDARROW="Default" DESTINATION="ID_5"/></node></node></map>
|
|
@ -1 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="pela" name="basic"><topic id="0" central="true" position="0,0" fontStyle="Arial;10;#000000;;;" shape="rounded rectagle" text="eeeeeeeeeee"><note text="%0A "/><topic id="1" position="200,-200" order="7" fontStyle="Arial;12;#cc0000;bold;italic;" shape="line" text="interne"><topic id="2" position="290,-225" order="0" fontStyle="Arial;12;#330033;bold;italic;" shape="line" text="faiblesses"/></topic><topic id="3" position="200,-100" order="3" shape="line" text="www.luxuo.com"><link url="www.luxuo.com"/></topic><topic id="4" position="200,0" order="0" shape="line" text=""/><topic id="5" position="200,100" order="4" fontStyle="Arial;12;#003333;bold;italic;" shape="line" text="forces"/><topic id="6" position="200,200" order="8" shape="line" text=""><note text="%5El%3A%5El%3A%5El%0A "/></topic><topic id="7" position="200,300" order="12" shape="line" text=""><topic id="8" position="290,275" order="0" fontStyle="Arial;12;#000066;bold;italic;" shape="line" text="externe"><topic id="9" position="380,250" order="0" fontStyle="Arial;12;#ff3300;bold;italic;" shape="line" text="opportunit?s"/><topic id="10" position="380,275" order="1" fontStyle="Arial;12;#333300;bold;italic;" shape="line" text="menaces"/></topic></topic></topic><relationship startArrow="false" endArrow="true" destCtrlPoint="108,0" srcCtrlPoint="108,0" lineType="3" destTopicId="6" srcTopicId="3" id="11"/><relationship startArrow="false" endArrow="true" destCtrlPoint="63,0" srcCtrlPoint="63,0" lineType="3" destTopicId="5" srcTopicId="7" id="12"/><relationship startArrow="false" endArrow="true" destCtrlPoint="211,0" srcCtrlPoint="211,0" lineType="3" destTopicId="0" srcTopicId="10" id="13"/></map>
|
|
@ -44,7 +44,7 @@ public class ExportTest {
|
|||||||
// Export mile content ...
|
// Export mile content ...
|
||||||
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
freemindExporter.export(mindmap, bos);
|
freemindExporter.export(mindmap, bos);
|
||||||
final String exportContent = new String(bos.toByteArray());
|
final String exportContent = new String(bos.toByteArray(),"UTF-8");
|
||||||
|
|
||||||
Assert.assertEquals(recContent.toString(), exportContent);
|
Assert.assertEquals(recContent.toString(), exportContent);
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ public class ExportTest {
|
|||||||
fis.close();
|
fis.close();
|
||||||
|
|
||||||
final MindMap result = new MindMap();
|
final MindMap result = new MindMap();
|
||||||
result.setXml(content.toString().getBytes());
|
result.setXml(content.toString().getBytes("UTF-8"));
|
||||||
result.setNativeXml(content.toString());
|
result.setNativeXml(content.toString());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class ImportExportTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test(dataProvider = "Data-Provider-Function")
|
@Test(dataProvider = "Data-Provider-Function")
|
||||||
public void exportImportExportTest(@NotNull final File freeMindFile, @NotNull final File wiseFile, @NotNull final File freeRecFile) throws ImporterException, IOException, ExportException {
|
public void exportImportTest(@NotNull final File freeMindFile, @NotNull final File wiseFile, @NotNull final File freeRecFile) throws ImporterException, IOException, ExportException {
|
||||||
|
|
||||||
|
|
||||||
final FileInputStream fileInputStream = new FileInputStream(freeMindFile.getAbsolutePath());
|
final FileInputStream fileInputStream = new FileInputStream(freeMindFile.getAbsolutePath());
|
||||||
@ -46,7 +46,7 @@ public class ImportExportTest {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
final FileOutputStream fos = new FileOutputStream(wiseFile);
|
final FileOutputStream fos = new FileOutputStream(wiseFile);
|
||||||
fos.write(mindMap.getUnzippedXml().getBytes());
|
fos.write(mindMap.getUnzippedXml().getBytes("UTF-8"));
|
||||||
fos.close();
|
fos.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,12 +55,11 @@ public class ImportExportTest {
|
|||||||
// Compare rec and file ...
|
// Compare rec and file ...
|
||||||
final String recContent = readFile(freeRecFile);
|
final String recContent = readFile(freeRecFile);
|
||||||
|
|
||||||
// Export mile content ...
|
// Export content ...
|
||||||
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
exporter.export(mindMap, bos);
|
exporter.export(mindMap, bos);
|
||||||
final String exportContent = new String(bos.toByteArray());
|
|
||||||
|
|
||||||
Assert.assertEquals(exportContent, recContent);
|
Assert.assertEquals(bos.toByteArray(), recContent.getBytes("UTF-8"));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
final FileOutputStream fos = new FileOutputStream(freeRecFile);
|
final FileOutputStream fos = new FileOutputStream(freeRecFile);
|
||||||
|
Loading…
Reference in New Issue
Block a user