@Test
public void preUpdateWithUpdatedFileAndFileType() throws Exception {

    this.file1 = new File("1_name.jpg");
    this.file2 = new File("12345.pdf");
    assertTrue(this.file1.createNewFile());
    assertTrue(this.file2.createNewFile());
    final String name = "name";
    final List<Receipt> receiptsInTrip = Arrays.asList(mock(Receipt.class), mock(Receipt.class), mock(Receipt.class));
    when(receiptsTable.get(trip)).thenReturn(Single.just(receiptsInTrip));
    final Receipt oldReceipt = mock(Receipt.class);
    when(oldReceipt.getIndex()).thenReturn(1);
    when(oldReceipt.getName()).thenReturn(name);
    when(oldReceipt.getFile()).thenReturn(file1);
    when(oldReceipt.getDate()).thenReturn(DATE);
    when(oldReceipt.getTimeZone()).thenReturn(TIMEZONE);
    when(receipt.getIndex()).thenReturn(1);
    when(receipt.getName()).thenReturn(name);
    when(receipt.getFile()).thenReturn(file2);
    final List<Receipt> onNextResults =
            receiptTableActionAlterations.preUpdate(oldReceipt, receipt)
                    .test()
                    .assertComplete()
                    .assertNoErrors()
                    .values();
    assertNotNull(onNextResults);
    assertTrue(onNextResults.size() == 1);
    final Receipt result = onNextResults.get(0);
    assertNotNull(result.getFile());
    assertEquals("1_name.pdf", result.getFile().getName());
    assertTrue(result.getFile().delete());
}