Skip to content

Instantly share code, notes, and snippets.

@nimeacuerdo
Created March 13, 2019 18:14
Show Gist options
  • Save nimeacuerdo/c80a561e7a07aeb863ab3e3a5580a80e to your computer and use it in GitHub Desktop.
Save nimeacuerdo/c80a561e7a07aeb863ab3e3a5580a80e to your computer and use it in GitHub Desktop.
One liner test
TEST
public class DownloadStuffInteractorTest extends UnitTest {
private static final String ANY_URL = "http://www.wherever.com";
private static final String ANY_FILE_NAME = "file.pdf";
private static final EmailWithStuff EMAIL = new EmailWithStuff(ANY_URL, ANY_FILE_NAME);
@Mock
private StuffDownloader StuffDownloader;
private DownloadStuffInteractor DownloadStuffInteractor;
@Before
public void setup() {
DownloadStuffInteractor = new DownloadStuffInteractor(StuffDownloader);
}
@Test
public void shouldDownloadFileSilently() {
DownloadStuffInteractor.execute(EMAIL);
verify(StuffDownloader).silentlyDownloadFile(ANY_URL, ANY_FILE_NAME);
}
}
SUT
public DownloadInvoiceInteractor(InvoiceDownloader invoiceDownloader) {
this.invoiceDownloader = invoiceDownloader;
}
public void execute(EmailWithAttachment emailWithAttachment) {
invoiceDownloader.downloadFileSilently(emailWithAttachment.getUrl(), emailWithAttachment.getFileName());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment