use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.
the class UploadServerContactsTest method reportDeleteContactDetailSuccess.
private void reportDeleteContactDetailSuccess(int reqId, List<BaseDataType> data) {
Log.d(LOG_TAG, "reportDeleteContactDetailSuccess");
mProcessor.verifyDeleteDetailsState();
Contact contact = new Contact();
mProcessor.testFetchContactDetailDeleteList(contact);
assertEquals(2, contact.details.size());
assertEquals(ContactDetail.DetailKeys.VCARD_NAME, contact.details.get(0).key);
assertEquals(ContactDetail.DetailKeys.VCARD_PHONE, contact.details.get(1).key);
ContactDetailDeletion contactDetailDeletion = new ContactDetailDeletion();
contactDetailDeletion.mServerVersionAfter = 1;
contactDetailDeletion.mServerVersionBefore = 0;
data.add(contactDetailDeletion);
contactDetailDeletion.mContactId = contact.contactID.intValue();
contactDetailDeletion.mDetails = new ArrayList<ContactDetail>();
for (ContactDetail detail : contact.details) {
ContactDetail tempDetail = new ContactDetail();
tempDetail.key = detail.key;
tempDetail.unique_id = detail.unique_id;
contactDetailDeletion.mDetails.add(tempDetail);
}
mItemCount--;
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 UploadServerContactsTest method reportBackAddContactSuccess.
private void reportBackAddContactSuccess(int reqId, List<BaseDataType> data) {
Log.d(LOG_TAG, "reportBackAddContactSuccess");
mProcessor.verifyNewContactsState();
List<Contact> contactChangeList = new ArrayList<Contact>();
mProcessor.testFetchContactChangeList(contactChangeList);
assertEquals(Math.min(mItemCount, mProcessor.testGetPageSize()), contactChangeList.size());
ContactChanges contactChanges = new ContactChanges();
contactChanges.mServerRevisionAfter = 1;
contactChanges.mServerRevisionBefore = 0;
data.add(contactChanges);
for (int i = 0; i < contactChangeList.size(); i++) {
Contact actualContact = contactChangeList.get(i);
Contact expectedContact = new Contact();
ServiceStatus status = mDb.fetchContact(actualContact.localContactID, expectedContact);
assertEquals(ServiceStatus.SUCCESS, status);
assertEquals(expectedContact.details.size(), actualContact.details.size());
assertEquals(null, actualContact.aboutMe);
assertEquals(null, actualContact.profilePath);
assertEquals(null, actualContact.contactID);
assertEquals(null, actualContact.deleted);
assertEquals(null, actualContact.friendOfMine);
assertEquals(null, actualContact.gender);
assertEquals(null, actualContact.groupList);
assertEquals(null, actualContact.sources);
assertEquals(expectedContact.synctophone, actualContact.synctophone);
assertEquals(null, actualContact.updated);
assertEquals(null, actualContact.userID);
final ListIterator<ContactDetail> itActDetails = actualContact.details.listIterator();
for (ContactDetail expDetail : expectedContact.details) {
ContactDetail actDetail = itActDetails.next();
assertTrue(DatabaseHelper.doDetailsMatch(expDetail, actDetail));
assertFalse(DatabaseHelper.hasDetailChanged(expDetail, actDetail));
}
generateReplyContact(expectedContact);
contactChanges.mContacts.add(mReplyContact);
}
mItemCount -= contactChangeList.size();
assertTrue(mItemCount >= 0);
if (mItemCount == 0) {
mInitialCount = mInitialContactGroupCount;
nextState(State.ADD_NEW_GROUP_LIST);
}
}
use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.
the class UploadServerContactsTest method reportBackToEngine.
@Override
public void reportBackToEngine(int reqId, EngineId engine) {
Log.d(LOG_TAG, "reportBackToEngine");
ResponseQueue respQueue = ResponseQueue.getInstance();
List<BaseDataType> data = new ArrayList<BaseDataType>();
try {
assertEquals(mEng.engineId(), engine);
synchronized (mEng.mWaitForReqIdLock) {
if (mEng.mActiveReqId == null || mEng.mActiveReqId.intValue() != reqId) {
try {
mEng.mWaitForReqIdLock.wait(MAX_WAIT_FOR_REQ_ID);
} catch (InterruptedException e) {
}
assertEquals(Integer.valueOf(reqId), mEng.mActiveReqId);
}
}
switch(mState) {
case ADD_CONTACT_LIST:
reportBackAddContactSuccess(reqId, data);
break;
case MODIFY_CONTACT_LIST:
reportModifyContactSuccess(reqId, data);
break;
case DELETE_CONTACT_LIST:
reportDeleteContactSuccess(reqId, data);
break;
case DELETE_CONTACT_DETAIL_LIST:
reportDeleteContactDetailSuccess(reqId, data);
break;
case ADD_NEW_GROUP_LIST:
reportBackAddGroupSuccess(reqId, data);
break;
case DELETE_GROUP_LIST:
reportDeleteGroupListSuccess(reqId, data);
break;
default:
fail("Unexpected request from processor");
}
} catch (Throwable err) {
ServerError serverError = new ServerError(ServerError.ErrorType.INTERNALERROR);
serverError.errorDescription = err + "\n";
for (int i = 0; i < err.getStackTrace().length; i++) {
StackTraceElement v = err.getStackTrace()[i];
serverError.errorDescription += "\t" + v + "\n";
}
Log.e(LOG_TAG, "Exception:\n" + serverError.errorDescription);
data.clear();
data.add(serverError);
}
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
Log.d(LOG_TAG, "reportBackToEngine - message added to response queue");
}
use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.
the class PeopleServiceTest method reportBackToFramework.
@Override
public void reportBackToFramework(int reqId, EngineId engine) {
/*
* We are not interested in testing specific engines in those tests then for all kind of
* requests we will return error because it is handled by all engines, just to finish flow.
*/
ResponseQueue respQueue = ResponseQueue.getInstance();
List<BaseDataType> data = new ArrayList<BaseDataType>();
ServerError se1 = new ServerError(ServerError.ErrorType.INTERNALERROR);
se1.errorDescription = "Test error produced by test framework, ignore it";
data.add(se1);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
}
use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.
the class HessianDecoder method parseExternalResponse.
private void parseExternalResponse(List<BaseDataType> clist, InputStream is, int tag) throws IOException {
mMicroHessianInput.init(is);
ExternalResponseObject resp = new ExternalResponseObject();
// now we read and check the response code
if (mMicroHessianInput.readInt(tag) != 200) {
return;
}
try {
resp.mMimeType = mMicroHessianInput.readString();
} catch (IOException ioe) {
LogUtils.logE("Failed to parse hessian string.");
return;
}
// read data - could be gzipped
try {
resp.mBody = mMicroHessianInput.readBytes();
} catch (IOException ioe) {
LogUtils.logE("Failed to read bytes.");
return;
}
LogUtils.logI("HessianDecoder.parseExternalResponse()" + " Parsed external object with length: " + resp.mBody.length);
clist.add(resp);
}
Aggregations