@Test public void addAndRemoveContactFromLists() throws HubSpotConnectorException, HubSpotConnectorNoAccessTokenException, HubSpotConnectorAccessTokenExpiredException { // Create a new contact final String email = createNewContact(); // Retrieve the contact by email and check that all the properties setted are stablished final Contact c = connector.getContactByEmail(USER_ID, email); Assert.assertNotNull(c); // Retrieve all the email lists and use one that is not dynamic final HubSpotListLists hsll = connector.getContactsLists(USER_ID, null, null); Assert.assertNotNull(hsll); for (final HubSpotList hbl : hsll.getLists()) { // It must be a non dynamic list if (!hbl.getDynamic()) { final String listId = hbl.getListId(); final HubSpotListAddContactToListResponse hslactlr = connector.addExistingContactInAList(USER_ID, listId, c.getVid()); Assert.assertNotNull(hslactlr); Assert.assertNotNull(hslactlr.getUpdated()); Assert.assertEquals(1, hslactlr.getUpdated().size()); Assert.assertEquals(Integer.valueOf(c.getVid()), hslactlr.getUpdated().get(0)); break; } } // 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()); }