當前位置: 首頁>>代碼示例>>Java>>正文


Java CsdlTerm.setType方法代碼示例

本文整理匯總了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());
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:17,代碼來源:EdmTermImplTest.java

示例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());
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:17,代碼來源:EdmTermImplTest.java

示例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());
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:17,代碼來源:EdmTermImplTest.java

示例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());
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:17,代碼來源:EdmTermImplTest.java

示例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());
  }
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:17,代碼來源:EdmTermImplTest.java

示例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);

}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:35,代碼來源:EdmTermImplTest.java

示例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());
  }
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:15,代碼來源:EdmTermImplTest.java

示例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;
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:36,代碼來源:MetadataParser.java


注:本文中的org.apache.olingo.commons.api.edm.provider.CsdlTerm.setType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。