package nl.tudelft.pl2016gr2.model;

import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Iterator;


public class NodeTest {
  
  private Node node;
  private String bases = "actcaggcagatcattcgctagacat";
  
  /**
   * Creates a new clean node before every test.
   */
  @Before
  public void setup() {
    String str1 = "ref1.fasta";
    String str2 = "ref2.fasta";
    ArrayList<String> ar = new ArrayList<>();
    ar.add(str1);
    ar.add(str2);
    node = new Node(3, 6, new ArrayList<>(), 5);
    node.setGenomes(ar);
  }

  @Test
  public void alignmentTest() {
    node.setAlignment(9);
    assertEquals(9, node.getAlignment());
  }
  
  @Test
  public void flowTest() {
    node.setFlow(5.0);
    node.addFlow(6.0);
    node.addFlow(-4.0);
    assertEquals(7.0, node.getFlow(), 0.001);
  }
  
  @Test
  public void toStringTest() {
    assertEquals(node.toString(), 
        "id: 3 sequencelength: 6 inlinks: [] outlinks: [] snips: 5, id: 3, flow: 0.0");
  }
  
  @Test
  public void getSnipsTest() {
    assertEquals(5, node.getSnips());
  }
  
  @Test
  public void basesTest() {
    node.setBases(bases);
    assertEquals(bases, node.getBases());
  }
  
  @Test
  public void genomeTest() {
    Iterator<String> it = node.getGenomes().iterator();
    it.next();
    assertEquals("ref2.fasta", it.next());
  }

}

@@ -74,16 +74,103 @@
 tEquals;
+%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertTrue;
 %0A%0Aimport
@@ -1040,17 +1040,16 @@
 tring(),
- 
 %0A       
@@ -1129,26 +1129,1252 @@
  0.0%22);%0A  %7D%0A
+%0A
   
+@Test%0A  public void testEquals1() %7B%0A    assertTrue(node.equals(new Node(3, 6, new ArrayList%3C%3E(), 5)));%0A  %7D%0A%0A  @Test%0A  public void testEquals2() %7B%0A    assertFalse(node.equals(new Node(2, 7, new ArrayList%3C%3E(), 5)));%0A  %7D%0A%0A  @Test%0A  public void testEquals3() %7B%0A    assertFalse(node.equals(new Object()));%0A  %7D%0A%0A  @Test%0A  public void testHashCode1() %7B%0A    assertEquals(node.hashCode(), new Node(3, 6, new ArrayList%3C%3E(), 5).hashCode());%0A  %7D%0A%0A  @Test%0A  public void testGetGenomesOverEdge1() %7B%0A%0A    node.addOutlink(2);%0A%0A    assertEquals(0, node.getGenomesOverEdge(new Node(2, 0, new ArrayList%3C%3E(), 0)));%0A  %7D%0A%0A  @Test%0A  public void testGetGenomesOverEdge2() %7B%0A    ArrayList%3CString%3E ar = new ArrayList%3C%3E();%0A    ar.add(%22ref1.fasta%22);%0A%0A    Node otherNode = new Node(2, 0, new ArrayList%3C%3E(), 0);%0A    otherNode.setGenomes(ar);%0A%0A    node.addOutlink(2);%0A%0A    assertEquals(1, node.getGenomesOverEdge(otherNode));%0A  %7D%0A%0A  @Test%0A  public void testGetGenomesOverEdge3() %7B%0A    ArrayList%3CString%3E ar = new ArrayList%3C%3E();%0A    ar.add(%22ref1.fasta%22);%0A    ar.add(%22ref2.fasta%22);%0A%0A    Node otherNode = new Node(2, 0, new ArrayList%3C%3E(), 0);%0A    otherNode.setGenomes(ar);%0A%0A    node.addOutlink(2);%0A%0A    assertEquals(2, node.getGenomesOverEdge(otherNode));%0A  %7D%0A
 %0A  @Test%0A  p

Test more lines in Node class