I'm developing an Android app that performs several requests to a server using the AndroidAsynchronousHttpClient. One of these requests (as an example) is responsible to send the username and password. I created a class Sign
that has a static method (see below) to which I provide a callback to handle the server's response. Is this considered a bad practice?
I'm asking this because I'm having a hard time testing with Mockito.
public class Sign {
public static void signin(String username, String password,
final SigninResponseHandler responseHandler) {
RequestParams params = new RequestParams();
params.put("username", username);
params.put("password", password);
MyAPIClient.getInstance().post(path, params,
new JsonHttpResponseHandler()
{
@Override
public void onSuccess(JSONObject responseObject)
{
String responseAPIStatus = responseObject.getString("status");
if (status.isEquals("success")
{
responseHandler.callback(true, null);
}
}
@Override
public void onFailure(Throwable e, JSONObject errorResponse)
{
responseHandler.callback(false, new CustomError(e));
}
});
}