-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fd128b
commit ea10142
Showing
6 changed files
with
87 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,6 @@ public interface Networking { | |
boolean check(CtxCore ctx); | ||
|
||
void stop(CtxCore ctx); | ||
|
||
Transport getTransport(); | ||
} |
39 changes: 39 additions & 0 deletions
39
sdk-java/src/test/java/ly/count/sdk/java/internal/ImmediateRequestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package ly.count.sdk.java.internal; | ||
|
||
import java.util.concurrent.atomic.AtomicReference; | ||
import ly.count.sdk.java.Countly; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
import static org.mockito.Mockito.mock; | ||
|
||
@RunWith(JUnit4.class) | ||
public class ImmediateRequestTest { | ||
Log L = mock(Log.class); | ||
|
||
/** | ||
* Immediate request maker "doWork" function | ||
* Immediate Request Generator is default and endpoint and data are not valid, and app key, server url is default | ||
* should return null because response is not okay | ||
* | ||
* @throws InterruptedException | ||
*/ | ||
@Test | ||
public void doWork_null() throws InterruptedException { | ||
Countly.instance().init(TestUtils.getBaseConfig()); | ||
AtomicReference<Boolean> callbackResult = new AtomicReference<>(true); | ||
|
||
ImmediateRequestMaker immediateRequestMaker = new ImmediateRequestMaker(); | ||
immediateRequestMaker.doWork("test_event", "/o?", SDKCore.instance.networking.getTransport(), false, true, | ||
(result) -> { | ||
if (result == null) { | ||
callbackResult.set(false); | ||
} | ||
}, L); | ||
|
||
Thread.sleep(2000); // wait for background thread to finish | ||
Assert.assertFalse(callbackResult.get()); // check if callback was called and response is null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters