@Test public void testSetup() { OpenStreetMapSimpleImporter importer = new OpenStreetMapSimpleImporter(); IIdGenerator idGenerator = EasyMock.createMock(IIdGenerator.class); idGenerator.sync(); EasyMock.replay(idGenerator); importer.setIdGenerator(idGenerator); importer.setup(); EasyMock.verify(idGenerator); }
@Test public void testImporterShouldImport() throws InterruptedException { System.out.println(openStreetMapImporter.getClass()); openStreetMapImporter.process(); /*if (openStreetMapImporter.getClass() != OpenStreetMapImporter.class){ Thread.sleep(10000L); }*/ assertEquals(4L, openStreetMapDao.count()); openStreetMapDao.getAll(); Long firstIdAssigned = (idGenerator.getGid() - 4 + 1); OpenStreetMap openStreetMap = openStreetMapDao.getByGid(firstIdAssigned); assertTrue("The oneWay attribute is not correct", openStreetMap.isOneWay()); assertEquals("The countryCode is not correct ", "FR", openStreetMap.getCountryCode()); assertEquals("The is_in is not correct ", "a city", openStreetMap.getIsIn()); assertEquals( "The openstreetmapId is not correct ", new Long(11), openStreetMap.getOpenstreetmapId()); assertEquals( "The streetType is not correct", StreetType.RESIDENTIAL, openStreetMap.getStreetType()); assertEquals("The name is not correct", "Bachlettenstrasse", openStreetMap.getName()); assertEquals( "The location->X is not correct ", ((Point) GeolocHelper.convertFromHEXEWKBToGeometry( "010100000006C82291A0521E4054CC39B16BC64740")) .getX(), openStreetMap.getLocation().getX()); assertEquals( "The location->Y is not correct ", ((Point) GeolocHelper.convertFromHEXEWKBToGeometry( "010100000006C82291A0521E4054CC39B16BC64740")) .getY(), openStreetMap.getLocation().getY()); assertEquals("The length is not correct", 0.00142246604529, openStreetMap.getLength()); assertEquals( "The shape is not correct ", GeolocHelper.convertFromHEXEWKBToGeometry( "01020000000200000009B254CD6218024038E22428D9EF484075C93846B217024090A8AB96CFEF4840") .toString(), openStreetMap.getShape().toString()); // check alternate names when there is 2 Assert.assertEquals(2, openStreetMap.getAlternateNames().size()); Assert.assertTrue( alternateNamesContain(openStreetMap.getAlternateNames(), "Rue de Bachlettenstrasse")); Assert.assertTrue( alternateNamesContain(openStreetMap.getAlternateNames(), "Bachletten strasse")); // check alternate names when there is no name but alternate openStreetMap = openStreetMapDao.getByGid(firstIdAssigned + 1); Assert.assertEquals(1, openStreetMap.getAlternateNames().size()); Assert.assertEquals( "When there is no name and some alternatename, the first alternatename is set to name ", "noName BUT an alternate", openStreetMap.getName()); Assert.assertTrue(alternateNamesContain(openStreetMap.getAlternateNames(), "other an")); // one alternate name openStreetMap = openStreetMapDao.getByGid(firstIdAssigned + 2); Assert.assertEquals(1, openStreetMap.getAlternateNames().size()); Assert.assertTrue(alternateNamesContain(openStreetMap.getAlternateNames(), "Friedhof")); // no alternate names openStreetMap = openStreetMapDao.getByGid(firstIdAssigned + 3); Assert.assertEquals(0, openStreetMap.getAlternateNames().size()); }