use of com.vodafone360.people.service.utils.hessian.HessianDecoder in project 360-Engine-for-Android by 360.
the class HessianDecoderTest method testErrorResponse.
@MediumTest
public void testErrorResponse() {
// boolean testPassed = true;
List<BaseDataType> clist = new ArrayList<BaseDataType>();
HessianDecoder hess = new HessianDecoder();
try {
DecodedResponse resp = hess.decodeHessianByteArray(6, testErrorResponse, Type.COMMON, false, EngineId.UNDEFINED);
clist = resp.mDataTypes;
} catch (IOException e) {
e.printStackTrace();
assertTrue("IOException thrown", false);
}
int size = clist.size();
assertTrue(size == 1);
assertTrue(clist.get(0) instanceof ServerError);
}
use of com.vodafone360.people.service.utils.hessian.HessianDecoder in project 360-Engine-for-Android by 360.
the class SmsBroadcastReceiver method onReceive.
/**
* Implementation of the {@link BroadcastReceiver#onReceive} function.
* Decodes Hessian from SMS text and broadcasts the data to the engines
*
* @param context The current context of the People application
* @param intent Intent containing the SMS data
*/
@Override
public void onReceive(Context context, Intent intent) {
LogUtils.logD("SmsBroadcastReceiver.onReceive - Begin of sms receiver. \n" + intent.toString());
Bundle bundle = intent.getExtras();
Object[] messages = (Object[]) bundle.get("pdus");
SmsMessage[] smsMessage = new SmsMessage[messages.length];
for (int n = 0; n < messages.length; n++) {
try {
smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
LogUtils.logD("SmsBroadcastReceiver.onReceive - SMS no [" + n + "]bytes: " + new String(smsMessage[n].getUserData()));
HessianDecoder hd = new HessianDecoder();
Hashtable<String, Object> ht = hd.decodeHessianByteArrayToHashtable(smsMessage[n].getUserData());
if (ht != null) {
LogUtils.logD("SmsBroadcastReceiver.onReceive - Decoded hashtable: " + ht.toString());
Hashtable<?, ?> codeTable = (Hashtable<?, ?>) ht.get("e");
String code = (String) codeTable.get("r");
LogUtils.logD("SmsBroadcastReceiver.onReceive - Activation code: " + code);
Intent in = new Intent(ACTION_ACTIVATION_CODE);
in.putExtra("code", code);
context.sendBroadcast(in);
} else {
String code = "No code in SMS";
LogUtils.logD("SmsBroadcastReceiver.onReceive - Code not in sms");
Intent in = new Intent(ACTION_ACTIVATION_CODE);
in.putExtra("code", code);
context.sendBroadcast(in);
}
} catch (IOException e) {
LogUtils.logE("SmsBroadcastReceiver.onReceive() " + "IOException while decoding SMS Message.", e);
}
}
}
use of com.vodafone360.people.service.utils.hessian.HessianDecoder in project 360-Engine-for-Android by 360.
the class HessianDecoderTest method testUserProfileResponse.
@MediumTest
public void testUserProfileResponse() {
// boolean testPassed = true;
List<BaseDataType> ulist = new ArrayList<BaseDataType>();
HessianDecoder hess = new HessianDecoder();
try {
DecodedResponse resp = hess.decodeHessianByteArray(2, testUserProfileData, Type.COMMON, false, EngineId.UNDEFINED);
ulist = resp.mDataTypes;
} catch (IOException e) {
e.printStackTrace();
assertTrue("IOException thrown", false);
}
int size = ulist.size();
assertTrue(size == 1);
assertTrue(ulist.get(0) instanceof UserProfile);
}
use of com.vodafone360.people.service.utils.hessian.HessianDecoder in project 360-Engine-for-Android by 360.
the class HessianDecoderTest method testSessionResponse.
/*
*
* r{1}{0}fS{0}{4}codeS{0}{14}INTERNAL_ERRORS{0}{7}
* messageS{0}hError occured while getting contacts. Message was: Object reference not set to an instance of an object.S{0}{7}detailsMt{0}{0}S{0}{5}classS{0}Dcom.vodafone.next.api.common.APIStructures$APIInternalErrorExceptionzzz
*/
@MediumTest
public void testSessionResponse() {
// boolean testPassed = true;
List<BaseDataType> slist = new ArrayList<BaseDataType>();
HessianDecoder hess = new HessianDecoder();
try {
DecodedResponse resp = hess.decodeHessianByteArray(1, testSessionData, Type.COMMON, false, EngineId.UNDEFINED);
slist = resp.mDataTypes;
} catch (IOException e) {
e.printStackTrace();
assertTrue("IOException thrown", false);
}
int size = slist.size();
assertTrue(size == 1);
assertTrue(slist.get(0) instanceof AuthSessionHolder);
}
use of com.vodafone360.people.service.utils.hessian.HessianDecoder in project 360-Engine-for-Android by 360.
the class HessianDecoderTest method testIdentityListResponse.
@MediumTest
public void testIdentityListResponse() {
// boolean testPassed = true;
List<BaseDataType> clist = new ArrayList<BaseDataType>();
HessianDecoder hess = new HessianDecoder();
try {
DecodedResponse resp = hess.decodeHessianByteArray(4, testIdentityListData, Type.COMMON, false, EngineId.UNDEFINED);
clist = resp.mDataTypes;
} catch (IOException e) {
e.printStackTrace();
assertTrue("IOException thrown", false);
}
int size = clist.size();
assertTrue(size == 1);
assertTrue(clist.get(0) instanceof Identity);
}
Aggregations