use of com.vodafone360.people.utils.DynamicArrayLong in project 360-Engine-for-Android by 360.
the class DynamicArrayLongTest method testDefaultContructor.
/**
* Tests the default constructor.
*/
public void testDefaultContructor() {
DynamicArrayLong array = new DynamicArrayLong();
// check that the array is empty after creation
assertEquals(0, array.size());
}
use of com.vodafone360.people.utils.DynamicArrayLong in project 360-Engine-for-Android by 360.
the class NativeImporter method getIdsLists.
/**
* Gets the list of native and people contacts ids.
*/
private void getIdsLists() {
LogUtils.logD("NativeImporter.getIdsLists()");
// Get the list of native ids for the contacts
if (mAccounts == null || 0 == mAccounts.length) {
// default account
LogUtils.logD("NativeImporter.getIdsLists() - using default account");
mNativeContactsIds = mNativeContactsApi.getContactIds(null);
} else if (mAccounts.length == 1) {
// one account
LogUtils.logD("NativeImporter.getIdsLists() - one account found: " + mAccounts[0]);
mNativeContactsIds = mNativeContactsApi.getContactIds(mAccounts[0]);
} else {
// we need to merge the ids from different accounts and sort them
final DynamicArrayLong allIds = new DynamicArrayLong();
LogUtils.logD("NativeImporter.getIdsLists() - more than one account found.");
for (int i = 0; i < mAccounts.length; i++) {
LogUtils.logD("NativeImporter.getIdsLists() - account=" + mAccounts[i]);
final long[] ids = mNativeContactsApi.getContactIds(mAccounts[i]);
if (ids != null) {
allIds.add(ids);
}
}
mNativeContactsIds = allIds.toArray();
// which is faster than sorting them afterwards
if (mNativeContactsIds != null) {
Arrays.sort(mNativeContactsIds);
}
}
// check if we have some work to do
if (mNativeContactsIds == null) {
complete(RESULT_OK);
return;
}
// Get a list of native ids for the contacts we have in the People
// database
mPeopleNativeContactsIds = mPeopleContactsApi.getNativeContactsIds();
mTotalIds = mNativeContactsIds.length;
if (mPeopleNativeContactsIds != null) {
mTotalIds += mPeopleNativeContactsIds.length;
}
mState = STATE_ITERATE_THROUGH_IDS;
}
use of com.vodafone360.people.utils.DynamicArrayLong in project 360-Engine-for-Android by 360.
the class DynamicArrayLongTest method testAddGetSizeOverInitialCapacity.
/**
* Tests the add(), get() and size() methods when going over the initial capacity
*/
public void testAddGetSizeOverInitialCapacity() {
final int ADDS_COUNT = 100;
final DynamicArrayLong array = new DynamicArrayLong(ADDS_COUNT / 2);
// check that the array is empty after creation
assertEquals(0, array.size());
// perform checks for add/get/size methods
for (int i = 0; i < ADDS_COUNT; i++) {
final int ret = array.add(i + 10);
assertEquals(i, ret);
assertEquals(i + 10, array.get(i));
assertEquals(i + 1, array.size());
}
// re-check the values from the beginning
for (int i = 0; i < ADDS_COUNT; i++) {
assertEquals(i + 10, array.get(i));
}
assertEquals(ADDS_COUNT, array.size());
}
use of com.vodafone360.people.utils.DynamicArrayLong in project 360-Engine-for-Android by 360.
the class DynamicArrayLongTest method testConstructorWithInitialCapacity.
/**
* Tests the constructor specifying the initial capacity.
*/
public void testConstructorWithInitialCapacity() {
DynamicArrayLong array = new DynamicArrayLong(10);
boolean exceptionThrown;
// check that the array is empty after creation
assertEquals(0, array.size());
// check that exceptions are thrown with capacity <= 0
try {
exceptionThrown = false;
array = new DynamicArrayLong(0);
} catch (IllegalArgumentException iae) {
exceptionThrown = true;
}
assertTrue(exceptionThrown);
try {
exceptionThrown = false;
array = new DynamicArrayLong(-10);
} catch (IllegalArgumentException iae) {
exceptionThrown = true;
}
assertTrue(exceptionThrown);
}
use of com.vodafone360.people.utils.DynamicArrayLong in project 360-Engine-for-Android by 360.
the class DynamicArrayLongTest method testGet.
/**
* Tests the get() method.
*/
public void testGet() {
final int ADDS_COUNT = 100;
final DynamicArrayLong array = new DynamicArrayLong();
testGetExceptions(array);
for (int i = 0; i < ADDS_COUNT; i++) {
final int ret = array.add(i + 10);
assertEquals(i, ret);
assertEquals(i + 10, array.get(i));
assertEquals(i + 1, array.size());
testGetExceptions(array);
}
testGetExceptions(array);
}
Aggregations