Search in sources :

Example 1 with SalesForceManager

use of org.orcid.core.manager.SalesForceManager in project ORCID-Source by ORCID.

the class GetConsortiumFromSalesForceById method main.

@SuppressWarnings("resource")
public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("orcid-core-context.xml");
    SalesForceManager salesForceManager = (SalesForceManager) context.getBean("salesForceManager");
    Consortium consortium = salesForceManager.retrieveConsortium(args[0]);
    System.out.println(consortium);
    System.exit(0);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Consortium(org.orcid.core.salesforce.model.Consortium) SalesForceManager(org.orcid.core.manager.SalesForceManager)

Example 2 with SalesForceManager

use of org.orcid.core.manager.SalesForceManager in project ORCID-Source by ORCID.

the class GetContactsFromSalesForceByAccountId method main.

@SuppressWarnings("resource")
public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("orcid-core-context.xml");
    SalesForceManager salesForceManager = (SalesForceManager) context.getBean("salesForceManager");
    List<Contact> contacts = salesForceManager.retrieveContactsByAccountId(args[0]);
    System.out.println(contacts);
    System.exit(0);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SalesForceManager(org.orcid.core.manager.SalesForceManager) Contact(org.orcid.core.salesforce.model.Contact)

Example 3 with SalesForceManager

use of org.orcid.core.manager.SalesForceManager in project ORCID-Source by ORCID.

the class GetMembersFromSalesForce method main.

@SuppressWarnings("resource")
public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("orcid-core-context.xml");
    SalesForceManager salesForceManager = (SalesForceManager) context.getBean("salesForceManager");
    List<Member> members = salesForceManager.retrieveMembers();
    members.stream().forEach(e -> System.out.println(e));
    System.exit(0);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SalesForceManager(org.orcid.core.manager.SalesForceManager) Member(org.orcid.core.salesforce.model.Member)

Example 4 with SalesForceManager

use of org.orcid.core.manager.SalesForceManager in project ORCID-Source by ORCID.

the class SalesForceManagerImplTest method testUpdateContact2.

@Test
public void testUpdateContact2() {
    // Switch from main to technical contact
    Contact contact = new Contact();
    contact.setId("contact2Id");
    contact.setAccountId("account1Id");
    ContactRole role = new ContactRole(ContactRoleType.TECHNICAL_CONTACT);
    role.setId("contact2Idrole1Id");
    contact.setRole(role);
    ((SalesForceManagerImpl) salesForceManager).updateContact(contact, Collections.<Contact>emptyList());
    verify(salesForceDao, times(1)).updateContactRole(argThat(r -> {
        return "contact2Idrole1Id".equals(r.getId()) && "contact2Id".equals(r.getContactId()) && ContactRoleType.MAIN_CONTACT.equals(r.getRoleType()) && !r.isCurrent();
    }));
    verify(salesForceDao, times(1)).createContactRole(argThat(r -> {
        return "contact2Id".equals(r.getContactId()) && "account1Id".equals(r.getAccountId()) && ContactRoleType.TECHNICAL_CONTACT.equals(r.getRoleType());
    }));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) SalesForceManager(org.orcid.core.manager.SalesForceManager) SalesForceConnectionDao(org.orcid.persistence.dao.SalesForceConnectionDao) TargetProxyHelper(org.orcid.test.TargetProxyHelper) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) URL(java.net.URL) Mock(org.mockito.Mock) Member(org.orcid.core.salesforce.model.Member) EmailManager(org.orcid.core.manager.EmailManager) ContactPermission(org.orcid.core.salesforce.model.ContactPermission) ArrayList(java.util.ArrayList) MockitoAnnotations(org.mockito.MockitoAnnotations) ProfileLastModifiedAspect(org.orcid.persistence.aop.ProfileLastModifiedAspect) SalesForceConnectionEntity(org.orcid.persistence.jpa.entities.SalesForceConnectionEntity) Map(java.util.Map) Assert.fail(org.junit.Assert.fail) ContactRole(org.orcid.core.salesforce.model.ContactRole) Before(org.junit.Before) SelfPopulatingCache(net.sf.ehcache.constructs.blocking.SelfPopulatingCache) MalformedURLException(java.net.MalformedURLException) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) SourceManager(org.orcid.core.manager.SourceManager) Contact(org.orcid.core.salesforce.model.Contact) Email(org.orcid.jaxb.model.record_v2.Email) ContactRoleType(org.orcid.core.salesforce.model.ContactRoleType) Emails(org.orcid.jaxb.model.record_v2.Emails) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) SalesForceDao(org.orcid.core.salesforce.dao.SalesForceDao) ContactRole(org.orcid.core.salesforce.model.ContactRole) Contact(org.orcid.core.salesforce.model.Contact) Test(org.junit.Test)

Aggregations

SalesForceManager (org.orcid.core.manager.SalesForceManager)4 ApplicationContext (org.springframework.context.ApplicationContext)3 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)3 Contact (org.orcid.core.salesforce.model.Contact)2 Member (org.orcid.core.salesforce.model.Member)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 SelfPopulatingCache (net.sf.ehcache.constructs.blocking.SelfPopulatingCache)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Assert.fail (org.junit.Assert.fail)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1