test_class.file: framework/db/src/test/java/com/cloud/utils/db/FilterTest.java
test_class.identifier: FilterTest
test_case.body: @Test
      /*
      *  This test verifies that the Order By clause generated by the filter is correct and it separates each
      *  order by field with a comma. Using DbTestVO to assert it
      */
      public void testAddOrderBy() {
          Filter filter = new Filter(DbTestVO.class, "fieldString", true, 1L, 1L);
  
          Assert.assertTrue(filter.getOrderBy().trim().toLowerCase().equals("order by test.fld_string asc"));
  
          filter.addOrderBy(DbTestVO.class, "fieldLong", true);
  
          Assert.assertTrue(filter.getOrderBy().contains(","));
          Assert.assertTrue(filter.getOrderBy().split(",")[1].trim().toLowerCase().equals("test.fld_long asc"));
  
          filter.addOrderBy(DbTestVO.class, "fieldInt", true);
  
          Assert.assertTrue(filter.getOrderBy().split(",").length == 3);
          Assert.assertTrue(filter.getOrderBy().split(",")[2].trim().toLowerCase().equals("test.fld_int asc"));
      }
test_case.class_method_signature: FilterTest.testAddOrderBy()
test_case.full_signature: @Test /* * This test verifies that the Order By clause generated by the filter is correct and it separates each * order by field with a comma. Using DbTestVO to assert it */ public void testAddOrderBy()
test_case.identifier: testAddOrderBy
test_case.invocations: assertTrue equals toLowerCase trim getOrderBy addOrderBy assertTrue contains getOrderBy assertTrue equals toLowerCase trim split getOrderBy addOrderBy assertTrue split getOrderBy assertTrue equals toLowerCase trim split getOrderBy
test_case.modifiers: @Test /* * This test verifies that the Order By clause generated by the filter is correct and it separates each * order by field with a comma. Using DbTestVO to assert it */ public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testAddOrderBy()
focal_class.declarator: _offset
focal_class.original_string: Long _offset;
focal_class.type: Long
focal_class.var_name: _offset
focal_class.declarator: _limit
focal_class.original_string: Long _limit;
focal_class.type: Long
focal_class.var_name: _limit
focal_class.declarator: _orderBy
focal_class.original_string: String _orderBy;
focal_class.type: String
focal_class.var_name: _orderBy
focal_class.file: framework/db/src/main/java/com/cloud/utils/db/Filter.java
focal_class.identifier: Filter
focal_class.class_method_signature: Filter.Filter(Class<?> clazz, String field, boolean ascending, Long offset, Long limit)
focal_class.full_signature: public  Filter(Class<?> clazz, String field, boolean ascending, Long offset, Long limit)
focal_class.identifier: Filter
focal_class.modifiers: public
focal_class.parameters: (Class<?> clazz, String field, boolean ascending, Long offset, Long limit)
focal_class.signature:  Filter(Class<?> clazz, String field, boolean ascending, Long offset, Long limit)
focal_class.class_method_signature: Filter.Filter(long limit)
focal_class.full_signature: public  Filter(long limit)
focal_class.identifier: Filter
focal_class.modifiers: public
focal_class.parameters: (long limit)
focal_class.signature:  Filter(long limit)
focal_class.class_method_signature: Filter.Filter(Filter that)
focal_class.full_signature: public  Filter(Filter that)
focal_class.identifier: Filter
focal_class.modifiers: public
focal_class.parameters: (Filter that)
focal_class.signature:  Filter(Filter that)
focal_class.class_method_signature: Filter.addOrderBy(Class<?> clazz, String field, boolean ascending)
focal_class.full_signature: public void addOrderBy(Class<?> clazz, String field, boolean ascending)
focal_class.identifier: addOrderBy
focal_class.modifiers: public
focal_class.parameters: (Class<?> clazz, String field, boolean ascending)
focal_class.return: void
focal_class.signature: void addOrderBy(Class<?> clazz, String field, boolean ascending)
focal_class.class_method_signature: Filter.getOrderBy()
focal_class.full_signature: public String getOrderBy()
focal_class.identifier: getOrderBy
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getOrderBy()
focal_class.class_method_signature: Filter.setOffset(Long offset)
focal_class.full_signature: public void setOffset(Long offset)
focal_class.identifier: setOffset
focal_class.modifiers: public
focal_class.parameters: (Long offset)
focal_class.return: void
focal_class.signature: void setOffset(Long offset)
focal_class.class_method_signature: Filter.getOffset()
focal_class.full_signature: public Long getOffset()
focal_class.identifier: getOffset
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Long
focal_class.signature: Long getOffset()
focal_class.class_method_signature: Filter.getLimit()
focal_class.full_signature: public Long getLimit()
focal_class.identifier: getLimit
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Long
focal_class.signature: Long getLimit()
focal_class.class_method_signature: Filter.setLimit(Long limit)
focal_class.full_signature: public void setLimit(Long limit)
focal_class.identifier: setLimit
focal_class.modifiers: public
focal_class.parameters: (Long limit)
focal_class.return: void
focal_class.signature: void setLimit(Long limit)
focal_method.body: public void addOrderBy(Class<?> clazz, String field, boolean ascending) {
          if (field == null) {
              return;
          }
          Field f;
          Pair<Class<?>, Field> pair = ReflectUtil.getAnyField(clazz, field);
          assert (pair != null) : "Can't find field " + field + " in " + clazz.getName();
          clazz = pair.first();
          f = pair.second();
  
          Column column = f.getAnnotation(Column.class);
          String name = column != null ? column.name() : field;
  
          StringBuilder order = new StringBuilder();
          if (column == null || column.table() == null || column.table().length() == 0) {
              order.append(DbUtil.getTableName(clazz));
          } else {
              order.append(column.table());
          }
          order.append(".").append(name).append(ascending ? " ASC " : " DESC ");
  
          if (_orderBy == null) {
              _orderBy = order.insert(0, " ORDER BY ").toString();
          } else {
              _orderBy = order.insert(0, _orderBy + ", ").toString();
          }
      }
focal_method.class_method_signature: Filter.addOrderBy(Class<?> clazz, String field, boolean ascending)
focal_method.full_signature: public void addOrderBy(Class<?> clazz, String field, boolean ascending)
focal_method.identifier: addOrderBy
focal_method.invocations: getAnyField getName first second getAnnotation name table length table append getTableName append table append append append toString insert toString insert
focal_method.modifiers: public
focal_method.parameters: (Class<?> clazz, String field, boolean ascending)
focal_method.return: void
focal_method.signature: void addOrderBy(Class<?> clazz, String field, boolean ascending)