@Test public void fromFileShouldReturnSource() throws IOException, URISyntaxException { Tinify.setKey("valid"); server.enqueue( new MockResponse() .setResponseCode(201) .addHeader("Location", "https://api.tinify.com/some/location") .addHeader("Compression-Count", 12)); String filePath = Paths.get(getClass().getResource("/dummy.png").toURI()).toAbsolutePath().toString(); assertThat(Tinify.fromFile(filePath), isA(Source.class)); }