本文整理汇总了Java中com.sforce.soap.partner.DescribeSObjectResult.setFields方法的典型用法代码示例。如果您正苦于以下问题:Java DescribeSObjectResult.setFields方法的具体用法?Java DescribeSObjectResult.setFields怎么用?Java DescribeSObjectResult.setFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sforce.soap.partner.DescribeSObjectResult
的用法示例。
在下文中一共展示了DescribeSObjectResult.setFields方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInferSchemaWithReferenceField
import com.sforce.soap.partner.DescribeSObjectResult; //导入方法依赖的package包/类
@Test
public void testInferSchemaWithReferenceField() {
Field referenceField = new Field();
referenceField.setName("reference");
referenceField.setType(FieldType.string);
referenceField.setReferenceTo(new String[]{"SomeRecord"});
referenceField.setRelationshipName("relationship");
DescribeSObjectResult dsor = new DescribeSObjectResult();
dsor.setName("MySObjectRecord");
dsor.setFields(new Field[] { referenceField });
Schema schema = sRegistry.inferSchema(dsor);
Schema.Field field = schema.getField("reference");
assertThat(field.schema().getType(), is(Schema.Type.STRING));
assertThat(field.getProp(SalesforceSchemaConstants.REF_MODULE_NAME), is("SomeRecord"));
assertThat(field.getProp(SalesforceSchemaConstants.REF_FIELD_NAME), is("relationship"));
}
示例2: testInferSchemaWithReferenceField
import com.sforce.soap.partner.DescribeSObjectResult; //导入方法依赖的package包/类
@Test
public void testInferSchemaWithReferenceField() {
Field referenceField = new Field();
referenceField.setName("reference");
referenceField.setType(FieldType.string);
referenceField.setReferenceTo(new String[]{"SomeRecord"});
referenceField.setRelationshipName("relationship");
DescribeSObjectResult dsor = new DescribeSObjectResult();
dsor.setName("MySObjectRecord");
dsor.setFields(new Field[] { referenceField });
Schema schema = SalesforceAvroRegistryString.get().inferSchema(dsor);
Schema.Field field = schema.getField("reference");
assertThat(field.schema().getType(), is(Schema.Type.STRING));
assertThat(field.getProp(SalesforceSchemaConstants.REF_MODULE_NAME), is("SomeRecord"));
assertThat(field.getProp(SalesforceSchemaConstants.REF_FIELD_NAME), is("relationship"));
}
示例3: testPickList
import com.sforce.soap.partner.DescribeSObjectResult; //导入方法依赖的package包/类
@Test
public void testPickList() throws Exception {
DescribeSObjectResult describeSObjectResult = new DescribeSObjectResult();
Field pickList = new Field();
pickList.setName("pickList");
pickList.setType(FieldType.picklist);
describeSObjectResult.setFields(new Field[] { pickList });
Schema schema = SalesforceAvroRegistryString.get().inferSchema(describeSObjectResult);
assertThat(1, is(schema.getFields().size()));
}
示例4: testPickListWithParent
import com.sforce.soap.partner.DescribeSObjectResult; //导入方法依赖的package包/类
@Test
public void testPickListWithParent() throws Exception {
DescribeSObjectResult describeSObjectResult = new DescribeSObjectResult();
Field pickList = new Field();
pickList.setName("pickList");
pickList.setType(FieldType.picklist);
pickList.setCompoundFieldName("parent");
describeSObjectResult.setFields(new Field[] { pickList });
Schema schema = SalesforceAvroRegistryString.get().inferSchema(describeSObjectResult);
assertTrue(schema.getFields().isEmpty());
}
示例5: testAddressTypeFilter
import com.sforce.soap.partner.DescribeSObjectResult; //导入方法依赖的package包/类
@Test
public void testAddressTypeFilter() throws Exception {
DescribeSObjectResult describeSObjectResult = new DescribeSObjectResult();
Field address = new Field();
address.setName("address");
address.setType(FieldType.address);
describeSObjectResult.setFields(new Field[] { address });
Schema schema = SalesforceAvroRegistryString.get().inferSchema(describeSObjectResult);
assertThat(0, is(schema.getFields().size()));
}
示例6: testLocationTypeFilter
import com.sforce.soap.partner.DescribeSObjectResult; //导入方法依赖的package包/类
@Test
public void testLocationTypeFilter() throws Exception {
DescribeSObjectResult describeSObjectResult = new DescribeSObjectResult();
Field location = new Field();
location.setName("location");
location.setType(FieldType.location);
describeSObjectResult.setFields(new Field[] { location });
Schema schema = SalesforceAvroRegistryString.get().inferSchema(describeSObjectResult);
assertThat(0, is(schema.getFields().size()));
}
示例7: testGuessSchema
import com.sforce.soap.partner.DescribeSObjectResult; //导入方法依赖的package包/类
/**
* Checks {@link SalesforceSourceOrSink#guessSchema(String)} returns the
* {@link org.apache.avro.Schema} with date and string type
*/
@Test
public void testGuessSchema() throws Exception {
String field0Name = "Id";
String field1Name = "LastModifiedDate";
String field2Name = "LastActivityDate";
String drivingEntity = "Account";
String soql = new StringBuilder().append("SELECT").append(" ")
.append(field0Name).append(",").append(SPACE)
.append(field1Name).append(",").append(SPACE)
.append(field2Name).append(SPACE)
.append("FROM").append(SPACE)
.append(drivingEntity).toString();
final PartnerConnection partnerConnectionMock = Mockito.mock(PartnerConnection.class);
class SalesforceSourceOrSinkChild extends SalesforceSourceOrSink {
@Override
protected ConnectionHolder connect(RuntimeContainer container) {
ConnectionHolder connectionHolder = new ConnectionHolder();
connectionHolder.connection = partnerConnectionMock;
return connectionHolder;
}
}
Field field0 = new Field();
field0.setName(field0Name);
field0.setType(FieldType.string);
Field field1 = new Field();
field1.setName(field1Name);
field1.setType(FieldType.date);
Field field2 = new Field();
field2.setName(field2Name);
field2.setType(FieldType.date);
Field[] fields = new Field[3];
fields[0] = field0;
fields[1] = field1;
fields[2] = field2;
DescribeSObjectResult describeSObjectResult = new DescribeSObjectResult();
describeSObjectResult.setFields(fields);
Mockito.when(partnerConnectionMock.describeSObject(drivingEntity)).thenReturn(describeSObjectResult);
SalesforceSourceOrSinkChild salesforceSourceOrSinkChild = new SalesforceSourceOrSinkChild();
salesforceSourceOrSinkChild.initialize(runtimeContainerMock, properties);
Schema resultSchema = salesforceSourceOrSinkChild.guessSchema(soql);
LOGGER.debug("result schema: " + resultSchema.toString());
Assert.assertEquals("GuessedSchema", resultSchema.getName());
Assert.assertEquals(field0Name, resultSchema.getFields().get(0).name());
Assert.assertEquals(field1Name, resultSchema.getFields().get(1).name());
Assert.assertEquals("java.util.Date",
AvroUtils.unwrapIfNullable(resultSchema.getFields().get(1).schema()).getProp("java-class"));
Assert.assertEquals("yyyy-MM-dd",
resultSchema.getFields().get(1).getProp(SchemaConstants.TALEND_COLUMN_PATTERN));
Assert.assertEquals(field2Name, resultSchema.getFields().get(2).name());
Assert.assertEquals("java.util.Date",
AvroUtils.unwrapIfNullable(resultSchema.getFields().get(2).schema()).getProp("java-class"));
Assert.assertEquals("yyyy-MM-dd",
resultSchema.getFields().get(2).getProp(SchemaConstants.TALEND_COLUMN_PATTERN));
}