diff --git a/converter/src/main/java/lcsb/mapviewer/converter/OverviewParser.java b/converter/src/main/java/lcsb/mapviewer/converter/OverviewParser.java index d23f450a0c983aca3109182be358b7799750e6a6..0e2473ec1bf13b15197eb981a387c52aff305add 100644 --- a/converter/src/main/java/lcsb/mapviewer/converter/OverviewParser.java +++ b/converter/src/main/java/lcsb/mapviewer/converter/OverviewParser.java @@ -113,7 +113,7 @@ public class OverviewParser { /** * Method that parse zip file and creates list of {@link OverviewImage images} * from it. - * + * * @param models * map with models where the key is name of the file and value is model * that was parsed from the file @@ -219,7 +219,7 @@ public class OverviewParser { /** * This method process data from {@link #COORDINATES_FILENAME} in zip archive. * This method adds connections between images and between images and models. - * + * * @param models * map with models where the key is name of the file and value is model * that was parsed from the file @@ -328,7 +328,7 @@ public class OverviewParser { } String filename = columns[filenameColumn]; String polygon = columns[polygonColumn]; - String modelName = FilenameUtils.removeExtension(columns[targetFilenameColumn]); + String modelName = FilenameUtils.getBaseName(columns[targetFilenameColumn]); String coord = columns[redirectionCoordinatesColumn]; String zoomLevel = columns[zoomLevelColumn]; String linkType = columns[targetTypeColumn]; @@ -365,7 +365,7 @@ public class OverviewParser { /** * Creates a link from parameters and place it in appropriate * {@link OverviewImage}. - * + * * @param filename * {@link OverviewImage#filename name of the image} * @param polygon diff --git a/converter/src/test/java/lcsb/mapviewer/converter/ProjectFactoryTest.java b/converter/src/test/java/lcsb/mapviewer/converter/ProjectFactoryTest.java index fc1d6640bb293a149fe830c972bd2ec29aff3492..0ab238b07f5a504fd3c010515e4d3c81c3e55182 100644 --- a/converter/src/test/java/lcsb/mapviewer/converter/ProjectFactoryTest.java +++ b/converter/src/test/java/lcsb/mapviewer/converter/ProjectFactoryTest.java @@ -25,70 +25,105 @@ import lcsb.mapviewer.model.map.model.ModelData; public class ProjectFactoryTest { - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testOverviewImageLink() throws Exception { - try { - ComplexZipConverter converter = new ComplexZipConverter(MockConverter.class); - ProjectFactory projectFactory = new ProjectFactory(converter); - ZipFile zipFile = new ZipFile("testFiles/complex_model_with_img.zip"); - ComplexZipConverterParams params = new ComplexZipConverterParams(); - params.zipFile(zipFile); - - ZipEntryFileFactory factory = new ZipEntryFileFactory(); - Enumeration<? extends ZipEntry> entries = zipFile.entries(); - while (entries.hasMoreElements()) { - ZipEntry entry = entries.nextElement(); - if (!entry.isDirectory()) { - params.entry(factory.createZipEntryFile(entry, zipFile)); - } - } - - Project project = projectFactory.create(params); - assertNotNull(project); - ModelData model = project.getModels().iterator().next(); - assertEquals("main", model.getName()); - - List<OverviewImage> result = project.getOverviewImages(); - - assertNotNull(result); - assertEquals(1, result.size()); - - OverviewImage img = result.get(0); - - assertEquals("test.png", img.getFilename()); - assertEquals((Integer) 639, img.getHeight()); - assertEquals((Integer) 963, img.getWidth()); - assertEquals(2, img.getLinks().size()); - - OverviewLink link = img.getLinks().get(0); - List<Point2D> polygon = link.getPolygonCoordinates(); - assertEquals(4, polygon.size()); - - assertTrue(link instanceof OverviewModelLink); - - OverviewModelLink mLink = (OverviewModelLink) link; - assertEquals((Integer) 10, mLink.getxCoord()); - assertEquals((Integer) 10, mLink.getyCoord()); - assertEquals((Integer) 3, mLink.getZoomLevel()); - assertEquals(model, mLink.getLinkedModel()); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testOverviewImageLink() throws Exception { + try { + ComplexZipConverter converter = new ComplexZipConverter(MockConverter.class); + ProjectFactory projectFactory = new ProjectFactory(converter); + ZipFile zipFile = new ZipFile("testFiles/complex_model_with_img.zip"); + ComplexZipConverterParams params = new ComplexZipConverterParams(); + params.zipFile(zipFile); + + ZipEntryFileFactory factory = new ZipEntryFileFactory(); + Enumeration<? extends ZipEntry> entries = zipFile.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = entries.nextElement(); + if (!entry.isDirectory()) { + params.entry(factory.createZipEntryFile(entry, zipFile)); + } + } + + Project project = projectFactory.create(params); + assertNotNull(project); + ModelData model = project.getModels().iterator().next(); + assertEquals("main", model.getName()); + + List<OverviewImage> result = project.getOverviewImages(); + + assertNotNull(result); + assertEquals(1, result.size()); + + OverviewImage img = result.get(0); + + assertEquals("test.png", img.getFilename()); + assertEquals((Integer) 639, img.getHeight()); + assertEquals((Integer) 963, img.getWidth()); + assertEquals(2, img.getLinks().size()); + + OverviewLink link = img.getLinks().get(0); + List<Point2D> polygon = link.getPolygonCoordinates(); + assertEquals(4, polygon.size()); + + assertTrue(link instanceof OverviewModelLink); + + OverviewModelLink mLink = (OverviewModelLink) link; + assertEquals((Integer) 10, mLink.getxCoord()); + assertEquals((Integer) 10, mLink.getyCoord()); + assertEquals((Integer) 3, mLink.getZoomLevel()); + assertEquals(model, mLink.getLinkedModel()); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + + @Test + public void testOverviewImageLinkToSubmapPath() throws Exception { + try { + ComplexZipConverter converter = new ComplexZipConverter(MockConverter.class); + ProjectFactory projectFactory = new ProjectFactory(converter); + ZipFile zipFile = new ZipFile("testFiles/complex_model_with_images_path.zip"); + ComplexZipConverterParams params = new ComplexZipConverterParams(); + params.zipFile(zipFile); + + ZipEntryFileFactory factory = new ZipEntryFileFactory(); + Enumeration<? extends ZipEntry> entries = zipFile.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = entries.nextElement(); + if (!entry.isDirectory()) { + params.entry(factory.createZipEntryFile(entry, zipFile)); + } + } + + Project project = projectFactory.create(params); + assertNotNull(project); + ModelData model = project.getModels().iterator().next(); + assertEquals("main", model.getName()); + + List<OverviewImage> result = project.getOverviewImages(); + + assertNotNull(result); + assertEquals(2, result.size()); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } } diff --git a/converter/testFiles/complex_model_with_images_path.zip b/converter/testFiles/complex_model_with_images_path.zip new file mode 100644 index 0000000000000000000000000000000000000000..10246001ea4573b9aa068bf8d9fa3c98299104bc Binary files /dev/null and b/converter/testFiles/complex_model_with_images_path.zip differ