gt:                 OsmRelation relation = relationCapturer.values.get(0);
context: /* 
   *  Hamburg-Nord Geocoder, by John King.
   *  Copyright (C) 2014,  John King
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program.  If not, see <http://www.gnu.org/licenses/>
   *
   *    
   */
  package com.jejking.osm;
  
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertFalse;
  import static org.junit.Assert.assertNotNull;
  import static org.junit.Assert.assertTrue;
  
  import org.junit.Test;
  
  import java.time.*;
  
  
  /**
   * Tests for {@link RxOsmParser}.
   * 
   * @author jejking
   *
   */
  public class RxOsmParserTest {
  
      private EventCapturer<OsmNode> nodeCapturer;
      private EventCapturer<OsmWay> wayCapturer;
      private EventCapturer<OsmRelation> relationCapturer;
      
      public void setUpAndParse(String resourceName) {
          RxOsmParser rxOsmParser = new RxOsmParser(RxOsmParser.class.getResourceAsStream(resourceName));
          this.nodeCapturer = new EventCapturer<>();
          this.wayCapturer = new EventCapturer<>();
          this.relationCapturer = new EventCapturer<>();
          
          rxOsmParser.getNodeObservable().subscribe(nodeCapturer);
          rxOsmParser.getWayObservable().subscribe(wayCapturer);
          rxOsmParser.getRelationObservable().subscribe(relationCapturer);
          
          rxOsmParser.parseOsmStream();
      }
      
      @Test
      public void runsThroughWithOsmExtract() {
          
          /*
           * Extract direct from Open Street Map website & API.
           */
      	setUpAndParse("/uhlenhorst-direct-export.osm");
      	
          assertTrue(nodeCapturer.completed);
          assertTrue(wayCapturer.completed);
          assertTrue(relationCapturer.completed);
          
          assertFalse(nodeCapturer.values.isEmpty());
          assertFalse(relationCapturer.values.isEmpty());
          assertFalse(wayCapturer.values.isEmpty());
          
      }
      
      @Test
      public void runsThroughWithOsmExtractNoAuthors() {
          
          /*
           * osmconver32 --drop-authors
           */
      	setUpAndParse("/uhlenhorst-direct-export-no-versions.osm");
          assertTrue(nodeCapturer.completed);
          assertTrue(wayCapturer.completed);
          assertTrue(relationCapturer.completed);
          
          assertFalse(nodeCapturer.values.isEmpty());
          assertFalse(relationCapturer.values.isEmpty());
          assertFalse(wayCapturer.values.isEmpty());
      }
      
      @Test
      public void runsThroughWithOsmExtractNoVersion() {
          /*
           * osmfilter --drop-version
           */
      	setUpAndParse("/uhlenhorst-direct-export-no-authors.osm");
          assertTrue(nodeCapturer.completed);
          assertTrue(wayCapturer.completed);
          assertTrue(relationCapturer.completed);
          
          assertFalse(nodeCapturer.values.isEmpty());
          assertFalse(relationCapturer.values.isEmpty());
          assertFalse(wayCapturer.values.isEmpty());
      }
      
      @Test
      public void runsThroughWithOsmExtractNoNodes() {
          /*
           * osmconvert32 --drop-nodes
           */
          setUpAndParse("/uhlenhorst-direct-export-no-nodes.osm");
          assertTrue(nodeCapturer.completed);
          assertTrue(wayCapturer.completed);
          assertTrue(relationCapturer.completed);
          
          assertTrue(nodeCapturer.values.isEmpty());
          assertFalse(relationCapturer.values.isEmpty());
          assertFalse(wayCapturer.values.isEmpty());
      }
      
      @Test
      public void runsThroughWithOsmExtractNoWays() {
  
          /*
           * osmconvert32 --drop-ways
           */
      	setUpAndParse("/uhlenhorst-direct-export-no-ways.osm");
          assertTrue(nodeCapturer.completed);
          assertTrue(wayCapturer.completed);
          assertTrue(relationCapturer.completed);
          
          assertFalse(nodeCapturer.values.isEmpty());
          assertTrue(wayCapturer.values.isEmpty());
          assertFalse(relationCapturer.values.isEmpty());
          
      }
      
      @Test
      public void runsThroughWithOsmExtractNoRelations() {
          /*
           * osmconvert32 --drop-relations
           */
      	setUpAndParse("/uhlenhorst-direct-export-no-relations.osm");
          assertTrue(nodeCapturer.completed);
          assertTrue(wayCapturer.completed);
          assertTrue(relationCapturer.completed);
          
          assertFalse(nodeCapturer.values.isEmpty());
          assertFalse(wayCapturer.values.isEmpty());
          assertTrue(relationCapturer.values.isEmpty());
      }
      
      @Test
      public void runsThroughWithOsmExtractAllToNodes() {
          /*
           * osmconvert32 --all-to-nodes
           */
      	setUpAndParse("/uhlenhorst-direct-export-all-to-nodes.osm");
          assertTrue(nodeCapturer.completed);
          assertTrue(wayCapturer.completed);
          assertTrue(relationCapturer.completed);
          
          assertFalse(nodeCapturer.values.isEmpty());
          assertTrue(relationCapturer.values.isEmpty());
          assertTrue(wayCapturer.values.isEmpty());
      }
      
      @Test
      public void readsTest1Correctly() {
      	setUpAndParse("/test1.osm");
          assertTrue(nodeCapturer.completed);
          assertTrue(wayCapturer.completed);
          assertTrue(relationCapturer.completed);
          
          assertFalse(nodeCapturer.values.isEmpty());
          assertFalse(relationCapturer.values.isEmpty());
          assertFalse(wayCapturer.values.isEmpty());
          
          checkNode1();
          
          checkNode2();
          
          checkWay3();
          
          checkRelation4();
      }
      
      @Test
      public void readsTest1AddedElementsCorrectly() {
      	setUpAndParse("/test1-addedElements.osm");
          assertFalse(nodeCapturer.completed);
          assertTrue(wayCapturer.completed);
          assertTrue(relationCapturer.completed);
          
          // this cannot be read due to use of characters, etc...
          assertNotNull(nodeCapturer.e);
      }
      
      @Test
      public void readsTest1AddedAttributesCorrectly() {
      	setUpAndParse("/test1-addedAttributes.osm");
          assertTrue(nodeCapturer.completed);
          assertTrue(wayCapturer.completed);
          assertTrue(relationCapturer.completed);
          
          assertFalse(nodeCapturer.values.isEmpty());
          assertFalse(relationCapturer.values.isEmpty());
          assertFalse(wayCapturer.values.isEmpty());
          
          checkNode1();
          
          checkNode2();
          
          checkWay3();
          
          checkRelation4();
      }
  
      @Test
      public void registersErrorForMissingNodeId() {
      	setUpAndParse("/test1-missing-node-id.osm");
          
          assertNotNull(nodeCapturer.e);
      }
      
      @Test
      public void registersErrorForMissingLat() {
      	setUpAndParse("/test1-missing-node-lat.osm");
          assertNotNull(nodeCapturer.e);
  
      }
      
      @Test
      public void registersErrorForMissingLon() {
      	setUpAndParse("/test1-missing-node-lon.osm");
          assertNotNull(nodeCapturer.e);
      }
      
      
      private void checkRelation4() {
          //        <relation id="4">
          //            <member type="node" ref="1"/>
          //            <member type="way" ref="3" role=""/>
          //            <member type="relation" ref="666" role="dark-satanic"/>
          //            <tag k="route" v="secret"/>
          //        </relation>
  