Examples of UtilResponse


Examples of com.github.jreddit.testsupport.UtilResponse

    /**
     * Succesfully get user information.
     */
    @Test
    public void getUserInformationSuccessfully() {
        response = new UtilResponse(null, createUserInfo(USERNAME), 200);
        when(restClient.get(ApiEndpointUtils.USER_INFO, COOKIE)).thenReturn(response);

        UserInfo info = subject.getUserInformation();
        assertNotNull(info);
    }
View Full Code Here

Examples of com.github.jreddit.testsupport.UtilResponse

    /**
     * Successfully get the information about a user.
     */
    @Test
    public void getAboutUserSuccessfully() {
        response = new UtilResponse(null, createUserAbout(USERNAME), 200);
        when(restClient.get(String.format(ApiEndpointUtils.USER_ABOUT, USERNAME), null)).thenReturn(response);

        UserInfo userInfo = subject.about(USERNAME);
        assertNotNull(userInfo);
        assertEquals(userInfo.getName(), USERNAME);
View Full Code Here

Examples of com.github.jreddit.testsupport.UtilResponse

    /**
     * Get the information about a user for a unknown user (should return null).
     */
    @Test
    public void getAboutUserForUnknownUser() {
        response = new UtilResponse(null, new JSONObject(singletonMap("error", 404)), 404);
        when(restClient.get(String.format(ApiEndpointUtils.USER_ABOUT, UNKNOWN_USERNAME), null)).thenReturn(response);

        UserInfo userInfo = subject.about(UNKNOWN_USERNAME);
        assertNull(userInfo);
    }
View Full Code Here

Examples of com.github.jreddit.testsupport.UtilResponse

     */
    @Test
    public void testConnect() throws Exception {
     
      // Stub response
      Response loginResponse = new UtilResponse(null, userLoginResponse(COOKIE, MOD_HASH), 200);
        when(restClient.post("api_type=json&user=" + USERNAME + "&passwd=" + PASSWORD, String.format(ApiEndpointUtils.USER_LOGIN, USERNAME), null)).thenReturn(loginResponse);
       
        // Connect user
        subject.connect();
       
View Full Code Here

Examples of com.github.jreddit.testsupport.UtilResponse

        restClient = mock(RestClient.class);
        subject = new MarkActions(restClient, user);

        Mockito.when(user.getCookie()).thenReturn(COOKIE);
        Mockito.when(user.getModhash()).thenReturn(MOD_HASH);
        normalResponse = new UtilResponse(null, new JSONObject(), 200);
       
    }
View Full Code Here

Examples of com.github.jreddit.testsupport.UtilResponse

        when(user.getModhash()).thenReturn(MOD_HASH);
    }

    @Test
    public void getUnreadMessages() {
        Response response = new UtilResponse("", someUnreadDirectMessage(), 200);

        when(restClient.get(String.format(MESSAGE_GET, UNREAD.getValue()), COOKIE)).thenReturn(response);

        List<Message> allUnread = underTest.getMessages(user, ALL_MESSAGES, UNREAD);
        assertNotNull(allUnread);
View Full Code Here

Examples of com.github.jreddit.testsupport.UtilResponse

        assertTrue(allUnread.size() == 2);
    }

    @Test
    public void getInboxMessages() {
        Response response = new UtilResponse("", allDirectMessage(), 200);

        when(restClient.get(String.format(MESSAGE_GET, SENT.getValue()), COOKIE)).thenReturn(response);

        List<Message> allUnread = underTest.getMessages(user, ALL_MESSAGES, SENT);
        assertNotNull(allUnread);
View Full Code Here

Examples of com.github.jreddit.testsupport.UtilResponse

        assertTrue(allUnread.size() == 3);
    }

    @Test
    public void getSentMessages() {
        Response response = new UtilResponse("", someSentMessages(), 200);

        when(restClient.get(String.format(MESSAGE_GET, INBOX.getValue()), COOKIE)).thenReturn(response);

        List<Message> allUnread = underTest.getMessages(user, ALL_MESSAGES, INBOX);
        assertNotNull(allUnread);
View Full Code Here

Examples of com.github.jreddit.testsupport.UtilResponse

        assertTrue(allUnread.size() == 2);
    }

    @Test
    public void successfullySendMessage() {
        Response response = new UtilResponse("", messageSendSuccessResponse(), 200);

        when(restClient.post("captcha=" + CAPTCHA_TEXT + "&iden=" + CAPTCHA_IDEN +
                        "&subject=" + TEST_SUBJECT + "&text=" + TEST_BODY + "&to=" + DESTINATION_USER +
                        "&uh=" + user.getModhash(),
                        ApiEndpointUtils.MESSAGE_COMPOSE, user.getCookie())
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.