@Test @SuppressWarnings("unchecked") public void testQueryWithSubquery() throws ApiException { PartnerQueryResult relQR = conn.query( "SELECT Id, Name, AnnualRevenue, (SELECT Id, FirstName, Email FROM Contacts), " + " (Select Id, Subject from Tasks), (Select Id, Subject from Cases) FROM Account WHERE Id='0015000000WWD7b'"); assertTrue(relQR.isDone()); assertNull(relQR.getQueryLocator()); assertEquals(1, relQR.getTotalSize()); PartnerSObject account = relQR.getSObjects().get(0); assertEquals(2, account.getRelationshipQueryResults().size()); PartnerQueryResult subqueryResult = account.getRelationshipQueryResults().get("Contacts"); assertTrue(subqueryResult.isDone()); assertNull(subqueryResult.getQueryLocator()); assertEquals(2, subqueryResult.getTotalSize()); List<PartnerSObject> expectedContacts = (List<PartnerSObject>) TestFixtureUtils .loadFixtures("/sObjectFixtures/ConnectionTests/subqueryContacts.xml"); List<PartnerSObject> actualContacts = subqueryResult.getSObjects(); assertEquals(expectedContacts.size(), actualContacts.size()); Map<Id, PartnerSObject> actualMap = SObjectUtil.mapifySObjects(actualContacts); Map<Id, PartnerSObject> expectedMap = SObjectUtil.mapifySObjects(expectedContacts); for (Map.Entry<Id, PartnerSObject> idSObjectEntry : expectedMap.entrySet()) { SObject actual = actualMap.get(idSObjectEntry.getKey()); SObject expected = idSObjectEntry.getValue(); assertNotNull("Object for id " + idSObjectEntry.getKey(), actual); Map<String, String> actualFields = actual.getAllFields(); actualFields.remove("Id"); assertEquals(expected.getAllFields(), actualFields); assertEquals(expected.getType(), actual.getType()); } assertFalse(account.getRelationshipQueryResults().containsKey("Tasks")); PartnerQueryResult cases = account.getRelationshipQueryResults().get("Cases"); assertNotNull(cases); assertTrue(cases.isDone()); assertNull(cases.getQueryLocator()); assertEquals(3, cases.getTotalSize()); Collection<String> subjects = Collections2.transform(cases.getSObjects(), new Function<PartnerSObject, String>() { @Nullable @Override public String apply(@Nullable PartnerSObject partnerSObject) { return partnerSObject.getField("Subject"); } }); assertEquals(newArrayList("Maintenance guidelines for generator unclear", "Electronic panel fitting loose", "Frequent mechanical breakdown"), newArrayList(subjects)); }
@Nonnull @Override public synchronized PartnerQueryResult query(@Nonnull String queryStr) throws ApiException { return getQueryResultForStub(this.queryImpl(queryStr)); }
PartnerConnectionImpl extends AbstractSalesforceConnection implements PartnerConnection { @Nonnull @Override public synchronized PartnerQueryResult query(@Nonnull String queryStr) throws ApiException { return getQueryResultForStub(this.queryImpl(queryStr)); } }
PartnerConnectionImpl extends AbstractSalesforceConnection implements PartnerConnection { @Nonnull @Override public synchronized PartnerQueryResult query(@Nonnull String queryStr) throws ApiException { return getQueryResultForStub(this.queryImpl(queryStr)); } private  PartnerConnectionImpl(@Nonnull CallSemaphore semaphore, @Nonnull ConnectionBundleImpl bundle,
            MetricRegistry metricRegistry); }
PartnerConnectionImpl extends AbstractSalesforceConnection implements PartnerConnection { @Nonnull @Override public synchronized PartnerQueryResult query(@Nonnull String queryStr) throws ApiException { return getQueryResultForStub(this.queryImpl(queryStr)); } private  PartnerConnectionImpl(@Nonnull CallSemaphore semaphore, @Nonnull ConnectionBundleImpl bundle,
            MetricRegistry metricRegistry); @Override synchronized int count(@Nonnull String sObjectType, @Nonnull String condition); @Override synchronized int count(@Nonnull String sObjectType); @Override synchronized int countAll(@Nonnull String sObjectType, @Nonnull String condition); @Override synchronized int countAll(@Nonnull String sObjectType); @Nonnull @Override synchronized List<SaveResult> create(@Nonnull List<SObject> sObjects); @Nonnull @Override synchronized List<DeleteResult> delete(@Nonnull List<Id> ids); @Nonnull @Override synchronized DescribeGlobalResult describeGlobal(); @Nonnull @Override synchronized SObjectDescription describeSObject(@Nonnull String sObjectType); @Nonnull @Override synchronized List<SObjectDescription> describeSObjects(@Nonnull List<String> sObjectTypes); @Nonnull @Override synchronized List<EmptyRecycleBinResult> emptyRecycleBin(@Nonnull List<Id> ids); @Nonnull @Override synchronized DateTime getServerTimestamp(); @Nonnull @Override synchronized UserInfo getUserInfo(); @Nonnull @Override synchronized PartnerQueryResult query(@Nonnull String queryStr); @Nonnull @Override synchronized PartnerQueryResult queryAll(@Nonnull String queryStr); @Nonnull @Override synchronized PartnerQueryResult queryMore(@Nonnull PartnerQueryLocator locator); @Nonnull @Override synchronized List<SObject> retrieve(@Nonnull String sObjectType, @Nonnull List<Id> ids,
            @Nonnull List<String> fieldList); @Nonnull @Override synchronized Map<Id, SObject> retrieveExtended(@Nonnull String sObjectType, @Nonnull List<Id> ids,
            @Nonnull List<String> fields,
            int maxFieldNameChunkSize); @Nonnull @Override synchronized List<UndeleteResult> undelete(@Nonnull List<Id> ids); @Nonnull @Override synchronized List<SaveResult> update(@Nonnull List<SObject> sObjects); @Nonnull @Override synchronized List<UpsertResult> upsert(@Nonnull String externalIdFieldName, @Nonnull List<SObject> sObjects); }
PartnerConnectionImpl extends AbstractSalesforceConnection implements PartnerConnection { @Nonnull @Override public synchronized PartnerQueryResult query(@Nonnull String queryStr) throws ApiException { return getQueryResultForStub(this.queryImpl(queryStr)); } private  PartnerConnectionImpl(@Nonnull CallSemaphore semaphore, @Nonnull ConnectionBundleImpl bundle,
            MetricRegistry metricRegistry); @Override synchronized int count(@Nonnull String sObjectType, @Nonnull String condition); @Override synchronized int count(@Nonnull String sObjectType); @Override synchronized int countAll(@Nonnull String sObjectType, @Nonnull String condition); @Override synchronized int countAll(@Nonnull String sObjectType); @Nonnull @Override synchronized List<SaveResult> create(@Nonnull List<SObject> sObjects); @Nonnull @Override synchronized List<DeleteResult> delete(@Nonnull List<Id> ids); @Nonnull @Override synchronized DescribeGlobalResult describeGlobal(); @Nonnull @Override synchronized SObjectDescription describeSObject(@Nonnull String sObjectType); @Nonnull @Override synchronized List<SObjectDescription> describeSObjects(@Nonnull List<String> sObjectTypes); @Nonnull @Override synchronized List<EmptyRecycleBinResult> emptyRecycleBin(@Nonnull List<Id> ids); @Nonnull @Override synchronized DateTime getServerTimestamp(); @Nonnull @Override synchronized UserInfo getUserInfo(); @Nonnull @Override synchronized PartnerQueryResult query(@Nonnull String queryStr); @Nonnull @Override synchronized PartnerQueryResult queryAll(@Nonnull String queryStr); @Nonnull @Override synchronized PartnerQueryResult queryMore(@Nonnull PartnerQueryLocator locator); @Nonnull @Override synchronized List<SObject> retrieve(@Nonnull String sObjectType, @Nonnull List<Id> ids,
            @Nonnull List<String> fieldList); @Nonnull @Override synchronized Map<Id, SObject> retrieveExtended(@Nonnull String sObjectType, @Nonnull List<Id> ids,
            @Nonnull List<String> fields,
            int maxFieldNameChunkSize); @Nonnull @Override synchronized List<UndeleteResult> undelete(@Nonnull List<Id> ids); @Nonnull @Override synchronized List<SaveResult> update(@Nonnull List<SObject> sObjects); @Nonnull @Override synchronized List<UpsertResult> upsert(@Nonnull String externalIdFieldName, @Nonnull List<SObject> sObjects);  }