package io.featureflow.client;

import com.google.gson.JsonPrimitive;
import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Created by oliver on 21/11/16.
 */
public class OperatorTest {
    @Test
    public void evaluateOperators() throws Exception {
        assertTrue(Operator.after.evaluate(new JsonPrimitive("2016-11-20T20:36:19Z"), new JsonPrimitive("2016-11-20T20:36:18Z")));
        assertTrue(Operator.before.evaluate(new JsonPrimitive("2016-11-20T20:36:18Z"), new JsonPrimitive("2016-11-20T20:36:19Z")));
        assertTrue(Operator.contains.evaluate(new JsonPrimitive("oliver"), new JsonPrimitive("liver")));
        assertTrue(Operator.endsWith.evaluate(new JsonPrimitive("oliver"), new JsonPrimitive("liver")));
        assertTrue(Operator.startsWith.evaluate(new JsonPrimitive("oliver"), new JsonPrimitive("oli")));
        assertTrue(Operator.contains.evaluate(new JsonPrimitive("oliver"), new JsonPrimitive("live")));
        assertTrue(Operator.equals.evaluate(new JsonPrimitive("oliver"), new JsonPrimitive("oliver")));
        assertTrue(Operator.greaterThan.evaluate(new JsonPrimitive(1d), new JsonPrimitive(0.999d)));
        assertTrue(Operator.greaterThanOrEqual.evaluate(new JsonPrimitive(1d), new JsonPrimitive(0.999d)));
        assertTrue(Operator.greaterThanOrEqual.evaluate(new JsonPrimitive(1d), new JsonPrimitive(1d)));
        assertTrue(Operator.greaterThan.evaluate(new JsonPrimitive(1d), new JsonPrimitive(0.999d)));
        assertTrue(Operator.lessThanOrEqual.evaluate(new JsonPrimitive(0.999d), new JsonPrimitive(1d)));
        assertTrue(Operator.lessThanOrEqual.evaluate(new JsonPrimitive(1d), new JsonPrimitive(1d)));
        assertTrue(Operator.lessThanOrEqual.evaluate(new JsonPrimitive(1d), new JsonPrimitive(1d)));
        assertTrue(Operator.matches.evaluate(new JsonPrimitive("oliver@featureflow.io"), new JsonPrimitive( "^(oliver).*$")));

    }

}
@@ -83,24 +83,50 @@
 unit.Test;%0A%0A
+import java.util.Arrays;%0A%0A
 import stati
@@ -147,16 +147,16 @@
 sert.*;%0A
-
 %0A/**%0A * 
@@ -365,24 +365,38 @@
 0:36:19Z%22), 
+Arrays.asList(
 new JsonPrim
@@ -422,24 +422,25 @@
 0:36:18Z%22)))
+)
 ;%0A        as
@@ -512,24 +512,38 @@
 0:36:18Z%22), 
+Arrays.asList(
 new JsonPrim
@@ -569,24 +569,25 @@
 0:36:19Z%22)))
+)
 ;%0A        as
@@ -643,32 +643,46 @@
 tive(%22oliver%22), 
+Arrays.asList(
 new JsonPrimitiv
@@ -685,32 +685,33 @@
 itive(%22liver%22)))
+)
 ;%0A        assert
@@ -763,32 +763,46 @@
 tive(%22oliver%22), 
+Arrays.asList(
 new JsonPrimitiv
@@ -805,32 +805,33 @@
 itive(%22liver%22)))
+)
 ;%0A        assert
@@ -885,32 +885,46 @@
 tive(%22oliver%22), 
+Arrays.asList(
 new JsonPrimitiv
@@ -929,24 +929,25 @@
 ive(%22oli%22)))
+)
 ;%0A        as
@@ -1003,32 +1003,46 @@
 tive(%22oliver%22), 
+Arrays.asList(
 new JsonPrimitiv
@@ -1048,24 +1048,25 @@
 ve(%22live%22)))
+)
 ;%0A        as
@@ -1124,24 +1124,38 @@
 (%22oliver%22), 
+Arrays.asList(
 new JsonPrim
@@ -1171,16 +1171,17 @@
 iver%22)))
+)
 ;%0A      
@@ -1238,32 +1238,46 @@
 nPrimitive(1d), 
+Arrays.asList(
 new JsonPrimitiv
@@ -1279,32 +1279,33 @@
 mitive(0.999d)))
+)
 ;%0A        assert
@@ -1361,32 +1361,46 @@
 nPrimitive(1d), 
+Arrays.asList(
 new JsonPrimitiv
@@ -1402,32 +1402,33 @@
 mitive(0.999d)))
+)
 ;%0A        assert
@@ -1484,32 +1484,46 @@
 nPrimitive(1d), 
+Arrays.asList(
 new JsonPrimitiv
@@ -1521,32 +1521,33 @@
 nPrimitive(1d)))
+)
 ;%0A        assert
@@ -1596,32 +1596,46 @@
 nPrimitive(1d), 
+Arrays.asList(
 new JsonPrimitiv
@@ -1641,24 +1641,25 @@
 ve(0.999d)))
+)
 ;%0A        as
@@ -1724,24 +1724,38 @@
 ve(0.999d), 
+Arrays.asList(
 new JsonPrim
@@ -1757,32 +1757,33 @@
 nPrimitive(1d)))
+)
 ;%0A        assert
@@ -1836,32 +1836,46 @@
 nPrimitive(1d), 
+Arrays.asList(
 new JsonPrimitiv
@@ -1873,32 +1873,33 @@
 nPrimitive(1d)))
+)
 ;%0A        assert
@@ -1960,16 +1960,30 @@
 ve(1d), 
+Arrays.asList(
 new Json
@@ -1997,16 +1997,17 @@
 ve(1d)))
+)
 ;%0A      
@@ -2089,16 +2089,30 @@
 w.io%22), 
+Arrays.asList(
 new Json
@@ -2139,16 +2139,17 @@
 ).*$%22)))
+)
 ;%0A%0A    %7D

Update condition values to array