use of com.jakdor.labday.common.network.RetrofitBuilder in project LabDayApp by jakdor.
the class ProjectRepositoryIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
targetContext = ApplicationProvider.getApplicationContext();
testContext = InstrumentationRegistry.getInstrumentation().getContext();
SoLoader.init(targetContext, false);
localDbHandler = new LocalDbHandler(Instrumentation.newApplication(TestApp.class, targetContext));
projectRepository = new ProjectRepository(new NetworkManager(new RetrofitBuilder()), localDbHandler, new RxSchedulersFacade());
}
use of com.jakdor.labday.common.network.RetrofitBuilder in project LabDayApp by jakdor.
the class RetrofitBuilderTest method createServiceWithInterceptor.
/**
* test RetrofitBuilder in isolation from AuthenticationInterceptor
*/
@Test
public void createServiceWithInterceptor() throws Exception {
Request request = new Request.Builder().header("Authorization", dummyToken).get().url(dummyApiUrl).build();
ResponseBody dummyResponse = new ResponseBody() {
@Override
public MediaType contentType() {
return null;
}
@Override
public long contentLength() {
return 0;
}
@Override
public BufferedSource source() {
return null;
}
};
when(authenticationInterceptor.intercept(any())).thenReturn(new Response.Builder().request(request).protocol(Protocol.HTTP_2).code(200).body(dummyResponse).message(message).build());
LabService labService = retrofitBuilder.createService(dummyApiUrl, LabService.class, dummyToken);
TestObserver<AppData> testObserver = labService.getAppData().test();
testObserver.assertSubscribed();
testObserver.onComplete();
InOrder order = inOrder(authenticationInterceptor);
order.verify(authenticationInterceptor, calls(1)).setAuthToken(dummyToken);
order.verify(authenticationInterceptor, calls(1)).intercept(any());
}
use of com.jakdor.labday.common.network.RetrofitBuilder in project LabDayApp by jakdor.
the class NetworkManagerIntegrationTest method setUp.
/**
* Setup local Mock REST API server for instrumentation tests
*/
@Before
public void setUp() throws Exception {
testContext = InstrumentationRegistry.getInstrumentation().getContext();
networkManager = new NetworkManager(new RetrofitBuilder());
}
Aggregations