@@ -57,6 +57,21 @@ public void initialize() {
5757 testTypedUserAttributes .put ("null_val" , null );
5858 }
5959
60+ @ Test
61+ public void nullConditionTest () throws Exception {
62+ NullCondition nullCondition = new NullCondition ();
63+ assertEquals (null , nullCondition .toJson ());
64+ assertEquals (null , nullCondition .getOperandOrId ());
65+ }
66+
67+ @ Test
68+ public void emptyConditionTest () throws Exception {
69+ EmptyCondition emptyCondition = new EmptyCondition ();
70+ assertEquals (null , emptyCondition .toJson ());
71+ assertEquals (null , emptyCondition .getOperandOrId ());
72+ assertEquals (true , emptyCondition .evaluate (null , null ));
73+ }
74+
6075 /**
6176 * Verify that UserAttribute.toJson returns a json represented string of conditions.
6277 */
@@ -67,11 +82,14 @@ public void userAttributeConditionsToJson() throws Exception {
6782 assertEquals (testInstance .toJson (), expectedConditionJsonString );
6883 }
6984
85+ /**
86+ * Verify that AndCondition.toJson returns a json represented string of conditions.
87+ */
7088 @ Test
71- public void userAttributeConditionsToJsonWithComma () throws Exception {
89+ public void andConditionsToJsonWithComma () throws Exception {
7290 UserAttribute testInstance1 = new UserAttribute ("browser_type" , "custom_attribute" , "true" , "safari" );
7391 UserAttribute testInstance2 = new UserAttribute ("browser_type" , "custom_attribute" , "true" , "safari" );
74- String expectedConditionJsonString = "[\" and\" [\" or\" {\" name\" :\" browser_type\" , \" type\" :\" custom_attribute\" , \" match\" :\" true\" , \" value\" :\" safari\" }, {\" name\" :\" browser_type\" , \" type\" :\" custom_attribute\" , \" match\" :\" true\" , \" value\" :\" safari\" }]]" ;
92+ String expectedConditionJsonString = "[\" and\" , [\" or\" , {\" name\" :\" browser_type\" , \" type\" :\" custom_attribute\" , \" match\" :\" true\" , \" value\" :\" safari\" }, {\" name\" :\" browser_type\" , \" type\" :\" custom_attribute\" , \" match\" :\" true\" , \" value\" :\" safari\" }]]" ;
7593 List <Condition > userConditions = new ArrayList <>();
7694 userConditions .add (testInstance1 );
7795 userConditions .add (testInstance2 );
@@ -82,6 +100,23 @@ public void userAttributeConditionsToJsonWithComma() throws Exception {
82100 assertEquals (andCondition .toJson (), expectedConditionJsonString );
83101 }
84102
103+ /**
104+ * Verify that orCondition.toJson returns a json represented string of conditions.
105+ */
106+ @ Test
107+ public void orConditionsToJsonWithComma () throws Exception {
108+ UserAttribute testInstance1 = new UserAttribute ("browser_type" , "custom_attribute" , "true" , "safari" );
109+ UserAttribute testInstance2 = new UserAttribute ("browser_type" , "custom_attribute" , "true" , "safari" );
110+ String expectedConditionJsonString = "[\" or\" , [\" and\" , {\" name\" :\" browser_type\" , \" type\" :\" custom_attribute\" , \" match\" :\" true\" , \" value\" :\" safari\" }, {\" name\" :\" browser_type\" , \" type\" :\" custom_attribute\" , \" match\" :\" true\" , \" value\" :\" safari\" }]]" ;
111+ List <Condition > userConditions = new ArrayList <>();
112+ userConditions .add (testInstance1 );
113+ userConditions .add (testInstance2 );
114+ AndCondition andCondition = new AndCondition (userConditions );
115+ List <Condition > andConditions = new ArrayList <>();
116+ andConditions .add (andCondition );
117+ OrCondition orCondition = new OrCondition (andConditions );
118+ assertEquals (orCondition .toJson (), expectedConditionJsonString );
119+ }
85120
86121 /**
87122 * Verify that UserAttribute.evaluate returns true on exact-matching visitor attribute data.
0 commit comments