package br.edu.ufcg.ccc.projeto2.warofkingdomstest; public class TestJsonParser { // private String LOG_TAG = "TestJsonParser"; public void testJsonParser() { // Move o = new Move(Action.ATTACK, new Territory("A", 0, 0)); // Move b = new Move(Action.ATTACK, new Territory("B", 0, 0)); // Move d = new Move(Action.ATTACK, new Territory("C", 0, 0)); // Move c = new Move(Action.ATTACK, new Territory("D", 0, 0)); // // Log.v(LOG_TAG, // JSONParser.parseMovesToJson(new Move[] { o, b, d, c }) // .toString()); // // JSONObject jsonPlayer = null; // try { // jsonPlayer = new JSONObject("{\"id\":\"64\"}"); // } catch (JSONException e) { // Log.e(LOG_TAG, e.toString()); // } // Player player = JSONParser.parseJsonToPlayer(jsonPlayer); // Log.v(LOG_TAG, player.getId()); // // JSONArray jsonPlayerArray = null; // try { // jsonPlayerArray = new JSONArray( // "[{\"id\":\"64\"},{\"id\":\"32\"},{\"id\":\"16\"},{\"id\":\"8\"}]"); // } catch (JSONException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // Player[] players = JSONParser.parseJsonToPlayers(jsonPlayerArray); // Log.v(LOG_TAG, players[0].getId()); // Log.v(LOG_TAG, players[1].getId()); // Log.v(LOG_TAG, players[2].getId()); // Log.v(LOG_TAG, players[3].getId()); // // JSONObject jsonConflict = null; // try { // jsonConflict = new JSONObject( // "{\"territory\":{\"name\":\"wintefell\"},\"players\":[{\"id\":\"64\"},{\"id\":\"32\"},{\"id\":\"16\"},{\"id\":\"8\"}]}"); // } catch (JSONException e) { // // } // Conflict conflict = JSONParser.parseJsonToConflict(jsonConflict); // Log.v(LOG_TAG, conflict.getTerritory().getName()); // Log.v(LOG_TAG, conflict.getPlayers()[0].getId()); // Log.v(LOG_TAG, conflict.getPlayers()[1].getId()); // Log.v(LOG_TAG, conflict.getPlayers()[2].getId()); // Log.v(LOG_TAG, conflict.getPlayers()[3].getId()); // // JSONArray jsonConflicts = null; // JSONObject jsonConflict0 = null; // JSONObject jsonConflict1 = null; // JSONObject jsonConflict2 = null; // JSONObject jsonConflict3 = null; // try { // jsonConflicts = new JSONArray( // "[{\"territory\":{\"name\":\"wintefell\"},\"players\":[{\"id\":\"64\"},{\"id\":\"32\"},{\"id\":\"16\"},{\"id\":\"8\"}]},{\"territory\":{\"name\":\"riverun\"},\"players\":[{\"id\":\"64\"},{\"id\":\"32\"},{\"id\":\"16\"},{\"id\":\"8\"}]},{\"territory\":{\"name\":\"whatever\"},\"players\":[{\"id\":\"64\"},{\"id\":\"32\"},{\"id\":\"16\"},{\"id\":\"8\"}]},{\"territory\":{\"name\":\"tsst\"},\"players\":[{\"id\":\"64\"},{\"id\":\"32\"},{\"id\":\"16\"},{\"id\":\"8\"}]}]"); // // jsonConflict0 = jsonConflicts.getJSONObject(0); // jsonConflict1 = jsonConflicts.getJSONObject(1); // jsonConflict2 = jsonConflicts.getJSONObject(2); // jsonConflict3 = jsonConflicts.getJSONObject(3); // // } catch (JSONException e) { // // } // // Conflict conflict0 = JSONParser.parseJsonToConflict(jsonConflict0); // Conflict conflict1 = JSONParser.parseJsonToConflict(jsonConflict1); // Conflict conflict2 = JSONParser.parseJsonToConflict(jsonConflict2); // Conflict conflict3 = JSONParser.parseJsonToConflict(jsonConflict3); // // Log.v(LOG_TAG, conflict0.getTerritory().getName()); // Log.v(LOG_TAG, conflict0.getPlayers()[0].getId()); // Log.v(LOG_TAG, conflict0.getPlayers()[1].getId()); // Log.v(LOG_TAG, conflict0.getPlayers()[2].getId()); // Log.v(LOG_TAG, conflict0.getPlayers()[3].getId()); // // Log.v(LOG_TAG, conflict1.getTerritory().getName()); // Log.v(LOG_TAG, conflict1.getPlayers()[0].getId()); // Log.v(LOG_TAG, conflict1.getPlayers()[1].getId()); // Log.v(LOG_TAG, conflict1.getPlayers()[2].getId()); // Log.v(LOG_TAG, conflict1.getPlayers()[3].getId()); // // Log.v(LOG_TAG, conflict2.getTerritory().getName()); // Log.v(LOG_TAG, conflict2.getPlayers()[0].getId()); // Log.v(LOG_TAG, conflict2.getPlayers()[1].getId()); // Log.v(LOG_TAG, conflict2.getPlayers()[2].getId()); // Log.v(LOG_TAG, conflict2.getPlayers()[3].getId()); // // Log.v(LOG_TAG, conflict3.getTerritory().getName()); // Log.v(LOG_TAG, conflict3.getPlayers()[0].getId()); // Log.v(LOG_TAG, conflict3.getPlayers()[1].getId()); // Log.v(LOG_TAG, conflict3.getPlayers()[2].getId()); // Log.v(LOG_TAG, conflict3.getPlayers()[3].getId()); } }