use of com.vodafone360.people.service.io.ResponseQueue.DecodedResponse in project 360-Engine-for-Android by 360.
the class DownloadServerContactsTest 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);
switch(mState) {
case RUN_WITH_NO_CHANGES:
reportBackWithNoChanges(reqId, data);
break;
case RUN_WITH_NEW_CONTACTS:
reportBackWithNewContacts(reqId, data);
break;
case RUN_WITH_DELETED_CONTACTS:
reportBackWithDeletedContacts(reqId, data);
break;
case RUN_WITH_MODIFIED_CONTACTS:
reportBackWithModifiedContacts(reqId, data);
break;
case RUN_WITH_DELETED_DETAILS:
reportBackWithDeletedDetails(reqId, data);
break;
default:
fail("Unexpected request rom 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.service.io.ResponseQueue.DecodedResponse in project 360-Engine-for-Android by 360.
the class IdentityEngineTest method reportBackToEngine.
@Override
public void reportBackToEngine(int reqId, EngineId engine) {
Log.d("TAG", "IdentityEngineTest.reportBackToEngine");
ResponseQueue respQueue = ResponseQueue.getInstance();
List<BaseDataType> data = new ArrayList<BaseDataType>();
switch(mState) {
case IDLE:
break;
case FETCH_IDENTITIES:
Log.d("TAG", "IdentityEngineTest.reportBackToEngine FETCH ids");
Identity id = new Identity();
data.add(id);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
Log.d("TAG", "IdentityEngineTest.reportBackToEngine add to Q");
mEng.onCommsInMessage();
break;
case GET_MY_IDENTITIES:
Log.d("TAG", "IdentityEngineTest.reportBackToEngine Get ids");
Identity myId = new Identity();
data.add(myId);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
Log.d("TAG", "IdentityEngineTest.reportBackToEngine add to Q");
mEng.onCommsInMessage();
break;
case FETCH_IDENTITIES_FAIL:
ServerError err = new ServerError("Catastrophe");
err.errorDescription = "Fail";
data.add(err);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
break;
case SET_IDENTITY_CAPABILTY:
StatusMsg msg = new StatusMsg();
msg.mCode = "ok";
msg.mDryRun = false;
msg.mStatus = true;
data.add(msg);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SET_IDENTITY_CAPABILITY_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case VALIDATE_ID_CREDENTIALS_SUCCESS:
StatusMsg msg2 = new StatusMsg();
msg2.mCode = "ok";
msg2.mDryRun = false;
msg2.mStatus = true;
data.add(msg2);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.VALIDATE_IDENTITY_CREDENTIALS_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case VALIDATE_ID_CREDENTIALS_FAIL:
ServerError err2 = new ServerError("Catastrophe");
err2.errorDescription = "Fail";
data.add(err2);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
break;
case GET_NEXT_RUNTIME:
break;
case GET_CHATABLE_IDENTITIES:
case FETCH_IDENTITIES_POPULATED:
Identity id2 = new Identity();
id2.mActive = true;
id2.mAuthType = "auth";
List<String> clist = new ArrayList<String>();
clist.add("uk");
clist.add("fr");
id2.mCountryList = clist;
id2.mCreated = new Long(0);
id2.mDisplayName = "Facebook";
// id2.mIcon2Mime = "jpeg";
id2.mIconMime = "jpeg";
try {
id2.mIcon2Url = new URL("url2");
id2.mIconUrl = new URL("url");
id2.mNetworkUrl = new URL("network");
} catch (Exception e) {
}
id2.mIdentityId = "fb";
id2.mIdentityType = "type";
id2.mName = "Facebook";
id2.mNetwork = "Facebook";
id2.mOrder = 0;
id2.mPluginId = "";
id2.mUpdated = new Long(0);
id2.mUserId = 23;
id2.mUserName = "user";
data.add(id2);
List<IdentityCapability> capList = new ArrayList<IdentityCapability>();
IdentityCapability idcap = new IdentityCapability();
idcap.mCapability = IdentityCapability.CapabilityID.sync_contacts;
idcap.mDescription = "sync cont";
idcap.mName = "sync cont";
idcap.mValue = true;
capList.add(idcap);
id2.mCapabilities = capList;
data.add(id2);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
Log.d("TAG", "IdentityEngineTest.reportBackToEngine add to Q");
mEng.onCommsInMessage();
break;
default:
}
}
use of com.vodafone360.people.service.io.ResponseQueue.DecodedResponse in project 360-Engine-for-Android by 360.
the class ActivitiesEngineTest method testPushMessage.
@Suppress
@MediumTest
public void testPushMessage() {
boolean testPass = true;
mState = ActivityTestState.GET_ACTIVITIES_SUCCESS;
// create test Push msg and put it is response Q
PushEvent evt = new PushEvent();
evt.mMessageType = PushMessageTypes.STATUS_ACTIVITY_CHANGE;
List<BaseDataType> data = new ArrayList<BaseDataType>();
data.add(evt);
NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
ResponseQueue.getInstance().addToResponseQueue(new DecodedResponse(0, data, mEng.engineId(), DecodedResponse.ResponseType.PUSH_MESSAGE.ordinal()));
mEng.onCommsInMessage();
// see if anything happens
assertEquals("Expected SUCCESS, not timeout", ServiceStatus.SUCCESS, mEngineTester.waitForEvent());
Object retdata = mEngineTester.data();
assertTrue(retdata == null);
assertTrue("testPushMessage() failed", testPass);
Log.i(LOG_TAG, "**** testPushMessage (SUCCESS) ****\n");
}
use of com.vodafone360.people.service.io.ResponseQueue.DecodedResponse in project 360-Engine-for-Android by 360.
the class ActivitiesEngineTest method reportBackToEngine.
@Override
public void reportBackToEngine(int reqId, EngineId engine) {
Log.d("TAG", "IdentityEngineTest.reportBackToEngine");
ResponseQueue respQueue = ResponseQueue.getInstance();
List<BaseDataType> data = new ArrayList<BaseDataType>();
switch(mState) {
case IDLE:
break;
case ON_CREATE:
case ON_DESTROY:
break;
case GET_ACTIVITIES_SUCCESS:
ActivityItem item = new ActivityItem();
data.add(item);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_ACTIVITY_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case GET_TIMELINE_EVENT_FROM_SERVER:
ActivityItem item2 = new ActivityItem();
ActivityContact act = new ActivityContact();
act.mName = "Bill Fleege";
act.mLocalContactId = new Long(8);
List<ActivityContact> clist = new ArrayList<ActivityContact>();
clist.add(act);
item2.contactList = clist;
item2.activityFlags = 2;
item2.type = ActivityItem.Type.CONTACT_JOINED;
item2.time = System.currentTimeMillis();
data.add(item2);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_ACTIVITY_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case GET_POPULATED_ACTIVITIES:
ActivityItem item3 = new ActivityItem();
ActivityContact act2 = new ActivityContact();
act2.mName = "Bill Fleege";
act2.mLocalContactId = new Long(8);
List<ActivityContact> clist2 = new ArrayList<ActivityContact>();
clist2.add(act2);
item3.contactList = clist2;
item3.activityFlags = 2;
item3.type = ActivityItem.Type.CONTACT_JOINED;
item3.time = System.currentTimeMillis();
item3.title = "bills new status";
item3.description = "a description";
data.add(item3);
ActivityItem item4 = new ActivityItem();
item4.contactList = clist2;
item4.activityFlags = 5;
item4.type = ActivityItem.Type.CONTACT_JOINED;
item4.time = System.currentTimeMillis();
item4.title = "bills new status";
item4.description = "a description";
item4.activityId = new Long(23);
item4.hasChildren = false;
item4.uri = "uri";
item4.parentActivity = new Long(0);
item4.preview = ByteBuffer.allocate(46);
item4.preview.position(0);
item4.preview.rewind();
for (int i = 0; i < 23; i++) {
item4.preview.putChar((char) i);
}
item4.previewMime = "jepg";
item4.previewUrl = "storeurl";
item4.store = "google";
item4.visibilityFlags = 0;
data.add(item4);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_ACTIVITY_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case GET_ACTIVITIES_SERVER_ERR:
ServerError err = new ServerError("Catastrophe");
err.errorDescription = "Fail";
data.add(err);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
break;
case GET_ACTIVITIES_UNEXPECTED_RESPONSE:
StatusMsg msg = new StatusMsg();
msg.mCode = "ok";
msg.mDryRun = false;
msg.mStatus = true;
data.add(msg);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.LOGIN_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case SET_STATUS:
Identity id3 = new Identity();
data.add(id3);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case ON_SYNC_COMPLETE:
ServerError err2 = new ServerError("Catastrophe");
err2.errorDescription = "Fail";
data.add(err2);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
break;
case GET_NEXT_RUNTIME:
break;
default:
}
}
use of com.vodafone360.people.service.io.ResponseQueue.DecodedResponse 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");
}
Aggregations