package com.peterphi.std.guice.hibernate.webquery;

import com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery;
import org.junit.Test;

public class WebQueryTest
{
	@Test
	public void testEncode()
	{
		new WebQuery().orderDesc("id")
		              .orderAsc("name")
		              .orderAsc("name2")
		              .limit(99)
		              .computeSize(true)
		              .or(g -> g.eq("id", 1)
		                        .contains("id",
		                                  "some_value"))
		              .eq("name", "x")
		              .encode();
	}
}

@@ -134,16 +134,62 @@
 .Test;%0A%0A
+import static org.junit.Assert.assertEquals;%0A%0A
 public c
@@ -242,30 +242,81 @@
 code
-()%0A%09%7B%0A%09%09new WebQuery()
+ResultStable()%0A%09%7B%0A%09%09WebQuery query = new WebQuery()%0A%09%09%09%09                 
 .ord
@@ -326,24 +326,29 @@
 esc(%22id%22)%0A%09%09
+%09%09   
             
@@ -365,24 +365,29 @@
 c(%22name%22)%0A%09%09
+%09%09   
             
@@ -405,24 +405,29 @@
 (%22name2%22)%0A%09%09
+%09
+%09   
             
@@ -439,16 +439,18 @@
 mit(99)%0A
+%09%09
 %09%09      
@@ -457,16 +457,19 @@
         
+   
 .compute
@@ -477,24 +477,27 @@
 ize(true)%0A%09%09
+%09%09 
             
@@ -498,16 +498,18 @@
         
+  
 .or(g -%3E
@@ -526,86 +526,23 @@
 , 1)
-%0A%09%09                        .contains(%22id%22,%0A%09%09                                 
+.contains(%22id%22,
  %22so
@@ -551,24 +551,29 @@
 _value%22))%0A%09%09
+%09%09   
             
@@ -594,33 +594,225 @@
 %22x%22)
+;%0A
 %0A%09%09
-              .encode(
+assertEquals(%0A%09%09%09%09%22%7B_compute_size=%5Btrue%5D, _expand=%5Ball%5D, _fetch=%5Bentity%5D, _order=%5Bid desc, name asc, name2 asc%5D, _limit=%5B99%5D, _offset=%5B0%5D, name=%5Bx%5D, id=%5B1, _f_contains_some_value%5D%7D%22,%0A%09%09%09%09query.encode().toString()
 );%0A%09

Update WebQueryTest to test that the encoding of a WebQuery is stable