Package org.apache.olingo.odata2.api.edm

Examples of org.apache.olingo.odata2.api.edm.EdmMapping


        .createMock(EdmStructuralType.class);
    EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
    EdmType edmType = EasyMock.createMock(EdmType.class);
    EdmProperty edmTyped01 = EasyMock.createMock(EdmProperty.class);
    EdmType edmType01 = EasyMock.createMock(EdmType.class);
    EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
    EdmMapping edmMapping01 = EasyMock.createMock(EdmMapping.class);

    try {
      EasyMock.expect(edmType.getKind())
          .andStubReturn(EdmTypeKind.SIMPLE);
      EasyMock.expect(edmType.getName()).andReturn("identifier");
      EasyMock.replay(edmType);
      EasyMock.expect(edmMapping.getInternalName()).andStubReturn("id");
      EasyMock.replay(edmMapping);
      EasyMock.expect(edmTyped.getType()).andStubThrow(
          new EdmException(null));
      EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
      EasyMock.expect(edmTyped.getName()).andReturn("identifier").anyTimes();
      EasyMock.replay(edmTyped);
      EasyMock.expect(structuralType.getProperty("identifier"))
          .andStubReturn(edmTyped);

      EasyMock.expect(edmType01.getKind()).andStubReturn(
          EdmTypeKind.SIMPLE);
      EasyMock.expect(edmType01.getName()).andStubReturn("value");
      EasyMock.replay(edmType01);
      EasyMock.expect(edmMapping01.getInternalName()).andStubReturn(
          "value");
      EasyMock.replay(edmMapping01);
      EasyMock.expect(edmTyped01.getName()).andReturn("value").anyTimes();
      EasyMock.expect(edmTyped01.getType()).andStubReturn(edmType01);
      EasyMock.expect(edmTyped01.getMapping())
View Full Code Here


    demoItem jpaEntity = new demoItem("laptop", 1);
    jpaEntity.setRelatedEntity(relatedEntity);
    List<EdmNavigationProperty> navigationPropertyList = new ArrayList<EdmNavigationProperty>();
    // Mocking a navigation property and its mapping object
    EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
    EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
    try {
      EasyMock.expect(edmMapping.getInternalName()).andStubReturn("relatedEntity");
      EasyMock.replay(edmMapping);
      EasyMock.expect(navigationProperty.getName()).andStubReturn("RelatedEntities");
      EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping);
      EasyMock.replay(navigationProperty);
    } catch (EdmException e) {
View Full Code Here

    EdmProperty edmProperty2 = EasyMock.createMock(EdmProperty.class);
    EdmProperty edmComplexProperty = EasyMock.createMock(EdmProperty.class);
    EdmType edmType1 = EasyMock.createMock(EdmType.class);
    EdmStructuralType edmType2 = EasyMock.createMock(EdmStructuralType.class);
    EdmType edmComplexType = EasyMock.createMock(EdmType.class);
    EdmMapping mapping1 = EasyMock.createMock(EdmMapping.class);
    EdmMapping mapping2 = EasyMock.createMock(EdmMapping.class);
    EdmMapping complexMapping = EasyMock.createMock(EdmMapping.class);
    try {
      EasyMock.expect(edmType1.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
      EasyMock.replay(edmType1);
      EasyMock.expect(mapping1.getInternalName()).andStubReturn("id");
      EasyMock.replay(mapping1);
      EasyMock.expect(edmProperty1.getName()).andStubReturn("Id");
      EasyMock.expect(edmProperty1.getMapping()).andStubReturn(mapping1);
      EasyMock.expect(edmProperty1.getType()).andStubReturn(edmType1);
      EasyMock.replay(edmProperty1);
      // Mocking the complex properties
      EasyMock.expect(edmComplexType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
      EasyMock.replay(edmComplexType);
      EasyMock.expect(complexMapping.getInternalName()).andStubReturn("order");
      EasyMock.replay(complexMapping);
      EasyMock.expect(edmComplexProperty.getName()).andStubReturn("OrderName");
      EasyMock.expect(edmComplexProperty.getMapping()).andStubReturn(complexMapping);
      EasyMock.expect(edmComplexProperty.getType()).andStubReturn(edmComplexType);
      EasyMock.replay(edmComplexProperty);
View Full Code Here

   * EdmProperty should be used for deriving the name
   */
  @Test
  public void testGetGettersWithMapping() {
    JPAEntityParser resultParser = new JPAEntityParser();
    EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
    EasyMock.expect(edmMapping.getInternalName()).andStubReturn("field1");
    EasyMock.replay(edmMapping);
    try {

      Class<?>[] pars = { String.class, EdmMapping.class, String.class };
      Object[] params = { "myField", edmMapping, "get" };
View Full Code Here

  }

  private EdmProperty getEdmProperty() {
    EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);

    EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
    EasyMock.expect(edmMapping.getInternalName()).andStubReturn("Field1");
    EasyMock.replay(edmMapping);

    EdmType edmType = EasyMock.createMock(EdmType.class);

    try {
View Full Code Here

      final List<EdmProperty> edmPropertylist, final String tableAlias) throws ODataJPARuntimeException {
    HashMap<String, String> orderByMap = new HashMap<String, String>();
    String propertyName = null;
    for (EdmProperty edmProperty : edmPropertylist) {
      try {
        EdmMapping mapping = edmProperty.getMapping();
        if (mapping != null && mapping.getInternalName() != null) {
          propertyName = mapping.getInternalName();// For embedded/complex keys
        } else {
          propertyName = edmProperty.getName();
        }
      } catch (EdmException e) {
        throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
View Full Code Here

    AtomEntityProvider ser = createAtomEntityProvider();
    Map<String, Object> localEmployeeData = new HashMap<String, Object>(employeeData);
    String mediaResourceSourceKey = "~src";
    localEmployeeData.put(mediaResourceSourceKey, "http://localhost:8080/images/image1");
    EdmEntitySet employeesSet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
    EdmMapping mapping = employeesSet.getEntityType().getMapping();
    when(mapping.getMediaResourceSourceKey()).thenReturn(mediaResourceSourceKey);

    ODataResponse response = ser.writeEntry(employeesSet, localEmployeeData, DEFAULT_PROPERTIES);
    String xmlString = verifyResponse(response);

    assertXpathExists(
View Full Code Here

    String mediaResourceSourceKey = "~src";
    localEmployeeData.put(mediaResourceSourceKey, "http://localhost:8080/images/image1");
    String mediaResourceMimeTypeKey = "~type";
    localEmployeeData.put(mediaResourceMimeTypeKey, "image/jpeg");
    EdmEntitySet employeesSet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
    EdmMapping mapping = employeesSet.getEntityType().getMapping();
    when(mapping.getMediaResourceSourceKey()).thenReturn(mediaResourceSourceKey);
    when(mapping.getMediaResourceMimeTypeKey()).thenReturn(mediaResourceMimeTypeKey);
    when(mapping.getMimeType()).thenReturn(null);
    ODataResponse response = ser.writeEntry(employeesSet, localEmployeeData, DEFAULT_PROPERTIES);
    String xmlString = verifyResponse(response);

    assertXpathExists(
        "/a:entry/a:link[@href=\"Employees('1')/$value\" and" +
View Full Code Here

    Map<String, Object> localRoomData = new HashMap<String, Object>(roomData);
    String mediaResourceSourceKey = "~src";
    localRoomData.put(mediaResourceSourceKey, "http://localhost:8080/images/image1");
    EdmEntitySet roomsSet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
    EdmEntityType roomType = roomsSet.getEntityType();
    EdmMapping mapping = mock(EdmMapping.class);
    when(roomType.getMapping()).thenReturn(mapping);
    when(mapping.getMediaResourceSourceKey()).thenReturn(mediaResourceSourceKey);

    ODataResponse response = ser.writeEntry(roomsSet, localRoomData, DEFAULT_PROPERTIES);
    String xmlString = verifyResponse(response);

    assertXpathNotExists(
View Full Code Here

    localRoomData.put(mediaResourceSourceKey, "http://localhost:8080/images/image1");
    String mediaResourceMimeTypeKey = "~type";
    localRoomData.put(mediaResourceMimeTypeKey, "image/jpeg");
    EdmEntitySet roomsSet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
    EdmEntityType roomType = roomsSet.getEntityType();
    EdmMapping mapping = mock(EdmMapping.class);
    when(roomType.getMapping()).thenReturn(mapping);
    when(mapping.getMediaResourceSourceKey()).thenReturn(mediaResourceSourceKey);
    when(mapping.getMediaResourceMimeTypeKey()).thenReturn(mediaResourceMimeTypeKey);

    ODataResponse response = ser.writeEntry(roomsSet, localRoomData, DEFAULT_PROPERTIES);
    String xmlString = verifyResponse(response);

    assertXpathNotExists(
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.edm.EdmMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.