diff --git a/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java b/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java index 175bbfd01674a95e95ee820f88dd980a1164fbce..d241c0d439b249d0978970f742876b1402353dff 100644 --- a/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java +++ b/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java @@ -5,11 +5,9 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Modifier; -import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -42,7 +40,7 @@ import lcsb.mapviewer.model.map.species.Species; /** * This class allows to create complex {@link Model} that contains submaps. It's - * written in generic way and use {@link IConverter} as a class to parse single + * written in generic way and use {@link Converter} as a class to parse single * submap. * * @author Piotr Gawron @@ -63,16 +61,16 @@ public class ComplexZipConverter { /** * Class used to create single submap from a file. */ - private Class<? extends IConverter> converterClazz; + private Class<? extends Converter> converterClazz; /** * Default constructor. Checks if the class given in the parameter is proper - * {@link IConverter} implementation. + * {@link Converter} implementation. * * @param clazz - * {@link IConverter} class used for creation of the single submap + * {@link Converter} class used for creation of the single submap */ - public ComplexZipConverter(Class<? extends IConverter> clazz) { + public ComplexZipConverter(Class<? extends Converter> clazz) { if (Modifier.isAbstract(clazz.getModifiers())) { throw new InvalidClassException("Param class cannot be abstract"); } @@ -94,13 +92,13 @@ public class ComplexZipConverter { * @throws InvalidInputDataExecption * thrown when there is a problem with accessing input data */ - public Model createModel(ComplexZipConverterParams params) throws InvalidInputDataExecption { + public Model createModel(ComplexZipConverterParams params) throws InvalidInputDataExecption, ConverterException { try { ZipFile zipFile = params.getZipFile(); Enumeration<? extends ZipEntry> entries; String mapping = validateSubmodelInformation(params, zipFile); - IConverter converter = createConverterInstance(); + Converter converter = createConverterInstance(); Map<String, Model> filenameModelMap = new HashMap<>(); Map<String, Model> nameModelMap = new HashMap<>(); @@ -316,7 +314,7 @@ public class ComplexZipConverter { * layout should be stored) * @param layoutEntry * {@link LayoutZipEntryFile} to transform - * @return {@link LAyout} for a given {@link LayoutZipEntryFile} + * @return {@link Layout} for a given {@link LayoutZipEntryFile} * @throws IOException * thrown when there is a problem with accessing {@link ZipFile} */ @@ -360,13 +358,13 @@ public class ComplexZipConverter { } /** - * Creates inctance of {@link IConverter} used as a template parameter for this + * Creates inctance of {@link Converter} used as a template parameter for this * class instatiation. * - * @return inctance of {@link IConverter} + * @return inctance of {@link Converter} */ - protected IConverter createConverterInstance() { - IConverter converter; + protected Converter createConverterInstance() { + Converter converter; try { converter = converterClazz.newInstance(); } catch (InstantiationException e) { diff --git a/converter/src/main/java/lcsb/mapviewer/converter/ConverterException.java b/converter/src/main/java/lcsb/mapviewer/converter/ConverterException.java index ffc14cefd6abe4e4e3a6c53ddd054514f4708520..fad178973d1e5c495857c9b18023320636feb47d 100644 --- a/converter/src/main/java/lcsb/mapviewer/converter/ConverterException.java +++ b/converter/src/main/java/lcsb/mapviewer/converter/ConverterException.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.converter; /** - * Generic exception thrown when implementation of {@link IConverter} encounter + * Generic exception thrown when implementation of {@link Converter} encounter * a problem. * * @author Piotr Gawron diff --git a/converter/src/main/java/lcsb/mapviewer/converter/ConverterParams.java b/converter/src/main/java/lcsb/mapviewer/converter/ConverterParams.java index 3eb7ff6424d87a561478fe089e042fd577ab1449..d774588c8b1d5a6081f6ffb105119f8e53f158c6 100644 --- a/converter/src/main/java/lcsb/mapviewer/converter/ConverterParams.java +++ b/converter/src/main/java/lcsb/mapviewer/converter/ConverterParams.java @@ -7,7 +7,7 @@ import java.io.InputStream; import org.apache.xerces.xni.parser.XMLInputSource; /** - * Class with params for {@link IConverter} interface. + * Class with params for {@link Converter} interface. * * @author Piotr Gawron */ diff --git a/converter/src/main/java/lcsb/mapviewer/converter/ProjectFactory.java b/converter/src/main/java/lcsb/mapviewer/converter/ProjectFactory.java index c81ac4604fcf4b70f2ab7b599a0ffd84fa5e944a..ebb7aea181d25e5b859fdd8247a4310020927490 100644 --- a/converter/src/main/java/lcsb/mapviewer/converter/ProjectFactory.java +++ b/converter/src/main/java/lcsb/mapviewer/converter/ProjectFactory.java @@ -33,11 +33,12 @@ public class ProjectFactory { this.converter = converter; } - public Project create(ComplexZipConverterParams params) throws InvalidInputDataExecption { + public Project create(ComplexZipConverterParams params) throws InvalidInputDataExecption, ConverterException { return create(params, new Project()); } - public Project create(ComplexZipConverterParams params, Project project) throws InvalidInputDataExecption { + public Project create(ComplexZipConverterParams params, Project project) + throws InvalidInputDataExecption, ConverterException { try { Model model = converter.createModel(params); diff --git a/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java b/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java index 5b2ffadb63d79afbe80ce87dd6fea06cc1c587c4..e26b8499c9fb87524403d96a3649adc5cd31d510 100644 --- a/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java +++ b/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java @@ -45,15 +45,7 @@ public class ComplexZipConverterTest { @SuppressWarnings("unused") private static Logger logger = Logger.getLogger(ComplexZipConverterTest.class); - private abstract class AbstractConverter implements IConverter { - - } - - private interface InterfaceConverter extends IConverter { - - } - - public static class MockConverter implements IConverter { + public static class MockConverter extends Converter { @Override public Model createModel(ConverterParams params) { @@ -117,13 +109,19 @@ public class ComplexZipConverterTest { } @Override - public InputStream exportModelToInputStream(Model model) throws InconsistentModelException { + public String model2Xml(Model model) throws InconsistentModelException, ConverterException { // TODO Auto-generated method stub return null; } @Override - public File exportModelToFile(Model model, String filePath) throws InconsistentModelException { + public InputStream model2InputStream(Model model) throws InconsistentModelException, ConverterException { + // TODO Auto-generated method stub + return null; + } + + @Override + public File model2File(Model model, String filePath) throws InconsistentModelException { // TODO Auto-generated method stub return null; } @@ -159,21 +157,7 @@ public class ComplexZipConverterTest { @Test public void testConstructor() throws Exception { try { - new ComplexZipConverter(AbstractConverter.class); - fail("Exception expected"); - - } catch (InvalidClassException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } - - @Test - public void testConstructor2() throws Exception { - try { - new ComplexZipConverter(InterfaceConverter.class); + new ComplexZipConverter(Converter.class); fail("Exception expected"); } catch (InvalidClassException e) { @@ -181,7 +165,6 @@ public class ComplexZipConverterTest { e.printStackTrace(); throw e; } - } @Test