package com.gurkensalat.osm.repository;

import com.gurkensalat.osm.entity.OsmRoot;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;

import java.io.IOException;
import java.io.InputStream;

import static org.apache.commons.io.IOUtils.closeQuietly;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class OsmRepositoryImplTest
{
    OsmRepositoryImpl testable;

    @Before
    public void setUp()
    {
        MockitoAnnotations.initMocks(this);
        testable = new OsmRepositoryImpl();
    }

    @Test
    public void parseMosqueGermeringData() throws IOException
    {
        InputStream is = getClass().getClassLoader().getResourceAsStream("germany-mosque-germering.osm");
        assertNotNull(is);

        OsmRoot root = testable.parse(is);
        closeQuietly(is);

        assertNotNull(root);
        assertEquals(1, root.getNodes().size());
    }

    @Test
    public void parsePlaceAnkaraData() throws IOException
    {
        InputStream is = getClass().getClassLoader().getResourceAsStream("turkey-places-city-ankara.osm");
        assertNotNull(is);

        OsmRoot root = testable.parse(is);
        closeQuietly(is);

        assertNotNull(root);
        assertEquals(1, root.getNodes().size());
    }
}

@@ -976,32 +976,391 @@
 size());%0A    %7D%0A%0A
+    @Test%0A    public void parseMosqueGermeringDataFromAPI() throws IOException%0A    %7B%0A        InputStream is = getClass().getClassLoader().getResourceAsStream(%22904317998.osm%22);%0A        assertNotNull(is);%0A%0A        OsmRoot root = testable.parse(is);%0A        closeQuietly(is);%0A%0A        assertNotNull(root);%0A        assertEquals(1, root.getNodes().size());%0A    %7D%0A%0A
     @Test%0A    pu

Test parsing the data fetched via HTTP