コード例 #1
0
  @Test
  public void returnColumnsTest() throws Exception {
    Query q = new Query();
    List<String> reqCols = new ArrayList<>();
    reqCols.add("ABC");
    reqCols.add("DEF");
    reqCols.add("GHI");
    reqCols.add("JKL");
    q.setRequestedColumns(reqCols);

    QueryAtom maintable = new QueryAtom();
    maintable.setIntent(IntentType.PERSON);

    q.setPrimaryQuery(maintable);

    EzSecurityToken token = MockEzSecurityToken.getMockAppToken("test", "test");
    String res = qgImpl.generateSQLString(q, token);

    assertTrue(res.startsWith("SELECT ABC,DEF,GHI,JKL FROM testapp_PERSON WHERE secuuid = '"));
  }
コード例 #2
0
  @Test
  public void binaryPredicatesAndTest() throws Exception {
    Query q = new Query();
    List<String> reqCols = new ArrayList<String>();
    reqCols.add("ABC");
    reqCols.add("DEF");
    reqCols.add("GHI");
    reqCols.add("JKL");
    q.setRequestedColumns(reqCols);

    QueryAtom maintable = new QueryAtom();
    maintable.setIntent(IntentType.PERSON);

    Predicate predicate = new Predicate();
    BinaryPredicate bpredicate = new BinaryPredicate();
    bpredicate.setColumnName("PRED1");
    bpredicate.setBinaryOperator(BinaryOperator.EQ);

    ColumnValue cv = new ColumnValue();
    cv.setStringValue("somestring");
    bpredicate.setValue(cv);
    predicate.setBinaryPredicate(bpredicate);

    Predicate predicate1 = new Predicate();
    BinaryPredicate bpredicate1 = new BinaryPredicate();
    bpredicate1.setColumnName("PRED2");
    bpredicate1.setBinaryOperator(BinaryOperator.GT);

    ColumnValue cv1 = new ColumnValue();
    cv1.setDoubleValue(1000000);
    bpredicate1.setValue(cv1);

    predicate1.setBinaryPredicate(bpredicate1);

    Predicate predicate2 = new Predicate();
    BinaryPredicate bpredicate2 = new BinaryPredicate();
    bpredicate2.setColumnName("PRED3");
    bpredicate2.setBinaryOperator(BinaryOperator.NE);

    ColumnValue cv2 = new ColumnValue();
    cv2.setBoolValue(false);
    bpredicate2.setValue(cv2);

    predicate2.setBinaryPredicate(bpredicate2);

    List<List<Predicate>> predicateList = new ArrayList<>();

    List<Predicate> predicates = new ArrayList<>();
    predicates.add(predicate);
    predicateList.add(predicates);

    List<Predicate> predicates1 = new ArrayList<>();
    predicates1.add(predicate1);
    predicateList.add(predicates1);

    List<Predicate> predicates2 = new ArrayList<>();
    predicates2.add(predicate2);
    predicateList.add(predicates2);

    maintable.setPredicates(predicateList);

    q.setPrimaryQuery(maintable);

    EzSecurityToken token = MockEzSecurityToken.getMockAppToken("test", "test");
    String res = qgImpl.generateSQLString(q, token);

    assertTrue(
        res.startsWith(
            "SELECT ABC,DEF,GHI,JKL FROM testapp_PERSON WHERE PRED1 = 'somestring' AND PRED2 > 1000000.0 "
                + "AND PRED3 != false AND secuuid = '"));
  }