org.apache.olingo.odata2.api.edm.provider.ComplexType Java Examples

The following examples show how to use org.apache.olingo.odata2.api.edm.provider.ComplexType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JPAEdmNameBuilder.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
public static void build(final JPAEdmComplexType view) {

    JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
    String jpaEmbeddableTypeName = view.getJPAEmbeddableType().getJavaType().getSimpleName();
    String edmComplexTypeName = null;
    if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
      edmComplexTypeName = mappingModelAccess.mapJPAEmbeddableType(jpaEmbeddableTypeName);
    }

    if (edmComplexTypeName == null) {
      edmComplexTypeName = jpaEmbeddableTypeName;
    }

    view.getEdmComplexType().setName(edmComplexTypeName);
    ComplexType complexType = view.getEdmComplexType();
    complexType.setName(edmComplexTypeName);
    JPAEdmMapping mapping = new JPAEdmMappingImpl();
    mapping.setJPAType(view.getJPAEmbeddableType().getJavaType());
    complexType.setMapping((Mapping) mapping);

  }
 
Example #2
Source File: JPAEdmComplexTypeTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testExpandEdmComplexType() {
  ComplexType complexType = new ComplexType();
  List<Property> properties = new ArrayList<Property>();
  JPAEdmMapping mapping1 = new JPAEdmMappingImpl();
  mapping1.setJPAColumnName("LINEITEMID");
  ((Mapping) mapping1).setInternalName("LineItemKey.LiId");
  JPAEdmMapping mapping2 = new JPAEdmMappingImpl();
  mapping2.setJPAColumnName("LINEITEMNAME");
  ((Mapping) mapping2).setInternalName("LineItemKey.LiName");
  properties.add(new SimpleProperty().setName("LIID").setMapping((Mapping) mapping1));
  properties.add(new SimpleProperty().setName("LINAME").setMapping((Mapping) mapping2));
  complexType.setProperties(properties);
  List<Property> expandedList = null;
  try {
    objComplexType.expandEdmComplexType(complexType, expandedList, "SalesOrderItemKey");
  } catch (ClassCastException e) {
    assertTrue(false);
  }
  assertTrue(true);

}
 
Example #3
Source File: AnnotationEdmProviderTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Test
public void facetsTest() throws Exception {
  EntityType employee = aep.getEntityType(new FullQualifiedName(ModelSharedConstants.NAMESPACE_1, "Employee"));
  assertEquals("Employee", employee.getName());
  Property name = getProperty(employee, "EmployeeName");
  assertEquals(Integer.valueOf(20), name.getFacets().getMaxLength());
  assertNull(name.getFacets().getConcurrencyMode());
  assertTrue(name.getFacets().isNullable());
  Property id = getProperty(employee, "EmployeeId");
  assertFalse(id.getFacets().isNullable());

  ComplexType city = aep.getComplexType(new FullQualifiedName(ModelSharedConstants.NAMESPACE_1, "c_City"));
  Property postalCode = getProperty(city.getProperties(), "PostalCode");
  assertEquals(Integer.valueOf(5), postalCode.getFacets().getMaxLength());

  EntityType room = aep.getEntityType(new FullQualifiedName(ModelSharedConstants.NAMESPACE_1, "Room"));
  Property version = getProperty(room, "Version");
  assertEquals(Integer.valueOf(0), version.getFacets().getScale());
  assertEquals(Integer.valueOf(0), version.getFacets().getPrecision());
  assertEquals(EdmConcurrencyMode.Fixed, version.getFacets().getConcurrencyMode());
}
 
Example #4
Source File: AnnotationEdmProviderTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Test
public void complexTypeLocation() throws Exception {
  // validate employee
  EntityType employee = aep.getEntityType(new FullQualifiedName(ModelSharedConstants.NAMESPACE_1, "Employee"));
  final List<Property> properties = employee.getProperties();
  Property location = null;
  for (Property property : properties) {
    if (property.getName().equals("Location")) {
      location = property;
    }
  }
  assertNotNull(location);
  assertEquals("Location", location.getName());

  // validate location complex type
  ComplexType locationType = aep.getComplexType(
      new FullQualifiedName(ModelSharedConstants.NAMESPACE_1, "c_Location"));
  assertEquals("c_Location", locationType.getName());
  assertEquals(2, locationType.getProperties().size());
  assertEquals(false, location.getFacets().isNullable());
}
 
Example #5
Source File: ServiceDocumentProducerTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Before
public void before() throws ODataException {
  EdmProvider edmProvider = mock(EdmProvider.class);

  EntityType entityType = new EntityType().setName("EntityType1");
  when(edmProvider.getEntityType(new FullQualifiedName("EntityType1Ns", "EntityType1"))).thenReturn(entityType);

  ComplexType complexType = new ComplexType().setName("ComplexType1");
  when(edmProvider.getComplexType(new FullQualifiedName("ComplexType1Ns", "ComplexType1"))).thenReturn(complexType);

  Association association = new Association().setName("Association1");
  when(edmProvider.getAssociation(new FullQualifiedName("Association1Ns", "Association1"))).thenReturn(association);

  EntityContainerInfo defaultEntityContainer = new EntityContainerInfo().setName("Container1");
  when(edmProvider.getEntityContainerInfo(null)).thenReturn(defaultEntityContainer);
  when(edmProvider.getEntityContainerInfo("Container1")).thenReturn(defaultEntityContainer);

  edm = new EdmImplProv(edmProvider);

}
 
Example #6
Source File: JPAEdmKey.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
public void normalizeComplexKey(final ComplexType complexType, final List<PropertyRef> propertyRefList) {
  for (Property property : complexType.getProperties()) {
    try {

      SimpleProperty simpleProperty = (SimpleProperty) property;
      Facets facets = (Facets) simpleProperty.getFacets();
      if (facets == null) {
        simpleProperty.setFacets(new Facets().setNullable(false));
      } else {
        facets.setNullable(false);
      }
      PropertyRef propertyRef = new PropertyRef();
      propertyRef.setName(simpleProperty.getName());
      propertyRefList.add(propertyRef);

    } catch (ClassCastException e) {
      ComplexProperty complexProperty = (ComplexProperty) property;
      normalizeComplexKey(complexTypeView.searchEdmComplexType(complexProperty.getType()), propertyRefList);
    }

  }
}
 
Example #7
Source File: EdmStructuralTypeImplProv.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public EdmStructuralTypeImplProv(final EdmImplProv edm, final ComplexType structuralType,
    final EdmTypeKind edmTypeKind, final String namespace) throws EdmException {
  super(edm, structuralType.getName());
  this.structuralType = structuralType;
  this.namespace = namespace;
  this.edmTypeKind = edmTypeKind;

  resolveBaseType();

  buildPropertiesInternal();

  edmProperties = new HashMap<String, EdmTyped>();
}
 
Example #8
Source File: EdmSchemaMock.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private static List<ComplexType> createComplexTypes() {
  List<ComplexType> complexTypes = new ArrayList<ComplexType>();
  ComplexType complexTypeOne = new ComplexType();
  complexTypeOne.setName(COMPLEX_TYPE_NAME_ONE);
  complexTypeOne.setProperties(createComplexTypePropertiesOne());
  complexTypes.add(complexTypeOne);
  ComplexType complexTypeTwo = new ComplexType();
  complexTypeTwo.setName(COMPLEX_TYPE_NAME_TWO);
  complexTypeTwo.setProperties(createComplexTypePropertiesTwo());
  complexTypes.add(complexTypeTwo);
  return complexTypes;
}
 
Example #9
Source File: JPAEdmKeyTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ComplexType searchEdmComplexType(final String arg0) {
  if (arg0.equals(JPAEdmMockData.ComplexType.ComplexTypeA.class.getName())) {
    return buildComplexTypeA();
  } else if (arg0.equals(JPAEdmMockData.ComplexType.ComplexTypeB.class.getSimpleName())) {
    return buildComplexTypeB();
  }

  return null;

}
 
Example #10
Source File: JPAEdmFunctionImportTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public Schema getEdmSchema() {
  Schema schema = new Schema();
  ComplexType complexType = new ComplexType();
  complexType.setName(JPACustomProcessorMock.nonJPAEmbeddableType);
  List<ComplexType> list = new ArrayList<ComplexType>();
  list.add(complexType);
  schema.setComplexTypes(list);

  return schema;

}
 
Example #11
Source File: JPAEdmFunctionImportTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ComplexType searchEdmComplexType(final String arg0) {
  if (arg0.equals(JPACustomProcessorMock.class.getName())) {
    return new ComplexType().setName(JPACustomProcessorMock.edmName);
  } else {
    return null;
  }
}
 
Example #12
Source File: XmlMetadataConsumer.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private void validateComplexTypes() throws EntityProviderException {
  for (Map.Entry<FullQualifiedName, ComplexType> complexTypes : complexTypesMap.entrySet()) {
    if (complexTypes.getValue() != null && complexTypes.getKey() != null) {
      ComplexType complexType = complexTypes.getValue();
      if (complexType.getBaseType() != null) {
        FullQualifiedName baseTypeFQName = complexType.getBaseType();
        if (!complexTypesMap.containsKey(baseTypeFQName)) {
          validateComplexTypeWithAlias(baseTypeFQName);
        }
      }
    }
  }
}
 
Example #13
Source File: EdmxProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ComplexType getComplexType(final FullQualifiedName edmFQName) throws ODataException {
  for (Schema schema : dataServices.getSchemas()) {
    if (schema.getNamespace().equals(edmFQName.getNamespace())) {
      for (ComplexType complexType : schema.getComplexTypes()) {
        if (complexType.getName().equals(edmFQName.getName())) {
          return complexType;
        }
      }
    }
  }
  return null;
}
 
Example #14
Source File: EdmImplProv.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
protected EdmComplexType createComplexType(final FullQualifiedName fqName) throws ODataException {
  ComplexType complexType = edmProvider.getComplexType(fqName);
  if (complexType == null) {
    return null;
  }
  return new EdmComplexTypeImplProv(this, complexType, fqName.getNamespace());
}
 
Example #15
Source File: Model.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public ComplexType getComplexType(FullQualifiedName edm_fq_name) throws ODataException
{
   if (edm_fq_name != null && edm_fq_name.getNamespace().equals(NAMESPACE))
   {
      return COMPLEX_TYPES.get(edm_fq_name.getName());
   }
   return null;
}
 
Example #16
Source File: EdmPropertyImplProvTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {

  edmProvider = mock(EdmProvider.class);
  EdmImplProv edmImplProv = new EdmImplProv(edmProvider);

  Mapping propertySimpleMapping = new Mapping().setInternalName("value");
  CustomizableFeedMappings propertySimpleFeedMappings = new CustomizableFeedMappings().setFcKeepInContent(true);
  SimpleProperty propertySimple =
      new SimpleProperty().setName("PropertyName").setType(EdmSimpleTypeKind.String)
          .setMimeType("mimeType").setMapping(propertySimpleMapping).setCustomizableFeedMappings(
              propertySimpleFeedMappings);
  propertySimpleProvider = new EdmSimplePropertyImplProv(edmImplProv, propertySimple);

  Facets facets = new Facets().setNullable(false);
  SimpleProperty propertySimpleWithFacets =
      new SimpleProperty().setName("PropertyName").setType(EdmSimpleTypeKind.String).setFacets(facets);
  propertySimpleWithFacetsProvider = new EdmSimplePropertyImplProv(edmImplProv, propertySimpleWithFacets);

  Facets facets2 = new Facets().setNullable(true);
  SimpleProperty propertySimpleWithFacets2 =
      new SimpleProperty().setName("PropertyName").setType(EdmSimpleTypeKind.String).setFacets(facets2);
  propertySimpleWithFacetsProvider2 = new EdmSimplePropertyImplProv(edmImplProv, propertySimpleWithFacets2);

  ComplexType complexType = new ComplexType().setName("complexType");
  FullQualifiedName complexName = new FullQualifiedName("namespace", "complexType");
  when(edmProvider.getComplexType(complexName)).thenReturn(complexType);

  ComplexProperty propertyComplex = new ComplexProperty().setName("complexProperty").setType(complexName);
  propertyComplexProvider = new EdmComplexPropertyImplProv(edmImplProv, propertyComplex);

}
 
Example #17
Source File: EdmComplexTypeImplProvTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void getEdmEntityContainerImpl() throws Exception {

  edmProvider = mock(EdmProvider.class);
  EdmImplProv edmImplProv = new EdmImplProv(edmProvider);

  ComplexType fooComplexType = new ComplexType().setName("fooComplexType");

  List<Property> keyPropertysFoo = new ArrayList<Property>();
  keyPropertysFoo.add(new SimpleProperty().setName("Name").setType(EdmSimpleTypeKind.String));
  keyPropertysFoo.add(new SimpleProperty().setName("Address").setType(EdmSimpleTypeKind.String));
  fooComplexType.setProperties(keyPropertysFoo);

  edmComplexType = new EdmComplexTypeImplProv(edmImplProv, fooComplexType, "namespace");

  FullQualifiedName barBaseTypeName = new FullQualifiedName("namespace", "barBase");
  ComplexType barBase = new ComplexType().setName("barBase");
  when(edmProvider.getComplexType(barBaseTypeName)).thenReturn(barBase);

  List<Property> propertysBarBase = new ArrayList<Property>();
  propertysBarBase.add(new SimpleProperty().setName("Name").setType(EdmSimpleTypeKind.String));
  propertysBarBase.add(new SimpleProperty().setName("Address").setType(EdmSimpleTypeKind.String));
  barBase.setProperties(propertysBarBase);

  ComplexType barComplexType = new ComplexType().setName("barComplexType").setBaseType(barBaseTypeName);
  edmComplexTypeWithBaseType = new EdmComplexTypeImplProv(edmImplProv, barComplexType, "namespace");

}
 
Example #18
Source File: EdmImplProvTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Before
public void getEdmImpl() throws Exception {
  EdmProvider edmProvider = mock(EdmProvider.class);

  List<AliasInfo> aliasInfos = new ArrayList<AliasInfo>();

  EntityType entityType = new EntityType().setName("EntityType1");
  when(edmProvider.getEntityType(new FullQualifiedName("EntityType1Ns", "EntityType1"))).thenReturn(entityType);
  AliasInfo aliasInfo1 = new AliasInfo().setAlias("et1").setNamespace("EntityType1Ns");
  aliasInfos.add(aliasInfo1);

  ComplexType complexType = new ComplexType().setName("ComplexType1");
  when(edmProvider.getComplexType(new FullQualifiedName("ComplexType1Ns", "ComplexType1"))).thenReturn(complexType);
  AliasInfo aliasInfo2 = new AliasInfo().setAlias("ct1").setNamespace("ComplexType1Ns");
  aliasInfos.add(aliasInfo2);

  Association association = new Association().setName("Association1");
  when(edmProvider.getAssociation(new FullQualifiedName("Association1Ns", "Association1"))).thenReturn(association);
  AliasInfo aliasInfo3 = new AliasInfo().setAlias("at1").setNamespace("Association1Ns");
  aliasInfos.add(aliasInfo3);

  when(edmProvider.getAliasInfos()).thenReturn(aliasInfos);

  EntityContainerInfo defaultEntityContainer = new EntityContainerInfo().setName("Container1");
  when(edmProvider.getEntityContainerInfo(null)).thenReturn(defaultEntityContainer);
  when(edmProvider.getEntityContainerInfo("Container1")).thenReturn(defaultEntityContainer);

  edm = new EdmImplProv(edmProvider);
}
 
Example #19
Source File: CarEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ComplexType getComplexType(final FullQualifiedName edmFQName) throws ODataException {
  if (NAMESPACE.equals(edmFQName.getNamespace())) {
    if (COMPLEX_TYPE.getName().equals(edmFQName.getName())) {
      List<Property> properties = new ArrayList<Property>();
      properties.add(new SimpleProperty().setName("Street").setType(EdmSimpleTypeKind.String));
      properties.add(new SimpleProperty().setName("City").setType(EdmSimpleTypeKind.String));
      properties.add(new SimpleProperty().setName("ZipCode").setType(EdmSimpleTypeKind.String));
      properties.add(new SimpleProperty().setName("Country").setType(EdmSimpleTypeKind.String));
      return new ComplexType().setName(COMPLEX_TYPE.getName()).setProperties(properties);
    }
  }

  return null;
}
 
Example #20
Source File: ComplexTypesDescriber.java    From cloud-sfsf-benefits-ext with Apache License 2.0 5 votes vote down vote up
private List<ComplexType> describeTypes() {
	List<ComplexType> types = new ArrayList<>();
	for (Entry<Class<?>, String> odataType : CLASS_TYPES.entrySet()) {
		try {
			types.add(describeType(odataType.getKey(), odataType.getValue()));
		} catch (SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException | NoSuchFieldException
				| IntrospectionException ex) {
			throw new IllegalStateException("Invalid OData configuration!", ex); //$NON-NLS-1$
		}
	}
	return types;
}
 
Example #21
Source File: ComplexTypesDescriber.java    From cloud-sfsf-benefits-ext with Apache License 2.0 5 votes vote down vote up
private ComplexType describeType(Class<?> odataType, String name) throws SecurityException, IllegalArgumentException, InstantiationException,
		IllegalAccessException, IntrospectionException, NoSuchFieldException {
	List<Field> fields = getTypeFields(odataType);

	List<Property> properties = new ArrayList<>();
	for (Field field : fields) {
		properties.add(createProperty(field));
	}

	ComplexType complexType = new ComplexType();
	complexType.setName(name);
	complexType.setProperties(properties);

	return complexType;
}
 
Example #22
Source File: MyEdmProvider.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public ComplexType getComplexType(FullQualifiedName edmFQName) throws ODataException {
    if (NAMESPACE.equals(edmFQName.getNamespace())) {
        if (COMPLEX_TYPE.getName().equals(edmFQName.getName())) {
            List<Property> properties = new ArrayList<>();
            properties.add(new SimpleProperty().setName("Street").setType(EdmSimpleTypeKind.String));
            properties.add(new SimpleProperty().setName("City").setType(EdmSimpleTypeKind.String));
            properties.add(new SimpleProperty().setName("ZipCode").setType(EdmSimpleTypeKind.String));
            properties.add(new SimpleProperty().setName("Country").setType(EdmSimpleTypeKind.String));
            return new ComplexType().setName(COMPLEX_TYPE.getName()).setProperties(properties);
        }
    }

    return null;
}
 
Example #23
Source File: Model.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
private static List<ComplexType> getComplexTypes()
{
   List<ComplexType> complexTypeList = new ArrayList<>();

   // Defines complex type TimeRange
   List<Property> timeRangeProperties = new ArrayList<>();
   timeRangeProperties.add(
         new SimpleProperty()
               .setName(TIME_RANGE_START)
               .setType(EdmSimpleTypeKind.DateTime));
   timeRangeProperties.add(
         new SimpleProperty()
               .setName(TIME_RANGE_END)
               .setType(EdmSimpleTypeKind.DateTime));
   complexTypeList.add(
         new ComplexType()
               .setName(TIME_RANGE.getName())
               .setProperties(timeRangeProperties));

   // Defines complex type Checksum
   List<Property> checksumProperties = new ArrayList<>();
   checksumProperties.add(
         new SimpleProperty()
               .setName(ALGORITHM)
               .setType(EdmSimpleTypeKind.String));
   checksumProperties.add(
         new SimpleProperty()
               .setName(VALUE)
               .setType(EdmSimpleTypeKind.String));
   complexTypeList.add(
         new ComplexType()
               .setName(CHECKSUM.getName())
               .setProperties(checksumProperties));

   return complexTypeList;
}
 
Example #24
Source File: ODataJPAEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ComplexType getComplexType(final FullQualifiedName edmFQName) throws ODataException {

  if (edmFQName != null) {
    if (complexTypes.containsKey(edmFQName.toString())) {
      return complexTypes.get(edmFQName.toString());
    } else if (schemas == null) {
      getSchemas();
    }

    for (Schema schema : schemas) {
      if (schema.getNamespace().equals(edmFQName.getNamespace())) {
        if (schema.getComplexTypes() == null) {
          return null;
        }
        for (ComplexType ct : schema.getComplexTypes()) {
          if (ct.getName().equals(edmFQName.getName())) {
            complexTypes.put(edmFQName.toString(), ct);
            return ct;
          }
        }
      }
    }
  }

  return null;
}
 
Example #25
Source File: ODataJPAEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public ODataJPAEdmProvider(final ODataJPAContext oDataJPAContext) {
  if (oDataJPAContext == null) {
    throw new IllegalArgumentException(ODataJPAException.ODATA_JPACTX_NULL);
  }
  entityTypes = new LinkedHashMap<String, EntityType>();
  entityContainerInfos = new LinkedHashMap<String, EntityContainerInfo>();
  complexTypes = new LinkedHashMap<String, ComplexType>();
  associations = new LinkedHashMap<String, Association>();
  functionImports = new LinkedHashMap<String, FunctionImport>();
  jpaEdmModel = ODataJPAFactory.createFactory().getJPAAccessFactory().getJPAEdmModelView(oDataJPAContext);
}
 
Example #26
Source File: JPAEdmComplexType.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private ComplexType searchComplexTypeByName(final String name) {
  for (ComplexType complexType : consistentComplextTypes) {
    if (null != complexType && null != complexType.getName() && complexType.getName().equals(name)) {
      return complexType;
    }
  }

  return null;
}
 
Example #27
Source File: ODataJPAEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public ODataJPAEdmProvider() {
  entityTypes = new LinkedHashMap<String, EntityType>();
  entityContainerInfos = new LinkedHashMap<String, EntityContainerInfo>();
  complexTypes = new LinkedHashMap<String, ComplexType>();
  associations = new LinkedHashMap<String, Association>();
  functionImports = new LinkedHashMap<String, FunctionImport>();
}
 
Example #28
Source File: AnnotationEdmProviderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void defaultNamespaceGenerationComplexType() throws ODataException {
  Collection<Class<?>> localAnnotatedClasses = new ArrayList<Class<?>>();
  localAnnotatedClasses.add(GeneratedNamesComplexTestClass.class);
  AnnotationEdmProvider localAep = new AnnotationEdmProvider(localAnnotatedClasses);
  // validate
  ComplexType testType = localAep.getComplexType(new FullQualifiedName(
      GeneratedNamesComplexTestClass.class.getPackage().getName(),
      GeneratedNamesComplexTestClass.class.getSimpleName()));
  assertNotNull("Requested entity not found.", testType);
  assertEquals("GeneratedNamesComplexTestClass", testType.getName());
  assertNull("This should not have a base type", testType.getBaseType());
}
 
Example #29
Source File: AnnotationEdmProviderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void defaultNameAndNamespaceGeneration() throws ODataException {
  Collection<Class<?>> localAnnotatedClasses = new ArrayList<Class<?>>();
  localAnnotatedClasses.add(GeneratedNamesTestClass.class);
  localAnnotatedClasses.add(GeneratedNamesComplexTestClass.class);
  AnnotationEdmProvider localAep = new AnnotationEdmProvider(localAnnotatedClasses);
  // validate
  EntityType testType = localAep.getEntityType(new FullQualifiedName(
      GeneratedNamesTestClass.class.getPackage().getName(),
      GeneratedNamesTestClass.class.getSimpleName()));
  assertNotNull("Requested entity not found.", testType);
  assertEquals("GeneratedNamesTestClass", testType.getName());
  assertNull("This should not have a base type", testType.getBaseType());
  List<Property> properties = testType.getProperties();
  assertEquals(1, properties.size());
  ComplexProperty propComplex = (ComplexProperty) properties.get(0);
  assertEquals("MyComplexProperty", propComplex.getName());
  assertEquals(GeneratedNamesComplexTestClass.class.getPackage().getName(), propComplex.getType().getNamespace());
  assertEquals(GeneratedNamesComplexTestClass.class.getSimpleName(), propComplex.getType().getName());


  ComplexType testComplexType = localAep.getComplexType(
      new FullQualifiedName(GeneratedNamesComplexTestClass.class.getPackage().getName(),
          GeneratedNamesComplexTestClass.class.getSimpleName()));
  assertNotNull("Requested entity not found.", testComplexType);
  assertEquals("GeneratedNamesComplexTestClass", testComplexType.getName());
  assertNull("This should not have a base type", testComplexType.getBaseType());
}
 
Example #30
Source File: AnnotationEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public ComplexType buildComplexType() {
  ComplexType complexType = new ComplexType();
  if (baseEntityType != null) {
    complexType.setBaseType(baseEntityType);
  }
  return complexType.setName(name).setProperties(properties);
}