@Test public void testCompound() { // test AND assertTrue( eval( builder .and( builder.profileProperty("properties.gender").equalTo("female"), builder.profileProperty("properties.age").equalTo(Integer.valueOf(30))) .build())); assertFalse( eval( builder .and( builder.profileProperty("properties.gender").equalTo("male"), builder.profileProperty("properties.age").equalTo(Integer.valueOf(30))) .build())); assertFalse( eval( builder .and( builder.profileProperty("properties.gender").equalTo("female"), builder.profileProperty("properties.age").equalTo(Integer.valueOf(40))) .build())); // test OR assertTrue( eval( builder .or( builder.profileProperty("properties.gender").equalTo("female"), builder.profileProperty("properties.age").equalTo(Integer.valueOf(40))) .build())); assertTrue( eval( builder .or( builder.profileProperty("properties.gender").equalTo("male"), builder.profileProperty("properties.age").equalTo(Integer.valueOf(30))) .build())); assertFalse( eval( builder .or( builder.profileProperty("properties.gender").equalTo("male"), builder.profileProperty("properties.age").equalTo(Integer.valueOf(40))) .build())); // test NOT assertTrue( eval(builder.not(builder.profileProperty("properties.gender").equalTo("male")).build())); assertFalse( eval( builder .not(builder.profileProperty("properties.age").equalTo(Integer.valueOf(30))) .build())); }
@Test public void testInteger() { assertTrue( eval(builder.profileProperty("properties.age").equalTo(Integer.valueOf(30)).build())); assertTrue( eval( builder .not(builder.profileProperty("properties.age").equalTo(Integer.valueOf(40))) .build())); assertTrue( eval(builder.profileProperty("properties.age").notEqualTo(Integer.valueOf(40)).build())); assertTrue( eval(builder.profileProperty("properties.age").lessThan(Integer.valueOf(40)).build())); assertTrue( eval(builder.profileProperty("properties.age").greaterThan(Integer.valueOf(20)).build())); assertTrue( eval( builder .profileProperty("properties.age") .greaterThanOrEqualTo(Integer.valueOf(30)) .build())); assertFalse( eval( builder .profileProperty("properties.age") .greaterThanOrEqualTo(Integer.valueOf(31)) .build())); assertTrue(eval(builder.profileProperty("properties.age").in(Integer.valueOf(30)).build())); assertTrue( eval( builder .profileProperty("properties.age") .in(Integer.valueOf(31), Integer.valueOf(30)) .build())); assertTrue( eval( builder .profileProperty("properties.age") .notIn(Integer.valueOf(25), Integer.valueOf(26)) .build())); assertFalse( eval( builder .profileProperty("properties.age") .notIn(Integer.valueOf(25), Integer.valueOf(30)) .build())); }
@Test public void testString() { assertTrue(eval(builder.profileProperty("properties.gender").equalTo("female").build())); assertFalse( eval(builder.not(builder.profileProperty("properties.gender").equalTo("female")).build())); assertTrue(eval(builder.profileProperty("properties.gender").notEqualTo("male").build())); // // assertFalse(eval(builder.not(builder.profileProperty("properties.gender").notEqualTo("male")).build())); assertTrue(eval(builder.profileProperty("properties.gender").startsWith("fe").build())); assertTrue(eval(builder.profileProperty("properties.gender").endsWith("le").build())); assertTrue(eval(builder.profileProperty("properties.gender").contains("fem").build())); assertFalse(eval(builder.profileProperty("properties.gender").contains("mu").build())); assertTrue(eval(builder.profileProperty("properties.gender").matchesRegex(".*ale").build())); assertTrue(eval(builder.profileProperty("properties.gender").in("male", "female").build())); assertTrue(eval(builder.profileProperty("properties.gender").notIn("one", "two").build())); assertFalse( eval(builder.profileProperty("properties.gender").notIn("one", "two", "female").build())); assertTrue(eval(builder.profileProperty("properties.gender").all("female").build())); // assertFalse(eval(builder.profileProperty("properties.gender").all("male", // "female").build())); }