Skip to content

Commit

Permalink
add SearchSystemMetadataRequest
Browse files Browse the repository at this point in the history
deprecate NosqlListMessageCriteriaVO
add SearchMetadataTest
improve ChatTest
  • Loading branch information
Farhad7d7 committed Dec 26, 2021
1 parent df5ebb5 commit 704afd7
Show file tree
Hide file tree
Showing 20 changed files with 1,275 additions and 198 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
All notable changes to this project will be documented here.


## [0.9.14.0] -2021-11-15
## [0.9.14.0] -2021-12-26

### Added

```SearchSystemMetadataRequest```

```startShareScreen``` callback

```onShareScreenStarted``` method
Expand All @@ -35,6 +37,8 @@ All notable changes to this project will be documented here.

Update podcall to 3.5.2

Deprecated NosqlListMessageCriteriaVO



## [0.9.13.0] -2021-10-18
Expand Down
35 changes: 14 additions & 21 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ android {
}
flavorDimensions "default"

productFlavors{
productFlavors {

withCall{
withCall {
versionName "1.3.0"
versionCode 1
matchingFallbacks = ["withCall","withoutCall"]
matchingFallbacks = ["withCall", "withoutCall"]
}
withoutCall{
withoutCall {
versionName "0.0.1"
versionCode 1
matchingFallbacks = ["withoutCall","withCall"]
matchingFallbacks = ["withoutCall", "withCall"]
}

}
Expand All @@ -53,17 +53,16 @@ android {
def buildType = variant.buildType.name // e. g. debug
def variantName = variant.name // e. g. withCallDebug

if(flavorName == "withCall"){
if (flavorName == "withCall") {
outputFileName = "PodCall-v${versionName}.apk"
}else if(flavorName=="withoutCall"){
} else if (flavorName == "withoutCall") {
outputFileName = "PodChat-v${versionName}.apk"
}

}
}



compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand All @@ -90,18 +89,12 @@ dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.3'


//Test
// androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

// androidTestImplementation 'org.mockito:mockito-core:3.1.0'
// required if you want to use Mockito for Android tests
// androidTestImplementation 'org.mockito:mockito-android:3.1.0'

testImplementation 'junit:junit:4.12'
// androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'

// androidTestImplementation 'com.android.support.test:rules:1.0.2'
// androidTestImplementation 'com.android.support.test:runner:1.0.2'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:4.1.0'
androidTestImplementation 'org.mockito:mockito-android:4.1.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

// implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.orhanobut:logger:2.2.0'
Expand All @@ -124,7 +117,7 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.8.0'
//placeholderview
// implementation 'com.mindorks:placeholderview:0.7.1'
implementation ('com.mindorks:placeholderview:0.7.1') {
implementation('com.mindorks:placeholderview:0.7.1') {
exclude group: 'com.android.support', module: 'recyclerview-v7'
}

Expand Down
164 changes: 41 additions & 123 deletions app/src/androidTest/java/com/example/podchat/ChatTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.example.chat.application.chatexample.ChatPresenter;
import com.fanap.podchat.ProgressHandler;
import com.fanap.podchat.chat.Chat;
import com.fanap.podchat.chat.ChatAdapter;
import com.fanap.podchat.chat.ChatListener;
import com.fanap.podchat.chat.pin.pin_message.model.RequestPinMessage;
import com.fanap.podchat.chat.user.profile.RequestUpdateProfile;
Expand Down Expand Up @@ -52,7 +51,6 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

import java.util.ArrayList;
import java.util.Date;
Expand All @@ -66,8 +64,9 @@


@RunWith(AndroidJUnit4.class)
public class ChatTest extends ChatAdapter {
public class ChatTest {

public static final boolean CACHE = false;
private static ChatContract.presenter presenter;
@Mock
private static ChatContract.view view;
Expand Down Expand Up @@ -109,63 +108,16 @@ public static void initial() {

chat = Chat.init(appContext);

// chat.isCacheables(true);
//
// chat.isLoggable(true);
// chat.rawLog(true);
// chat.isSentryLogActive(true);
// chat.isSentryResponseLogActive(true);
//
// chat.setDownloadDirectory(appContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS));
//
// TimeoutConfig timeout = new TimeoutConfig()
// .newConfigBuilder()
// .withConnectTimeout(30, TimeUnit.SECONDS)
// .withWriteTimeout(30, TimeUnit.MINUTES)
// .withReadTimeout(30, TimeUnit.MINUTES)
// .build();
//
//
// chat.setUploadTimeoutConfig(timeout);
//
// chat.setDownloadTimeoutConfig(timeout);
//
// NetworkPingSender.NetworkStateConfig build = new NetworkPingSender.NetworkStateConfig()
// .setHostName("msg.pod.ir")
// .setPort(443)
// .setDisConnectionThreshold(2)
// .setInterval(7000)
// .setConnectTimeout(10000)
// .build();


// TimeoutConfig uploadConfig = new TimeoutConfig()
// .newConfigBuilder()
// .withConnectTimeout(120, TimeUnit.MINUTES)
// .withWriteTimeout(120, TimeUnit.MINUTES)
// .withReadTimeout(120, TimeUnit.MINUTES)
// .build();
//
// TimeoutConfig downloadConfig = new TimeoutConfig()
// .newConfigBuilder()
// .withConnectTimeout(20, TimeUnit.SECONDS)
// .withWriteTimeout(0, TimeUnit.SECONDS)
// .withReadTimeout(5, TimeUnit.MINUTES)
// .build();

// chat.setNetworkStateConfig(build);
//
// chat.setUploadConfig(uploadConfig);
//
// chat.setDownloadConfig(downloadConfig);


}

@Before
public void createChat() {
Looper.prepare();
MockitoAnnotations.initMocks(this);

view = Mockito.mock(ChatContract.view.class);

chatActivity = chatActivityRule.getActivity();
presenter = new ChatPresenter(appContext, view, chatActivity);

RequestConnect rc = new RequestConnect.Builder(
socketAddress,
Expand All @@ -192,37 +144,16 @@ public void onChatState(String state) {

chat.connect(rc);

chat.isCacheables(CACHE);

pauseProcess();


}

@Before
public void setUp() {
// Looper.prepare();
// appContext = InstrumentationRegistry.getTargetContext();
// MockitoAnnotations.initMocks(this);
chatActivity = chatActivityRule.getActivity();
presenter = new ChatPresenter(appContext, view, chatActivity);

// RequestConnect rc = new RequestConnect.Builder(
// socketAddress,
// APP_ID,
// serverName,
// "f29512343de1472fa15d1e497e264c54",
// ssoHost,
// platformHost,
// fileServer,
// "podSpaceServer")
// .build();

// presenter.connect(rc);

}

final ArrayList<Thread> threads = new ArrayList<>();


//requests for list of threads
@Test
public void populateThreadsListFromServerOrCache() {
Expand All @@ -234,7 +165,6 @@ public void onGetThread(String content, ChatResponse<ResultThreads> thread) {

System.out.println("Received List: " + content);
threads.addAll(thread.getResult().getThreads());
resumeProcess();
}
};

Expand All @@ -247,8 +177,10 @@ public void onGetThread(String content, ChatResponse<ResultThreads> thread) {

presenter.getThreads(requestThread, null);

pauseProcess();
System.out.println("Received List: " + threads.size());
long t1 = System.currentTimeMillis();
Mockito.verify(view, Mockito.after(10000).atLeastOnce()).onGetThreadList(Mockito.any(), Mockito.any());
long t2 = System.currentTimeMillis();
System.out.println("Received List: " + threads.size() + " after: " + (t2 - t1) + " ms");

}

Expand All @@ -261,7 +193,7 @@ public void populateThreadsListFromServerOnly() {
@Override
public void onGetThread(String content, ChatResponse<ResultThreads> thread) {

if(!thread.isCache()){
if (!thread.isCache()) {
System.out.println("Received List: " + content);
threads.addAll(thread.getResult().getThreads());
resumeProcess();
Expand All @@ -270,11 +202,12 @@ public void onGetThread(String content, ChatResponse<ResultThreads> thread) {
}
};

chat.addListener(chatListeners);
chat.setListener(chatListeners);

RequestThread requestThread =
new RequestThread.Builder()
.count(25)
.withNoCache()
.build();

presenter.getThreads(requestThread, null);
Expand All @@ -293,7 +226,7 @@ public void populateThreadsListFromCacheOnly() {
@Override
public void onGetThread(String content, ChatResponse<ResultThreads> thread) {

if(thread.isCache()){
if (thread.isCache()) {
System.out.println("Received List: " + content);
threads.addAll(thread.getResult().getThreads());
resumeProcess();
Expand All @@ -316,32 +249,6 @@ public void onGetThread(String content, ChatResponse<ResultThreads> thread) {

}

private void resumeProcess() {
synchronized (sync) {
sync.notify();
}
}

private void pauseProcess() {
synchronized (sync) {
try {
sync.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}

// @After
// public void closeChat() {
// if (chat != null) {
// chat.closeChat();
// } else if (presenter != null) {
// presenter.closeChat();
// }
// }


@Test
public void chatListeners() {

Expand Down Expand Up @@ -529,7 +436,7 @@ public void sendALotOfMessageToThread() {
long threadID = threads.get(0).getId();
for (Thread thread : new ArrayList<>(threads)) {
if (!thread.isClosed() &&
thread.getParticipantCount() > 1) {
thread.getParticipantCount() > 1) {
threadID = thread.getId();
}
}
Expand Down Expand Up @@ -867,20 +774,8 @@ public void unpinMessage() {

}

private void sleep(int i) {
try {
java.lang.Thread.sleep(i);
} catch (InterruptedException e) {
e.printStackTrace();
}
}


@Override
public void onGetThread(String content, ChatResponse<ResultThreads> thread) {
super.onGetThread(content, thread);

}

@Test
@MediumTest
Expand Down Expand Up @@ -1325,4 +1220,27 @@ public void searchMap() {
sleep(3000);
Mockito.verify(view, Mockito.times(1)).onMapSearch();
}

private void sleep(int i) {
try {
java.lang.Thread.sleep(i);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
private void resumeProcess() {
synchronized (sync) {
sync.notify();
}
}

private void pauseProcess() {
synchronized (sync) {
try {
sync.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.support.test.filters.MediumTest;
import android.support.test.runner.AndroidJUnit4;

import com.example.chat.application.chatexample.ChatActivity;
import com.example.chat.application.chatexample.ChatContract;
import com.example.chat.application.chatexample.ChatPresenter;
import com.fanap.podchat.mainmodel.History;
Expand Down Expand Up @@ -57,7 +58,7 @@ public class LocalChatTest {

private static String TYPE_CODE = "";

private ChatSandBoxActivity activy;
private ChatActivity activy;

@Before
public void setUp() {
Expand Down
Loading

0 comments on commit 704afd7

Please sign in to comment.