use of it.angelic.mpw.model.jsonpojos.miners.MinerRoot in project MPW by shineangelic.
the class MasterInstrumentedTest method TestJsonWalletSyncReq.
@Test
public void TestJsonWalletSyncReq() {
RequestFuture<JSONObject> future = RequestFuture.newFuture();
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, Utils.getMinersStatsUrl(sharedPreferences), new JSONObject(), future, future);
JSONClientSingleton.getInstance(appContext).addToRequestQueue(request);
Gson gson = TestUtils.getGsonFromBuilder();
String addr = null;
try {
// this will block
JSONObject response = future.get();
MinerRoot retrieved = gson.fromJson(response.toString(), MinerRoot.class);
HashMap<String, Miner> map = retrieved.getMiners();
String[] minerArr = new String[map.size()];
minerArr = map.keySet().toArray(minerArr);
Assume.assumeTrue(minerArr.length > 0);
addr = minerArr[0];
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getMessage());
}
RequestFuture<JSONObject> futuress = RequestFuture.newFuture();
try {
JsonObjectRequest requesst = new JsonObjectRequest(Request.Method.GET, Utils.getWalletStatsUrl(sharedPreferences) + addr, new JSONObject(), futuress, futuress);
JSONClientSingleton.getInstance(appContext).addToRequestQueue(requesst);
// this will block
JSONObject response = futuress.get();
Wallet retrieved = gson.fromJson(response.toString(), Wallet.class);
assertNotNull(retrieved);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getMessage());
}
}
use of it.angelic.mpw.model.jsonpojos.miners.MinerRoot in project MPW by shineangelic.
the class MasterInstrumentedTest method getFirstMinerAddress.
private String getFirstMinerAddress(RequestFuture<JSONObject> future, Gson gson) throws ExecutionException, InterruptedException {
// this will block
JSONObject response = future.get();
MinerRoot retrieved = gson.fromJson(response.toString(), MinerRoot.class);
assertNotNull(retrieved);
HashMap<String, Miner> map = retrieved.getMiners();
String[] minerArr = new String[map.size()];
minerArr = map.keySet().toArray(minerArr);
assertNotNull(minerArr);
return minerArr[0];
// assertNotNull(minerAddr);
}
use of it.angelic.mpw.model.jsonpojos.miners.MinerRoot in project MPW by shineangelic.
the class NoobPoolInstrumentedTest method testJsonMinerRequest.
@Test
public void testJsonMinerRequest() throws Exception {
final GsonBuilder builder = new GsonBuilder();
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, Utils.getMinersStatsUrl(sharedPreferences), null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(final JSONObject response) {
Log.i(Constants.TAG, response.toString());
Gson gson = builder.create();
// Register an adapter to manage the date types as long values
MinerRoot retrieved = gson.fromJson(response.toString(), MinerRoot.class);
minerAddr = retrieved.getMiners().values().iterator().next().getAddress();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(Constants.TAG, "Error: " + error.getMessage());
}
});
// Adding request to request queue
JSONClientSingleton.getInstance(appContext).addToRequestQueue(jsonObjReq);
}
use of it.angelic.mpw.model.jsonpojos.miners.MinerRoot in project MPW by shineangelic.
the class MaxHashInstrumentedTest method testJsonMinerRequest.
@Test
public void testJsonMinerRequest() throws Exception {
final GsonBuilder builder = new GsonBuilder();
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, Utils.getMinersStatsUrl(sharedPreferences), null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(final JSONObject response) {
Log.i(Constants.TAG, response.toString());
Gson gson = builder.create();
// Register an adapter to manage the date types as long values
MinerRoot retrieved = gson.fromJson(response.toString(), MinerRoot.class);
minerAddr = retrieved.getMiners().values().iterator().next().getAddress();
assertNotNull(retrieved);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(Constants.TAG, "Error: " + error.getMessage());
fail();
}
});
// Adding request to request queue
JSONClientSingleton.getInstance(appContext).addToRequestQueue(jsonObjReq);
}
use of it.angelic.mpw.model.jsonpojos.miners.MinerRoot in project MPW by shineangelic.
the class KratosInstrumentedTest method testJsonMinerRequest.
@Test
public void testJsonMinerRequest() throws Exception {
final GsonBuilder builder = new GsonBuilder();
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, Utils.getMinersStatsUrl(sharedPreferences), null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(final JSONObject response) {
Log.i(Constants.TAG, response.toString());
Gson gson = builder.create();
// Register an adapter to manage the date types as long values
MinerRoot retrieved = gson.fromJson(response.toString(), MinerRoot.class);
minerAddr = retrieved.getMiners().values().iterator().next().getAddress();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(Constants.TAG, "Error: " + error.getMessage());
fail(error.getMessage());
}
});
// Adding request to request queue
JSONClientSingleton.getInstance(appContext).addToRequestQueue(jsonObjReq);
}
Aggregations