Beispiel #1
0
  @Test
  public void checkNullsInGetElements() {
    assumeTrue(dataStructure instanceof INodeListDatastructureReadable);
    INodeListDatastructureReadable tempDS = (INodeListDatastructureReadable) dataStructure;

    dataStructure.reinitializeWithSize(10);
    for (IElement singleDummy : tempDS.getElements()) {
      assertNotNull(singleDummy);
    }
  }
Beispiel #2
0
  @Test
  public void checkGetNodeWithGaps() {
    /*
     * Don't run this test for non-node datastructures and non-nodes
     */
    assumeTrue(dataStructure instanceof INodeListDatastructureReadable);
    assumeTrue(Node.class.isAssignableFrom(this.elementClass));

    INodeListDatastructureReadable tempDS = (INodeListDatastructureReadable) dataStructure;

    Node dummy1 = (Node) mock(this.elementClass);
    when(dummy1.getIndex()).thenReturn(0);
    assertTrue(tempDS.add(dummy1));

    assertEquals(null, tempDS.get(1));
    assertEquals(0, dummy1.getIndex());
    assertEquals(dummy1, tempDS.get(0));

    Node dummy2 = (Node) mock(this.elementClass);
    when(dummy2.getIndex()).thenReturn(1);
    assertTrue(tempDS.add(dummy2));

    assertEquals(1, dummy2.getIndex());
    assertEquals(dummy2, tempDS.get(1));

    // Remove first node and get second one
    assertTrue(tempDS.remove(dummy1));
    assertEquals(1, tempDS.size());
    assertEquals(dummy2, tempDS.get(1));
  }
Beispiel #3
0
  @Test
  public void checkGetNode() {
    assumeTrue(dataStructure instanceof INodeListDatastructureReadable);
    assumeTrue(Node.class.isAssignableFrom(this.elementClass));
    INodeListDatastructureReadable tempDS = (INodeListDatastructureReadable) dataStructure;

    Node dummy = (Node) mock(this.elementClass);
    when(dummy.getIndex()).thenReturn(42);
    assertTrue(tempDS.add(dummy));

    assertEquals(null, tempDS.get(43));
    assertEquals(42, dummy.getIndex());
    assertEquals(dummy, tempDS.get(42));
  }