Example #1
0
 @Test(expected = EmptySession.class)
 public void listAllThrowsEmpySession()
     throws EmptySession, EmptyUsername, EmptyResponse, InvalidFormat, InvalidResponse, APIError,
         RequestFailed, InvalidUsername {
   Task task = setUp();
   task.storage.purgeSession();
   replay(task);
   task.listAll();
 }
Example #2
0
 @Test(expected = EmptyUsername.class)
 public void detailsThrowsEmptyUsername()
     throws EmptySession, EmptyUsername, EmptyResponse, InvalidFormat, InvalidResponse, APIError,
         RequestFailed, InvalidUsername {
   Task task = setUp();
   task.storage.setUsername("");
   replay(task);
   task.details(123);
 }
Example #3
0
 public Task setUp() {
   Task task =
       EasyMock.createMockBuilder(Task.class)
           .addMockedMethod("fetch", String.class, String.class)
           .createMock();
   task.storage = new Storage();
   task.storage.purgeSession();
   task.storage.setSessionToken("token");
   task.storage.setUsername("username");
   return task;
 }
Example #4
0
 @Test
 public void detailsReturnsJson()
     throws ParseException, EmptyResponse, InvalidFormat, InvalidResponse, APIError, RequestFailed,
         EmptySession, EmptyUsername, InvalidUsername {
   Task task = setUp();
   JSONParser parser = new JSONParser();
   JSONObject json = (JSONObject) parser.parse("{\"info\":{\"info\":\"info\"}}");
   expect(task.fetch(isA(String.class), isA(String.class))).andReturn(json);
   replay(task);
   JSONObject obj = (JSONObject) parser.parse("{\"info\":\"info\"}");
   assertEquals(obj, task.details(123));
 }
Example #5
0
 @Test
 public void listAllReturnsArray()
     throws ParseException, EmptyResponse, InvalidFormat, InvalidResponse, APIError, RequestFailed,
         EmptySession, EmptyUsername, InvalidUsername {
   Task task = setUp();
   JSONParser parser = new JSONParser();
   JSONObject json = (JSONObject) parser.parse("{\"list\":[\"response\"]}");
   expect(task.fetch(isA(String.class), isA(String.class))).andReturn(json);
   replay(task);
   JSONArray array = new JSONArray();
   array.add("response");
   assertEquals(array, task.listAll());
 }