Search in sources :

Example 21 with ErrorOutPut

use of com.fanap.podchat.model.ErrorOutPut in project pod-chat-android-sdk by FanapSoft.

the class ChatTestSandbox method uploadProgressImage.

@Test
@MediumTest
public void uploadProgressImage() {
    sleep(3000);
    Uri uri = Uri.parse("content://media/external/images/media/781");
    presenter.uploadImageProgress(appContext, activity, uri, new ProgressHandler.onProgress() {

        @Override
        public void onProgressUpdate(int progress) {
            Mockito.anyInt();
        }

        @Override
        public void onFinish(String imageJson, ChatResponse<ResultImageFile> chatResponse) {
        }

        @Override
        public void onError(String jsonError, ErrorOutPut error) {
        }
    });
}
Also used : ResultImageFile(com.fanap.podchat.model.ResultImageFile) ProgressHandler(com.fanap.podchat.ProgressHandler) ErrorOutPut(com.fanap.podchat.model.ErrorOutPut) Uri(android.net.Uri) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest) MediumTest(android.support.test.filters.MediumTest)

Example 22 with ErrorOutPut

use of com.fanap.podchat.model.ErrorOutPut in project pod-chat-android-sdk by FanapSoft.

the class TextMessagesQueueTest method banUserScenario.

@Test
public void banUserScenario() {
    populateThreadsListFromServerOnly();
    assert threads.size() > 0;
    Thread thread = threads.get(0);
    final boolean[] isBanned = { false };
    ChatListener mTestListener = new ChatListener() {

        @Override
        public void onError(String content, ErrorOutPut error) {
            if (error.getErrorCode() == 208) {
                isBanned[0] = true;
            }
        }
    };
    chat.setListener(mTestListener);
    int counter = 0;
    while (!isBanned[0]) {
        counter++;
        RequestMessage request = new RequestMessage.Builder("Ban me i'm the " + counter + "th message", thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
        chat.sendTextMessage(request, null);
    }
    RequestMessage request = new RequestMessage.Builder("Ok! i'm ban now. but i'll be send after 60 000 milli second is passed", thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
    chat.sendTextMessage(request, null);
    Assert.assertTrue(chat.getWaitingQ().size() > 0);
}
Also used : RequestMessage(com.fanap.podchat.requestobject.RequestMessage) ChatListener(com.fanap.podchat.chat.ChatListener) ErrorOutPut(com.fanap.podchat.model.ErrorOutPut) Thread(com.fanap.podchat.mainmodel.Thread) RequestThread(com.fanap.podchat.requestobject.RequestThread) Test(org.junit.Test)

Example 23 with ErrorOutPut

use of com.fanap.podchat.model.ErrorOutPut in project pod-chat-android-sdk by FanapSoft.

the class ThreadCacheTest method sendMessageAndDelete.

public void sendMessageAndDelete() {
    populateThreadsFromServer();
    Collections.shuffle(threadsInServer);
    Thread thread = threadsInServer.get(0);
    Assert.assertNotNull(thread);
    ArrayList<Long> msgIds = new ArrayList<>();
    // send new message
    chatListeners = new ChatListener() {

        @Override
        public void onNewMessage(String content, ChatResponse<ResultNewMessage> response) {
            resumeProcess();
            msgIds.add(response.getResult().getMessageVO().getId());
            System.out.println("new message sent -> msg : " + content);
            chat.removeListener(chatListeners);
        }

        @Override
        public void onError(String content, ErrorOutPut error) {
            resumeProcess();
            System.out.println("Error: " + content);
            Assert.assertEquals(0, 1);
            chat.removeListener(chatListeners);
        }
    };
    chat.addListener(chatListeners);
    RequestMessage request = new RequestMessage.Builder("Message for test delete :" + thread.getId(), thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
    chat.sendTextMessage(request, null);
    pauseProcess();
    // delete last message
    chatListeners = new ChatListener() {

        @Override
        public void onDeleteMessage(String content, ChatResponse<ResultDeleteMessage> response) {
            resumeProcess();
            System.out.println("Deleted: " + content);
            chat.removeListener(chatListeners);
        }

        @Override
        public void onError(String content, ErrorOutPut error) {
            resumeProcess();
            System.out.println("Error: " + content);
            Assert.assertEquals(0, 1);
            chat.removeListener(chatListeners);
        }
    };
    chat.addListener(chatListeners);
    RequestDeleteMessage requestDeleteMessage = new RequestDeleteMessage.Builder().messageIds(msgIds).deleteForAll(true).build();
    presenter.deleteMessage(requestDeleteMessage, null);
    pauseProcess();
}
Also used : RequestDeleteMessage(com.fanap.podchat.requestobject.RequestDeleteMessage) ArrayList(java.util.ArrayList) Thread(com.fanap.podchat.mainmodel.Thread) RequestThread(com.fanap.podchat.requestobject.RequestThread) ResultThread(com.fanap.podchat.model.ResultThread) ResultNewMessage(com.fanap.podchat.model.ResultNewMessage) RequestMessage(com.fanap.podchat.requestobject.RequestMessage) ChatListener(com.fanap.podchat.chat.ChatListener) ErrorOutPut(com.fanap.podchat.model.ErrorOutPut) ResultDeleteMessage(com.fanap.podchat.mainmodel.ResultDeleteMessage)

Example 24 with ErrorOutPut

use of com.fanap.podchat.model.ErrorOutPut in project pod-chat-android-sdk by FanapSoft.

the class ThreadCacheTest method sendMessageAndEdit.

public void sendMessageAndEdit() {
    populateThreadsFromServer();
    Collections.shuffle(threadsInServer);
    Thread thread = threadsInServer.get(0);
    Assert.assertNotNull(thread);
    final long[] messageId = { 0 };
    // send new message
    chatListeners = new ChatListener() {

        @Override
        public void onNewMessage(String content, ChatResponse<ResultNewMessage> response) {
            messageId[0] = response.getResult().getMessageVO().getId();
            resumeProcess();
            System.out.println("new message sent -> msg : " + content);
            chat.removeListener(chatListeners);
        }

        @Override
        public void onError(String content, ErrorOutPut error) {
            resumeProcess();
            System.out.println("Error: " + content);
            Assert.assertEquals(0, 1);
            chat.removeListener(chatListeners);
        }
    };
    chat.addListener(chatListeners);
    RequestMessage request = new RequestMessage.Builder("Message for test edit :" + thread.getId(), thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
    chat.sendTextMessage(request, null);
    pauseProcess();
    // delete last message
    chatListeners = new ChatListener() {

        @Override
        public void onEditedMessage(String content, ChatResponse<ResultNewMessage> response) {
            resumeProcess();
            System.out.println("Edited: " + content);
            chat.removeListener(chatListeners);
        }

        @Override
        public void onError(String content, ErrorOutPut error) {
            resumeProcess();
            System.out.println("Error: " + content);
            Assert.assertEquals(0, 1);
            chat.removeListener(chatListeners);
        }
    };
    chat.addListener(chatListeners);
    RequestEditMessage requestEditMessage = new RequestEditMessage.Builder("last message edited " + messageId[0], messageId[0]).build();
    chat.editMessage(requestEditMessage, null);
    pauseProcess();
}
Also used : ResultNewMessage(com.fanap.podchat.model.ResultNewMessage) RequestMessage(com.fanap.podchat.requestobject.RequestMessage) ChatListener(com.fanap.podchat.chat.ChatListener) RequestEditMessage(com.fanap.podchat.requestobject.RequestEditMessage) ErrorOutPut(com.fanap.podchat.model.ErrorOutPut) Thread(com.fanap.podchat.mainmodel.Thread) RequestThread(com.fanap.podchat.requestobject.RequestThread) ResultThread(com.fanap.podchat.model.ResultThread)

Example 25 with ErrorOutPut

use of com.fanap.podchat.model.ErrorOutPut in project pod-chat-android-sdk by FanapSoft.

the class ChatActivity method sendLocationMsg.

private void sendLocationMsg() {
    String center = "35.7003510,51.3376472";
    String meta = getMetaData();
    RequestLocationMessage requestLocationMessage = new RequestLocationMessage.Builder().systemMetadata(meta).center(center).message("Im here now    :   ) ").setUserGroupHash(TEST_THREAD_HASH).activity(ChatActivity.this).threadId(TEST_THREAD_ID).build();
    // presenter.sendLocationMessage(requestLocationMessage);
    presenter.sendLocationMessage(requestLocationMessage, new ProgressHandler.sendFileMessage() {

        @Override
        public void onProgressUpdate(String uniqueId, int progress, int totalBytesSent, int totalBytesToSend) {
            Log.d("MTAG", "Update progress: " + "Total Bytes sent: " + totalBytesSent + " Total Bytes left " + totalBytesToSend);
        }

        @Override
        public void onFinishImage(String json, ChatResponse<ResultImageFile> chatResponse) {
            Log.d("MTAG", "Finish upload");
        }

        @Override
        public void onError(String jsonError, ErrorOutPut error) {
            Log.d("MTAG", "Error upload");
        }
    });
}
Also used : ResultImageFile(com.fanap.podchat.model.ResultImageFile) ProgressHandler(com.fanap.podchat.ProgressHandler) ErrorOutPut(com.fanap.podchat.model.ErrorOutPut) RequestLocationMessage(com.fanap.podchat.requestobject.RequestLocationMessage)

Aggregations

ErrorOutPut (com.fanap.podchat.model.ErrorOutPut)26 ResultImageFile (com.fanap.podchat.model.ResultImageFile)16 ChatResponse (com.fanap.podchat.model.ChatResponse)12 ResultFile (com.fanap.podchat.model.ResultFile)12 RequestCreateThreadWithFile (com.fanap.podchat.requestobject.RequestCreateThreadWithFile)12 RequestUploadFile (com.fanap.podchat.requestobject.RequestUploadFile)12 PodChatException (com.fanap.podchat.util.PodChatException)12 ResultDownloadFile (com.fanap.podchat.chat.file_manager.download_file.model.ResultDownloadFile)11 MetaDataFile (com.fanap.podchat.model.MetaDataFile)11 RequestGetFile (com.fanap.podchat.requestobject.RequestGetFile)11 RequestGetPodSpaceFile (com.fanap.podchat.requestobject.RequestGetPodSpaceFile)11 File (java.io.File)11 Subscription (rx.Subscription)11 RoomIntegrityException (com.fanap.podchat.persistance.RoomIntegrityException)10 JsonSyntaxException (com.google.gson.JsonSyntaxException)10 SentryException (io.sentry.core.protocol.SentryException)10 IOException (java.io.IOException)10 JSONException (org.json.JSONException)10 UploadToPodSpaceResult (com.fanap.podchat.chat.file_manager.upload_file.UploadToPodSpaceResult)9 ProgressHandler (com.fanap.podchat.ProgressHandler)7