Skip to content

Commit

Permalink
Integ-test
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Kwok <[email protected]>
  • Loading branch information
andy-k-improving committed Feb 3, 2025
1 parent 0fcd688 commit 898d3a6
Showing 1 changed file with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,65 @@ public void testTrendlineWithSort() throws IOException {
TEST_INDEX_BANK));
verifyDataRows(result, rows(new Object[] {null}), rows(44313.0), rows(39882.5));
}

@Test
public void testTrendlineWma() throws IOException {
final JSONObject result =
executeQuery(
String.format(
"source=%s | where balance > 39000 | sort balance | trendline wma(2, balance) as"
+ " balance_trend | fields balance_trend",
TEST_INDEX_BANK));
System.out.println("Result (Base): " + result.toString());
verifyDataRows(result, rows(new Object[] {null}), rows(45570.666666666664), rows(40101.666666666664));
}

@Test
public void testTrendlineMultipleFieldsWma() throws IOException {
final JSONObject result =
executeQuery(
String.format(
"source=%s | where balance > 39000 | sort balance | trendline wma(2, balance) as"
+ " balance_trend wma(2, account_number) as account_number_trend | fields"
+ " balance_trend, account_number_trend",
TEST_INDEX_BANK));
verifyDataRows(result, rows(null, null),
rows(40101.666666666664,16.999999999999996),
rows(45570.666666666664,29.666666666666664));
}

@Test
public void testTrendlineOverwritesExistingFieldWma() throws IOException {
final JSONObject result =
executeQuery(
String.format(
"source=%s | where balance > 39000 | sort balance | trendline wma(2, balance) as"
+ " age | fields age",
TEST_INDEX_BANK));
System.out.println("Result (Overwrite) : " + result.toString());
verifyDataRows(result, rows(new Object[] {null}), rows(40101.666666666664), rows(45570.666666666664));
}

@Test
public void testTrendlineNoAliasWma() throws IOException {
final JSONObject result =
executeQuery(
String.format(
"source=%s | where balance > 39000 | sort balance | trendline wma(2, balance) |"
+ " fields balance_trendline",
TEST_INDEX_BANK));
verifyDataRows(result, rows(new Object[] {null}), rows(40101.666666666664), rows(45570.666666666664));
}

@Test
public void testTrendlineWithSortWma() throws IOException {
final JSONObject result =
executeQuery(
String.format(
"source=%s | where balance > 39000 | trendline sort balance wma(2, balance) |"
+ " fields balance_trendline",
TEST_INDEX_BANK));
System.out.println("Result (WithSortWma): " + result.toString());
verifyDataRows(result, rows(new Object[] {null}), rows(40101.666666666664), rows(45570.666666666664));
}
}

0 comments on commit 898d3a6

Please sign in to comment.