Last active
April 5, 2016 01:32
-
-
Save patrykpoborca/d8bcd51a03f4556f49e770e3660b4f97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface DemoService { | |
@GET("/somesuffix") | |
void getData(Callback<List<Data>> callback); | |
} | |
public class MockDemoService implements DemoService { | |
public void getData(Callback<List<Data>> callback){ | |
//do your own implementation for mocking | |
throw new IllegalStateException("Stub"); | |
} | |
} | |
public class NetworkModule { | |
@Provides | |
@Singleton | |
DemoService providesDemoService(@Named("okclient") OkClient okClient) { | |
return new RestAdapter.Builder() | |
.setClient(okClient) | |
.setEndpoint("https://www.yourdomain.com") | |
.build() | |
.create(DemoService.class); | |
} | |
} | |
//Simply provide this module to your dagger builder instead of actual module | |
public class MockNetworkModule extends NetworkModule { | |
@Override | |
DemoService providesDemoService(@Named("okclient") OkClient okClient) { | |
return new MockDemoService(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment