use of com.microsoft.graph.concurrency.MockExecutors in project msgraph-sdk-java by microsoftgraph.
the class BaseRequestTests method setUp.
@Before
public void setUp() throws Exception {
mAuthenticationProvider = new MockAuthenticationProvider();
mBaseClient = new MockBaseClient();
final ITestConnectionData data = new ITestConnectionData() {
@Override
public int getRequestCode() {
return 200;
}
@Override
public String getJsonResponse() {
return "{ \"id\": \"zzz\" }";
}
@Override
public Map<String, String> getHeaders() {
final HashMap<String, String> map = new HashMap<>();
map.put("Content-Type", "application/json");
return map;
}
};
MockHttpProvider mProvider = new MockHttpProvider(new MockSerializer(null, ""), mAuthenticationProvider, new MockExecutors(), new MockLogger());
mProvider.setConnectionFactory(new MockConnectionFactory(new MockConnection(data)));
mBaseClient.setHttpProvider(mProvider);
request = new BaseRequest("https://a.b.c", mBaseClient, null, null) {
};
}
use of com.microsoft.graph.concurrency.MockExecutors in project msgraph-sdk-java by microsoftgraph.
the class BaseStreamRequestTests method testSendWithContent.
@Test
public void testSendWithContent() {
final ITestConnectionData data = new ITestConnectionData() {
@Override
public int getRequestCode() {
return 200;
}
@Override
public String getJsonResponse() {
return "{ \"id\": \"zzz\" }";
}
@Override
public Map<String, String> getHeaders() {
final HashMap<String, String> map = new HashMap<>();
map.put("Content-Type", "application/json");
return map;
}
};
DefaultHttpProvider mProvider = new DefaultHttpProvider(new MockSerializer(null, ""), mAuthenticationProvider, new MockExecutors(), new MockLogger());
mProvider.setConnectionFactory(new MockConnectionFactory(new MockConnection(data)));
mBaseClient.setHttpProvider(mProvider);
final BaseStreamRequest<InputStream> request = new BaseStreamRequest<InputStream>("https://a.b.c", mBaseClient, null, InputStream.class) {
};
request.send(new byte[] { 1, 2, 3, 4 });
assertEquals(1, mAuthenticationProvider.getInterceptionCount());
}
use of com.microsoft.graph.concurrency.MockExecutors in project msgraph-sdk-java by microsoftgraph.
the class BaseStreamRequestTests method testSendWithContentAndCallback.
@Test
public void testSendWithContentAndCallback() {
final ITestConnectionData data = new ITestConnectionData() {
@Override
public int getRequestCode() {
return 200;
}
@Override
public String getJsonResponse() {
return "{ \"id\": \"zzz\" }";
}
@Override
public Map<String, String> getHeaders() {
final HashMap<String, String> map = new HashMap<>();
map.put("Content-Type", "application/json");
return map;
}
};
DefaultHttpProvider mProvider = new DefaultHttpProvider(new MockSerializer(null, ""), mAuthenticationProvider, new MockExecutors(), new MockLogger());
mProvider.setConnectionFactory(new MockConnectionFactory(new MockConnection(data)));
mBaseClient.setHttpProvider(mProvider);
final AtomicBoolean success = new AtomicBoolean(false);
final AtomicBoolean failure = new AtomicBoolean(false);
final ICallback<InputStream> callback = new ICallback<InputStream>() {
@Override
public void success(InputStream inputStream) {
success.set(true);
}
@Override
public void failure(ClientException ex) {
failure.set(true);
}
};
final BaseStreamRequest<InputStream> request = new BaseStreamRequest<InputStream>("https://a.b.c", mBaseClient, null, InputStream.class) {
};
request.send(new byte[] { 1, 2, 3, 4 }, callback);
assertTrue(success.get());
assertFalse(failure.get());
assertEquals(1, mAuthenticationProvider.getInterceptionCount());
}
use of com.microsoft.graph.concurrency.MockExecutors in project msgraph-sdk-java by microsoftgraph.
the class BaseStreamRequestTests method testSendWithCallback.
@Test
public void testSendWithCallback() {
final ITestConnectionData data = new ITestConnectionData() {
@Override
public int getRequestCode() {
return 200;
}
@Override
public String getJsonResponse() {
return "{ \"id\": \"zzz\" }";
}
@Override
public Map<String, String> getHeaders() {
final HashMap<String, String> map = new HashMap<>();
map.put("Content-Type", "application/json");
return map;
}
};
DefaultHttpProvider mProvider = new DefaultHttpProvider(new MockSerializer(null, ""), mAuthenticationProvider, new MockExecutors(), new MockLogger());
mProvider.setConnectionFactory(new MockConnectionFactory(new MockConnection(data)));
mBaseClient.setHttpProvider(mProvider);
final AtomicBoolean success = new AtomicBoolean(false);
final AtomicBoolean failure = new AtomicBoolean(false);
final ICallback<InputStream> callback = new ICallback<InputStream>() {
@Override
public void success(InputStream inputStream) {
success.set(true);
}
@Override
public void failure(ClientException ex) {
failure.set(true);
}
};
final BaseStreamRequest<InputStream> request = new BaseStreamRequest<InputStream>("https://a.b.c", mBaseClient, null, InputStream.class) {
};
request.send(callback);
assertTrue(success.get());
assertFalse(failure.get());
assertEquals(1, mAuthenticationProvider.getInterceptionCount());
}
use of com.microsoft.graph.concurrency.MockExecutors in project msgraph-sdk-java by microsoftgraph.
the class BaseCollectionRequestTests method setUp.
@Before
public void setUp() throws Exception {
mAuthenticationProvider = new MockAuthenticationProvider();
mBaseClient = new MockBaseClient();
final ITestConnectionData data = new ITestConnectionData() {
@Override
public int getRequestCode() {
return 200;
}
@Override
public String getJsonResponse() {
return "{ \"id\": \"zzz\" }";
}
@Override
public Map<String, String> getHeaders() {
final HashMap<String, String> map = new HashMap<>();
map.put("Content-Type", "application/json");
return map;
}
};
MockHttpProvider mProvider = new MockHttpProvider(new MockSerializer(null, ""), mAuthenticationProvider, new MockExecutors(), new MockLogger());
mProvider.setConnectionFactory(new MockConnectionFactory(new MockConnection(data)));
mBaseClient.setHttpProvider(mProvider);
request = new BaseCollectionRequest<JsonObject, String>("https://a.b.c", mBaseClient, null, JsonObject.class, null) {
};
}
Aggregations