本文整理汇总了Java中org.apache.olingo.commons.api.edm.provider.CsdlTerm.setType方法的典型用法代码示例。如果您正苦于以下问题:Java CsdlTerm.setType方法的具体用法?Java CsdlTerm.setType怎么用?Java CsdlTerm.setType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.olingo.commons.api.edm.provider.CsdlTerm
的用法示例。
在下文中一共展示了CsdlTerm.setType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: termWithTypeDef
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入方法依赖的package包/类
@Test
public void termWithTypeDef() {
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
String namespaceAndName = "mySchema.TypeDef";
String name = "TypeDef";
csdlTerm.setType(namespaceAndName);
Edm edm = mock(Edm.class);
EdmTypeDefinition typeMock = mock(EdmTypeDefinition.class);
when(typeMock.getName()).thenReturn(name);
when(edm.getTypeDefinition(new FullQualifiedName(namespaceAndName))).thenReturn(typeMock);
EdmTerm localTerm = new EdmTermImpl(edm, "namespace", csdlTerm);
assertNotNull(localTerm.getType());
assertEquals(name, localTerm.getType().getName());
}
示例2: termWithEnumType
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入方法依赖的package包/类
@Test
public void termWithEnumType() {
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
String namespaceAndName = "mySchema.Enum";
String name = "Enum";
csdlTerm.setType(namespaceAndName);
Edm edm = mock(Edm.class);
EdmEnumType typeMock = mock(EdmEnumType.class);
when(typeMock.getName()).thenReturn(name);
when(edm.getEnumType(new FullQualifiedName(namespaceAndName))).thenReturn(typeMock);
EdmTerm localTerm = new EdmTermImpl(edm, "namespace", csdlTerm);
assertNotNull(localTerm.getType());
assertEquals(name, localTerm.getType().getName());
}
示例3: termWithComplexType
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入方法依赖的package包/类
@Test
public void termWithComplexType() {
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
String namespaceAndName = "mySchema.Complex";
String name = "Complex";
csdlTerm.setType(namespaceAndName);
Edm edm = mock(Edm.class);
EdmComplexType typeMock = mock(EdmComplexType.class);
when(typeMock.getName()).thenReturn(name);
when(edm.getComplexType(new FullQualifiedName(namespaceAndName))).thenReturn(typeMock);
EdmTerm localTerm = new EdmTermImpl(edm, "namespace", csdlTerm);
assertNotNull(localTerm.getType());
assertEquals(name, localTerm.getType().getName());
}
示例4: termWithEntityType
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入方法依赖的package包/类
@Test
public void termWithEntityType() {
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
String namespaceAndName = "mySchema.Entity";
String name = "Entity";
csdlTerm.setType(namespaceAndName);
Edm edm = mock(Edm.class);
EdmEntityType typeMock = mock(EdmEntityType.class);
when(typeMock.getName()).thenReturn(name);
when(edm.getEntityType(new FullQualifiedName(namespaceAndName))).thenReturn(typeMock);
EdmTerm localTerm = new EdmTermImpl(edm, "namespace", csdlTerm);
assertNotNull(localTerm.getType());
assertEquals(name, localTerm.getType().getName());
}
示例5: invalidAppliesToContent
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入方法依赖的package包/类
@Test
public void invalidAppliesToContent() {
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
csdlTerm.setType("Edm.String");
csdlTerm.setAppliesTo(Arrays.asList("Invalid"));
EdmTerm localTerm = new EdmTermImpl(mock(Edm.class), "namespace", csdlTerm);
try {
localTerm.getAppliesTo();
fail("Expected an EdmException");
} catch (EdmException e) {
assertEquals("Invalid AppliesTo value: Invalid", e.getMessage());
}
}
示例6: setupTypes
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入方法依赖的package包/类
@Before
public void setupTypes() throws Exception {
CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
EdmProviderImpl edm = new EdmProviderImpl(provider);
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
csdlTerm.setType("Edm.String");
when(provider.getTerm(csdlTerm1Name)).thenReturn(csdlTerm);
initialTerm = new EdmTermImpl(edm, "namespace", csdlTerm);
CsdlTerm derivedCsdlTerm = new CsdlTerm();
FullQualifiedName derivedTermName = new FullQualifiedName("namespace", "name2");
derivedCsdlTerm.setName(derivedTermName.getName());
derivedCsdlTerm.setType("Edm.String");
derivedCsdlTerm.setBaseTerm("namespace.name1");
List<String> appliesTo = new ArrayList<String>();
appliesTo.add("Property");
derivedCsdlTerm.setAppliesTo(appliesTo);
List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
csdlAnnotations.add(new CsdlAnnotation().setTerm("name1"));
derivedCsdlTerm.setAnnotations(csdlAnnotations);
derivedCsdlTerm.setNullable(false);
derivedCsdlTerm.setMaxLength(new Integer(15));
derivedCsdlTerm.setDefaultValue("abc");
derivedCsdlTerm.setPrecision(new Integer(14));
derivedCsdlTerm.setScale(new Integer(13));
when(provider.getTerm(derivedTermName)).thenReturn(derivedCsdlTerm);
derivedTerm = new EdmTermImpl(edm, "namespace", derivedCsdlTerm);
}
示例7: invalidType
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入方法依赖的package包/类
@Test
public void invalidType() {
CsdlTerm csdlTerm = new CsdlTerm();
FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
csdlTerm.setName(csdlTerm1Name.getName());
csdlTerm.setType("invalid.invalid");
EdmTerm localTerm = new EdmTermImpl(mock(Edm.class), "namespace", csdlTerm);
try {
localTerm.getType();
fail("Expected an EdmException");
} catch (EdmException e) {
assertEquals("Cannot find type with name: invalid.invalid", e.getMessage());
}
}
示例8: readTerm
import org.apache.olingo.commons.api.edm.provider.CsdlTerm; //导入方法依赖的package包/类
private CsdlTerm readTerm(XMLEventReader reader, StartElement element) throws XMLStreamException {
CsdlTerm term = new CsdlTerm();
term.setName(attr(element, "Name"));
term.setType(attr(element, "Type"));
if (attr(element, "BaseTerm") != null) {
term.setBaseTerm(attr(element, "BaseTerm"));
}
if (attr(element, "DefaultValue") != null) {
term.setDefaultValue(attr(element, "DefaultValue"));
}
if (attr(element, "AppliesTo") != null) {
String[] appliesTo = attr(element, "AppliesTo").split("\\s+");
term.setAppliesTo(Arrays.asList(appliesTo));
}
term.setNullable(Boolean.parseBoolean(attr(element, "Nullable")));
String maxLength = attr(element, "MaxLength");
if (maxLength != null) {
term.setMaxLength(Integer.parseInt(maxLength));
}
String precision = attr(element, "Precision");
if (precision != null) {
term.setPrecision(Integer.parseInt(precision));
}
String scale = attr(element, "Scale");
if (scale != null) {
term.setScale(Integer.parseInt(scale));
}
String srid = attr(element, "SRID");
if (srid != null) {
term.setSrid(SRID.valueOf(srid));
}
peekAnnotations(reader, "Term", term);
return term;
}