Package org.apache.olingo.odata2.api.uri.info

Examples of org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo


    List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
    return expandList;
  }

  private GetEntitySetUriInfo getResultsViewWithNullSelects() {
    GetEntitySetUriInfo objGetEntitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
    EasyMock.expect(objGetEntitySetUriInfo.getInlineCount()).andStubReturn(getLocalInlineCount());
    EasyMock.expect(objGetEntitySetUriInfo.getTargetEntitySet()).andStubReturn(getLocalTargetEntitySet());
    EasyMock.expect(objGetEntitySetUriInfo.getSelect()).andStubReturn(null);
    EasyMock.expect(objGetEntitySetUriInfo.getExpand()).andStubReturn(null);
    EasyMock.expect(objGetEntitySetUriInfo.getSkip()).andStubReturn(new Integer(1));

    EasyMock.replay(objGetEntitySetUriInfo);
    return objGetEntitySetUriInfo;
  }
View Full Code Here


    EasyMock.expect(navigationPropertySegment.getTargetEntitySet()).andStubReturn(getTargetEntitySetForExpand());
    EasyMock.replay(navigationPropertySegment);
    navigationPropertyList.add(navigationPropertySegment);
    expandList.add(navigationPropertyList);
    // Mocking EntityUriInfo
    GetEntitySetUriInfo entitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
    EasyMock.expect(entitySetUriInfo.getSelect()).andStubReturn(selectItemList);
    EasyMock.expect(entitySetUriInfo.getExpand()).andStubReturn(expandList);
    EasyMock.expect(entitySetUriInfo.getInlineCount()).andStubReturn(InlineCount.ALLPAGES);
    EasyMock.expect(entitySetUriInfo.getSkip()).andStubReturn(new Integer(1));
    EasyMock.expect(entitySetUriInfo.getTop()).andStubReturn(new Integer(2));
    EasyMock.replay(entitySetUriInfo);
    return entitySetUriInfo;
  }
View Full Code Here

  }

  @Test
  public void testEntityNameThrowingException() {
    // buildSelectContext(false, false, false);
    GetEntitySetUriInfo resultsView = EasyMock.createMock(GetEntitySetUriInfo.class);

    EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
    EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);

    try {
      EasyMock.expect(entityType.getName()).andStubThrow(new EdmException(null));
      EasyMock.expect(entitySet.getEntityType()).andStubThrow(new EdmException(null));
    } catch (EdmException e1) {
      // throw new ODataException();
    }

    EasyMock.replay(entityType);
    EasyMock.replay(entitySet);

    EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
    EasyMock.expect(resultsView.getOrderBy()).andStubReturn(null);
    EasyMock.expect(resultsView.getSelect()).andStubReturn(null);
    EasyMock.expect(resultsView.getFilter()).andStubReturn(null);
    EasyMock.replay(resultsView);
    try {
      JPQLSelectContextBuilder builder1 =
          (JPQLSelectContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT, resultsView);
View Full Code Here

  private JPQLSelectContext createSelectContext(final OrderByExpression orderByExpression,
      final FilterExpression filterExpression) throws ODataJPARuntimeException, EdmException {
    // Object Instantiation

    JPQLSelectContext jpqlSelectContextImpl = null;
    GetEntitySetUriInfo getEntitySetView = EasyMock.createMock(GetEntitySetUriInfo.class);

    EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
    EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
    List<SelectItem> selectItemList = null;

    // Setting up the expected value

    EasyMock.expect(getEntitySetView.getTargetEntitySet()).andStubReturn(edmEntitySet);
    EasyMock.expect(getEntitySetView.getOrderBy()).andStubReturn(orderByExpression);
    EasyMock.expect(getEntitySetView.getSelect()).andStubReturn(selectItemList);
    EasyMock.expect(getEntitySetView.getFilter()).andStubReturn(filterExpression);
    EasyMock.replay(getEntitySetView);
    EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
    EasyMock.replay(edmEntitySet);
    EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
    EasyMock.expect(edmEntityType.getName()).andStubReturn("SalesOrderHeader");
View Full Code Here

  private void buildSelectContext(final boolean orderByIsNull, final boolean selectFieldsIsNull,
      final boolean filterIsNull, final boolean isTopNull, final boolean isSkipNull) {
    builder = null;
    selectContext = null;
    keyPredicates = new ArrayList<KeyPredicate>();
    GetEntitySetUriInfo resultsView = EasyMock.createMock(GetEntitySetUriInfo.class);

    EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
    EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
    KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
    EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
    EdmType edmType1 = EasyMock.createMock(EdmType.class);
    EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
    EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
    try {
      EasyMock.expect(mapping.getInternalName()).andStubReturn("Field1");
      EasyMock.expect(kpProperty.getMapping()).andStubReturn(mapping);
      EasyMock.expect(kpProperty.getType()).andStubReturn(edmType1);

    } catch (EdmException e2) {
      fail("this should not happen");
    }
    EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
    EasyMock.replay(mapping, edmType1, kpProperty, keyPredicate);
    keyPredicates.add(keyPredicate);
    int i = 0;
    List<OrderExpression> orderList = new ArrayList<OrderExpression>(2);
    do {

      EdmType edmType = EasyMock.createMock(EdmType.class);
      try {
        EasyMock.expect(edmType.getName()).andStubReturn(fields[i]);
        EasyMock.replay(edmType);
      } catch (EdmException e2) {
        fail("Exception not Expected");
      }

      PropertyExpression commonExpression = EasyMock.createMock(PropertyExpression.class);
      EasyMock.expect(commonExpression.getEdmType()).andStubReturn(edmType);

      EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
      EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
      EasyMock.expect(edmMapping.getInternalName()).andStubReturn(fields[i]);
      try {
        EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
      } catch (EdmException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      EasyMock.expect(commonExpression.getEdmProperty()).andStubReturn(edmTyped);
      OrderExpression order = EasyMock.createMock(OrderExpression.class);
      EasyMock.expect(order.getExpression()).andStubReturn(commonExpression);
      EasyMock.expect(order.getSortOrder()).andStubReturn(orderType[i]);
      EasyMock.replay(edmMapping, edmTyped, commonExpression);
      EasyMock.replay(order);

      orderList.add(order);

    } while (++i < 2);

    OrderByExpression orderBy = EasyMock.createMock(OrderByExpression.class);
    EasyMock.expect(orderBy.getOrders()).andStubReturn(orderList);
    EasyMock.replay(orderBy);

    try {
      i = 0;
      List<SelectItem> selectItemList = new ArrayList<SelectItem>(2);
      do {
        EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
        EasyMock.expect(edmMapping.getInternalName()).andStubReturn(fields[i]);
        EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
        EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
        EasyMock.replay(edmMapping, edmProperty);

        SelectItem selectItem = EasyMock.createMock(SelectItem.class);
        EasyMock.expect(selectItem.getProperty()).andStubReturn(edmProperty);
        EasyMock.replay(selectItem);

        selectItemList.add(selectItem);

      } while (++i < 2);
      EasyMock.expect(entityType.getMapping()).andStubReturn(null);
      EasyMock.expect(entityType.getName()).andStubReturn(entityTypeName);
      EasyMock.expect(entityType.getKeyProperties()).andStubReturn(getLocalKeyProperties());

      EasyMock.replay(entityType);
      EasyMock.expect(entitySet.getEntityType()).andStubReturn(entityType);
      EasyMock.replay(entitySet);

      EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
      if (orderByIsNull) {
        EasyMock.expect(resultsView.getOrderBy()).andStubReturn(null);
      } else {
        EasyMock.expect(resultsView.getOrderBy()).andStubReturn(orderBy);
      }
      if (selectFieldsIsNull) {
        EasyMock.expect(resultsView.getSelect()).andStubReturn(null);
      } else {
        EasyMock.expect(resultsView.getSelect()).andStubReturn(selectItemList);
      }
      // FilterExpression filterExpression =
      // EasyMock.createMock(FilterExpression.class);
      // EasyMock.expect(filterExpression.g)
      if (filterIsNull) {
        EasyMock.expect(resultsView.getFilter()).andStubReturn(null);
      } else {
        EasyMock.expect(resultsView.getFilter()).andStubReturn(
            getFilterExpressionMockedObj(ExpressionKind.PROPERTY, "SalesOrder"));
      }
      if (isTopNull) {
        EasyMock.expect(resultsView.getTop()).andStubReturn(null);
      } else {
        EasyMock.expect(resultsView.getTop()).andStubReturn(10);
      }
      if (isSkipNull) {
        EasyMock.expect(resultsView.getSkip()).andStubReturn(null);
      } else {
        EasyMock.expect(resultsView.getSkip()).andStubReturn(0);
      }
      EasyMock.expect(resultsView.getKeyPredicates()).andStubReturn(keyPredicates);
      EasyMock.replay(resultsView);

    } catch (EdmException e1) {
      fail("Exception not Expected");
    }
View Full Code Here

public class JPQLBuilderFactoryTest {

  @Test
  public void testGetStatementBuilderFactoryforSelect() throws ODataException {

    GetEntitySetUriInfo getEntitySetView = getUriInfo();

    // Build JPQL Context
    JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.SELECT, getEntitySetView).build();
    JPQLStatementBuilder statementBuilder =
        new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
View Full Code Here

  }

  @Test
  public void testGetStatementBuilderFactoryforJoinSelect() throws ODataException {

    GetEntitySetUriInfo getEntitySetView = getUriInfo();

    // Build JPQL Context
    JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.JOIN, getEntitySetView).build();
    JPQLStatementBuilder statementBuilder =
        new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
View Full Code Here

    assertTrue(contextBuilder instanceof JPQLSelectSingleContextBuilder);

  }

  private GetEntitySetUriInfo getUriInfo() throws EdmException {
    GetEntitySetUriInfo getEntitySetView = EasyMock.createMock(GetEntitySetUriInfo.class);
    EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
    EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
    EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
    EasyMock.expect(edmEntityType.getName()).andStubReturn("SOItem");
    EasyMock.replay(edmEntityType);
    OrderByExpression orderByExpression = EasyMock.createMock(OrderByExpression.class);
    EasyMock.expect(getEntitySetView.getTargetEntitySet()).andStubReturn(edmEntitySet);
    EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
    EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
    EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
    EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
    EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
    EasyMock.expect(getEntitySetView.getStartEntitySet()).andStubReturn(startEdmEntitySet);
    EasyMock.replay(startEdmEntityType, startEdmEntitySet);
    EasyMock.expect(getEntitySetView.getOrderBy()).andStubReturn(orderByExpression);
    EasyMock.expect(getEntitySetView.getSelect()).andStubReturn(null);
    EasyMock.expect(getEntitySetView.getFilter()).andStubReturn(null);
    List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
    EasyMock.expect(getEntitySetView.getNavigationSegments()).andStubReturn(navigationSegments);
    KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
    EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
    EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
    EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
    EasyMock.expect(edmMapping.getInternalName()).andStubReturn("Field1");
    EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
    try {
      EasyMock.expect(kpProperty.getName()).andStubReturn("Field1");
      EasyMock.expect(kpProperty.getType()).andStubReturn(edmType);

      EasyMock.expect(kpProperty.getMapping()).andStubReturn(edmMapping);

    } catch (EdmException e2) {
      fail("this should not happen");
    }
    EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
    EasyMock.replay(edmMapping, edmType, kpProperty, keyPredicate);
    List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
    keyPredicates.add(keyPredicate);
    EasyMock.expect(getEntitySetView.getKeyPredicates()).andStubReturn(keyPredicates);
    EasyMock.replay(getEntitySetView);
    EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
    EasyMock.replay(edmEntitySet);
    return getEntitySetView;
  }
View Full Code Here

  /*
   * This Unit is supposed to test the building of Entity Provider Properties for query with $expand
   */
  @Test
  public void testGetEntityProviderPropertiesQuery() {
    GetEntitySetUriInfo getEntitySetUriInfo = mockEntitySetUriInfoForExpand();
    ODataJPAContext oDataJPAContext = getODataJPAContext();
    // Building the edm entity
    List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
    Map<String, Object> edmEntity = new HashMap<String, Object>();
    edmEntity.put("ID", 1);
View Full Code Here

    }
    return uri;
  }

  private GetEntitySetUriInfo getResultsView() {
    GetEntitySetUriInfo objGetEntitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
    EasyMock.expect(objGetEntitySetUriInfo.getInlineCount()).andStubReturn(getLocalInlineCount());
    EasyMock.expect(objGetEntitySetUriInfo.getTargetEntitySet()).andStubReturn(getLocalTargetEntitySet());
    EasyMock.expect(objGetEntitySetUriInfo.getSelect()).andStubReturn(getSelectItemList());
    EasyMock.expect(objGetEntitySetUriInfo.getExpand()).andStubReturn(getExpandList());
    EasyMock.expect(objGetEntitySetUriInfo.getSkip()).andStubReturn(new Integer(1));
    EasyMock.replay(objGetEntitySetUriInfo);
    return objGetEntitySetUriInfo;
  }
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo

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.