Search in sources :

Example 1 with NodeMapState

use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.NodeMapState in project opennms by OpenNMS.

the class NodeMapComponentTest method testShowNodes.

@Test
public void testShowNodes() {
    final NodeMapState state = new NodeMapState();
    final NodeMapComponent component = new NodeMapComponent() {

        private static final long serialVersionUID = 1L;

        public NodeMapState getState() {
            return state;
        }
    };
    final Map<Integer, MapNode> entries = new HashMap<>();
    component.showNodes(entries);
    assertEquals(0, state.nodes.size());
    entries.put(1, createMapNode(1, "Foo", 3f, 4f));
    component.showNodes(entries);
    assertEquals(1, state.nodes.size());
    assertEquals("Foo", state.nodes.get(0).getNodeLabel());
    assertEquals(3d, state.nodes.get(0).getLongitude(), 0.1d);
    assertEquals(4d, state.nodes.get(0).getLatitude(), 0.1d);
    entries.put(1, createMapNode(1, "Bar", 6f, 8f));
    component.showNodes(entries);
    assertEquals(1, state.nodes.size());
    assertEquals("Bar", state.nodes.get(0).getNodeLabel());
    assertEquals(6d, state.nodes.get(0).getLongitude(), 0.1d);
    assertEquals(8d, state.nodes.get(0).getLatitude(), 0.1d);
    entries.remove(1);
    component.showNodes(entries);
    assertEquals(0, state.nodes.size());
}
Also used : NodeMapState(org.opennms.features.vaadin.nodemaps.internal.gwt.client.NodeMapState) HashMap(java.util.HashMap) MapNode(org.opennms.features.vaadin.nodemaps.internal.gwt.client.MapNode) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Test (org.junit.Test)1 MapNode (org.opennms.features.vaadin.nodemaps.internal.gwt.client.MapNode)1 NodeMapState (org.opennms.features.vaadin.nodemaps.internal.gwt.client.NodeMapState)1