use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.
the class SyncMeEngineTest method testPushMessage.
@Suppress
@MediumTest
public void testPushMessage() {
setUpContactSyncMeEngineTestFramework();
PushEvent evt = new PushEvent();
evt.mMessageType = PushMessageTypes.PROFILE_CHANGE;
List<BaseDataType> data = new ArrayList<BaseDataType>();
data.add(evt);
NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
ResponseQueue.getInstance().addToResponseQueue(new DecodedResponse(0, data, mEngine.engineId(), DecodedResponse.ResponseType.PUSH_MESSAGE.ordinal()));
mEngine.onCommsInMessage();
// see if anything happens
assertEquals("Expected SUCCESS, not timeout", ServiceStatus.SUCCESS, mEngineTester.waitForEvent());
Object retdata = mEngineTester.data();
assertTrue(retdata == null);
Log.i(LOG_TAG, "**** testPushMessage (SUCCESS) ****\n");
}
use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.
the class EngineTestFramework method reportBackToFramework.
@Override
public void reportBackToFramework(int reqId, EngineId engine) {
Log.d("TAG", "EngineTestFramework.reportBackToFramework");
mObserver.reportBackToEngine(reqId, engine);
final QueueManager reqQ = QueueManager.getInstance();
final ResponseQueue respQ = ResponseQueue.getInstance();
if (reqQ.getRequest(reqId) != null) {
List<BaseDataType> dataTypeList = new ArrayList<BaseDataType>();
ServerError err = new ServerError(ServerError.ErrorType.UNKNOWN);
dataTypeList.add(err);
respQ.addToResponseQueue(new DecodedResponse(reqId, dataTypeList, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
}
}
use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.
the class EngineTestFramework method callRun.
public void callRun(int reqId, List<BaseDataType> data) {
ResponseQueue.getInstance().addToResponseQueue(new DecodedResponse(reqId, data, mEngine.engineId(), DecodedResponse.ResponseType.UNKNOWN.ordinal()));
try {
mEngine.onCommsInMessage();
mEngine.run();
} catch (Exception e) {
onEngineException(e);
}
}
use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.
the class DownloadServerContactsTest method reportBackWithDeletedDetails.
private void reportBackWithDeletedDetails(int reqId, List<BaseDataType> data) {
Log.d(LOG_TAG, "reportBackWithDeletedDetails");
Integer pageNo = mProcessor.testGetPageFromReqId(reqId);
int pageSize = mProcessor.getDownloadPageSize();
assertTrue(pageNo != null);
assertEquals(Integer.valueOf(mPageCount), pageNo);
ContactChanges contactChanges = new ContactChanges();
data.add(contactChanges);
contactChanges.mCurrentServerVersion = CURRENT_SERVER_VERSION;
contactChanges.mServerRevisionBefore = CURRENT_SERVER_VERSION;
contactChanges.mServerRevisionAfter = CURRENT_SERVER_VERSION;
contactChanges.mVersionAnchor = CURRENT_SERVER_VERSION;
assertTrue(pageSize > 0);
if (pageSize > 0) {
contactChanges.mNumberOfPages = 1 + mPageCount + (mItemCount / pageSize);
}
int noOfContacts = Math.min(pageSize, mItemCount);
for (int i = 0; i < noOfContacts; i++) {
Contact curContact = new Contact();
curContact.contactID = FIRST_MODIFIED_CONTACT_ID + mItemCount - 1;
contactChanges.mContacts.add(curContact);
ContactDetail delDetail1 = new ContactDetail();
delDetail1.key = ContactDetail.DetailKeys.VCARD_NAME;
delDetail1.deleted = true;
ContactDetail delDetail2 = new ContactDetail();
delDetail2.key = ContactDetail.DetailKeys.VCARD_NICKNAME;
delDetail2.deleted = true;
ContactDetail delDetail3 = new ContactDetail();
delDetail3.key = ContactDetail.DetailKeys.VCARD_EMAIL;
delDetail3.unique_id = NEW_EMAIL_DETAIL_ID + mItemCount - 1;
delDetail3.deleted = true;
curContact.details.add(delDetail1);
curContact.details.add(delDetail2);
curContact.details.add(delDetail3);
mItemCount--;
}
mPageCount++;
assertTrue(mItemCount >= 0);
if (mItemCount == 0) {
nextState(State.IDLE);
}
}
use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.
the class DownloadServerContactsTest method reportBackWithNewContacts.
private void reportBackWithNewContacts(int reqId, List<BaseDataType> data) {
Log.d(LOG_TAG, "reportBackWithNewContacts");
Integer pageNo = mProcessor.testGetPageFromReqId(reqId);
int pageSize = mProcessor.getDownloadPageSize();
assertTrue(pageNo != null);
assertEquals(Integer.valueOf(mPageCount), pageNo);
ContactChanges contactChanges = new ContactChanges();
data.add(contactChanges);
contactChanges.mCurrentServerVersion = CURRENT_SERVER_VERSION;
contactChanges.mServerRevisionBefore = CURRENT_SERVER_VERSION;
contactChanges.mServerRevisionAfter = CURRENT_SERVER_VERSION;
contactChanges.mVersionAnchor = CURRENT_SERVER_VERSION;
assertTrue(pageSize > 0);
if (pageSize > 0) {
contactChanges.mNumberOfPages = 1 + mPageCount + (mItemCount / pageSize);
}
int noOfContacts = Math.min(pageSize, mItemCount);
for (int i = 0; i < noOfContacts; i++) {
Contact newContact = mTestModule.createDummyContactData();
if (mLastNewContact == null) {
mLastNewContact = newContact;
}
newContact.contactID = FIRST_MODIFIED_CONTACT_ID + mItemCount - 1;
newContact.userID = generateTestUserID(newContact.contactID);
ContactDetail detail1 = new ContactDetail();
detail1.key = ContactDetail.DetailKeys.VCARD_PHONE;
detail1.unique_id = OLD_PHONE_DETAIL_ID + mItemCount - 1;
detail1.value = OLD_PHONE_DETAIL_VALUE;
newContact.details.add(detail1);
for (int j = 0; j < newContact.details.size(); j++) {
ContactDetail detail = newContact.details.get(j);
switch(detail.key) {
case VCARD_PHONE:
case VCARD_EMAIL:
if (detail.unique_id == null) {
detail.unique_id = ALT_PHONE_DETAIL_ID + j;
}
break;
}
}
contactChanges.mContacts.add(newContact);
mItemCount--;
}
mPageCount++;
assertTrue(mItemCount >= 0);
if (mItemCount == 0) {
nextState(State.IDLE);
}
}
Aggregations