Person person = new Person(); com.apptentive.android.sdk.migration.v4_0_0.Person personOld = new com.apptentive.android.sdk.migration.v4_0_0.Person(personString); person.setEmail(personOld.getEmail()); person.setBirthday(personOld.getBirthday()); person.setCity(personOld.getCity()); person.setCountry(personOld.getCountry()); person.setFacebookId(personOld.getFacebookId()); person.setId(personOld.getId()); person.setName(personOld.getName()); person.setPhoneNumber(personOld.getPhoneNumber()); person.setStreet(personOld.getStreet()); person.setZip(personOld.getZip()); person.setCustomData(customData);
if (oldPerson == null || !equal(oldPerson.getId(), newPerson.getId())) { ret.setId(newPerson.getId()); changed = true; if (oldPerson == null || !equal(oldPerson.getEmail(), newPerson.getEmail())) { ret.setEmail(newPerson.getEmail()); changed = true; if (oldPerson == null || !equal(oldPerson.getName(), newPerson.getName())) { ret.setName(newPerson.getName()); changed = true; if (oldPerson == null || !equal(oldPerson.getFacebookId(), newPerson.getFacebookId())) { ret.setFacebookId(newPerson.getFacebookId()); changed = true; if (oldPerson == null || !equal(oldPerson.getPhoneNumber(), newPerson.getPhoneNumber())) { ret.setPhoneNumber(newPerson.getPhoneNumber()); changed = true; if (oldPerson == null || !equal(oldPerson.getStreet(), newPerson.getStreet())) { ret.setStreet(newPerson.getStreet()); changed = true; if (oldPerson == null || !equal(oldPerson.getCity(), newPerson.getCity())) { ret.setCity(newPerson.getCity()); changed = true; if (oldPerson == null || !equal(oldPerson.getZip(), newPerson.getZip())) {
public Person clone() { Person person = new Person(); person.id = id; person.email = email; person.name = name; person.facebookId = facebookId; person.phoneNumber = phoneNumber; person.street = street; person.city = city; person.zip = zip; person.country = country; person.birthday = birthday; if (customData != null) { person.customData.putAll(customData); } person.listener = listener; return person; }
@Test public void queriesAgainstPerson() throws JSONException { String json = loadTextAssetAsString(TEST_DATA_DIR + "testQueriesAgainstPerson.json"); InteractionCriteria criteria = new InteractionCriteria(json); Person person = new Person(); person.setEmail("example@example.com"); person.getCustomData().put("foo", "bar"); EventData eventData = new EventData(); FieldManager fieldManager = new FieldManager(targetContext, new VersionHistory(), eventData, person, new Device(), new AppRelease()); // 0 assertTrue(criteria.isMet(fieldManager)); // 1 eventData.storeEventForCurrentAppVersion(Util.currentTimeSeconds(), versionCode, versionName, "switch.code.point"); assertFalse(criteria.isMet(fieldManager)); // 2 eventData.storeEventForCurrentAppVersion(Util.currentTimeSeconds(), versionCode, versionName, "switch.code.point"); assertTrue(criteria.isMet(fieldManager)); // 3 person.getCustomData().put("foo", "bar"); eventData.storeEventForCurrentAppVersion(Util.currentTimeSeconds(), versionCode, versionName, "switch.code.point"); assertTrue(criteria.isMet(fieldManager)); // 4 eventData.storeEventForCurrentAppVersion(Util.currentTimeSeconds(), versionCode, versionName, "switch.code.point"); assertFalse(criteria.isMet(fieldManager)); // 5 eventData.storeEventForCurrentAppVersion(Util.currentTimeSeconds(), versionCode, versionName, "switch.code.point"); assertTrue(criteria.isMet(fieldManager)); }
@Override protected boolean execute(Conversation conversation) { conversation.getPerson().getCustomData().put(key, value); return true; } }, "add custom person data");
case custom_data: String customDataKey = tokens[2].trim(); CustomData customData = person.getCustomData(); if (customData != null) { return person.getName(); case email: return person.getEmail(); case other: return null;
@Override protected void execute() { conversation.getPerson().setEmail(personEmail); } });
@Override protected void execute() { conversation.getPerson().setName(personName); } });
public ConversationData() { this.localIdentifier = UUID.randomUUID().toString(); this.device = new Device(); this.person = new Person(); this.sdk = new Sdk(); this.appRelease = new AppRelease(); this.eventData = new EventData(); this.versionHistory = new VersionHistory(); }
@Override protected boolean execute(Conversation conversation) { conversation.getPerson().getCustomData().put(key, value); return true; } }, "add custom person data");
data.setPerson(new Person()); assertTrue(listenerFired); listenerFired = false; data.getPerson().setId("foo"); assertTrue(listenerFired); listenerFired = false; data.getPerson().setEmail("foo"); assertTrue(listenerFired); listenerFired = false; data.getPerson().setName("foo"); assertTrue(listenerFired); listenerFired = false; data.getPerson().setFacebookId("foo"); assertTrue(listenerFired); listenerFired = false; data.getPerson().setPhoneNumber("foo"); assertTrue(listenerFired); listenerFired = false; data.getPerson().setStreet("foo"); assertTrue(listenerFired); listenerFired = false; data.getPerson().setCity("foo");
@Test public void criteriaApplicationVersionCode() throws JSONException { AppRelease appRelease = AppReleaseManager.generateCurrentAppRelease(targetContext, null); String json = loadTextAssetAsString(TEST_DATA_DIR + "criteria/testCriteriaApplicationVersionCode.json"); json = json.replace("\"APPLICATION_VERSION_CODE\"", String.valueOf(appRelease.getVersionCode())); InteractionCriteria criteria = new InteractionCriteria(json); FieldManager fieldManager = new FieldManager(targetContext, new VersionHistory(), new EventData(), new Person(), new Device(), appRelease); assertTrue(criteria.isMet(fieldManager)); }
@Override protected boolean execute(Conversation conversation) { conversation.getPerson().getCustomData().put(key, version); return true; } }, "add custom person data");
@Test public void criteriaApplicationDebug() throws JSONException { AppRelease appRelease = AppReleaseManager.generateCurrentAppRelease(targetContext, null); String json = loadTextAssetAsString(TEST_DATA_DIR + "criteria/testCriteriaApplicationDebug.json"); json = json.replace("APPLICATION_DEBUG", Boolean.toString(appRelease.isDebug())); InteractionCriteria criteria = new InteractionCriteria(json); FieldManager fieldManager = new FieldManager(targetContext, new VersionHistory(), new EventData(), new Person(), new Device(), appRelease); assertTrue(criteria.isMet(fieldManager)); }
@Override protected boolean execute(Conversation conversation) { conversation.getPerson().getCustomData().put(key, dateTime); return true; } }, "add custom person data");
@Test public void criteriaApplicationVersionName() throws JSONException { AppRelease appRelease = AppReleaseManager.generateCurrentAppRelease(targetContext, null); String json = loadTextAssetAsString(TEST_DATA_DIR + "criteria/testCriteriaApplicationVersionName.json"); json = json.replace("APPLICATION_VERSION_NAME", appRelease.getVersionName()); InteractionCriteria criteria = new InteractionCriteria(json); FieldManager fieldManager = new FieldManager(targetContext, new VersionHistory(), new EventData(), new Person(), new Device(), appRelease); assertTrue(criteria.isMet(fieldManager)); }
@Override protected boolean execute(Conversation conversation) { conversation.getPerson().getCustomData().remove(key); return true; } }, "remove custom person data");
@Test public void defaultValues() throws JSONException { String json = loadTextAssetAsString(TEST_DATA_DIR + "testDefaultValues.json"); InteractionCriteria criteria = new InteractionCriteria(json); FieldManager fieldManager = new FieldManager(targetContext, new VersionHistory(), new EventData(), new Person(), new Device(), new AppRelease()); assertNotNull("Criteria was null, but it shouldn't be.", criteria); assertTrue(criteria.isMet(fieldManager)); } }
@Override protected boolean execute(Conversation conversation) { conversation.getPerson().getCustomData().put(key, trim(value)); return true; } }, "add custom person data");
@Test public void cornerCasesThatShouldBeTrue() throws JSONException { String json = loadTextAssetAsString(TEST_DATA_DIR + "testCornerCasesThatShouldBeTrue.json"); InteractionCriteria criteria = new InteractionCriteria(json); EventData eventData = new EventData(); Device device = new Device(); device.getCustomData().put("key_with_null_value", null); FieldManager fieldManager = new FieldManager(targetContext, new VersionHistory(), eventData, new Person(), device, new AppRelease()); assertNotNull("Criteria was null, but it shouldn't be.", criteria); assertTrue(criteria.isMet(fieldManager)); ApptentiveLog.e("Finished test."); }