forked from apache/metamodel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2f9711
commit fff3a93
Showing
7 changed files
with
100 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
salesforce/src/test/java/org/apache/metamodel/salesforce/SalesforceDataSetTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.metamodel.salesforce; | ||
|
||
import com.sforce.soap.partner.QueryResult; | ||
import com.sforce.ws.ConnectionException; | ||
import com.sforce.ws.bind.TypeMapper; | ||
import com.sforce.ws.parser.PullParserException; | ||
import com.sforce.ws.parser.XmlInputStream; | ||
import org.apache.metamodel.data.Row; | ||
import org.apache.metamodel.schema.Column; | ||
import org.apache.metamodel.schema.ColumnType; | ||
import org.apache.metamodel.schema.MutableColumn; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class SalesforceDataSetTest { | ||
|
||
@Test | ||
public void testQuery() throws Exception { | ||
QueryResult qr = queryResult("/result/double-value.xml"); | ||
MutableColumn version = new MutableColumn("Version", ColumnType.DOUBLE); | ||
|
||
SalesforceDataSet dataSet = new SalesforceDataSet(new Column[] { version }, qr, null); | ||
List<Row> rows = dataSet.toRows(); | ||
|
||
assertEquals(5386.21, rows.get(0).getValue(version)); | ||
assertEquals(53.0, rows.get(1).getValue(version)); | ||
|
||
dataSet.close(); | ||
} | ||
|
||
private QueryResult queryResult(String input) throws PullParserException, IOException, ConnectionException { | ||
QueryResult queryResult = new QueryResult(); | ||
XmlInputStream in = new XmlInputStream(); | ||
in.setInput(getClass().getResourceAsStream(input), "UTF-8"); | ||
queryResult.load(in, new TypeMapper()); | ||
return queryResult; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<n1:queryResponse xmlns:n1="urn:partner.soap.sforce.com"> | ||
<n1:done>true</n1:done> | ||
<n1:queryLocator n2:nil="true" | ||
xmlns:n2="http://www.w3.org/2001/XMLSchema-instance" /> | ||
<n1:records> | ||
<n3:type n4:type="string" xmlns:n3="urn:sobject.partner.soap.sforce.com" | ||
xmlns:n4="http://www.w3.org/2001/XMLSchema-instance">Application</n3:type> | ||
<n5:Version n6:type="string" xmlns:n5="urn:sobject.partner.soap.sforce.com" | ||
xmlns:n6="http://www.w3.org/2001/XMLSchema-instance">5386.21</n5:Version> | ||
</n1:records> | ||
<n1:records> | ||
<n7:type n8:type="string" xmlns:n7="urn:sobject.partner.soap.sforce.com" | ||
xmlns:n8="http://www.w3.org/2001/XMLSchema-instance">Application</n7:type> | ||
<n9:Version n10:type="string" xmlns:n9="urn:sobject.partner.soap.sforce.com" | ||
xmlns:n10="http://www.w3.org/2001/XMLSchema-instance">53.0</n9:Version> | ||
</n1:records> | ||
<n1:size>2</n1:size> | ||
</n1:queryResponse> |