/**
   * Tests the retriggered method of the class {@link BuildMemory}. With two started builds and the
   * one to be retriggered as completed already in memory.
   */
  @Test
  public void testRetriggeredExistingMemory() {
    PatchsetCreated event = Setup.createPatchsetCreated();
    BuildMemory instance = new BuildMemory();

    AbstractProject project = mock(AbstractProject.class);
    AbstractBuild build = mock(AbstractBuild.class);
    when(build.getProject()).thenReturn(project);
    AbstractProject project2 = mock(AbstractProject.class);
    AbstractBuild build2 = mock(AbstractBuild.class);
    when(build2.getProject()).thenReturn(project2);
    AbstractProject project3 = mock(AbstractProject.class);
    AbstractBuild build3 = mock(AbstractBuild.class);
    when(build3.getProject()).thenReturn(project3);

    instance.started(event, build);
    instance.completed(event, build2);
    instance.started(event, build3);

    instance.retriggered(event, project2, null);
    MemoryImprint memory = instance.getMemoryImprint(event);
    assertNotNull(memory);
    assertEquals(3, memory.getEntries().length);

    MemoryImprint.Entry entry = null;
    for (MemoryImprint.Entry e : memory.getEntries()) {
      if (e.getProject().equals(project2)) {
        entry = e;
        break;
      }
    }
    assertNotNull(entry);
    assertFalse(entry.isBuildCompleted());
  }
 /**
  * Tests the retriggered method of the class {@link BuildMemory}. With no previous memory and null
  * list of "others".
  */
 @Test
 public void testRetriggeredNoMemoryOneProjectNullOthers() {
   PatchsetCreated event = Setup.createPatchsetCreated();
   BuildMemory instance = new BuildMemory();
   AbstractProject project = mock(AbstractProject.class);
   instance.retriggered(event, project, null);
   MemoryImprint memory = instance.getMemoryImprint(event);
   assertNotNull(memory);
   assertEquals(1, memory.getEntries().length);
   assertEquals(project, memory.getEntries()[0].getProject());
   assertFalse(memory.getEntries()[0].isBuildCompleted());
 }