use of com.sforce.soap.partner.QueryResult in project teiid by teiid.
the class SalesForce41ExecutionFactory method buildQueryResult.
/*
* Handles an api difference with {@link QueryResult}.setRecords
*/
@Override
public QueryResult buildQueryResult(SObject[] results) {
QueryResult result = new QueryResult();
result.setRecords(results);
result.setSize(results.length);
result.setDone(true);
return result;
}
use of com.sforce.soap.partner.QueryResult in project teiid by teiid.
the class SalesForceExecutionFactory method buildQueryResult.
public QueryResult buildQueryResult(SObject[] objects) {
QueryResult result = new QueryResult();
result.setRecords(objects);
result.setSize(objects.length);
result.setDone(true);
return result;
}
use of com.sforce.soap.partner.QueryResult in project teiid by teiid.
the class TestQueryExecutionImpl method testJoin.
@Test
public void testJoin() throws Exception {
// $NON-NLS-1$
Select command = (Select) translationUtility.parseCommand("select Account.Name, Contact.Id from Account inner join Contact on Account.Id = Contact.AccountId");
SalesforceConnection sfc = Mockito.mock(SalesforceConnection.class);
QueryResult qr = new QueryResult();
SObject so = new SObject();
so.setType("Account");
so.addField("Name", "account name");
SObject so1 = new SObject();
so1.setType("Contact");
so1.addField("Id", "contact id");
so.addField("Contacts", so1);
qr.setRecords(new SObject[] { so });
qr.setDone(true);
Mockito.stub(sfc.query("SELECT Account.Name, Contact.Id FROM Contact WHERE Contact.AccountId != NULL", 0, false)).toReturn(qr);
QueryExecutionImpl qei = new QueryExecutionImpl(command, sfc, Mockito.mock(RuntimeMetadata.class), Mockito.mock(ExecutionContext.class), new SalesForceExecutionFactory());
qei.execute();
assertEquals(Arrays.asList("account name", "contact id"), qei.next());
assertNull(qei.next());
}
use of com.sforce.soap.partner.QueryResult in project teiid by teiid.
the class TestQueryExecutionImpl method testBatching.
@Test
public void testBatching() throws Exception {
// $NON-NLS-1$
Select command = (Select) translationUtility.parseCommand("select Name from Account");
SalesforceConnection sfc = Mockito.mock(SalesforceConnection.class);
QueryResult qr = new QueryResult();
SObject so = new SObject();
so.setType("Account");
so.addField("Name", null);
qr.setRecords(new SObject[] { so });
qr.setDone(false);
QueryResult finalQr = new QueryResult();
finalQr.setRecords(new SObject[] { so });
finalQr.setDone(true);
Mockito.stub(sfc.query("SELECT Account.Name FROM Account", 0, false)).toReturn(qr);
Mockito.stub(sfc.queryMore(null, 0)).toReturn(finalQr);
QueryExecutionImpl qei = new QueryExecutionImpl(command, sfc, Mockito.mock(RuntimeMetadata.class), Mockito.mock(ExecutionContext.class), new SalesForceExecutionFactory());
qei.execute();
assertNotNull(qei.next());
assertNotNull(qei.next());
assertNull(qei.next());
}
use of com.sforce.soap.partner.QueryResult in project teiid by teiid.
the class TestSalesForceDirectQueryExecution method testSearch.
@Test
public void testSearch() throws Exception {
String input = "exec native('search;SELECT Account.Id, Account.Type, Account.Name FROM Account')";
TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
Command command = util.parseCommand(input);
ExecutionContext ec = Mockito.mock(ExecutionContext.class);
RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
SalesforceConnection connection = Mockito.mock(SalesforceConnection.class);
QueryResult qr = Mockito.mock(QueryResult.class);
Mockito.stub(qr.isDone()).toReturn(true);
SObject[] results = new SObject[1];
SObject s = new SObject();
s.setType("Account");
s.setId("The ID");
results[0] = s;
s.addField("Type", "The Type");
s.addField("Name", "The Name");
Mockito.stub(qr.getRecords()).toReturn(results);
Mockito.stub(connection.query("SELECT Account.Id, Account.Type, Account.Name FROM Account", 0, false)).toReturn(qr);
DirectQueryExecution execution = (DirectQueryExecution) TRANSLATOR.createExecution(command, ec, rm, connection);
execution.execute();
Mockito.verify(connection, Mockito.times(1)).query("SELECT Account.Id, Account.Type, Account.Name FROM Account", 0, false);
assertArrayEquals(new Object[] { "The ID", "The Type", "The Name" }, (Object[]) execution.next().get(0));
}
Aggregations