// Adding new contact void addContact(Contact contact) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(KEY_FNAME, contact.getfName().toString()); // Contact First Name values.put(KEY_LNAME, contact.getlName().toString()); // Contact Last Name values.put(KEY_PH_NO, contact.getContactNumber().toString()); // Contact Number values.put(KEY_EMAIL, contact.getEmailAddress().toString() ); // Contact Email // Inserting Row db.insert(TABLE_CONTACTS, null, values); db.close(); // Closing database connection }
/** * Generates the contact section of the metadata's template * * @param contacts * List of contact objects * * @return the contact section of the metadata's template */ private String toContactsXml(List<Contact> contacts) { StringBuilder contactsXml = new StringBuilder(); for (Contact contact : contacts) { contactsXml.append("<md:ContactPerson contactType=\"" + contact.getContactType() + "\">"); contactsXml.append("<md:GivenName>" + contact.getGivenName() + "</md:GivenName>"); contactsXml.append("<md:EmailAddress>" + contact.getEmailAddress() + "</md:EmailAddress>"); contactsXml.append("</md:ContactPerson>"); } return contactsXml.toString(); }
if (contact.getEmailAddress().isEmpty() || contact.getGivenName().isEmpty()) { errorMsg = "contact_not_enought_data"; errors.add(errorMsg);
/** * Tests the Contact constructor * * @see com.onelogin.saml2.model.Contact */ @Test public void testContact() { Contact contact = new Contact(null, null, null); assertEquals("", contact.getContactType()); assertEquals("", contact.getGivenName()); assertEquals("", contact.getEmailAddress()); Contact contact2 = new Contact("", "", ""); assertEquals("", contact2.getContactType()); assertEquals("", contact2.getGivenName()); assertEquals("", contact2.getEmailAddress()); Contact contact3 = new Contact("technical", "Name", "mail@example.com"); assertEquals("technical", contact3.getContactType()); assertEquals("Name", contact3.getGivenName()); assertEquals("mail@example.com", contact3.getEmailAddress()); } }
Contact c1 = contacts.get(0); assertEquals("technical", c1.getContactType()); assertEquals("technical@example.org", c1.getEmailAddress()); assertEquals("Technical Guy", c1.getGivenName()); Contact c2 = contacts.get(1); assertEquals("support", c2.getContactType()); assertEquals("support@example.org", c2.getEmailAddress()); assertEquals("Support Guy", c2.getGivenName());
Contact c1 = contacts.get(0); assertEquals("technical", c1.getContactType()); assertEquals("technical@example.org", c1.getEmailAddress()); assertEquals("Technical Guy", c1.getGivenName()); Contact c2 = contacts.get(1); assertEquals("support", c2.getContactType()); assertEquals("support@example.org", c2.getEmailAddress()); assertEquals("Support Guy", c2.getGivenName());
Contact c1 = contacts.get(0); assertEquals("technical", c1.getContactType()); assertTrue(c1.getEmailAddress().isEmpty()); assertEquals("Technical Guy", c1.getGivenName()); Contact c2 = contacts.get(1); assertEquals("support", c2.getContactType()); assertEquals("support@example.com", c2.getEmailAddress()); assertTrue(c2.getGivenName().isEmpty());
assertEquals("technical", c1.getContactType()); assertTrue(c1.getGivenName().isEmpty()); assertEquals("technical@example.com", c1.getEmailAddress()); Contact c2 = contacts.get(1); assertEquals("support", c2.getContactType()); assertEquals("Support Guy", c2.getGivenName()); assertTrue(c2.getEmailAddress().isEmpty());
Contact c1 = contacts.get(0); assertEquals("technical", c1.getContactType()); assertEquals("technical@example.com", c1.getEmailAddress()); assertEquals("Technical Guy", c1.getGivenName()); Contact c2 = contacts.get(1); assertEquals("support", c2.getContactType()); assertEquals("support@example.com", c2.getEmailAddress()); assertEquals("Support Guy", c2.getGivenName());