/* * 1. create a new Contact (OP: createContact) 2. retrieve contact by email (OP: getContactByEmail) 3. update the contact (OP: updateContact) 4. retrieve contact by id (OP: * getContactById) 5. delete contact by id (OP: */ @Test public void createRetrieveDeleteContact() throws HubSpotConnectorException, HubSpotConnectorNoAccessTokenException, HubSpotConnectorAccessTokenExpiredException { // 1. Create a new contact ContactProperties cp; final String email = createNewContact(); // 2. Retrieve the contact by email and check that all the properties setted are stablished Contact c = connector.getContactByEmail(USER_ID, email); Assert.assertNotNull(c); cp = c.getContactProperties(); Assert.assertNotNull(cp); Assert.assertFalse(StringUtils.isEmpty(c.getVid())); Assert.assertEquals(cp.getFirstname(), "theFirstName"); Assert.assertEquals(cp.getLastname(), "theLastName"); Assert.assertEquals(cp.getNumemployees(), ContactPropertiesNumberOfEmployees._25_50); Assert.assertEquals(cp.getLifecyclestage(), ContactPropertiesLifecycleStage.LEAD); Assert.assertEquals(cp.getCity(), "beautifulCity"); // 3. Update the lastname of the contact cp = new ContactProperties(); cp.setLastname("lastNameModified"); connector.updateContact(USER_ID, c.getVid(), cp); // 4. Retrieve again the same contact but this time by ID, and check that the lastname holds the // modified value c = connector.getContactById(USER_ID, c.getVid()); Assert.assertNotNull(c); cp = c.getContactProperties(); Assert.assertNotNull(cp); Assert.assertEquals(cp.getLastname(), "lastNameModified"); // 5. Delete the contact by his ID and check the response final ContactDeleted cd = connector.deleteContact(USER_ID, c.getVid()); Assert.assertNotNull(cd); Assert.assertTrue(cd.getDeleted()); Assert.assertEquals(cd.getVid(), c.getVid()); }
private String createNewContact() throws HubSpotConnectorException, HubSpotConnectorNoAccessTokenException, HubSpotConnectorAccessTokenExpiredException { final ContactProperties cp = new ContactProperties(); final long date = new Date().getTime(); final String email = String.format("*****@*****.**", date); cp.setEmail(email); cp.setFirstname("theFirstName"); cp.setLastname("theLastName"); cp.setNumemployees(ContactPropertiesNumberOfEmployees._25_50); cp.setLifecyclestage(ContactPropertiesLifecycleStage.LEAD); cp.setCity("beautifulCity"); final Contact c = connector.createContact(USER_ID, cp); c.toString(); return email; }