Search in sources :

Example 11 with Function

use of com.srotya.sidewinder.core.functions.list.Function in project sidewinder by srotya.

the class TestTransformFunctions method testCube.

@Test
public void testCube() {
    Function f = new CubeFunction();
    List<SeriesOutput> series = new ArrayList<>();
    SeriesOutput s = new SeriesOutput(Arrays.asList(new DataPoint(1L, 3), new DataPoint(1L, 4)));
    series.add(s);
    List<SeriesOutput> apply = f.apply(series);
    assertEquals(2, apply.get(0).getDataPoints().size());
    assertEquals(27, apply.get(0).getDataPoints().get(0).getLongValue());
    assertEquals(64, apply.get(0).getDataPoints().get(1).getLongValue());
}
Also used : Function(com.srotya.sidewinder.core.functions.list.Function) DataPoint(com.srotya.sidewinder.core.storage.DataPoint) ArrayList(java.util.ArrayList) SeriesOutput(com.srotya.sidewinder.core.storage.SeriesOutput) Test(org.junit.Test)

Aggregations

Function (com.srotya.sidewinder.core.functions.list.Function)11 DataPoint (com.srotya.sidewinder.core.storage.DataPoint)10 SeriesOutput (com.srotya.sidewinder.core.storage.SeriesOutput)7 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 BadRequestException (javax.ws.rs.BadRequestException)4 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 ComplexTagFilter (com.srotya.sidewinder.core.filters.ComplexTagFilter)2 SimpleTagFilter (com.srotya.sidewinder.core.filters.SimpleTagFilter)2 TagFilter (com.srotya.sidewinder.core.filters.TagFilter)2 FunctionIteratorFactory (com.srotya.sidewinder.core.functions.iterative.FunctionIteratorFactory)2 ChainFunction (com.srotya.sidewinder.core.functions.list.ChainFunction)2 ByteString (com.srotya.sidewinder.core.storage.ByteString)2 ItemNotFoundException (com.srotya.sidewinder.core.storage.ItemNotFoundException)2 InvalidFilterException (com.srotya.sidewinder.core.utils.InvalidFilterException)2 IOException (java.io.IOException)2 NotFoundException (javax.ws.rs.NotFoundException)2 JsonElement (com.google.gson.JsonElement)1 TargetSeries (com.srotya.sidewinder.core.api.grafana.TargetSeries)1