Skip to content

Instantly share code, notes, and snippets.

@desireesantos
Created August 11, 2013 13:04
Show Gist options
  • Save desireesantos/6204801 to your computer and use it in GitHub Desktop.
Save desireesantos/6204801 to your computer and use it in GitHub Desktop.
PdfFactoryTest
package com.trailblazers.freewheelers.model;
import com.itextpdf.text.Document;
import static org.mockito.Mockito.verify;
import com.itextpdf.text.pdf.PdfWriter;
import org.junit.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class PdfFactoryTest {
@Test
public void shouldGetPdfInstance() throws Exception {
//Given
PdfFactory pdfFactory = mock(PdfFactory.class);
Document mockPdf = mock(Document.class);
ReserveOrder mockReserveOrder = mock(ReserveOrder.class);
PdfWriter mockPdfWriter = mock(PdfWriter.class);
when(pdfFactory.getPdfWriter()).thenReturn(mockPdfWriter);
//When
pdfFactory.create(mockPdf, mockReserveOrder);
//Then
verify(pdfFactory.getPdfWriter());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment