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

Examples of org.apache.olingo.odata2.api.uri.expression.UnaryExpression


  }

  @Test
  public void testParseUnaryExpression() {

    UnaryExpression unaryExpression =
        getUnaryExpressionMockedObj(getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, "deliveryStatus"),
            org.apache.olingo.odata2.api.uri.expression.UnaryOperator.NOT);
    try {
      assertEquals(EXPECTED_STR_11, ODataExpressionParser.parseToJPAWhereExpression(unaryExpression, TABLE_ALIAS));
    } catch (ODataException e) {
View Full Code Here


  }

  private UnaryExpression
      getUnaryExpressionMockedObj(final CommonExpression operand, final UnaryOperator unaryOperator) {
    UnaryExpression unaryExpression = EasyMock.createMock(UnaryExpression.class);
    EasyMock.expect(unaryExpression.getKind()).andStubReturn(ExpressionKind.UNARY);
    EasyMock.expect(unaryExpression.getOperand()).andStubReturn(operand);
    EasyMock.expect(unaryExpression.getOperator()).andStubReturn(unaryOperator);

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

  }

  private static <T> String evaluateExpression(final T data, final CommonExpression expression) throws ODataException {
    switch (expression.getKind()) {
    case UNARY:
      final UnaryExpression unaryExpression = (UnaryExpression) expression;
      final String operand = evaluateExpression(data, unaryExpression.getOperand());

      switch (unaryExpression.getOperator()) {
      case NOT:
        return Boolean.toString(!Boolean.parseBoolean(operand));
      case MINUS:
        return operand.startsWith("-") ? operand.substring(1) : "-" + operand;
      default:
View Full Code Here

  }

  @Test
  public void testParseUnaryExpression() {

    UnaryExpression unaryExpression =
        getUnaryExpressionMockedObj(getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, "deliveryStatus"),
            org.apache.olingo.odata2.api.uri.expression.UnaryOperator.NOT);
    try {
      assertEquals(EXPECTED_STR_11, ODataExpressionParser.parseToJPAWhereExpression(unaryExpression, TABLE_ALIAS));
    } catch (ODataException e) {
View Full Code Here

  }

  private UnaryExpression
      getUnaryExpressionMockedObj(final CommonExpression operand, final UnaryOperator unaryOperator) {
    UnaryExpression unaryExpression = EasyMock.createMock(UnaryExpression.class);
    EasyMock.expect(unaryExpression.getKind()).andStubReturn(ExpressionKind.UNARY);
    EasyMock.expect(unaryExpression.getOperand()).andStubReturn(operand);
    EasyMock.expect(unaryExpression.getOperator()).andStubReturn(unaryOperator);

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

  protected CommonExpression readUnaryoperator(final Token lookToken, final InfoUnaryOperator unaryOperator)
      throws ExpressionParserException, ExpressionParserInternalError {
    tokenList.expectToken(lookToken.getUriLiteral(), true);

    CommonExpression operand = readElement(null);
    UnaryExpression unaryExpression = new UnaryExpressionImpl(unaryOperator, operand);
    validateUnaryOperatorTypes(unaryExpression); // throws ExpressionInvalidOperatorTypeException

    return unaryExpression;
  }
View Full Code Here

  public static String parseToJPAWhereExpression(final CommonExpression whereExpression, final String tableAlias)
      throws ODataException {
    switch (whereExpression.getKind()) {
    case UNARY:
      final UnaryExpression unaryExpression = (UnaryExpression) whereExpression;
      final String operand = parseToJPAWhereExpression(unaryExpression.getOperand(), tableAlias);

      switch (unaryExpression.getOperator()) {
      case NOT:
        return JPQLStatement.Operator.NOT + "(" + operand + ")"; //$NON-NLS-1$ //$NON-NLS-2$
      case MINUS:
        if (operand.startsWith("-")) {
          return operand.substring(1);
View Full Code Here

  }

  private <T> String evaluateExpression(final T data, final CommonExpression expression) throws ODataException {
    switch (expression.getKind()) {
    case UNARY:
      final UnaryExpression unaryExpression = (UnaryExpression) expression;
      final String operand = evaluateExpression(data, unaryExpression.getOperand());

      switch (unaryExpression.getOperator()) {
      case NOT:
        return Boolean.toString(!Boolean.parseBoolean(operand));
      case MINUS:
        return operand.startsWith("-") ? operand.substring(1) : "-" + operand;
      default:
View Full Code Here

  }

  private <T> String evaluateExpression(final T data, final CommonExpression expression) throws ODataException {
    switch (expression.getKind()) {
    case UNARY:
      final UnaryExpression unaryExpression = (UnaryExpression) expression;
      final String operand = evaluateExpression(data, unaryExpression.getOperand());

      switch (unaryExpression.getOperator()) {
      case NOT:
        return Boolean.toString(!Boolean.parseBoolean(operand));
      case MINUS:
        return operand.startsWith("-") ? operand.substring(1) : "-" + operand;
      default:
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

TOP

Related Classes of org.apache.olingo.odata2.api.uri.expression.UnaryExpression

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.