-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from lensesio/feat/NGN-1216_DocumentUdfInstalla…
…tion NGN-1216: Added test example for udafs
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.lenses.sql.udaf; | ||
|
||
import io.lenses.sql.udf.UdfException; | ||
import io.lenses.sql.udf.datatype.DataType; | ||
import io.lenses.sql.udf.value.LongValue; | ||
import io.lenses.sql.udf.value.Value; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class count_doubleTest { | ||
private count_double func = new count_double(); | ||
|
||
@Test | ||
public void typesTheUdaf() throws UdfException { | ||
assertTrue(func.typer(DataType.ltDouble()).isLong()); | ||
assertTrue(func.typer(DataType.ltFloat()).isLong()); | ||
assertTrue(func.typer(DataType.ltInt()).isLong()); | ||
assertTrue(func.typer(DataType.ltLong()).isLong()); | ||
|
||
assertTrue(func.typer(DataType.ltOptional(DataType.ltDouble())).isLong()); | ||
assertTrue(func.typer(DataType.ltOptional(DataType.ltFloat())).isLong()); | ||
assertTrue(func.typer(DataType.ltOptional(DataType.ltInt())).isLong()); | ||
assertTrue(func.typer(DataType.ltOptional(DataType.ltLong())).isLong()); | ||
} | ||
|
||
@Test | ||
public void correctlyCalculatesEmpty() throws UdfException { | ||
assertEquals(func.empty().get(), 0L); | ||
} | ||
|
||
@Test | ||
public void correctlyAddsElements() throws UdfException { | ||
Value added1 = func.add(func.empty(), func.empty(), null); | ||
assertEquals(added1.get(), 2L); | ||
} | ||
|
||
@Test | ||
public void correctlyMergesElements() throws UdfException { | ||
Value merge = func.merge(null, new LongValue(3), new LongValue(2)); | ||
assertEquals(merge.get(), 5L); | ||
} | ||
|
||
|
||
} |