本文整理汇总了Java中org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty.setType方法的典型用法代码示例。如果您正苦于以下问题:Java CsdlNavigationProperty.setType方法的具体用法?Java CsdlNavigationProperty.setType怎么用?Java CsdlNavigationProperty.setType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty
的用法示例。
在下文中一共展示了CsdlNavigationProperty.setType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: navigationProperty
import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入方法依赖的package包/类
@Test
public void navigationProperty() throws Exception {
CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
EdmProviderImpl edm = new EdmProviderImpl(provider);
final FullQualifiedName entityTypeName = new FullQualifiedName("ns", "entity");
CsdlEntityType entityTypeProvider = new CsdlEntityType();
entityTypeProvider.setKey(Collections.<CsdlPropertyRef> emptyList());
when(provider.getEntityType(entityTypeName)).thenReturn(entityTypeProvider);
CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty();
propertyProvider.setType(entityTypeName);
propertyProvider.setNullable(false);
EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
assertFalse(property.isCollection());
assertFalse(property.isNullable());
EdmType type = property.getType();
assertEquals(EdmTypeKind.ENTITY, type.getKind());
assertEquals("ns", type.getNamespace());
assertEquals("entity", type.getName());
assertNull(property.getReferencingPropertyName("referencedPropertyName"));
assertNull(property.getPartner());
assertFalse(property.containsTarget());
// Test caching
EdmType cachedType = property.getType();
assertTrue(type == cachedType);
}
示例2: navigationPropertyWithPartner
import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入方法依赖的package包/类
@Test
public void navigationPropertyWithPartner() throws Exception {
CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
EdmProviderImpl edm = new EdmProviderImpl(provider);
final FullQualifiedName entityTypeName = new FullQualifiedName("ns", "entity");
CsdlEntityType entityTypeProvider = new CsdlEntityType();
entityTypeProvider.setKey(Collections.<CsdlPropertyRef> emptyList());
List<CsdlNavigationProperty> navigationProperties = new ArrayList<CsdlNavigationProperty>();
navigationProperties.add(new CsdlNavigationProperty().setName("partnerName").setType(entityTypeName));
entityTypeProvider.setNavigationProperties(navigationProperties);
when(provider.getEntityType(entityTypeName)).thenReturn(entityTypeProvider);
CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty();
propertyProvider.setType(entityTypeName);
propertyProvider.setNullable(false);
propertyProvider.setPartner("partnerName");
EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
EdmNavigationProperty partner = property.getPartner();
assertNotNull(partner);
// Caching
assertTrue(partner == property.getPartner());
}
示例3: navigationPropertyWithNonexistentPartner
import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入方法依赖的package包/类
@Test(expected = EdmException.class)
public void navigationPropertyWithNonexistentPartner() throws Exception {
CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
EdmProviderImpl edm = new EdmProviderImpl(provider);
final FullQualifiedName entityTypeName = new FullQualifiedName("ns", "entity");
CsdlEntityType entityTypeProvider = new CsdlEntityType();
entityTypeProvider.setKey(Collections.<CsdlPropertyRef> emptyList());
List<CsdlNavigationProperty> navigationProperties = new ArrayList<CsdlNavigationProperty>();
navigationProperties.add(new CsdlNavigationProperty().setName("partnerName").setType(entityTypeName));
entityTypeProvider.setNavigationProperties(navigationProperties);
when(provider.getEntityType(entityTypeName)).thenReturn(entityTypeProvider);
CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty();
propertyProvider.setType(entityTypeName);
propertyProvider.setNullable(false);
propertyProvider.setPartner("wrong");
EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
property.getPartner();
}
示例4: navigationPropertyWithReferntialConstraint
import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入方法依赖的package包/类
@Test
public void navigationPropertyWithReferntialConstraint() throws Exception {
CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
EdmProviderImpl edm = new EdmProviderImpl(provider);
final FullQualifiedName entityTypeName = new FullQualifiedName("ns", "entity");
CsdlEntityType entityTypeProvider = new CsdlEntityType();
entityTypeProvider.setKey(Collections.<CsdlPropertyRef> emptyList());
when(provider.getEntityType(entityTypeName)).thenReturn(entityTypeProvider);
CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty();
propertyProvider.setType(entityTypeName);
propertyProvider.setNullable(false);
propertyProvider.setContainsTarget(true);
List<CsdlReferentialConstraint> referentialConstraints = new ArrayList<CsdlReferentialConstraint>();
referentialConstraints.add(new CsdlReferentialConstraint().setProperty("property").setReferencedProperty(
"referencedProperty"));
propertyProvider.setReferentialConstraints(referentialConstraints);
EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
assertEquals("property", property.getReferencingPropertyName("referencedProperty"));
assertNull(property.getReferencingPropertyName("wrong"));
assertTrue(property.containsTarget());
assertNotNull(property.getReferentialConstraints());
List<EdmReferentialConstraint> edmReferentialConstraints = property.getReferentialConstraints();
assertEquals(1, edmReferentialConstraints.size());
assertTrue(edmReferentialConstraints == property.getReferentialConstraints());
}
示例5: doDeserialize
import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; //导入方法依赖的package包/类
@Override
protected CsdlNavigationProperty doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
throws IOException {
final CsdlNavigationProperty property = new ClientCsdlNavigationProperty();
for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
final JsonToken token = jp.getCurrentToken();
if (token == JsonToken.FIELD_NAME) {
if ("Name".equals(jp.getCurrentName())) {
property.setName(jp.nextTextValue());
} else if ("Type".equals(jp.getCurrentName())) {
String metadataTypeName = jp.nextTextValue();
if (metadataTypeName.startsWith("Collection(")) {
property.setType(metadataTypeName.substring(metadataTypeName.indexOf("(") + 1,
metadataTypeName.length() - 1));
property.setCollection(true);
} else {
property.setType(metadataTypeName);
property.setCollection(false);
}
} else if ("Nullable".equals(jp.getCurrentName())) {
property.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
} else if ("Partner".equals(jp.getCurrentName())) {
property.setPartner(jp.nextTextValue());
} else if ("ContainsTarget".equals(jp.getCurrentName())) {
property.setContainsTarget(BooleanUtils.toBoolean(jp.nextTextValue()));
} else if ("ReferentialConstraint".equals(jp.getCurrentName())) {
jp.nextToken();
property.getReferentialConstraints().add(jp.readValueAs(ClientCsdlReferentialConstraint.class));
} else if ("OnDelete".equals(jp.getCurrentName())) {
jp.nextToken();
property.setOnDelete(jp.readValueAs(ClientCsdlOnDelete.class));
} else if ("Annotation".equals(jp.getCurrentName())) {
jp.nextToken();
property.getAnnotations().add(jp.readValueAs(ClientCsdlAnnotation.class));
}
}
}
return property;
}