Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void test_C_Asset_fetch() throws Exception {
public void onCompletion(ResponseType responseType, Error error) {
assertEquals(BuildConfig.assetUID, asset.getAssetUid());
assertEquals("image/jpeg", asset.getFileType());
assertEquals("phoenix2.jpg", asset.getFileName());
assertEquals("image1.jpg", asset.getFileName());
latch.countDown();
}
});
Expand All @@ -84,7 +84,7 @@ public void test_E_AssetLibrary_includeCount_fetch() throws InterruptedException
assetLibrary.fetchAll(new FetchAssetsCallback() {
@Override
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
assertEquals(6, assetLibrary.getCount());
assertEquals(5, assetLibrary.getCount());
latch.countDown();
}
});
Expand Down Expand Up @@ -122,22 +122,6 @@ public void onCompletion(ResponseType responseType, Error error) {
latch.await(5, TimeUnit.SECONDS);
}

@Test
public void test_include_branch() {
final Asset asset = stack.asset(assetUid);
asset.includeBranch();
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
if (error == null) {
Log.d(TAG, asset.getAssetUid());
assertEquals(assetUid, asset.getAssetUid());
}
}
});
}


@Test
public void test_AZURE_NA() throws Exception {
Config config = new Config();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static junit.framework.TestCase.assertEquals;

import android.content.Context;
import android.util.Log;

import androidx.test.core.app.ApplicationProvider;

Expand All @@ -14,7 +13,6 @@
import org.junit.Test;
import static org.junit.Assert.*;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
Expand Down Expand Up @@ -46,7 +44,7 @@ public void testFindEntry() throws InterruptedException {
public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error) {
assertNull("There should be no error", error);
assertNotNull("Entry should have been fetched", queryResult);
assertEquals("variant-base-product", queryResult.getResultObjects().get(0).getTitle());
assertEquals("source5", queryResult.getResultObjects().get(0).getTitle());
// Unlock the latch to allow the test to proceed
latch.countDown();
}
Expand Down Expand Up @@ -126,18 +124,18 @@ public void onCompletion(ResponseType responseType, QueryResult queryResult, Err
@Test
public void testFindLessThan() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final Query query = stack.contentType(CONTENT_TYPE_UID).query();
int value = 90;
query.lessThan("price", value);
final Query query = stack.contentType("numbers_content_type").query();
int value = 11;
query.lessThan("num_field", value);
query.find(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error) {
assertNull("There should be no error", error);
assertNotNull("Entry should have been fetched", queryResult);
List<Entry> entries = queryResult.getResultObjects();
for (int i = 0; i < entries.size(); i++) {
Integer currNum = (int)entries.get(i).get("price");
assertTrue("Curr price should be less than the value", currNum < value);
Integer currNum = (int)entries.get(i).get("num_field");
assertTrue("Curr num_field should be less than the value", currNum < value);
}
latch.countDown();
}
Expand All @@ -149,18 +147,18 @@ public void onCompletion(ResponseType responseType, QueryResult queryResult, Err
@Test
public void testFindLessThanOrEqualTo() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final Query query = stack.contentType(CONTENT_TYPE_UID).query();
int value = 90;
query.lessThanOrEqualTo("price", value);
final Query query = stack.contentType("numbers_content_type").query();
int value = 11;
query.lessThanOrEqualTo("num_field", value);
query.find(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error) {
assertNull("There should be no error", error);
assertNotNull("Entry should have been fetched", queryResult);
List<Entry> entries = queryResult.getResultObjects();
for (int i = 0; i < entries.size(); i++) {
Integer currNum = (int)entries.get(i).get("price");
assertTrue("Curr price should be less than or equal to the value", currNum <= value);
Integer currNum = (int)entries.get(i).get("num_field");
assertTrue("Curr num_field should be less than or equal to the value", currNum <= value);
}
latch.countDown();
}
Expand All @@ -172,18 +170,18 @@ public void onCompletion(ResponseType responseType, QueryResult queryResult, Err
@Test
public void testFindGreaterThan() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final Query query = stack.contentType(CONTENT_TYPE_UID).query();
int value = 90;
query.greaterThan("price", value);
final Query query = stack.contentType("numbers_content_type").query();
int value = 11;
query.greaterThan("num_field", value);
query.find(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error) {
assertNull("There should be no error", error);
assertNotNull("Entry should have been fetched", queryResult);
List<Entry> entries = queryResult.getResultObjects();
for (int i = 0; i < entries.size(); i++) {
Integer currNum = (int)entries.get(i).get("price");
assertTrue("Curr price should be greater than the value", currNum > value);
Integer currNum = (int)entries.get(i).get("num_field");
assertTrue("Curr num_field should be greater than the value", currNum > value);
}
latch.countDown();
}
Expand All @@ -195,18 +193,18 @@ public void onCompletion(ResponseType responseType, QueryResult queryResult, Err
@Test
public void testFindGreaterThanOREqualTo() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final Query query = stack.contentType(CONTENT_TYPE_UID).query();
int value = 90;
query.greaterThanOrEqualTo("price", value);
final Query query = stack.contentType("numbers_content_type").query();
int value = 11;
query.greaterThanOrEqualTo("num_field", value);
query.find(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error) {
assertNull("There should be no error", error);
assertNotNull("Entry should have been fetched", queryResult);
List<Entry> entries = queryResult.getResultObjects();
for (int i = 0; i < entries.size(); i++) {
Integer currNum = (int)entries.get(i).get("price");
assertTrue("Curr price should be greater than or equal to the value", currNum >= value);
Integer currNum = (int)entries.get(i).get("num_field");
assertTrue("Curr num_field should be greater than or equal to the value", currNum >= value);
}
latch.countDown();
}
Expand All @@ -219,7 +217,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryResult, Err
public void testFindContainedIn() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final Query query = stack.contentType(CONTENT_TYPE_UID).query();
String[] values = {"kids dress"};
String[] values = {"source1"};
query.containedIn("title", values);
query.find(new QueryResultsCallBack() {
@Override
Expand All @@ -242,7 +240,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryResult, Err
public void testFindNotContainedIn() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final Query query = stack.contentType(CONTENT_TYPE_UID).query();
String[] values = {"kids dress"};
String[] values = {"source1"};
query.notContainedIn("title", values);
query.find(new QueryResultsCallBack() {
@Override
Expand Down Expand Up @@ -308,10 +306,10 @@ public void onCompletion(ResponseType responseType, QueryResult queryResult, Err
@Test
public void testFindOr() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
String[] values = {"kids dress"};
String field = "in_stock";
String[] values = {"source1"};
String field = "boolean";
final Query query1 = stack.contentType(CONTENT_TYPE_UID).query().containedIn("title", values);
final Query query2 = stack.contentType(CONTENT_TYPE_UID).query().where(field, 300);
final Query query2 = stack.contentType(CONTENT_TYPE_UID).query().where(field, true);
final Query query = stack.contentType(CONTENT_TYPE_UID).query();
ArrayList<Query> queryList = new ArrayList<>();
queryList.add(query1);
Expand Down Expand Up @@ -364,7 +362,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryResult, Err
@Test
public void testFindIncludeReference() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
String field = "image";
String field = "reference";
final Query query = stack.contentType(CONTENT_TYPE_UID).query();
query.includeReference(field);
query.find(new QueryResultsCallBack() {
Expand All @@ -375,8 +373,15 @@ public void onCompletion(ResponseType responseType, QueryResult queryResult, Err
List<Entry> entries = queryResult.getResultObjects();
for (int i = 0; i < entries.size(); i++) {
try {
Log.d("Entry", entries.get(i).get(field).toString());
} catch (Exception e) {
JSONArray ref = (JSONArray)entries.get(i).get(field);
// Convert JSONArray to List
List<String> list = new ArrayList<>();
for (int j = 0; j < ref.length(); j++) {
JSONObject jsonObject = ref.getJSONObject(j); // Get the first JSONObject
// Title is a mandatory field, so we can test against it being present
assertTrue("One of or should be true", jsonObject.has("title"));
}
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
Expand Down
Loading
Loading