Initial OpenECOMP policy/engine commit
[policy/engine.git] / ECOMP-XACML / src / test / java / org / openecomp / policy / xacml / test / json / RequestCategoryTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP-XACML
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.policy.xacml.test.json;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.fail;
25
26 import org.junit.Test;
27
28 import com.att.research.xacml.api.Request;
29 import com.att.research.xacml.std.json.JSONRequest;
30 import com.att.research.xacml.std.json.JSONStructureException;
31
32 /**
33  * Test JSON Request convert to object - Category sub-component.  Does not include "Default" Categories (Subject, Action, Resource, Environment).
34  * Basic existance/absence of Category is tested in RequestMainTest.
35  * 
36  * TO RUN - use jUnit
37  * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
38  * 
39  * NOTE:
40  * The "correct" way to verify that each JSON string gets translated into our internal Objects correctly is to look explicitly at each of the child objects
41  * and verify that they are correct.  This would involve a lot of coding to get child of child of child and individually verify each property of each element.
42  * To simplify testing we assume that request.toString() correctly includes a complete text representation of every sub-component of the Request object
43  * and we compare the resulting String to our expected String.
44  * This has two possible sources of error:
45  *      - toString might not include some sub-component, and
46  *      - the initial verification of the resulting string is done by hand and may have been incorrect.
47  * 
48  *
49  */
50 public class RequestCategoryTest {
51         
52         // The request object output from each test conversion from JSON string
53         Request request;
54
55         
56         /*
57          * Request that uses all fields with both single and multiple  entries
58          */
59         String allFieldsRequest = 
60                         "{\"Request\": {" +
61                                         "\"ReturnPolicyIdList\" : true ," +
62                                         "\"CombinedDecision\" : true ," +
63                                         "\"XPathVersion\" : \"http://www.w3.org/TR/1999/REC-xpath-19991116\"," +
64                                         "\"MultiRequests\" : {" +
65                                     "\"RequestReference\": [" +
66                                         "{ " +
67                                                 "\"ReferenceId\" : [\"foo1\",\"bar1\"]" +
68                                         "}," +
69                                         "{" +
70                                                 "\"ReferenceId\" : [\"foo2\",\"bar1\"]" +
71                                         "}]" +   
72                                   "}," +
73
74                                         "\"Category\": [" +
75                                                 "{ " +
76                                                 "\"CategoryId\": \"custom-category\", " +
77                                                 "\"Id\" : \"customId\", " +
78                                                 "\"Attribute\" : [" +
79                                                         "{" +
80                                                                 "\"AttributeId\"                : \"document-id\", " +
81                                                                 "\"DataType\"   : \"integer\", " +
82                                                                 "\"Value\"      : 123 " +
83                                                                 "}, " +
84                                                                 "{" +
85                                                                 "\"AttributeId\"                : \"document-url\", " +
86                                                                 "\"DataType\"   : \"anyURI\", " +
87                                                                 "\"Value\"      : \"http://somewhere.over.the.com/rainbow\" " +
88                                                         "}, " +
89                                                                 "{" +
90                                                                 "\"AttributeId\"                : \"page-list\", " +
91                                                                 "\"Value\"      : [1, 2, 3, 4.5, 3, 2, 1] " +
92                                                         "} " +
93                                                 "]" +
94                                             "}, " +
95                                             "{ " +
96                                                 "\"CategoryId\": \"another-custom-cat\", " +
97                                                 "\"Id\" : \"anotherXmlId\", " +
98                                                 "\"Attribute\" : []" +
99                                             "} " +
100                                         "], " +
101                                             
102                                         "\"AccessSubject\":{ " +
103                                                 "\"Content\" : \"<?xml version=\\\"1.0\\\"?><catalog>" + 
104                                                         "<book id=\\\"bk101\\\"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre>" +
105                                                         "<price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description>"+
106                                                         "</book></catalog>\"," +
107                                                 "\"Attribute\" : []" +
108                                         "}, " +
109                                         
110                                         "\"Resource\" : {" +
111                                                 "\"Content\" : \"PD94bWwgdmVyc2lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9yPkdhbWJhcmRlbGxhLCBNYXR0aGV3PC9hdXRob3I+PHRpdGxlPlhNT" +
112                                                         "CBEZXZlbG9wZXIncyBHdWlkZTwvdGl0bGU+PGdlbnJlPkNvbXB1dGVyPC9nZW5yZT48cHJpY2U+NDQuOTU8L3ByaWNlPjxwdWJsaXNoX2RhdGU+MjAwMC0xMC0wMTwvcHVibGlzaF"+
113                                                         "9kYXRlPjxkZXNjcmlwdGlvbj5BbiBpbi1kZXB0aCBsb29rIGF0IGNyZWF0aW5nIGFwcGxpY2F0aW9ucyB3aXRoIFhNTC48L2Rlc2NyaXB0aW9uPjwvYm9vaz48L2NhdGFsb2c+\"" +
114
115
116                                         "} " +
117
118                                   
119                         "}}";
120         
121         /*
122          * The following example comes directly from the JSON Profile Spec
123          */
124         String exampleFromSpec = "{ " +
125                         "\"Request\" : { " +
126                                 "\"AccessSubject\" : { " +
127                                         "\"Attribute\": [ " +
128                                                 "{ " +
129                                                         "\"Id\" : \"subject-id\", " +
130                                                         "\"Value\" : \"Andreas\" " +
131                                                 "}, " +
132                                                 "{ " +
133                                                         "\"Id\" : \"location\", " +
134                                                         "\"Value\" : \"Gamla Stan\" " +
135                                                 "} " +
136                                         "] " +
137                                 "}, " +
138                                 "\"Action\" : { " +
139                                         "\"Attribute\":  " +
140                                                 "{ " +
141                                                         "\"Id\" : \"action-id\", " +
142                                                         "\"Value\" : \"http://www.xacml.eu/buy\", " +
143                                                         "\"DataType\" : \"anyURI\" " +
144                                                 "} " +
145                                 "}, " +
146                                 "\"Resource\" : { " +
147                                         "\"Attribute\": [ " +
148                                                 "{ " +
149                                                         "\"Id\" : \"book-title\", " +
150                                                         "\"Value\" : \"Learn German in 90 days\" " +
151                                                 "}, " +
152                                                 "{ " +
153                                                         "\"Id\" : \"currency\", " +
154                                                         "\"Value\" : \"SEK\" " +
155                                                 "}, " +
156                                                 "{ " +
157                                                         "\"Id\" : \"price\", " +
158                                                         "\"Value\" : 123.34 " +
159                                                 "} " +
160                                                 "] " +
161                                         "} " +
162                                 "} " +
163                         "} ";
164
165         
166         /*
167          * The following example comes directly from the JSON Profile Spec (modified to include a "</Catalog>" missing from both examples).
168          * It shows the two ways of handling XPath content, as escaped XML and as Base64 encoding.
169          */
170         String xPathExampleFromSpec = "{ " +
171                         "\"Request\" : { " +
172                                 "\"Resource\" : { " +
173                                         "\"Attribute\": [ " +
174                                                 "{ " +
175                                                         "\"Id\" : \"urn:oasis:names:tc:xacml:3.0:content-selector\", " +
176                                             "\"DataType\" : \"xpathExpression\", " +
177                                             "\"Value\" : { " +
178                                                 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", " +
179                                                 "\"Namespaces\" : [{ " +
180                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
181                                                         "}, " +
182                                                     "{ " +
183                                                         "\"Prefix\" : \"md\", " +
184                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
185                                                     "} " +
186                                                 "], " +
187                                                 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" " +
188                                             "} " +
189                                         "} " +
190                                         "] " +
191                                 "} " +
192                         "} " +
193                 "} ";
194
195
196         
197 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
198
199         // Top-level of Category
200         @Test
201         public void testCategoryTopLevel() {    
202                 
203                 // empty Category
204                 try {
205                         request = JSONRequest.load("{\"Request\" : {\"Category\": [] }}");
206                         assertEquals("{returnPolicyIdList=false,combinedDecision=false}", request.toString());
207                 } catch (Exception e) {
208                         fail ("Failed convert from JSON to object: " + e);
209                 }
210                 
211                 // Missing value
212                 try {
213                         request = JSONRequest.load("{\"Request\" : {\"Category\" }}");
214                         fail("Operation should throw exception");
215                 } catch (JSONStructureException e) {
216                         // correct response
217                 } catch (Exception e) {
218                         fail ("Failed convert from JSON to object: " + e);
219                 }
220                 
221                 try {
222                         request = JSONRequest.load("{\"Request\" : {\"Category\" : }}");
223                         fail("Operation should throw exception");
224                 } catch (JSONStructureException e) {
225                         // correct response
226                 } catch (Exception e) {
227                         fail ("Failed convert from JSON to object: " + e);
228                 }
229                 
230                 // Category without CategoryId
231                 try {
232                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{}] }}");
233                         fail("Operation should throw exception");
234                 } catch (JSONStructureException e) {
235                         // correct response
236                 } catch (Exception e) {
237                         fail ("Failed convert from JSON to object: " + e);
238                 }
239                 
240                 // Category with CategoryId value missing or =""
241                 try {
242                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\"] }}");
243                         fail("Operation should throw exception");
244                 } catch (JSONStructureException e) {
245                         // correct response
246                 } catch (Exception e) {
247                         fail ("Failed convert from JSON to object: " + e);
248                 }
249                 
250                 try {
251                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : ] }}");
252                         fail("Operation should throw exception");
253                 } catch (JSONStructureException e) {
254                         // correct response
255                 } catch (Exception e) {
256                         fail ("Failed convert from JSON to object: " + e);
257                 }
258                 
259                 try {
260                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"\" ] }}");
261                         fail("Operation should throw exception");
262                 } catch (JSONStructureException e) {
263                         // correct response
264                 } catch (Exception e) {
265                         fail ("Failed convert from JSON to object: " + e);
266                 }
267                 
268                 // CategoryId wrong type
269                 try {
270                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : true } ] }}");
271                         fail("Operation should throw exception");
272                 } catch (JSONStructureException e) {
273                         // correct response
274                 } catch (Exception e) {
275                         fail ("Failed convert from JSON to object: " + e);
276                 }
277                 try {
278                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : 123 } ] }}");
279                         fail("Operation should throw exception");
280                 } catch (JSONStructureException e) {
281                         // correct response
282                 } catch (Exception e) {
283                         fail ("Failed convert from JSON to object: " + e);
284                 }
285                 
286                 // Category with Id
287                 try {
288                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Id\" : \"customId\" } ] }}");
289                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category},xmlId=customId}]}", request.toString());
290                 } catch (Exception e) {
291                         fail ("Failed convert from JSON to object: " + e);
292                 }
293                 
294                 // Category with Id - wrong type
295                 try {
296                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Id\" : true } ] }}");
297                         fail("Operation should throw exception");
298                 } catch (JSONStructureException e) {
299                         // correct response
300                 } catch (Exception e) {
301                         fail ("Failed convert from JSON to object: " + e);
302                 }
303                 try {
304                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Id\" : 123 } ] }}");
305                         fail("Operation should throw exception");
306                 } catch (JSONStructureException e) {
307                         // correct response
308                 } catch (Exception e) {
309                         fail ("Failed convert from JSON to object: " + e);
310                 }
311                 
312                 
313                 // Category without Id  
314                 try {
315                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\" } ] }}");
316                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category}}]}", request.toString());
317                 } catch (Exception e) {
318                         fail ("Failed convert from JSON to object: " + e);
319                 }
320                 
321                 
322                 // Category with standard CategoryId
323                 try {
324                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" } ] }}");
325                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:1.0:subject-category:access-subject}}]}", request.toString());
326                 } catch (Exception e) {
327                         fail ("Failed convert from JSON to object: " + e);
328                 }
329                 
330                 // Category with extra unknown field
331                 try {
332                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", unknown } ] }}");
333                         fail("Operation should throw exception");
334                 } catch (JSONStructureException e) {
335                         // correct response
336                 } catch (Exception e) {
337                         fail ("Failed convert from JSON to object: " + e);
338                 }
339                 
340                 try {
341                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"unknown\" : 123 } ] }}");
342                         fail("Operation should throw exception");
343                 } catch (JSONStructureException e) {
344                         // correct response
345                 } catch (Exception e) {
346                         fail ("Failed convert from JSON to object: " + e);
347                 }
348                 
349                 // Category with multiple sub-Category objects using same CategoryId
350                 try {
351                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"category1\" }, {\"CategoryId\" : \"category1\" } ] }}");
352                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=category1}}{super={category=category1}}]}", request.toString());
353                 } catch (Exception e) {
354                         fail ("Failed convert from JSON to object: " + e);
355                 }
356                 
357         }
358
359         
360         
361         // Tests related to Attributes
362         @Test
363         public void testCategoryAttributes() {  
364         
365                 // Category with Attribute but none given ("Attribute" : [] )           
366                 try {
367                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [] } ] }}");
368                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category}}]}", request.toString());
369                 } catch (Exception e) {
370                         fail ("Failed convert from JSON to object: " + e);
371                 }
372
373                 // Category Attribute with empty attribute (missing both AttributeId and Id)
374                 try {
375                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{}] } ] }}");
376                         fail("Operation should throw exception");
377                 } catch (JSONStructureException e) {
378                         // correct response
379                 } catch (Exception e) {
380                         fail ("Failed convert from JSON to object: " + e);
381                 }
382                 
383                 // Category Attribute with AttributeId and no Value
384                 try {
385                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
386                                 "\"AttributeId\" : \"document-id\" " +
387                                         "}] } ] }}");
388                         fail("Operation should throw exception");
389                 } catch (JSONStructureException e) {
390                         // correct response
391                 } catch (Exception e) {
392                         fail ("Failed convert from JSON to object: " + e);
393                 }
394                 
395                 // Category Attribute missing AttributeId but with Id           
396                 try {
397                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
398                                 "\"AttributeId\" : \"document-id\", " +
399                                 "\"Value\"      : 123 " +
400                                         "}] } ] }}");
401                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
402                 } catch (Exception e) {
403                         fail ("Failed convert from JSON to object: " + e);
404                 }
405                 
406                 // Category Attribute missing AttributeId but with Id
407                 try {
408                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
409                                 "\"Id\" : \"document-id\", " +
410                                 "\"Value\"      : 123 " +
411                                         "}] } ] }}");
412                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
413                 } catch (Exception e) {
414                         fail ("Failed convert from JSON to object: " + e);
415                 }
416                 
417                 // Category Attribute including both AttributeId and Id with same value
418                 try {
419                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
420                                 "\"AttributeId\" : \"document-id\", " +
421                                 "\"Id\" : \"document-id\", " +
422                                 "\"Value\"      : 123 " +
423                                         "}] } ] }}");
424                         fail("Operation should throw exception");
425                 } catch (JSONStructureException e) {
426                         // correct response
427                 } catch (Exception e) {
428                         fail ("Failed convert from JSON to object: " + e);
429                 }
430                 
431                 // Category Attribute missing both AttributeId and Id
432                 try {
433                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
434                                 "\"Value\"      : 123 " +
435                                         "}] } ] }}");
436                         fail("Operation should throw exception");
437                 } catch (JSONStructureException e) {
438                         // correct response
439                 } catch (Exception e) {
440                         fail ("Failed convert from JSON to object: " + e);
441                 }
442                 
443                 // Category Attribute AttributeId not string
444                 try {
445                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
446                                 "\"AttributeId\" : true, " +
447                                 "\"Value\"      : 123 " +
448                                         "}] } ] }}");
449                         fail("Operation should throw exception");
450                 } catch (JSONStructureException e) {
451                         // correct response
452                 } catch (Exception e) {
453                         fail ("Failed convert from JSON to object: " + e);
454                 }
455                 
456                 try {
457                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
458                                 "\"AttributeId\" : 123, " +
459                                 "\"Value\"      : 123 " +
460                                         "}] } ] }}");
461                         fail("Operation should throw exception");
462                 } catch (JSONStructureException e) {
463                         // correct response
464                 } catch (Exception e) {
465                         fail ("Failed convert from JSON to object: " + e);
466                 }
467                 
468                 // Category Attribute Id not string
469                 try {
470                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
471                                 "\"Id\" : true, " +
472                                 "\"Value\"      : 123 " +
473                                         "}] } ] }}");
474                         fail("Operation should throw exception");
475                 } catch (JSONStructureException e) {
476                         // correct response
477                 } catch (Exception e) {
478                         fail ("Failed convert from JSON to object: " + e);
479                 }
480                 
481                 try {
482                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
483                                 "\"Id\" : 123, " +
484                                 "\"Value\"      : 123 " +
485                                         "}] } ] }}");
486                         fail("Operation should throw exception");
487                 } catch (JSONStructureException e) {
488                         // correct response
489                 } catch (Exception e) {
490                         fail ("Failed convert from JSON to object: " + e);
491                 }
492                 
493                 
494                 // Category Attribute with DataType
495                 try {
496                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
497                                 "\"Id\" : \"document-id\", " +
498                                 "\"DataType\"   : \"integer\", " +
499                                 "\"Value\"      : 123 " +
500                                         "}] } ] }}");
501                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
502                 } catch (Exception e) {
503                         fail ("Failed convert from JSON to object: " + e);
504                 }
505                 
506                 // Category Attribute with DataType not string (e.g. "DataType" : 55.5 )
507                 try {
508                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
509                                 "\"Id\" : \"document-id\", " +
510                                 "\"DataType\"   : true, " +
511                                 "\"Value\"      : 123 " +
512                                         "}] } ] }}");
513                         fail("Operation should throw exception");
514                 } catch (JSONStructureException e) {
515                         // correct response
516                 } catch (Exception e) {
517                         fail ("Failed convert from JSON to object: " + e);
518                 }
519                 
520                 // Category Attribute with unknown DataType
521                 try {
522                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
523                                 "\"Id\" : \"document-id\", " +
524                                 "\"DataType\"   : \"no such data type\", " +
525                                 "\"Value\"      : 123 " +
526                                         "}] } ] }}");
527                         fail("Operation should throw exception");
528                 } catch (JSONStructureException e) {
529                         // correct response
530                 } catch (Exception e) {
531                         fail ("Failed convert from JSON to object: " + e);
532                 }
533                 
534                 try {
535                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
536                                 "\"Id\" : \"document-id\", " +
537                                 "\"DataType\"   : 321, " +
538                                 "\"Value\"      : 123 " +
539                                         "}] } ] }}");
540                         fail("Operation should throw exception");
541                 } catch (JSONStructureException e) {
542                         // correct response
543                 } catch (Exception e) {
544                         fail ("Failed convert from JSON to object: " + e);
545                 }
546                 
547                 // Category Attribute with multiple value array
548                 try {
549                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
550                                 "\"Id\" : \"document-id\", " +
551                                 "\"DataType\"   : \"dayTimeDuration\", " +
552                                 "\"Value\"      : [\"P3D\", \"P2DT12H34M\", \"PT15M\"] " +
553                                         "}] } ] }}");
554                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=3hours=0minutes=0seconds=0millis=0},factionalSeconds=0.0}}{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=2hours=12minutes=34seconds=0millis=0},factionalSeconds=0.0}}{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=0hours=0minutes=15seconds=0millis=0},factionalSeconds=0.0}}],includeInResults=false}]}}]}", request.toString());
555                 } catch (Exception e) {
556                         fail ("Failed convert from JSON to object: " + e);
557                 }
558                 
559                 // Category Attribute multiple value with null in array
560                 try {
561                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
562                                 "\"Id\" : \"document-id\", " +
563                                 "\"DataType\"   : \"dayTimeDuration\", " +
564                                 "\"Value\"      : [\"P3D\", , \"P15M\"] " +
565                                         "}] } ] }}");
566                         fail("Operation should throw exception");
567                 } catch (JSONStructureException e) {
568                         // correct response
569                 } catch (Exception e) {
570                         fail ("Failed convert from JSON to object: " + e);
571                 }
572                 
573                 // Category Attribute with array value with no values ("Attribute": [ {"AttributeId" :"a", Value:[] } ] }  )
574                 try {
575                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
576                                 "\"Id\" : \"document-id\", " +
577                                 "\"DataType\"   : \"dayTimeDuration\", " +
578                                 "\"Value\"      : [ ] " +
579                                         "}] } ] }}");
580                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,includeInResults=false}]}}]}", request.toString());
581                 } catch (Exception e) {
582                         fail ("Failed convert from JSON to object: " + e);
583                 }
584                 
585                 // Category Attribute with no DataType and array with no values
586                 try {
587                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
588                                 "\"Id\" : \"document-id\", " +
589                                 "\"Value\"      : [ ] " +
590                                         "}] } ] }}");
591                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,includeInResults=false}]}}]}", request.toString());
592                 } catch (Exception e) {
593                         fail ("Failed convert from JSON to object: " + e);
594                 }
595                 
596                 // Category Attribute with Issuer
597                 try {
598                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
599                                 "\"Id\" : \"document-id\", " +
600                                         "\"Issuer\" : \"University Press\", " +
601                                 "\"DataType\"   : \"integer\", " +
602                                 "\"Value\"      : 123 " +
603                                         "}] } ] }}");
604                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],issuer=University Press,includeInResults=false}]}}]}", request.toString());
605                 } catch (Exception e) {
606                         fail ("Failed convert from JSON to object: " + e);
607                 }
608                 
609                 // Category Attribute with Issuer not string
610                 try {
611                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
612                                 "\"Id\" : \"document-id\", " +
613                                         "\"Issuer\" : true, " +
614                                 "\"DataType\"   : \"integer\", " +
615                                 "\"Value\"      : 123 " +
616                                         "}] } ] }}");
617                         fail("Operation should throw exception");
618                 } catch (JSONStructureException e) {
619                         // correct response
620                 } catch (Exception e) {
621                         fail ("Failed convert from JSON to object: " + e);
622                 }
623                 
624                 try {
625                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
626                                 "\"Id\" : \"document-id\", " +
627                                         "\"Issuer\" : 4.56, " +
628                                 "\"DataType\"   : \"integer\", " +
629                                 "\"Value\"      : 123 " +
630                                         "}] } ] }}");
631                         fail("Operation should throw exception");
632                 } catch (JSONStructureException e) {
633                         // correct response
634                 } catch (Exception e) {
635                         fail ("Failed convert from JSON to object: " + e);
636                 }
637                 
638                 // Category Attribute with includeInResult=true
639                 try {
640                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
641                                 "\"Id\" : \"document-id\", " +
642                                 "\"Value\"      : 123, " +
643                                 "\"IncludeInResult\" : true " +
644                                         "}] } ] }}");
645                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=true}]}}]}", request.toString());
646                 } catch (Exception e) {
647                         fail ("Failed convert from JSON to object: " + e);
648                 }
649                 
650                 // Category Attribute with includeInResult = false
651                 try {
652                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
653                                 "\"Id\" : \"document-id\", " +
654                                 "\"Value\"      : 123, " +
655                                 "\"IncludeInResult\" : false " +
656                                         "}] } ] }}");
657                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
658                 } catch (Exception e) {
659                         fail ("Failed convert from JSON to object: " + e);
660                 }
661                 
662                 // Category Attribute with includeInResult not boolean
663                 try {
664                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
665                                 "\"Id\" : \"document-id\", " +
666                                 "\"Value\"      : 123, " +
667                                 "\"IncludeInResult\" : \"abc\" " +
668                                         "}] } ] }}");
669                         fail("Operation should throw exception");
670                 } catch (JSONStructureException e) {
671                         // correct response
672                 } catch (Exception e) {
673                         fail ("Failed convert from JSON to object: " + e);
674                 }
675                 
676                 try {
677                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
678                                 "\"Id\" : \"document-id\", " +
679                                 "\"Value\"      : 123, " +
680                                 "\"IncludeInResult\" : 123.45 " +
681                                         "}] } ] }}");
682                         fail("Operation should throw exception");
683                 } catch (JSONStructureException e) {
684                         // correct response
685                 } catch (Exception e) {
686                         fail ("Failed convert from JSON to object: " + e);
687                 }
688         }
689
690         
691         
692         // Tests related to DataTypes within Attributes
693         @Test
694         public void testCategoryAttributesDataTypesSimple() {   
695                 
696                 // Category Attribute using full Identifier for each data type
697                 try {
698                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
699                                 "\"Id\" : \"document-id\", " +
700                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
701                                 "\"Value\"      : \"abc\" " +
702                                         "}] } ] }}");
703                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}],includeInResults=false}]}}]}", request.toString());
704                 } catch (Exception e) {
705                         fail ("Failed convert from JSON to object: " + e);
706                 }
707                 
708                 try {
709                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
710                                 "\"Id\" : \"document-id\", " +
711                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
712                                 "\"Value\"      : true " +
713                                         "}] } ] }}");
714                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}],includeInResults=false}]}}]}", request.toString());
715                 } catch (Exception e) {
716                         fail ("Failed convert from JSON to object: " + e);
717                 }
718                 
719                 try {
720                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
721                                 "\"Id\" : \"document-id\", " +
722                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
723                                 "\"Value\"      : 123 " +
724                                         "}] } ] }}");
725                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
726                 } catch (Exception e) {
727                         fail ("Failed convert from JSON to object: " + e);
728                 }
729                 
730                 try {
731                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
732                                 "\"Id\" : \"document-id\", " +
733                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
734                                 "\"Value\"      : 123.34 " +
735                                         "}] } ] }}");
736                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}],includeInResults=false}]}}]}", request.toString());
737                 } catch (Exception e) {
738                         fail ("Failed convert from JSON to object: " + e);
739                 }
740                 
741                 try {
742                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
743                                 "\"Id\" : \"document-id\", " +
744                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
745                                 "\"Value\"      : \"12:00:00Z\" " +
746                                         "}] } ] }}");
747                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
748                 } catch (Exception e) {
749                         fail ("Failed convert from JSON to object: " + e);
750                 }
751                 
752                 try {
753                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
754                                 "\"Id\" : \"document-id\", " +
755                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
756                                 "\"Value\"      : \"2002-10-10\" " +
757                                         "}] } ] }}");
758                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
759                 } catch (Exception e) {
760                         fail ("Failed convert from JSON to object: " + e);
761                 }
762                 
763                 try {
764                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
765                                 "\"Id\" : \"document-id\", " +
766                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
767                                 "\"Value\"      : \"2002-10-10T12:00:00Z\" " +
768                                         "}] } ] }}");
769                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
770                 } catch (Exception e) {
771                         fail ("Failed convert from JSON to object: " + e);
772                 }
773                 
774                 try {
775                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
776                                 "\"Id\" : \"document-id\", " +
777                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
778                                 "\"Value\"      : \"P23DT7H12M54S\" " +
779                                         "}] } ] }}");
780                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}],includeInResults=false}]}}]}", request.toString());
781                 } catch (Exception e) {
782                         fail ("Failed convert from JSON to object: " + e);
783                 }
784                 
785                 try {
786                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
787                                 "\"Id\" : \"document-id\", " +
788                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
789                                 "\"Value\"      : \"P165Y8M\" " +
790                                         "}] } ] }}");
791                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}],includeInResults=false}]}}]}", request.toString());
792                 } catch (Exception e) {
793                         fail ("Failed convert from JSON to object: " + e);
794                 }
795                 
796                 try {
797                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
798                                 "\"Id\" : \"document-id\", " +
799                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#anyURI\", " +
800                                 "\"Value\"      : \"aValue\" " +
801                                         "}] } ] }}");
802                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
803                 } catch (Exception e) {
804                         fail ("Failed convert from JSON to object: " + e);
805                 }
806                 
807                 try {
808                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
809                                 "\"Id\" : \"document-id\", " +
810                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#hexBinary\", " +
811                                 "\"Value\"      : \"FA027B7D12CC34DDD20012AEEF\" " +
812                                         "}] } ] }}");
813                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}],includeInResults=false}]}}]}", request.toString());
814                 } catch (Exception e) {
815                         fail ("Failed convert from JSON to object: " + e);
816                 }
817                 
818                 try {
819                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
820                                 "\"Id\" : \"document-id\", " +
821                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#base64Binary\", " +
822                                 "\"Value\"      : \"lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9y\" " +
823                                         "}] } ] }}");
824                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,-46,35,18,-29,2,35,-13,-29,-58,54,23,70,22,-58,-10,115,-29,-58,38,-10,-10,-78,6,-106,67,-46,38,38,-77,19,3,18,35,-29,-58,23,87,70,-122,-9]}}],includeInResults=false}]}}]}", request.toString());
825                 } catch (Exception e) {
826                         fail ("Failed convert from JSON to object: " + e);
827                 }
828                 
829                 try {
830                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
831                                 "\"Id\" : \"document-id\", " +
832                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
833                                 "\"Value\"      : \"someone.else@A.COMPANY.com\" " +
834                                         "}] } ] }}");
835                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=someone.else,domainName=A.COMPANY.com}}],includeInResults=false}]}}]}", request.toString());
836                 } catch (Exception e) {
837                         fail ("Failed convert from JSON to object: " + e);
838                 }
839                 
840                 try {
841                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
842                                 "\"Id\" : \"document-id\", " +
843                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
844                                 "\"Value\"      : \"cn=Julius Hibbert, o=Medi Corporation, c=US\" " +
845                                         "}] } ] }}");
846                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}],includeInResults=false}]}}]}", request.toString());
847                 } catch (Exception e) {
848                         fail ("Failed convert from JSON to object: " + e);
849                 }
850                 
851                 try {
852                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
853                                 "\"Id\" : \"document-id\", " +
854                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
855                                 "\"Value\"      : \"10.221.43.58:12345\" " +
856                                         "}] } ] }}");
857                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=10.221.43.58:12345-12345}],includeInResults=false}]}}]}", request.toString());
858                 } catch (Exception e) {
859                         fail ("Failed convert from JSON to object: " + e);
860                 }
861                 
862                 try {
863                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
864                                 "\"Id\" : \"document-id\", " +
865                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\", " +
866                                 "\"Value\"      : \"aValue\" " +
867                                         "}] } ] }}");
868                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}],includeInResults=false}]}}]}", request.toString());
869                 } catch (Exception e) {
870                         fail ("Failed convert from JSON to object: " + e);
871                 }
872                 
873                 try {
874                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
875                                 "\"Id\" : \"document-id\", " +
876                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\", " +
877                                 "\"Value\"      : {" +
878                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
879                                         "\"Namespaces\" : ["
880                                                 + "{ "+
881                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
882                                                         "}," +
883                                                         "{" +
884                                                                 "\"Prefix\" : \"md\", " +
885                                                                 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
886                                                         "}], "+
887                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
888                         "}" +
889                                         "}] } ] }}");
890                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace={[{md,urn:example:med:schemas:record}{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}]},status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
891
892                 } catch (Exception e) {
893                         fail ("Failed convert from JSON to object: " + e);
894                 }
895
896                 
897                 // Category Attribute shorthand notation for each data type
898                 try {
899                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
900                                 "\"Id\" : \"document-id\", " +
901                                 "\"DataType\"   : \"string\", " +
902                                 "\"Value\"      : \"abc\" " +
903                                         "}] } ] }}");
904                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}],includeInResults=false}]}}]}", request.toString());
905                 } catch (Exception e) {
906                         fail ("Failed convert from JSON to object: " + e);
907                 }
908                 
909                 try {
910                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
911                                 "\"Id\" : \"document-id\", " +
912                                 "\"DataType\"   : \"boolean\", " +
913                                 "\"Value\"      : true " +
914                                         "}] } ] }}");
915                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}],includeInResults=false}]}}]}", request.toString());
916                 } catch (Exception e) {
917                         fail ("Failed convert from JSON to object: " + e);
918                 }
919                 
920                 try {
921                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
922                                 "\"Id\" : \"document-id\", " +
923                                 "\"DataType\"   : \"integer\", " +
924                                 "\"Value\"      : 123 " +
925                                         "}] } ] }}");
926                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
927                 } catch (Exception e) {
928                         fail ("Failed convert from JSON to object: " + e);
929                 }
930                 
931                 try {
932                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
933                                 "\"Id\" : \"document-id\", " +
934                                 "\"DataType\"   : \"double\", " +
935                                 "\"Value\"      : 123.34 " +
936                                         "}] } ] }}");
937                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}],includeInResults=false}]}}]}", request.toString());
938                 } catch (Exception e) {
939                         fail ("Failed convert from JSON to object: " + e);
940                 }
941                 
942                 try {
943                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
944                                 "\"Id\" : \"document-id\", " +
945                                 "\"DataType\"   : \"time\", " +
946                                 "\"Value\"      : \"12:00:00Z\" " +
947                                         "}] } ] }}");
948                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
949                 } catch (Exception e) {
950                         fail ("Failed convert from JSON to object: " + e);
951                 }
952                 
953                 try {
954                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
955                                 "\"Id\" : \"document-id\", " +
956                                 "\"DataType\"   : \"date\", " +
957                                 "\"Value\"      : \"2002-10-10\" " +
958                                         "}] } ] }}");
959                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
960                 } catch (Exception e) {
961                         fail ("Failed convert from JSON to object: " + e);
962                 }
963                 
964                 try {
965                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
966                                 "\"Id\" : \"document-id\", " +
967                                 "\"DataType\"   : \"dateTime\", " +
968                                 "\"Value\"      : \"2002-10-10T12:00:00Z\" " +
969                                         "}] } ] }}");
970                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
971                 } catch (Exception e) {
972                         fail ("Failed convert from JSON to object: " + e);
973                 }
974                 
975                 try {
976                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
977                                 "\"Id\" : \"document-id\", " +
978                                 "\"DataType\"   : \"dayTimeDuration\", " +
979                                 "\"Value\"      : \"P23DT7H12M54S\" " +
980                                         "}] } ] }}");
981                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}],includeInResults=false}]}}]}", request.toString());
982                 } catch (Exception e) {
983                         fail ("Failed convert from JSON to object: " + e);
984                 }
985                 
986                 try {
987                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
988                                 "\"Id\" : \"document-id\", " +
989                                 "\"DataType\"   : \"yearMonthDuration\", " +
990                                 "\"Value\"      : \"P165Y8M\" " +
991                                         "}] } ] }}");
992                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}],includeInResults=false}]}}]}", request.toString());
993                 } catch (Exception e) {
994                         fail ("Failed convert from JSON to object: " + e);
995                 }
996                 
997                 try {
998                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
999                                 "\"Id\" : \"document-id\", " +
1000                                 "\"DataType\"   : \"anyURI\", " +
1001                                 "\"Value\"      : \"aValue\" " +
1002                                         "}] } ] }}");
1003                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
1004                 } catch (Exception e) {
1005                         fail ("Failed convert from JSON to object: " + e);
1006                 }
1007                 
1008                 try {
1009                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1010                                 "\"Id\" : \"document-id\", " +
1011                                 "\"DataType\"   : \"hexBinary\", " +
1012                                 "\"Value\"      : \"FA027B7D12CC34DDD20012AEEF\" " +
1013                                         "}] } ] }}");
1014                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}],includeInResults=false}]}}]}", request.toString());
1015                 } catch (Exception e) {
1016                         fail ("Failed convert from JSON to object: " + e);
1017                 }
1018                 
1019                 try {
1020                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1021                                 "\"Id\" : \"document-id\", " +
1022                                 "\"DataType\"   : \"base64Binary\", " +
1023                                 "\"Value\"      : \"lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9y\" " +
1024                                         "}] } ] }}");
1025                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,-46,35,18,-29,2,35,-13,-29,-58,54,23,70,22,-58,-10,115,-29,-58,38,-10,-10,-78,6,-106,67,-46,38,38,-77,19,3,18,35,-29,-58,23,87,70,-122,-9]}}],includeInResults=false}]}}]}", request.toString());
1026                 } catch (Exception e) {
1027                         fail ("Failed convert from JSON to object: " + e);
1028                 }
1029                 
1030                 try {
1031                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1032                                 "\"Id\" : \"document-id\", " +
1033                                 "\"DataType\"   : \"rfc822Name\", " +
1034                                 "\"Value\"      : \"someone.else@A.COMPANY.com\" " +
1035                                         "}] } ] }}");
1036                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=someone.else,domainName=A.COMPANY.com}}],includeInResults=false}]}}]}", request.toString());
1037                 } catch (Exception e) {
1038                         fail ("Failed convert from JSON to object: " + e);
1039                 }
1040                 
1041                 try {
1042                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1043                                 "\"Id\" : \"document-id\", " +
1044                                 "\"DataType\"   : \"x500Name\", " +
1045                                 "\"Value\"      : \"cn=Julius Hibbert, o=Medi Corporation, c=US\" " +
1046                                         "}] } ] }}");
1047                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}],includeInResults=false}]}}]}", request.toString());
1048                 } catch (Exception e) {
1049                         fail ("Failed convert from JSON to object: " + e);
1050                 }
1051                 
1052                 try {
1053                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1054                                 "\"Id\" : \"document-id\", " +
1055                                 "\"DataType\"   : \"ipAddress\", " +
1056                                 "\"Value\"      : \"10.221.43.58:12345\" " +
1057                                         "}] } ] }}");
1058                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=10.221.43.58:12345-12345}],includeInResults=false}]}}]}", request.toString());
1059                 } catch (Exception e) {
1060                         fail ("Failed convert from JSON to object: " + e);
1061                 }
1062                 
1063                 try {
1064                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1065                                 "\"Id\" : \"document-id\", " +
1066                                 "\"DataType\"   : \"dnsName\", " +
1067                                 "\"Value\"      : \"aValue\" " +
1068                                         "}] } ] }}");
1069                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}],includeInResults=false}]}}]}", request.toString());
1070                 } catch (Exception e) {
1071                         fail ("Failed convert from JSON to object: " + e);
1072                 }
1073                 
1074                 try {
1075                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1076                                 "\"Id\" : \"document-id\", " +
1077                                 "\"DataType\"   : \"xpathExpression\", " +
1078                                 "\"Value\"      : {" +
1079                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
1080                                         "\"Namespaces\" : ["
1081                                                 + "{ "+
1082                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
1083                                                         "}," +
1084                                                         "{" +
1085                                                                 "\"Prefix\" : \"md\", " +
1086                                                                 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
1087                                                         "}], "+
1088                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
1089                         "}" +
1090                                         "}] } ] }}");
1091                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace={[{md,urn:example:med:schemas:record}{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}]},status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
1092
1093                 } catch (Exception e) {
1094                         fail ("Failed convert from JSON to object: " + e);
1095                 }
1096
1097                 
1098                 
1099                 // infer data type - only integer, boolean and double are distinguishable from strings; everything else is treated as a string
1100                 try {
1101                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1102                                 "\"Id\" : \"document-id\", " +
1103                                 "\"Value\"      : \"abc\" " +
1104                                         "}] } ] }}");
1105                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}],includeInResults=false}]}}]}", request.toString());
1106                 } catch (Exception e) {
1107                         fail ("Failed convert from JSON to object: " + e);
1108                 }
1109                 
1110                 try {
1111                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1112                                 "\"Id\" : \"document-id\", " +
1113                                 "\"Value\"      : true " +
1114                                         "}] } ] }}");
1115                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}],includeInResults=false}]}}]}", request.toString());
1116                 } catch (Exception e) {
1117                         fail ("Failed convert from JSON to object: " + e);
1118                 }
1119                 
1120                 try {
1121                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1122                                 "\"Id\" : \"document-id\", " +
1123                                 "\"Value\"      : 123 " +
1124                                         "}] } ] }}");
1125                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
1126                 } catch (Exception e) {
1127                         fail ("Failed convert from JSON to object: " + e);
1128                 }
1129                 
1130                 try {
1131                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1132                                 "\"Id\" : \"document-id\", " +
1133                                 "\"Value\"      : 123.34 " +
1134                                         "}] } ] }}");
1135                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}],includeInResults=false}]}}]}", request.toString());
1136                 } catch (Exception e) {
1137                         fail ("Failed convert from JSON to object: " + e);
1138                 }
1139                 
1140                 try {
1141                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1142                                 "\"Id\" : \"document-id\", " +
1143                                 "\"Value\"      : \"12:00:00Z\" " +
1144                                         "}] } ] }}");
1145                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
1146                 } catch (Exception e) {
1147                         fail ("Failed convert from JSON to object: " + e);
1148                 }
1149                 
1150                 try {
1151                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1152                                 "\"Id\" : \"document-id\", " +
1153                                 "\"Value\"      : \"2002-10-10\" " +
1154                                         "}] } ] }}");
1155                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
1156                 } catch (Exception e) {
1157                         fail ("Failed convert from JSON to object: " + e);
1158                 }
1159                 
1160                 try {
1161                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1162                                 "\"Id\" : \"document-id\", " +
1163                                 "\"Value\"      : \"2002-10-10T12:00:00Z\" " +
1164                                         "}] } ] }}");
1165                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
1166                 } catch (Exception e) {
1167                         fail ("Failed convert from JSON to object: " + e);
1168                 }
1169                 
1170                 try {
1171                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1172                                 "\"Id\" : \"document-id\", " +
1173                                 "\"Value\"      : \"P23DT7H12M54S\" " +
1174                                         "}] } ] }}");
1175                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}],includeInResults=false}]}}]}", request.toString());
1176                 } catch (Exception e) {
1177                         fail ("Failed convert from JSON to object: " + e);
1178                 }
1179                 
1180                 try {
1181                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1182                                 "\"Id\" : \"document-id\", " +
1183                                 "\"Value\"      : \"P165Y8M\" " +
1184                                         "}] } ] }}");
1185                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}],includeInResults=false}]}}]}", request.toString());
1186                 } catch (Exception e) {
1187                         fail ("Failed convert from JSON to object: " + e);
1188                 }
1189                 
1190                 try {
1191                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1192                                 "\"Id\" : \"document-id\", " +
1193                                 "\"Value\"      : \"aValue\" " +
1194                                         "}] } ] }}");
1195                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
1196                 } catch (Exception e) {
1197                         fail ("Failed convert from JSON to object: " + e);
1198                 }
1199                 
1200                 try {
1201                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1202                                 "\"Id\" : \"document-id\", " +
1203                                 "\"Value\"      : \"FA027B7D12CC34DDD20012AEEF\" " +
1204                                         "}] } ] }}");
1205                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}],includeInResults=false}]}}]}", request.toString());
1206                 } catch (Exception e) {
1207                         fail ("Failed convert from JSON to object: " + e);
1208                 }
1209                 
1210                 try {
1211                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1212                                 "\"Id\" : \"document-id\", " +
1213                                 "\"Value\"      : \"lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9y\" " +
1214                                         "}] } ] }}");
1215                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9y}],includeInResults=false}]}}]}", request.toString());
1216                 } catch (Exception e) {
1217                         fail ("Failed convert from JSON to object: " + e);
1218                 }
1219                 
1220                 try {
1221                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1222                                 "\"Id\" : \"document-id\", " +
1223                                 "\"Value\"      : \"someone.else@A.COMPANY.com\" " +
1224                                         "}] } ] }}");
1225                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=someone.else@A.COMPANY.com}],includeInResults=false}]}}]}", request.toString());
1226                 } catch (Exception e) {
1227                         fail ("Failed convert from JSON to object: " + e);
1228                 }
1229                 
1230                 try {
1231                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1232                                 "\"Id\" : \"document-id\", " +
1233                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
1234                                 "\"Value\"      : \"cn=Julius Hibbert, o=Medi Corporation, c=US\" " +
1235                                         "}] } ] }}");
1236                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}],includeInResults=false}]}}]}", request.toString());
1237                 } catch (Exception e) {
1238                         fail ("Failed convert from JSON to object: " + e);
1239                 }
1240                 
1241                 try {
1242                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1243                                 "\"Id\" : \"document-id\", " +
1244                                 "\"Value\"      : \"10.221.43.58:12345\" " +
1245                                         "}] } ] }}");
1246                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=10.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
1247                 } catch (Exception e) {
1248                         fail ("Failed convert from JSON to object: " + e);
1249                 }
1250                 
1251                 try {
1252                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1253                                 "\"Id\" : \"document-id\", " +
1254                                 "\"Value\"      : \"aValue\" " +
1255                                         "}] } ] }}");
1256                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
1257                 } catch (Exception e) {
1258                         fail ("Failed convert from JSON to object: " + e);
1259                 }
1260                 
1261                 try {
1262                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1263                                 "\"Id\" : \"document-id\", " +
1264                                 "\"Value\"      : \"aValue\" " +
1265                                         "}] } ] }}");
1266                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
1267                 } catch (Exception e) {
1268                         fail ("Failed convert from JSON to object: " + e);
1269                 }
1270                 
1271                 try {
1272                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1273                                 "\"Id\" : \"document-id\", " +
1274                                 "\"Value\"      : {" +
1275                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
1276                                         "\"Namespaces\" : ["
1277                                                 + "{ "+
1278                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
1279                                                         "}," +
1280                                                         "{" +
1281                                                                 "\"Prefix\" : \"md\", " +
1282                                                                 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
1283                                                         "}], "+
1284                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
1285                         "}" +
1286                                         "}] } ] }}");
1287                         // gets inferred to a String containing the whole structure under Value as a String
1288                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value={XPathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource, Namespaces=[{Namespace=urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}, {Prefix=md, Namespace=urn:example:med:schemas:record}], XPath=md:record/md:patient/md:patientDoB}}],includeInResults=false}]}}]}", request.toString());
1289
1290                 } catch (Exception e) {
1291                         fail ("Failed convert from JSON to object: " + e);
1292                 }
1293         }
1294         
1295         
1296         
1297         @Test
1298         public void testCategoryAttributesDataTypesNotMatchValue() {    
1299
1300                 // Category Attribute with DataType not matching value type (JSON type derived from syntax)
1301                 // AUTO-CONVERSION from Boolean to String!
1302                 try {
1303                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1304                                 "\"Id\" : \"document-id\", " +
1305                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
1306                                 "\"Value\"      : true " +
1307                                         "}] } ] }}");
1308                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}],includeInResults=false}]}}]}", request.toString());
1309                 } catch (Exception e) {
1310                         fail ("Failed convert from JSON to object: " + e);
1311                 }
1312                 // SUCCESSFUL AUTO-CONVERT
1313                 try {
1314                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1315                                 "\"Id\" : \"document-id\", " +
1316                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
1317                                 "\"Value\"      : 123 " +
1318                                         "}] } ] }}");
1319                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}],includeInResults=false}]}}]}", request.toString());
1320                 } catch (Exception e) {
1321                         fail ("Failed convert from JSON to object: " + e);
1322                 }
1323                 // SUCCESSFUL AUTO-CONVERT
1324                 try {
1325                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1326                                 "\"Id\" : \"document-id\", " +
1327                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
1328                                 "\"Value\"      : 123.34 " +
1329                                         "}] } ] }}");
1330                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123.34}],includeInResults=false}]}}]}", request.toString());
1331                 } catch (Exception e) {
1332                         fail ("Failed convert from JSON to object: " + e);
1333                 }
1334                 
1335
1336                 
1337                 try {
1338                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1339                                 "\"Id\" : \"document-id\", " +
1340                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
1341                                 "\"Value\"      : \"abc\" " +
1342                                         "}] } ] }}");
1343                         fail("Operation should throw exception");
1344                 } catch (JSONStructureException e) {
1345                         // correct response
1346                 } catch (Exception e) {
1347                         fail ("Failed convert from JSON to object: " + e);
1348                 }
1349                 
1350                 try {
1351                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1352                                 "\"Id\" : \"document-id\", " +
1353                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
1354                                 "\"Value\"      : 123 " +
1355                                         "}] } ] }}");
1356                         fail("Operation should throw exception");
1357                 } catch (JSONStructureException e) {
1358                         // correct response
1359                 } catch (Exception e) {
1360                         fail ("Failed convert from JSON to object: " + e);
1361                 }
1362                 
1363                 try {
1364                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1365                                 "\"Id\" : \"document-id\", " +
1366                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
1367                                 "\"Value\"      : 123.45 " +
1368                                         "}] } ] }}");
1369                         fail("Operation should throw exception");
1370                 } catch (JSONStructureException e) {
1371                         // correct response
1372                 } catch (Exception e) {
1373                         fail ("Failed convert from JSON to object: " + e);
1374                 }
1375                 
1376                 // SUCCESSFUL AUTO-CONVERT
1377                 try {
1378                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1379                                 "\"Id\" : \"document-id\", " +
1380                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
1381                                 "\"Value\"      : \"123\" " +
1382                                         "}] } ] }}");
1383                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}],includeInResults=false}]}}]}", request.toString());
1384                 } catch (Exception e) {
1385                         fail ("Failed convert from JSON to object: " + e);
1386                 }
1387                 
1388                 try {
1389                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1390                                 "\"Id\" : \"document-id\", " +
1391                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
1392                                 "\"Value\"      : true " +
1393                                         "}] } ] }}");
1394                         fail("Operation should throw exception");
1395                 } catch (JSONStructureException e) {
1396                         // correct response
1397                 } catch (Exception e) {
1398                         fail ("Failed convert from JSON to object: " + e);
1399                 }
1400                 
1401                 try {
1402                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1403                                 "\"Id\" : \"document-id\", " +
1404                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
1405                                 "\"Value\"      : 123.45 " +
1406                                         "}] } ] }}");
1407                         fail("Operation should throw exception");
1408                 } catch (JSONStructureException e) {
1409                         // correct response
1410                 } catch (Exception e) {
1411                         fail ("Failed convert from JSON to object: " + e);
1412                 }
1413                 
1414
1415                 // SUCCESSFUL AUTO-CONVERT
1416                 try {
1417                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1418                                 "\"Id\" : \"document-id\", " +
1419                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
1420                                 "\"Value\"      : \"123.34\" " +
1421                                         "}] } ] }}");
1422                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}],includeInResults=false}]}}]}", request.toString());
1423                 } catch (Exception e) {
1424                         fail ("Failed convert from JSON to object: " + e);
1425                 }
1426                 
1427                 try {
1428                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1429                                 "\"Id\" : \"document-id\", " +
1430                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
1431                                 "\"Value\"      : true " +
1432                                         "}] } ] }}");
1433                         fail("Operation should throw exception");
1434                 } catch (JSONStructureException e) {
1435                         // correct response
1436                 } catch (Exception e) {
1437                         fail ("Failed convert from JSON to object: " + e);
1438                 }
1439                 
1440                 // allow integer to auto-convert to double when DataType is given
1441                 try {
1442                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1443                                 "\"Id\" : \"document-id\", " +
1444                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
1445                                 "\"Value\"      : 123 " +
1446                                         "}] } ] }}");
1447                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.0}],includeInResults=false}]}}]}", request.toString());
1448                 } catch (Exception e) {
1449                         fail ("Failed convert from JSON to object: " + e);
1450                 }
1451                 
1452                 // special JavaScript values not allowed except for -0 (inappropriate requirement in spec - check it anyway)
1453                 try {
1454                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1455                                 "\"Id\" : \"document-id\", " +
1456                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
1457                                 "\"Value\"      : \"NaN\" " +
1458                                         "}] } ] }}");
1459                         fail("Operation should throw exception");
1460                 } catch (JSONStructureException e) {
1461                         // correct response
1462                 } catch (Exception e) {
1463                         fail ("Failed convert from JSON to object: " + e);
1464                 }
1465                 
1466                 try {
1467                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1468                                 "\"Id\" : \"document-id\", " +
1469                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
1470                                 "\"Value\"      : \"INF\" " +
1471                                         "}] } ] }}");
1472                         fail("Operation should throw exception");
1473                 } catch (JSONStructureException e) {
1474                         // correct response
1475                 } catch (Exception e) {
1476                         fail ("Failed convert from JSON to object: " + e);
1477                 }
1478                 
1479                 try {
1480                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1481                                 "\"Id\" : \"document-id\", " +
1482                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
1483                                 "\"Value\"      : \"-INF\" " +
1484                                         "}] } ] }}");
1485                         fail("Operation should throw exception");
1486                 } catch (JSONStructureException e) {
1487                         // correct response
1488                 } catch (Exception e) {
1489                         fail ("Failed convert from JSON to object: " + e);
1490                 }
1491                 
1492                 // JavaScript 0 and -0 are ok
1493                 try {
1494                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1495                                 "\"Id\" : \"document-id\", " +
1496                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
1497                                 "\"Value\"      : 0 " +
1498                                         "}] } ] }}");
1499                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=0}],includeInResults=false}]}}]}", request.toString());
1500                 } catch (Exception e) {
1501                         fail ("Failed convert from JSON to object: " + e);
1502                 }
1503                 
1504                 try {
1505                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1506                                 "\"Id\" : \"document-id\", " +
1507                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
1508                                 "\"Value\"      : -0 " +
1509                                         "}] } ] }}");
1510                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=0}],includeInResults=false}]}}]}", request.toString());
1511                 } catch (Exception e) {
1512                         fail ("Failed convert from JSON to object: " + e);
1513                 }
1514                 
1515                 
1516                 // All other data types are checked when we convert internally, so value must be syntactically correct
1517                 
1518                 try {
1519                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1520                                 "\"Id\" : \"document-id\", " +
1521                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
1522                                 "\"Value\"      : \"syntactically incorrect value\" " +
1523                                         "}] } ] }}");
1524                         fail("Operation should throw exception");
1525                 } catch (JSONStructureException e) {
1526                         // correct response
1527                 } catch (Exception e) {
1528                         fail ("Failed convert from JSON to object: " + e);
1529                 }
1530                 
1531                 try {
1532                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1533                                 "\"Id\" : \"document-id\", " +
1534                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
1535                                 "\"Value\"      : \"syntactically incorrect value\" " +
1536                                         "}] } ] }}");
1537                         fail("Operation should throw exception");
1538                 } catch (JSONStructureException e) {
1539                         // correct response
1540                 } catch (Exception e) {
1541                         fail ("Failed convert from JSON to object: " + e);
1542                 }
1543                 
1544                 try {
1545                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1546                                 "\"Id\" : \"document-id\", " +
1547                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
1548                                 "\"Value\"      : \"syntactically incorrect value\" " +
1549                                         "}] } ] }}");
1550                         fail("Operation should throw exception");
1551                 } catch (JSONStructureException e) {
1552                         // correct response
1553                 } catch (Exception e) {
1554                         fail ("Failed convert from JSON to object: " + e);
1555                 }
1556                 
1557                 try {
1558                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1559                                 "\"Id\" : \"document-id\", " +
1560                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
1561                                 "\"Value\"      : \"syntactically incorrect value\" " +
1562                                         "}] } ] }}");
1563                         fail("Operation should throw exception");
1564                 } catch (JSONStructureException e) {
1565                         // correct response
1566                 } catch (Exception e) {
1567                         fail ("Failed convert from JSON to object: " + e);
1568                 }
1569                 
1570                 try {
1571                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1572                                 "\"Id\" : \"document-id\", " +
1573                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
1574                                 "\"Value\"      : \"syntactically incorrect value\" " +
1575                                         "}] } ] }}");
1576                         fail("Operation should throw exception");
1577                 } catch (JSONStructureException e) {
1578                         // correct response
1579                 } catch (Exception e) {
1580                         fail ("Failed convert from JSON to object: " + e);
1581                 }
1582                 
1583                 try {
1584                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1585                                 "\"Id\" : \"document-id\", " +
1586                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#anyURI\", " +
1587                                 "\"Value\"      : \"syntactically incorrect value\" " +
1588                                         "}] } ] }}");
1589                         fail("Operation should throw exception");
1590                 } catch (JSONStructureException e) {
1591                         // correct response
1592                 } catch (Exception e) {
1593                         fail ("Failed convert from JSON to object: " + e);
1594                 }
1595                 
1596                 try {
1597                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1598                                 "\"Id\" : \"document-id\", " +
1599                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#hexBinary\", " +
1600                                 "\"Value\"      : \"syntactically incorrect value\" " +
1601                                         "}] } ] }}");
1602                         fail("Operation should throw exception");
1603                 } catch (JSONStructureException e) {
1604                         // correct response
1605                 } catch (Exception e) {
1606                         fail ("Failed convert from JSON to object: " + e);
1607                 }
1608                 
1609                 // Base64 convert does not throw an exception if the contents are not Base64, so cannot test for this.
1610                 // Any problem with the data will have to be discovered later when the data is used.
1611                 
1612                 try {
1613                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1614                                 "\"Id\" : \"document-id\", " +
1615                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
1616                                 "\"Value\"      : \"syntactically incorrect value\" " +
1617                                         "}] } ] }}");
1618                         fail("Operation should throw exception");
1619                 } catch (JSONStructureException e) {
1620                         // correct response
1621                 } catch (Exception e) {
1622                         fail ("Failed convert from JSON to object: " + e);
1623                 }
1624                 
1625                 try {
1626                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1627                                 "\"Id\" : \"document-id\", " +
1628                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
1629                                 "\"Value\"      : \"syntactically incorrect value\" " +
1630                                         "}] } ] }}");
1631                         fail("Operation should throw exception");
1632                 } catch (JSONStructureException e) {
1633                         // correct response
1634                 } catch (Exception e) {
1635                         fail ("Failed convert from JSON to object: " + e);
1636                 }
1637                 
1638                 try {
1639                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1640                                 "\"Id\" : \"document-id\", " +
1641                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
1642                                 "\"Value\"      : \"syntactically incorrect value\" " +
1643                                         "}] } ] }}");
1644                         fail("Operation should throw exception");
1645                 } catch (JSONStructureException e) {
1646                         // correct response
1647                 } catch (Exception e) {
1648                         fail ("Failed convert from JSON to object: " + e);
1649                 }
1650                 
1651                 try {
1652                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1653                                 "\"Id\" : \"document-id\", " +
1654                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\", " +
1655                                 "\"Value\"      : \"syntactically incorrect value\" " +
1656                                         "}] } ] }}");
1657                         fail("Operation should throw exception");
1658                 } catch (JSONStructureException e) {
1659                         // correct response
1660                 } catch (Exception e) {
1661                         fail ("Failed convert from JSON to object: " + e);
1662                 }
1663                 
1664
1665                 // Cannot test XPathExpressions here.  The XPathExpression gets converted into a simple String value within the XPathExpression object,
1666                 // but it is not evaluated or compiled at that time.  Therefore we do not know whether or not the value is valid until it is used in a computation.
1667
1668         }
1669         
1670         
1671         @Test
1672         public void testArrayDataTypes() {
1673                 
1674                 // array of size 0
1675                 try {
1676                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1677                                 "\"Id\" : \"document-id\", " +
1678                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
1679                                 "\"Value\"      : [] " +
1680                                         "}] } ] }}");
1681                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,includeInResults=false}]}}]}", request.toString());
1682                 } catch (Exception e) {
1683                         fail ("Failed convert from JSON to object: " + e);
1684                 }
1685                 
1686                 
1687                 // Category Attribute value array DataType given (repeat for all data types)
1688                 // Category Attribute using full Identifier for each data type
1689                 // Category Attribute shorthand notation for each data type
1690                 // Also tests for mixes of different JSON types (trying incorrect strings for XACML data types whenever possible)
1691                 // string
1692                 try {
1693                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1694                                 "\"Id\" : \"document-id\", " +
1695                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
1696                                 "\"Value\"      : [\"abc\", \"def\", \"hig\", \"lmn\"] " +
1697                                         "}] } ] }}");
1698                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=def}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
1699                 } catch (Exception e) {
1700                         fail ("Failed convert from JSON to object: " + e);
1701                 }
1702                 try {
1703                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1704                                 "\"Id\" : \"document-id\", " +
1705                                 "\"DataType\"   : \"string\", " +
1706                                 "\"Value\"      : [\"abc\", \"def\", \"hig\", \"lmn\"] " +
1707                                         "}] } ] }}");
1708                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=def}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
1709                 } catch (Exception e) {
1710                         fail ("Failed convert from JSON to object: " + e);
1711                 }
1712                 // SUCCESSFUL AUTO-CONVERT to DataType
1713                 try {
1714                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1715                                 "\"Id\" : \"document-id\", " +
1716                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
1717                                 "\"Value\"      : [\"abc\", true, \"hig\", \"lmn\"] " +
1718                                         "}] } ] }}");
1719                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
1720                 } catch (Exception e) {
1721                         fail ("Failed convert from JSON to object: " + e);
1722                 }
1723                 // SUCCESSFUL AUTO-CONVERT
1724                 try {
1725                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1726                                 "\"Id\" : \"document-id\", " +
1727                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
1728                                 "\"Value\"      : [\"abc\",123, \"hig\", \"lmn\"] " +
1729                                         "}] } ] }}");
1730                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
1731                 } catch (Exception e) {
1732                         fail ("Failed convert from JSON to object: " + e);
1733                 }
1734                 // SUCCESSFUL AUTO-CONVERT
1735                 try {
1736                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1737                                 "\"Id\" : \"document-id\", " +
1738                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
1739                                 "\"Value\"      : [\"abc\", 34.34, \"hig\", \"lmn\"] " +
1740                                         "}] } ] }}");
1741                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=34.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
1742                 } catch (Exception e) {
1743                         fail ("Failed convert from JSON to object: " + e);
1744                 }
1745                 
1746                 
1747                 // boolean
1748                 try {
1749                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1750                                 "\"Id\" : \"document-id\", " +
1751                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
1752                                 "\"Value\"      : [true, true, false, true, false ] " +
1753                                         "}] } ] }}");
1754                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=false}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=false}],includeInResults=false}]}}]}", request.toString());
1755                 } catch (Exception e) {
1756                         fail ("Failed convert from JSON to object: " + e);
1757                 }
1758                 try {
1759                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1760                                 "\"Id\" : \"document-id\", " +
1761                                 "\"DataType\"   : \"boolean\", " +
1762                                 "\"Value\"      : [true, true, false, true, false ] " +
1763                                         "}] } ] }}");
1764                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=false}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=false}],includeInResults=false}]}}]}", request.toString());
1765                 } catch (Exception e) {
1766                         fail ("Failed convert from JSON to object: " + e);
1767                 }
1768                 try {
1769                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1770                                 "\"Id\" : \"document-id\", " +
1771                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
1772                                 "\"Value\"      : [true, \"abc\", false, true, false ] " +
1773                                         "}] } ] }}");
1774                         fail("Operation should throw exception");
1775                 } catch (JSONStructureException e) {
1776                         // correct response
1777                 } catch (Exception e) {
1778                         fail ("Failed convert from JSON to object: " + e);
1779                 }
1780                 try {
1781                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1782                                 "\"Id\" : \"document-id\", " +
1783                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
1784                                 "\"Value\"      : [true, 123, false, true, false ] " +
1785                                         "}] } ] }}");
1786                         fail("Operation should throw exception");
1787                 } catch (JSONStructureException e) {
1788                         // correct response
1789                 } catch (Exception e) {
1790                         fail ("Failed convert from JSON to object: " + e);
1791                 }
1792                 try {
1793                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1794                                 "\"Id\" : \"document-id\", " +
1795                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#boolean\", " +
1796                                 "\"Value\"      : [true, 12.34, false, true, false ] " +
1797                                         "}] } ] }}");
1798                         fail("Operation should throw exception");
1799                 } catch (JSONStructureException e) {
1800                         // correct response
1801                 } catch (Exception e) {
1802                         fail ("Failed convert from JSON to object: " + e);
1803                 }
1804                 
1805                 
1806                 
1807                 // integer
1808                 try {
1809                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1810                                 "\"Id\" : \"document-id\", " +
1811                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
1812                                 "\"Value\"      : [123, 456, 765, 234] " +
1813                                         "}] } ] }}");
1814                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=456}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=765}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=234}],includeInResults=false}]}}]}", request.toString());
1815                 } catch (Exception e) {
1816                         fail ("Failed convert from JSON to object: " + e);
1817                 }
1818                 try {
1819                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1820                                 "\"Id\" : \"document-id\", " +
1821                                 "\"DataType\"   : \"integer\", " +
1822                                 "\"Value\"      : [123, 456, 765, 234] " +
1823                                         "}] } ] }}");
1824                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=456}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=765}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=234}],includeInResults=false}]}}]}", request.toString());
1825                 } catch (Exception e) {
1826                         fail ("Failed convert from JSON to object: " + e);
1827                 }
1828                 try {
1829                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1830                                 "\"Id\" : \"document-id\", " +
1831                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
1832                                 "\"Value\"      : [123, \"abc\", 765, 234] " +
1833                                         "}] } ] }}");
1834                         fail("Operation should throw exception");
1835                 } catch (JSONStructureException e) {
1836                         // correct response
1837                 } catch (Exception e) {
1838                         fail ("Failed convert from JSON to object: " + e);
1839                 }
1840                 try {
1841                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1842                                 "\"Id\" : \"document-id\", " +
1843                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
1844                                 "\"Value\"      : [123, true, 765, 234] " +
1845                                         "}] } ] }}");
1846                         fail("Operation should throw exception");
1847                 } catch (JSONStructureException e) {
1848                         // correct response
1849                 } catch (Exception e) {
1850                         fail ("Failed convert from JSON to object: " + e);
1851                 }
1852                 try {
1853                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1854                                 "\"Id\" : \"document-id\", " +
1855                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#integer\", " +
1856                                 "\"Value\"      : [123, 34.56, 765, 234] " +
1857                                         "}] } ] }}");
1858                         fail("Operation should throw exception");
1859                 } catch (JSONStructureException e) {
1860                         // correct response
1861                 } catch (Exception e) {
1862                         fail ("Failed convert from JSON to object: " + e);
1863                 }
1864                 
1865                 
1866                 // double
1867                 try {
1868                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1869                                 "\"Id\" : \"document-id\", " +
1870                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
1871                                 "\"Value\"      : [ 123.34, 543.54, 3445.455, 4543,543 ] " +
1872                                         "}] } ] }}");
1873                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.54}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=3445.455}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=4543.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.0}],includeInResults=false}]}}]}", request.toString());
1874                 } catch (Exception e) {
1875                         fail ("Failed convert from JSON to object: " + e);
1876                 }
1877                 try {
1878                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1879                                 "\"Id\" : \"document-id\", " +
1880                                 "\"DataType\"   : \"double\", " +
1881                                 "\"Value\"      : [ 123.34, 543.54, 3445.455, 4543,543 ] " +
1882                                         "}] } ] }}");
1883                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.54}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=3445.455}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=4543.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.0}],includeInResults=false}]}}]}", request.toString());
1884                 } catch (Exception e) {
1885                         fail ("Failed convert from JSON to object: " + e);
1886                 }
1887                 // special case - auto-convert integer to boolean
1888                 try {
1889                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1890                                 "\"Id\" : \"document-id\", " +
1891                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
1892                                 "\"Value\"      : [ 123.34, 111122, 3445.455, 4543,543 ] " +
1893                                         "}] } ] }}");
1894                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=111122.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=3445.455}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=4543.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.0}],includeInResults=false}]}}]}", request.toString());
1895                 } catch (Exception e) {
1896                         fail ("Failed convert from JSON to object: " + e);
1897                 }
1898                 try {
1899                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1900                                 "\"Id\" : \"document-id\", " +
1901                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
1902                                 "\"Value\"      : [ 123.34, true, 3445.455, 4543,543 ] " +
1903                                         "}] } ] }}");
1904                         fail("Operation should throw exception");
1905                 } catch (JSONStructureException e) {
1906                         // correct response
1907                 } catch (Exception e) {
1908                         fail ("Failed convert from JSON to object: " + e);
1909                 }
1910                 try {
1911                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1912                                 "\"Id\" : \"document-id\", " +
1913                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#double\", " +
1914                                 "\"Value\"      : [ 123.34, \"abb\", 3445.455, 4543,543 ] " +
1915                                         "}] } ] }}");
1916                         fail("Operation should throw exception");
1917                 } catch (JSONStructureException e) {
1918                         // correct response
1919                 } catch (Exception e) {
1920                         fail ("Failed convert from JSON to object: " + e);
1921                 }
1922                 
1923                 
1924                 // time
1925                 try {
1926                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1927                                 "\"Id\" : \"document-id\", " +
1928                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
1929                                 "\"Value\"      : [ \"12:00:00Z\", \"12:00:00Z\", \"12:00:00Z\"] " +
1930                                         "}] } ] }}");
1931                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
1932                 } catch (Exception e) {
1933                         fail ("Failed convert from JSON to object: " + e);
1934                 }
1935                 try {
1936                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1937                                 "\"Id\" : \"document-id\", " +
1938                                 "\"DataType\"   : \"time\", " +
1939                                 "\"Value\"      : [ \"12:00:00Z\", \"12:00:00Z\", \"12:00:00Z\"] " +
1940                                         "}] } ] }}");
1941                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#time,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
1942                 } catch (Exception e) {
1943                         fail ("Failed convert from JSON to object: " + e);
1944                 }
1945                 try {
1946                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1947                                 "\"Id\" : \"document-id\", " +
1948                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
1949                                 "\"Value\"      : [ \"12:00:00Z\", \"not a time\", \"12:00:00Z\"] " +
1950                                         "}] } ] }}");
1951                         fail("Operation should throw exception");
1952                 } catch (JSONStructureException e) {
1953                         // correct response
1954                 } catch (Exception e) {
1955                         fail ("Failed convert from JSON to object: " + e);
1956                 }
1957                 try {
1958                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1959                                 "\"Id\" : \"document-id\", " +
1960                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
1961                                 "\"Value\"      : [ \"12:00:00Z\", true, \"12:00:00Z\"] " +
1962                                         "}] } ] }}");
1963                         fail("Operation should throw exception");
1964                 } catch (JSONStructureException e) {
1965                         // correct response
1966                 } catch (Exception e) {
1967                         fail ("Failed convert from JSON to object: " + e);
1968                 }
1969                 try {
1970                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1971                                 "\"Id\" : \"document-id\", " +
1972                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
1973                                 "\"Value\"      : [ \"12:00:00Z\", 123, \"12:00:00Z\"] " +
1974                                         "}] } ] }}");
1975                         fail("Operation should throw exception");
1976                 } catch (JSONStructureException e) {
1977                         // correct response
1978                 } catch (Exception e) {
1979                         fail ("Failed convert from JSON to object: " + e);
1980                 }
1981                 try {
1982                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1983                                 "\"Id\" : \"document-id\", " +
1984                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#time\", " +
1985                                 "\"Value\"      : [ \"12:00:00Z\", 12.34, \"12:00:00Z\"] " +
1986                                         "}] } ] }}");
1987                         fail("Operation should throw exception");
1988                 } catch (JSONStructureException e) {
1989                         // correct response
1990                 } catch (Exception e) {
1991                         fail ("Failed convert from JSON to object: " + e);
1992                 }
1993                 
1994                 
1995                 // date
1996                 try {
1997                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1998                                 "\"Id\" : \"document-id\", " +
1999                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
2000                                 "\"Value\"      : [\"2002-10-10\",\"2002-10-10\",\"2002-10-10\" ] " +
2001                                         "}] } ] }}");
2002                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
2003                 } catch (Exception e) {
2004                         fail ("Failed convert from JSON to object: " + e);
2005                 }
2006                 try {
2007                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2008                                 "\"Id\" : \"document-id\", " +
2009                                 "\"DataType\"   : \"date\", " +
2010                                 "\"Value\"      : [\"2002-10-10\",\"2002-10-10\",\"2002-10-10\" ] " +
2011                                         "}] } ] }}");
2012                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#date,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
2013                 } catch (Exception e) {
2014                         fail ("Failed convert from JSON to object: " + e);
2015                 }
2016                 try {
2017                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2018                                 "\"Id\" : \"document-id\", " +
2019                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
2020                                 "\"Value\"      : [\"2002-10-10\",\"not a date\",\"2002-10-10\" ] " +
2021                                         "}] } ] }}");
2022                         fail("Operation should throw exception");
2023                 } catch (JSONStructureException e) {
2024                         // correct response
2025                 } catch (Exception e) {
2026                         fail ("Failed convert from JSON to object: " + e);
2027                 }
2028                 try {
2029                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2030                                 "\"Id\" : \"document-id\", " +
2031                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
2032                                 "\"Value\"      : [\"2002-10-10\",true,\"2002-10-10\" ] " +
2033                                         "}] } ] }}");
2034                         fail("Operation should throw exception");
2035                 } catch (JSONStructureException e) {
2036                         // correct response
2037                 } catch (Exception e) {
2038                         fail ("Failed convert from JSON to object: " + e);
2039                 }
2040                 try {
2041                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2042                                 "\"Id\" : \"document-id\", " +
2043                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
2044                                 "\"Value\"      : [\"2002-10-10\",123,\"2002-10-10\" ] " +
2045                                         "}] } ] }}");
2046                         fail("Operation should throw exception");
2047                 } catch (JSONStructureException e) {
2048                         // correct response
2049                 } catch (Exception e) {
2050                         fail ("Failed convert from JSON to object: " + e);
2051                 }
2052                 try {
2053                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2054                                 "\"Id\" : \"document-id\", " +
2055                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#date\", " +
2056                                 "\"Value\"      : [\"2002-10-10\",123.45,\"2002-10-10\" ] " +
2057                                         "}] } ] }}");
2058                         fail("Operation should throw exception");
2059                 } catch (JSONStructureException e) {
2060                         // correct response
2061                 } catch (Exception e) {
2062                         fail ("Failed convert from JSON to object: " + e);
2063                 }
2064                 
2065                 
2066                 // dateTime
2067                 try {
2068                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2069                                 "\"Id\" : \"document-id\", " +
2070                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
2071                                 "\"Value\"      : [ \"2002-10-10T12:00:00Z\",\"2002-10-10T12:00:00Z\",\"2002-10-10T12:00:00Z\" ] " +
2072                                         "}] } ] }}");
2073                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
2074                 } catch (Exception e) {
2075                         fail ("Failed convert from JSON to object: " + e);
2076                 }
2077                 try {
2078                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2079                                 "\"Id\" : \"document-id\", " +
2080                                 "\"DataType\"   : \"dateTime\", " +
2081                                 "\"Value\"      : [ \"2002-10-10T12:00:00Z\",\"2002-10-10T12:00:00Z\",\"2002-10-10T12:00:00Z\" ] " +
2082                                         "}] } ] }}");
2083                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#dateTime,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
2084                 } catch (Exception e) {
2085                         fail ("Failed convert from JSON to object: " + e);
2086                 }
2087                 try {
2088                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2089                                 "\"Id\" : \"document-id\", " +
2090                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
2091                                 "\"Value\"      : [ \"2002-10-10T12:00:00Z\",\"not a dateTime\",\"2002-10-10T12:00:00Z\" ] " +
2092                                         "}] } ] }}");
2093                         fail("Operation should throw exception");
2094                 } catch (JSONStructureException e) {
2095                         // correct response
2096                 } catch (Exception e) {
2097                         fail ("Failed convert from JSON to object: " + e);
2098                 }
2099                 try {
2100                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2101                                 "\"Id\" : \"document-id\", " +
2102                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
2103                                 "\"Value\"      : [ \"2002-10-10T12:00:00Z\",true,\"2002-10-10T12:00:00Z\" ] " +
2104                                         "}] } ] }}");
2105                         fail("Operation should throw exception");
2106                 } catch (JSONStructureException e) {
2107                         // correct response
2108                 } catch (Exception e) {
2109                         fail ("Failed convert from JSON to object: " + e);
2110                 }
2111                 try {
2112                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2113                                 "\"Id\" : \"document-id\", " +
2114                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
2115                                 "\"Value\"      : [ \"2002-10-10T12:00:00Z\",123,\"2002-10-10T12:00:00Z\" ] " +
2116                                         "}] } ] }}");
2117                         fail("Operation should throw exception");
2118                 } catch (JSONStructureException e) {
2119                         // correct response
2120                 } catch (Exception e) {
2121                         fail ("Failed convert from JSON to object: " + e);
2122                 }
2123                 try {
2124                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2125                                 "\"Id\" : \"document-id\", " +
2126                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dateTime\", " +
2127                                 "\"Value\"      : [ \"2002-10-10T12:00:00Z\",12.34,\"2002-10-10T12:00:00Z\" ] " +
2128                                         "}] } ] }}");
2129                         fail("Operation should throw exception");
2130                 } catch (JSONStructureException e) {
2131                         // correct response
2132                 } catch (Exception e) {
2133                         fail ("Failed convert from JSON to object: " + e);
2134                 }
2135                 
2136                 
2137                 // dayTimeDuration
2138                 try {
2139                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2140                                 "\"Id\" : \"document-id\", " +
2141                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
2142                                 "\"Value\"      : [ \"P23DT7H12M54S\",\"P23DT7H12M54S\",\"P23DT7H12M54S\" ] " +
2143                                         "}] } ] }}");
2144                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}],includeInResults=false}]}}]}", request.toString());
2145                 } catch (Exception e) {
2146                         fail ("Failed convert from JSON to object: " + e);
2147                 }
2148                 try {
2149                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2150                                 "\"Id\" : \"document-id\", " +
2151                                 "\"DataType\"   : \"dayTimeDuration\", " +
2152                                 "\"Value\"      : [ \"P23DT7H12M54S\",\"P23DT7H12M54S\",\"P23DT7H12M54S\" ] " +
2153                                         "}] } ] }}");
2154                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}{dataTypeId=http://www.w3.org/2001/XMLSchema#dayTimeDuration,value={super={durationSign=1years=0months=0days=23hours=7minutes=12seconds=54millis=0},factionalSeconds=54.0}}],includeInResults=false}]}}]}", request.toString());
2155                 } catch (Exception e) {
2156                         fail ("Failed convert from JSON to object: " + e);
2157                 }
2158                 try {
2159                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2160                                 "\"Id\" : \"document-id\", " +
2161                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
2162                                 "\"Value\"      : [ \"P23DT7H12M54S\",\"not a duration\",\"P23DT7H12M54S\" ] " +
2163                                         "}] } ] }}");
2164                         fail("Operation should throw exception");
2165                 } catch (JSONStructureException e) {
2166                         // correct response
2167                 } catch (Exception e) {
2168                         fail ("Failed convert from JSON to object: " + e);
2169                 }
2170                 try {
2171                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2172                                 "\"Id\" : \"document-id\", " +
2173                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
2174                                 "\"Value\"      : [ \"P23DT7H12M54S\",true,\"P23DT7H12M54S\" ] " +
2175                                         "}] } ] }}");
2176                         fail("Operation should throw exception");
2177                 } catch (JSONStructureException e) {
2178                         // correct response
2179                 } catch (Exception e) {
2180                         fail ("Failed convert from JSON to object: " + e);
2181                 }
2182                 try {
2183                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2184                                 "\"Id\" : \"document-id\", " +
2185                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
2186                                 "\"Value\"      : [ \"P23DT7H12M54S\",123,\"P23DT7H12M54S\" ] " +
2187                                         "}] } ] }}");
2188                         fail("Operation should throw exception");
2189                 } catch (JSONStructureException e) {
2190                         // correct response
2191                 } catch (Exception e) {
2192                         fail ("Failed convert from JSON to object: " + e);
2193                 }
2194                 try {
2195                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2196                                 "\"Id\" : \"document-id\", " +
2197                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#dayTimeDuration\", " +
2198                                 "\"Value\"      : [ \"P23DT7H12M54S\",11.22,\"P23DT7H12M54S\" ] " +
2199                                         "}] } ] }}");
2200                         fail("Operation should throw exception");
2201                 } catch (JSONStructureException e) {
2202                         // correct response
2203                 } catch (Exception e) {
2204                         fail ("Failed convert from JSON to object: " + e);
2205                 }
2206                 
2207                 
2208                 // yearMonth duration
2209                 try {
2210                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2211                                 "\"Id\" : \"document-id\", " +
2212                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
2213                                 "\"Value\"      : [ \"P165Y8M\",\"P165Y8M\",\"P165Y8M\" ] " +
2214                                         "}] } ] }}");
2215                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}],includeInResults=false}]}}]}", request.toString());
2216                 } catch (Exception e) {
2217                         fail ("Failed convert from JSON to object: " + e);
2218                 }
2219                 try {
2220                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2221                                 "\"Id\" : \"document-id\", " +
2222                                 "\"DataType\"   : \"yearMonthDuration\", " +
2223                                 "\"Value\"      : [ \"P165Y8M\",\"P165Y8M\",\"P165Y8M\" ] " +
2224                                         "}] } ] }}");
2225                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}{dataTypeId=http://www.w3.org/2001/XMLSchema#yearMonthDuration,value={super={durationSign=1years=165months=8days=0hours=0minutes=0seconds=0millis=0},monthsDuration=1988}}],includeInResults=false}]}}]}", request.toString());
2226                 } catch (Exception e) {
2227                         fail ("Failed convert from JSON to object: " + e);
2228                 }
2229                 try {
2230                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2231                                 "\"Id\" : \"document-id\", " +
2232                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
2233                                 "\"Value\"      : [ \"P165Y8M\",\"not a duration\",\"P165Y8M\" ] " +
2234                                         "}] } ] }}");
2235                         fail("Operation should throw exception");
2236                 } catch (JSONStructureException e) {
2237                         // correct response
2238                 } catch (Exception e) {
2239                         fail ("Failed convert from JSON to object: " + e);
2240                 }
2241                 try {
2242                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2243                                 "\"Id\" : \"document-id\", " +
2244                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
2245                                 "\"Value\"      : [ \"P165Y8M\",true,\"P165Y8M\" ] " +
2246                                         "}] } ] }}");
2247                         fail("Operation should throw exception");
2248                 } catch (JSONStructureException e) {
2249                         // correct response
2250                 } catch (Exception e) {
2251                         fail ("Failed convert from JSON to object: " + e);
2252                 }
2253                 try {
2254                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2255                                 "\"Id\" : \"document-id\", " +
2256                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
2257                                 "\"Value\"      : [ \"P165Y8M\",123,\"P165Y8M\" ] " +
2258                                         "}] } ] }}");
2259                         fail("Operation should throw exception");
2260                 } catch (JSONStructureException e) {
2261                         // correct response
2262                 } catch (Exception e) {
2263                         fail ("Failed convert from JSON to object: " + e);
2264                 }
2265                 try {
2266                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2267                                 "\"Id\" : \"document-id\", " +
2268                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#yearMonthDuration\", " +
2269                                 "\"Value\"      : [ \"P165Y8M\",11.22,\"P165Y8M\" ] " +
2270                                         "}] } ] }}");
2271                         fail("Operation should throw exception");
2272                 } catch (JSONStructureException e) {
2273                         // correct response
2274                 } catch (Exception e) {
2275                         fail ("Failed convert from JSON to object: " + e);
2276                 }
2277                 
2278                 
2279                 // anyURI
2280                 try {
2281                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2282                                 "\"Id\" : \"document-id\", " +
2283                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#anyURI\", " +
2284                                 "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
2285                                         "}] } ] }}");
2286                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
2287                 } catch (Exception e) {
2288                         fail ("Failed convert from JSON to object: " + e);
2289                 }
2290                 try {
2291                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2292                                 "\"Id\" : \"document-id\", " +
2293                                 "\"DataType\"   : \"anyURI\", " +
2294                                 "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
2295                                         "}] } ] }}");
2296                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
2297                 } catch (Exception e) {
2298                         fail ("Failed convert from JSON to object: " + e);
2299                 }
2300                 // SUCCESSFUL AUTO-CONVERT
2301                 try {
2302                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2303                                 "\"Id\" : \"document-id\", " +
2304                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#anyURI\", " +
2305                                 "\"Value\"      : [ \"aValue\",true,\"aValue\"] " +
2306                                         "}] } ] }}");
2307                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
2308                 } catch (Exception e) {
2309                         fail ("Failed convert from JSON to object: " + e);
2310                 }
2311                 // SUCCESSFUL AUTO-CONVERT
2312                 try {
2313                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2314                                 "\"Id\" : \"document-id\", " +
2315                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#anyURI\", " +
2316                                 "\"Value\"      : [ \"aValue\",123,\"aValue\"] " +
2317                                         "}] } ] }}");
2318                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
2319                 } catch (Exception e) {
2320                         fail ("Failed convert from JSON to object: " + e);
2321                 }
2322                 // AUTO-CONVERT
2323                 try {
2324                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2325                                 "\"Id\" : \"document-id\", " +
2326                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#anyURI\", " +
2327                                 "\"Value\"      : [ \"aValue\",11.111,\"aValue\"] " +
2328                                         "}] } ] }}");
2329                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=11.111}{dataTypeId=http://www.w3.org/2001/XMLSchema#anyURI,value=aValue}],includeInResults=false}]}}]}", request.toString());
2330                 } catch (Exception e) {
2331                         fail ("Failed convert from JSON to object: " + e);
2332                 }
2333                 
2334                 
2335                 // hexBinary
2336                 try {
2337                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2338                                 "\"Id\" : \"document-id\", " +
2339                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#hexBinary\", " +
2340                                 "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\" ] " +
2341                                         "}] } ] }}");
2342                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}],includeInResults=false}]}}]}", request.toString());
2343                 } catch (Exception e) {
2344                         fail ("Failed convert from JSON to object: " + e);
2345                 }
2346                 try {
2347                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2348                                 "\"Id\" : \"document-id\", " +
2349                                 "\"DataType\"   : \"hexBinary\", " +
2350                                 "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\" ] " +
2351                                         "}] } ] }}");
2352                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#hexBinary,value={data=[-6,2,123,125,18,-52,52,-35,-46,0,18,-82,-17]}}],includeInResults=false}]}}]}", request.toString());
2353                 } catch (Exception e) {
2354                         fail ("Failed convert from JSON to object: " + e);
2355                 }
2356                 try {
2357                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2358                                 "\"Id\" : \"document-id\", " +
2359                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#hexBinary\", " +
2360                                 "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",true,\"012AEEF\" ] " +
2361                                         "}] } ] }}");
2362                         fail("Operation should throw exception");
2363                 } catch (JSONStructureException e) {
2364                         // correct response
2365                 } catch (Exception e) {
2366                         fail ("Failed convert from JSON to object: " + e);
2367                 }
2368                 try {
2369                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2370                                 "\"Id\" : \"document-id\", " +
2371                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#hexBinary\", " +
2372                                 "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",123,\"012AEEF\" ] " +
2373                                         "}] } ] }}");
2374                         fail("Operation should throw exception");
2375                 } catch (JSONStructureException e) {
2376                         // correct response
2377                 } catch (Exception e) {
2378                         fail ("Failed convert from JSON to object: " + e);
2379                 }
2380                 try {
2381                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2382                                 "\"Id\" : \"document-id\", " +
2383                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#hexBinary\", " +
2384                                 "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",11.44,\"012AEEF\" ] " +
2385                                         "}] } ] }}");
2386                         fail("Operation should throw exception");
2387                 } catch (JSONStructureException e) {
2388                         // correct response
2389                 } catch (Exception e) {
2390                         fail ("Failed convert from JSON to object: " + e);
2391                 }
2392                 
2393                 
2394                 // base64Binary
2395                 try {
2396                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2397                                 "\"Id\" : \"document-id\", " +
2398                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#base64Binary\", " +
2399                                 "\"Value\"      : [ \"aG9y\",\"lvbj0iMS4xIj48YXV0aG9y\",\"lvbjIj48YXV0aG9y\" ] " +
2400                                         "}] } ] }}");
2401                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[104,111,114]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,-46,35,18,-29,18,35,-29,-58,23,87,70,-122,-9]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,34,62,60,97,117,116,104,111,114]}}],includeInResults=false}]}}]}", request.toString());
2402                 } catch (Exception e) {
2403                         fail ("Failed convert from JSON to object: " + e);
2404                 }
2405                 try {
2406                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2407                                 "\"Id\" : \"document-id\", " +
2408                                 "\"DataType\"   : \"base64Binary\", " +
2409                                 "\"Value\"      : [ \"aG9y\",\"lvbj0iMS4xIj48YXV0aG9y\",\"lvbjIj48YXV0aG9y\" ] " +
2410                                         "}] } ] }}");
2411                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[104,111,114]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,-46,35,18,-29,18,35,-29,-58,23,87,70,-122,-9]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,34,62,60,97,117,116,104,111,114]}}],includeInResults=false}]}}]}", request.toString());
2412                 } catch (Exception e) {
2413                         fail ("Failed convert from JSON to object: " + e);
2414                 }
2415                 // AUTO-CONVERT
2416                 try {
2417                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2418                                 "\"Id\" : \"document-id\", " +
2419                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#base64Binary\", " +
2420                                 "\"Value\"      : [ \"aG9y\",true,\"lvbjIj48YXV0aG9y\" ] " +
2421                                         "}] } ] }}");
2422                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[104,111,114]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-74,-69,-98]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,34,62,60,97,117,116,104,111,114]}}],includeInResults=false}]}}]}", request.toString());
2423                 } catch (Exception e) {
2424                         fail ("Failed convert from JSON to object: " + e);
2425                 }
2426                 // AUTO-CONVERT
2427                 try {
2428                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2429                                 "\"Id\" : \"document-id\", " +
2430                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#base64Binary\", " +
2431                                 "\"Value\"      : [ \"aG9y\",1123,\"lvbjIj48YXV0aG9y\" ] " +
2432                                         "}] } ] }}");
2433                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[104,111,114]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-41,93,-73]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,34,62,60,97,117,116,104,111,114]}}],includeInResults=false}]}}]}", request.toString());
2434                 } catch (Exception e) {
2435                         fail ("Failed convert from JSON to object: " + e);
2436                 }
2437                 // AUTO-CONVERT
2438                 try {
2439                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2440                                 "\"Id\" : \"document-id\", " +
2441                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#base64Binary\", " +
2442                                 "\"Value\"      : [ \"aG9y\",11.22,\"lvbjIj48YXV0aG9y\" ] " +
2443                                         "}] } ] }}");
2444                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[104,111,114]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-41,93,-74]}}{dataTypeId=http://www.w3.org/2001/XMLSchema#base64Binary,value={data=[-106,-10,-29,34,62,60,97,117,116,104,111,114]}}],includeInResults=false}]}}]}", request.toString());
2445                 } catch (Exception e) {
2446                         fail ("Failed convert from JSON to object: " + e);
2447                 }
2448                 
2449                 
2450                 // RFC822 name
2451                 try {
2452                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2453                                 "\"Id\" : \"document-id\", " +
2454                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
2455                                 "\"Value\"      : [ \"sne.else@A.COMPANY.com\",\"one.else@A.COMPANY.com\",\"someone.else@A.CONY.com\" ] " +
2456                                         "}] } ] }}");
2457                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=sne.else,domainName=A.COMPANY.com}}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=one.else,domainName=A.COMPANY.com}}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=someone.else,domainName=A.CONY.com}}],includeInResults=false}]}}]}", request.toString());
2458                 } catch (Exception e) {
2459                         fail ("Failed convert from JSON to object: " + e);
2460                 }
2461                 try {
2462                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2463                                 "\"Id\" : \"document-id\", " +
2464                                 "\"DataType\"   : \"rfc822Name\", " +
2465                                 "\"Value\"      : [ \"sne.else@A.COMPANY.com\",\"one.else@A.COMPANY.com\",\"someone.else@A.CONY.com\" ] " +
2466                                         "}] } ] }}");
2467                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=sne.else,domainName=A.COMPANY.com}}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=one.else,domainName=A.COMPANY.com}}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name,value={localName=someone.else,domainName=A.CONY.com}}],includeInResults=false}]}}]}", request.toString());
2468                 } catch (Exception e) {
2469                         fail ("Failed convert from JSON to object: " + e);
2470                 }
2471                 try {
2472                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2473                                 "\"Id\" : \"document-id\", " +
2474                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
2475                                 "\"Value\"      : [ \"sne.else@A.COMPANY.com\",\"not a dns\",\"someone.else@A.CONY.com\" ] " +
2476                                         "}] } ] }}");
2477                         fail("Operation should throw exception");
2478                 } catch (JSONStructureException e) {
2479                         // correct response
2480                 } catch (Exception e) {
2481                         fail ("Failed convert from JSON to object: " + e);
2482                 }
2483                 try {
2484                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2485                                 "\"Id\" : \"document-id\", " +
2486                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
2487                                 "\"Value\"      : [ \"sne.else@A.COMPANY.com\",true,\"someone.else@A.CONY.com\" ] " +
2488                                         "}] } ] }}");
2489                         fail("Operation should throw exception");
2490                 } catch (JSONStructureException e) {
2491                         // correct response
2492                 } catch (Exception e) {
2493                         fail ("Failed convert from JSON to object: " + e);
2494                 }
2495                 try {
2496                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2497                                 "\"Id\" : \"document-id\", " +
2498                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
2499                                 "\"Value\"      : [ \"sne.else@A.COMPANY.com\",111,\"someone.else@A.CONY.com\" ] " +
2500                                         "}] } ] }}");
2501                         fail("Operation should throw exception");
2502                 } catch (JSONStructureException e) {
2503                         // correct response
2504                 } catch (Exception e) {
2505                         fail ("Failed convert from JSON to object: " + e);
2506                 }
2507                 try {
2508                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2509                                 "\"Id\" : \"document-id\", " +
2510                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name\", " +
2511                                 "\"Value\"      : [ \"sne.else@A.COMPANY.com\",11.22,\"someone.else@A.CONY.com\" ] " +
2512                                         "}] } ] }}");
2513                         fail("Operation should throw exception");
2514                 } catch (JSONStructureException e) {
2515                         // correct response
2516                 } catch (Exception e) {
2517                         fail ("Failed convert from JSON to object: " + e);
2518                 }
2519                 
2520                 
2521                 // x500
2522                 try {
2523                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2524                                 "\"Id\" : \"document-id\", " +
2525                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
2526                                 "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
2527                                         "}] } ] }}");
2528                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}],includeInResults=false}]}}]}", request.toString());
2529                 } catch (Exception e) {
2530                         fail ("Failed convert from JSON to object: " + e);
2531                 }
2532                 try {
2533                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2534                                 "\"Id\" : \"document-id\", " +
2535                                 "\"DataType\"   : \"x500Name\", " +
2536                                 "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
2537                                         "}] } ] }}");
2538                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}{dataTypeId=urn:oasis:names:tc:xacml:1.0:data-type:x500Name,value=CN=Julius Hibbert, O=Medi Corporation, C=US}],includeInResults=false}]}}]}", request.toString());
2539                 } catch (Exception e) {
2540                         fail ("Failed convert from JSON to object: " + e);
2541                 }
2542                 try {
2543                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2544                                 "\"Id\" : \"document-id\", " +
2545                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
2546                                 "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"non-x500 string\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
2547                                         "}] } ] }}");
2548                         fail("Operation should throw exception");
2549                 } catch (JSONStructureException e) {
2550                         // correct response
2551                 } catch (Exception e) {
2552                         fail ("Failed convert from JSON to object: " + e);
2553                 }
2554                 try {
2555                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2556                                 "\"Id\" : \"document-id\", " +
2557                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
2558                                 "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", true, \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
2559                                         "}] } ] }}");
2560                         fail("Operation should throw exception");
2561                 } catch (JSONStructureException e) {
2562                         // correct response
2563                 } catch (Exception e) {
2564                         fail ("Failed convert from JSON to object: " + e);
2565                 }
2566                 try {
2567                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2568                                 "\"Id\" : \"document-id\", " +
2569                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
2570                                 "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", 1111, \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
2571                                         "}] } ] }}");
2572                         fail("Operation should throw exception");
2573                 } catch (JSONStructureException e) {
2574                         // correct response
2575                 } catch (Exception e) {
2576                         fail ("Failed convert from JSON to object: " + e);
2577                 }
2578                 try {
2579                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2580                                 "\"Id\" : \"document-id\", " +
2581                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:1.0:data-type:x500Name\", " +
2582                                 "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", 11.22, \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
2583                                         "}] } ] }}");
2584                         fail("Operation should throw exception");
2585                 } catch (JSONStructureException e) {
2586                         // correct response
2587                 } catch (Exception e) {
2588                         fail ("Failed convert from JSON to object: " + e);
2589                 }
2590                 
2591                 
2592                 // ipAddress
2593                 try {
2594                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2595                                 "\"Id\" : \"document-id\", " +
2596                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
2597                                 "\"Value\"      : [ \"10.221.43.58:12345\",\"10.221.43.58:12345\",\"10.221.43.58:12345\" ] " +
2598                                         "}] } ] }}");
2599                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=10.221.43.58:12345-12345}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=10.221.43.58:12345-12345}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=10.221.43.58:12345-12345}],includeInResults=false}]}}]}", request.toString());
2600                 } catch (Exception e) {
2601                         fail ("Failed convert from JSON to object: " + e);
2602                 }
2603                 try {
2604                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2605                                 "\"Id\" : \"document-id\", " +
2606                                 "\"DataType\"   : \"ipAddress\", " +
2607                                 "\"Value\"      : [ \"10.221.43.58:12345\",\"10.221.43.58:12345\",\"10.221.43.58:12345\" ] " +
2608                                         "}] } ] }}");
2609                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=10.221.43.58:12345-12345}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=10.221.43.58:12345-12345}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=10.221.43.58:12345-12345}],includeInResults=false}]}}]}", request.toString());
2610                 } catch (Exception e) {
2611                         fail ("Failed convert from JSON to object: " + e);
2612                 }
2613                 try {
2614                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2615                                 "\"Id\" : \"document-id\", " +
2616                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
2617                                 "\"Value\"      : [ \"10.221.43.58:12345\",\"not an ip address\",\"10.221.43.58:12345\" ] " +
2618                                         "}] } ] }}");
2619                         fail("Operation should throw exception");
2620                 } catch (JSONStructureException e) {
2621                         // correct response
2622                 } catch (Exception e) {
2623                         fail ("Failed convert from JSON to object: " + e);
2624                 }
2625                 try {
2626                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2627                                 "\"Id\" : \"document-id\", " +
2628                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
2629                                 "\"Value\"      : [ \"10.221.43.58:12345\",true,\"10.221.43.58:12345\" ] " +
2630                                         "}] } ] }}");
2631                         fail("Operation should throw exception");
2632                 } catch (JSONStructureException e) {
2633                         // correct response
2634                 } catch (Exception e) {
2635                         fail ("Failed convert from JSON to object: " + e);
2636                 }
2637                 try {
2638                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2639                                 "\"Id\" : \"document-id\", " +
2640                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
2641                                 "\"Value\"      : [ \"10.221.43.58:12345\",1111,\"10.221.43.58:12345\" ] " +
2642                                         "}] } ] }}");
2643                         fail("Operation should throw exception");
2644                 } catch (JSONStructureException e) {
2645                         // correct response
2646                 } catch (Exception e) {
2647                         fail ("Failed convert from JSON to object: " + e);
2648                 }
2649                 try {
2650                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2651                                 "\"Id\" : \"document-id\", " +
2652                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:ipAddress\", " +
2653                                 "\"Value\"      : [ \"10.221.43.58:12345\",11.22,\"10.221.43.58:12345\" ] " +
2654                                         "}] } ] }}");
2655                         fail("Operation should throw exception");
2656                 } catch (JSONStructureException e) {
2657                         // correct response
2658                 } catch (Exception e) {
2659                         fail ("Failed convert from JSON to object: " + e);
2660                 }
2661                 
2662                 
2663                 // dnsName
2664                 try {
2665                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2666                                 "\"Id\" : \"document-id\", " +
2667                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\", " +
2668                                 "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
2669                                         "}] } ] }}");
2670                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}],includeInResults=false}]}}]}", request.toString());
2671                 } catch (Exception e) {
2672                         fail ("Failed convert from JSON to object: " + e);
2673                 }
2674                 try {
2675                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2676                                 "\"Id\" : \"document-id\", " +
2677                                 "\"DataType\"   : \"dnsName\", " +
2678                                 "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
2679                                         "}] } ] }}");
2680                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}],includeInResults=false}]}}]}", request.toString());
2681                 } catch (Exception e) {
2682                         fail ("Failed convert from JSON to object: " + e);
2683                 }
2684                 // AUTO-CONVERT
2685                 try {
2686                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2687                                 "\"Id\" : \"document-id\", " +
2688                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\", " +
2689                                 "\"Value\"      : [ \"aValue\", true, \"aValue\" ] " +
2690                                         "}] } ] }}");
2691                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=true}}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:dnsName,value={domainName=aValue}}],includeInResults=false}]}}]}", request.toString());
2692                 } catch (Exception e) {
2693                         fail ("Failed convert from JSON to object: " + e);
2694                 }
2695                 try {
2696                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2697                                 "\"Id\" : \"document-id\", " +
2698                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\", " +
2699                                 "\"Value\"      : [ \"aValue\", 1111, \"aValue\" ] " +
2700                                         "}] } ] }}");
2701                         fail("Operation should throw exception");
2702                 } catch (JSONStructureException e) {
2703                         // correct response
2704                 } catch (Exception e) {
2705                         fail ("Failed convert from JSON to object: " + e);
2706                 }
2707                 try {
2708                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2709                                 "\"Id\" : \"document-id\", " +
2710                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:2.0:data-type:dnsName\", " +
2711                                 "\"Value\"      : [ \"aValue\", 11.22, \"aValue\" ] " +
2712                                         "}] } ] }}");
2713                         fail("Operation should throw exception");
2714                 } catch (JSONStructureException e) {
2715                         // correct response
2716                 } catch (Exception e) {
2717                         fail ("Failed convert from JSON to object: " + e);
2718                 }
2719                 
2720                 
2721                 // xPathExpression
2722                 try {
2723                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", \"Attribute\" : [{" +
2724                                 "\"Id\" : \"document-id\", " +
2725                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\", " +
2726                                 "\"Value\"      : [ "
2727                                 + "{" +
2728                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2729                                         "\"Namespaces\" : ["
2730                                                 + "{ "+
2731                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2732                                                         "}," +
2733                                                         "{" +
2734                                                                 "\"Prefix\" : \"md\", " +
2735                                                                 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2736                                                         "}], "+
2737                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2738                         "}," +
2739                         "{" +
2740                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2741                                         "\"Namespaces\" : ["
2742                                                 + "{ "+
2743                                                                 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2744                                                                 "}," +
2745                                                                 "{" +
2746                                                                         "\"Prefix\" : \"md\", " +
2747                                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2748                                                                 "}], "+
2749                                                 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2750                                 "}," +
2751                                 "{" +
2752                                                 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2753                                                 "\"Namespaces\" : ["
2754                                                         + "{ "+
2755                                                                 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2756                                                                 "}," +
2757                                                                 "{" +
2758                                                                         "\"Prefix\" : \"md\", " +
2759                                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2760                                                                 "}], "+
2761                                                 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2762                                 "}"
2763                                 + "] " +
2764                                         "}] } ] }}");
2765                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,attributes=[{attributeId=document-id,category=urn:oasis:names:tc:xacml:3.0:attribute-category:resource,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace={[{md,urn:example:med:schemas:record}{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}]},status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace={[{md,urn:example:med:schemas:record}{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}]},status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace={[{md,urn:example:med:schemas:record}{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}]},status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
2766                 } catch (Exception e) {
2767                         fail ("Failed convert from JSON to object: " + e);
2768                 }
2769
2770                 try {
2771                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", \"Attribute\" : [{" +
2772                                 "\"Id\" : \"document-id\", " +
2773                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\", " +
2774                                 "\"Value\"      : [ "
2775                                 + "{" +
2776                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2777                                         "\"Namespaces\" : ["
2778                                                 + "{ "+
2779                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2780                                                         "}," +
2781                                                         "{" +
2782                                                                 "\"Prefix\" : \"md\", " +
2783                                                                 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2784                                                         "}], "+
2785                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2786                         "}," +
2787                         "\"simpleString\"," +
2788                                 "{" +
2789                                                 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2790                                                 "\"Namespaces\" : ["
2791                                                         + "{ "+
2792                                                                 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2793                                                                 "}," +
2794                                                                 "{" +
2795                                                                         "\"Prefix\" : \"md\", " +
2796                                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2797                                                                 "}], "+
2798                                                 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2799                                 "}"
2800                                 + "] " +
2801                                         "}] } ] }}");
2802                         fail("Operation should throw exception");
2803                 } catch (JSONStructureException e) {
2804                         // correct response
2805                 } catch (Exception e) {
2806                         fail ("Failed convert from JSON to object: " + e);
2807                 }
2808                 try {
2809                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", \"Attribute\" : [{" +
2810                                 "\"Id\" : \"document-id\", " +
2811                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\", " +
2812                                 "\"Value\"      : [ "
2813                                 + "{" +
2814                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2815                                         "\"Namespaces\" : ["
2816                                                 + "{ "+
2817                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2818                                                         "}," +
2819                                                         "{" +
2820                                                                 "\"Prefix\" : \"md\", " +
2821                                                                 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2822                                                         "}], "+
2823                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2824                         "}," +
2825                         "true," +
2826                                 "{" +
2827                                                 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2828                                                 "\"Namespaces\" : ["
2829                                                         + "{ "+
2830                                                                 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2831                                                                 "}," +
2832                                                                 "{" +
2833                                                                         "\"Prefix\" : \"md\", " +
2834                                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2835                                                                 "}], "+
2836                                                 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2837                                 "}"
2838                                 + "] " +
2839                                         "}] } ] }}");
2840                         fail("Operation should throw exception");
2841                 } catch (JSONStructureException e) {
2842                         // correct response
2843                 } catch (Exception e) {
2844                         fail ("Failed convert from JSON to object: " + e);
2845                 }
2846                 try {
2847                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", \"Attribute\" : [{" +
2848                                 "\"Id\" : \"document-id\", " +
2849                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\", " +
2850                                 "\"Value\"      : [ "
2851                                 + "{" +
2852                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2853                                         "\"Namespaces\" : ["
2854                                                 + "{ "+
2855                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2856                                                         "}," +
2857                                                         "{" +
2858                                                                 "\"Prefix\" : \"md\", " +
2859                                                                 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2860                                                         "}], "+
2861                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2862                         "}," +
2863                         "123," +
2864                                 "{" +
2865                                                 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2866                                                 "\"Namespaces\" : ["
2867                                                         + "{ "+
2868                                                                 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2869                                                                 "}," +
2870                                                                 "{" +
2871                                                                         "\"Prefix\" : \"md\", " +
2872                                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2873                                                                 "}], "+
2874                                                 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2875                                 "}"
2876                                 + "] " +
2877                                         "}] } ] }}");
2878                         fail("Operation should throw exception");
2879                 } catch (JSONStructureException e) {
2880                         // correct response
2881                 } catch (Exception e) {
2882                         fail ("Failed convert from JSON to object: " + e);
2883                 }
2884                 try {
2885                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\", \"Attribute\" : [{" +
2886                                 "\"Id\" : \"document-id\", " +
2887                                 "\"DataType\"   : \"urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression\", " +
2888                                 "\"Value\"      : [ "
2889                                 + "{" +
2890                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2891                                         "\"Namespaces\" : ["
2892                                                 + "{ "+
2893                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2894                                                         "}," +
2895                                                         "{" +
2896                                                                 "\"Prefix\" : \"md\", " +
2897                                                                 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2898                                                         "}], "+
2899                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2900                         "}," +
2901                         "12.34," +
2902                                 "{" +
2903                                                 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2904                                                 "\"Namespaces\" : ["
2905                                                         + "{ "+
2906                                                                 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2907                                                                 "}," +
2908                                                                 "{" +
2909                                                                         "\"Prefix\" : \"md\", " +
2910                                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2911                                                                 "}], "+
2912                                                 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2913                                 "}"
2914                                 + "] " +
2915                                         "}] } ] }}");
2916                         fail("Operation should throw exception");
2917                 } catch (JSONStructureException e) {
2918                         // correct response
2919                 } catch (Exception e) {
2920                         fail ("Failed convert from JSON to object: " + e);
2921                 }
2922                 
2923
2924         }
2925         
2926
2927         
2928         
2929         
2930         
2931         
2932         @Test
2933         public void testArrayNoDataTypes() {
2934                 
2935                 // array of size 0
2936                 try {
2937                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2938                                 "\"Id\" : \"document-id\", " +
2939                                 "\"Value\"      : [] " +
2940                                         "}] } ] }}");
2941                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,includeInResults=false}]}}]}", request.toString());
2942                 } catch (Exception e) {
2943                         fail ("Failed convert from JSON to object: " + e);
2944                 }
2945                 
2946                 
2947                 // Category Attribute value array DataType Not given (repeat for all data types)
2948                 // Also tests for mixes of different JSON types (trying incorrect strings for XACML data types whenever possible)
2949                 // string
2950                 try {
2951                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2952                                 "\"Id\" : \"document-id\", " +
2953                                 "\"Value\"      : [\"abc\", \"def\", \"hig\", \"lmn\"] " +
2954                                         "}] } ] }}");
2955                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=def}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
2956                 } catch (Exception e) {
2957                         fail ("Failed convert from JSON to object: " + e);
2958                 }
2959                 // SUCCESSFUL AUTO-CONVERT to DataType
2960                 try {
2961                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2962                                 "\"Id\" : \"document-id\", " +
2963                                 "\"Value\"      : [\"abc\", true, \"hig\", \"lmn\"] " +
2964                                         "}] } ] }}");
2965                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
2966                 } catch (Exception e) {
2967                         fail ("Failed convert from JSON to object: " + e);
2968                 }
2969                 // SUCCESSFUL AUTO-CONVERT
2970                 try {
2971                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2972                                 "\"Id\" : \"document-id\", " +
2973                                 "\"Value\"      : [\"abc\",123, \"hig\", \"lmn\"] " +
2974                                         "}] } ] }}");
2975                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
2976                 } catch (Exception e) {
2977                         fail ("Failed convert from JSON to object: " + e);
2978                 }
2979                 // SUCCESSFUL AUTO-CONVERT
2980                 try {
2981                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2982                                 "\"Id\" : \"document-id\", " +
2983                                 "\"Value\"      : [\"abc\", 34.34, \"hig\", \"lmn\"] " +
2984                                         "}] } ] }}");
2985                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=34.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=hig}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lmn}],includeInResults=false}]}}]}", request.toString());
2986                 } catch (Exception e) {
2987                         fail ("Failed convert from JSON to object: " + e);
2988                 }
2989                 
2990                 
2991                 // boolean
2992                 try {
2993                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2994                                 "\"Id\" : \"document-id\", " +
2995                                 "\"Value\"      : [true, true, false, true, false ] " +
2996                                         "}] } ] }}");
2997                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=false}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#boolean,value=false}],includeInResults=false}]}}]}", request.toString());
2998                 } catch (Exception e) {
2999                         fail ("Failed convert from JSON to object: " + e);
3000                 }
3001                 try {
3002                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3003                                 "\"Id\" : \"document-id\", " +
3004                                 "\"Value\"      : [true, \"abc\", false, true, false ] " +
3005                                         "}] } ] }}");
3006                         fail("Operation should throw exception");
3007                 } catch (JSONStructureException e) {
3008                         // correct response
3009                 } catch (Exception e) {
3010                         fail ("Failed convert from JSON to object: " + e);
3011                 }
3012                 try {
3013                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3014                                 "\"Id\" : \"document-id\", " +
3015                                 "\"Value\"      : [true, 123, false, true, false ] " +
3016                                         "}] } ] }}");
3017                         fail("Operation should throw exception");
3018                 } catch (JSONStructureException e) {
3019                         // correct response
3020                 } catch (Exception e) {
3021                         fail ("Failed convert from JSON to object: " + e);
3022                 }
3023                 try {
3024                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3025                                 "\"Id\" : \"document-id\", " +
3026                                 "\"Value\"      : [true, 12.34, false, true, false ] " +
3027                                         "}] } ] }}");
3028                         fail("Operation should throw exception");
3029                 } catch (JSONStructureException e) {
3030                         // correct response
3031                 } catch (Exception e) {
3032                         fail ("Failed convert from JSON to object: " + e);
3033                 }
3034                 
3035                 
3036                 
3037                 // integer
3038                 try {
3039                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3040                                 "\"Id\" : \"document-id\", " +
3041                                 "\"Value\"      : [123, 456, 765, 234] " +
3042                                         "}] } ] }}");
3043                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=456}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=765}{dataTypeId=http://www.w3.org/2001/XMLSchema#integer,value=234}],includeInResults=false}]}}]}", request.toString());
3044                 } catch (Exception e) {
3045                         fail ("Failed convert from JSON to object: " + e);
3046                 }
3047                 try {
3048                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3049                                 "\"Id\" : \"document-id\", " +
3050                                 "\"Value\"      : [123, \"abc\", 765, 234] " +
3051                                         "}] } ] }}");
3052                         fail("Operation should throw exception");
3053                 } catch (JSONStructureException e) {
3054                         // correct response
3055                 } catch (Exception e) {
3056                         fail ("Failed convert from JSON to object: " + e);
3057                 }
3058                 try {
3059                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3060                                 "\"Id\" : \"document-id\", " +
3061                                 "\"Value\"      : [123, true, 765, 234] " +
3062                                         "}] } ] }}");
3063                         fail("Operation should throw exception");
3064                 } catch (JSONStructureException e) {
3065                         // correct response
3066                 } catch (Exception e) {
3067                         fail ("Failed convert from JSON to object: " + e);
3068                 }
3069
3070                 
3071                 
3072                 // double
3073                 try {
3074                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3075                                 "\"Id\" : \"document-id\", " +
3076                                 "\"Value\"      : [ 123.34, 543.54, 3445.455, 4543,543 ] " +
3077                                         "}] } ] }}");
3078                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.54}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=3445.455}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=4543.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.0}],includeInResults=false}]}}]}", request.toString());
3079                 } catch (Exception e) {
3080                         fail ("Failed convert from JSON to object: " + e);
3081                 }
3082                 // special case - auto-convert integer to boolean
3083                 try {
3084                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3085                                 "\"Id\" : \"document-id\", " +
3086                                 "\"Value\"      : [ 123.34, 111122, 3445.455, 4543,543 ] " +
3087                                         "}] } ] }}");
3088                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=123.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=111122.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=3445.455}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=4543.0}{dataTypeId=http://www.w3.org/2001/XMLSchema#double,value=543.0}],includeInResults=false}]}}]}", request.toString());
3089                 } catch (Exception e) {
3090                         fail ("Failed convert from JSON to object: " + e);
3091                 }
3092                 try {
3093                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3094                                 "\"Id\" : \"document-id\", " +
3095                                 "\"Value\"      : [ 123.34, true, 3445.455, 4543,543 ] " +
3096                                         "}] } ] }}");
3097                         fail("Operation should throw exception");
3098                 } catch (JSONStructureException e) {
3099                         // correct response
3100                 } catch (Exception e) {
3101                         fail ("Failed convert from JSON to object: " + e);
3102                 }
3103                 try {
3104                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3105                                 "\"Id\" : \"document-id\", " +
3106                                 "\"Value\"      : [ 123.34, \"abb\", 3445.455, 4543,543 ] " +
3107                                         "}] } ] }}");
3108                         fail("Operation should throw exception");
3109                 } catch (JSONStructureException e) {
3110                         // correct response
3111                 } catch (Exception e) {
3112                         fail ("Failed convert from JSON to object: " + e);
3113                 }
3114                 
3115                 
3116                 // time - defaults to String
3117                 try {
3118                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3119                                 "\"Id\" : \"document-id\", " +
3120                                 "\"Value\"      : [ \"12:00:00Z\", \"12:00:00Z\", \"12:00:00Z\"] " +
3121                                         "}] } ] }}");
3122                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
3123                 } catch (Exception e) {
3124                         fail ("Failed convert from JSON to object: " + e);
3125                 }
3126                 // SUCCESSFUL AUTO-CONVERT
3127                 try {
3128                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3129                                 "\"Id\" : \"document-id\", " +
3130                                 "\"Value\"      : [ \"12:00:00Z\", true, \"12:00:00Z\"] " +
3131                                         "}] } ] }}");
3132                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
3133                 } catch (Exception e) {
3134                         fail ("Failed convert from JSON to object: " + e);
3135                 }
3136                 // SUCCESSFUL AUTO-CONVERT
3137                 try {
3138                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3139                                 "\"Id\" : \"document-id\", " +
3140                                 "\"Value\"      : [ \"12:00:00Z\", 123, \"12:00:00Z\"] " +
3141                                         "}] } ] }}");
3142                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
3143                 } catch (Exception e) {
3144                         fail ("Failed convert from JSON to object: " + e);
3145                 }
3146                 // AUTO-CONVERT
3147                 try {
3148                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3149                                 "\"Id\" : \"document-id\", " +
3150                                 "\"Value\"      : [ \"12:00:00Z\", 12.34, \"12:00:00Z\"] " +
3151                                         "}] } ] }}");
3152                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12:00:00Z}],includeInResults=false}]}}]}", request.toString());
3153                 } catch (Exception e) {
3154                         fail ("Failed convert from JSON to object: " + e);
3155                 }
3156                 
3157                 
3158                 // date - defaults to String
3159                 try {
3160                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3161                                 "\"Id\" : \"document-id\", " +
3162                                 "\"Value\"      : [\"2002-10-10\",\"2002-10-10\",\"2002-10-10\" ] " +
3163                                         "}] } ] }}");
3164                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
3165                 } catch (Exception e) {
3166                         fail ("Failed convert from JSON to object: " + e);
3167                 }
3168                 // AUTO-CONVERT
3169                 try {
3170                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3171                                 "\"Id\" : \"document-id\", " +
3172                                 "\"Value\"      : [\"2002-10-10\",true,\"2002-10-10\" ] " +
3173                                         "}] } ] }}");
3174                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
3175                 } catch (Exception e) {
3176                         fail ("Failed convert from JSON to object: " + e);
3177                 }
3178                 // AUTO-CONVERT
3179                 try {
3180                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3181                                 "\"Id\" : \"document-id\", " +
3182                                 "\"Value\"      : [\"2002-10-10\",123,\"2002-10-10\" ] " +
3183                                         "}] } ] }}");
3184                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
3185                 } catch (Exception e) {
3186                         fail ("Failed convert from JSON to object: " + e);
3187                 }
3188                 // AUTO-CONVERT
3189                 try {
3190                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3191                                 "\"Id\" : \"document-id\", " +
3192                                 "\"Value\"      : [\"2002-10-10\",123.45,\"2002-10-10\" ] " +
3193                                         "}] } ] }}");
3194                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123.45}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10}],includeInResults=false}]}}]}", request.toString());
3195                 } catch (Exception e) {
3196                         fail ("Failed convert from JSON to object: " + e);
3197                 }
3198                 
3199                 
3200                 // dateTime - defaults to String
3201                 try {
3202                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3203                                 "\"Id\" : \"document-id\", " +
3204                                 "\"Value\"      : [ \"2002-10-10T12:00:00Z\",\"2002-10-10T12:00:00Z\",\"2002-10-10T12:00:00Z\" ] " +
3205                                         "}] } ] }}");
3206                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
3207                 } catch (Exception e) {
3208                         fail ("Failed convert from JSON to object: " + e);
3209                 }
3210                 // AUTO-CONVERT
3211                 try {
3212                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3213                                 "\"Id\" : \"document-id\", " +
3214                                 "\"Value\"      : [ \"2002-10-10T12:00:00Z\",true,\"2002-10-10T12:00:00Z\" ] " +
3215                                         "}] } ] }}");
3216                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
3217                 } catch (Exception e) {
3218                         fail ("Failed convert from JSON to object: " + e);
3219                 }
3220                 // AUTO-CONVERT
3221                 try {
3222                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3223                                 "\"Id\" : \"document-id\", " +
3224                                 "\"Value\"      : [ \"2002-10-10T12:00:00Z\",123,\"2002-10-10T12:00:00Z\" ] " +
3225                                         "}] } ] }}");
3226                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
3227                 } catch (Exception e) {
3228                         fail ("Failed convert from JSON to object: " + e);
3229                 }
3230                 // AUTO-CONVERT
3231                 try {
3232                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3233                                 "\"Id\" : \"document-id\", " +
3234                                 "\"Value\"      : [ \"2002-10-10T12:00:00Z\",12.34,\"2002-10-10T12:00:00Z\" ] " +
3235                                         "}] } ] }}");
3236                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=12.34}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=2002-10-10T12:00:00Z}],includeInResults=false}]}}]}", request.toString());
3237                 } catch (Exception e) {
3238                         fail ("Failed convert from JSON to object: " + e);
3239                 }
3240                 
3241                 
3242                 // dayTimeDuration - defaults to String
3243                 try {
3244                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3245                                 "\"Id\" : \"document-id\", " +
3246                                 "\"Value\"      : [ \"P23DT7H12M54S\",\"P23DT7H12M54S\",\"P23DT7H12M54S\" ] " +
3247                                         "}] } ] }}");
3248                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}],includeInResults=false}]}}]}", request.toString());
3249                 } catch (Exception e) {
3250                         fail ("Failed convert from JSON to object: " + e);
3251                 }
3252                 //AUTO-CONVERT
3253                 try {
3254                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3255                                 "\"Id\" : \"document-id\", " +
3256                                 "\"Value\"      : [ \"P23DT7H12M54S\",true,\"P23DT7H12M54S\" ] " +
3257                                         "}] } ] }}");
3258                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}],includeInResults=false}]}}]}", request.toString());
3259                 } catch (Exception e) {
3260                         fail ("Failed convert from JSON to object: " + e);
3261                 }
3262                 // AUTO-CONVERT
3263                 try {
3264                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3265                                 "\"Id\" : \"document-id\", " +
3266                                 "\"Value\"      : [ \"P23DT7H12M54S\",123,\"P23DT7H12M54S\" ] " +
3267                                         "}] } ] }}");
3268                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}],includeInResults=false}]}}]}", request.toString());
3269                 } catch (Exception e) {
3270                         fail ("Failed convert from JSON to object: " + e);
3271                 }
3272                 try {
3273                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3274                                 "\"Id\" : \"document-id\", " +
3275                                 "\"Value\"      : [ \"P23DT7H12M54S\",11.22,\"P23DT7H12M54S\" ] " +
3276                                         "}] } ] }}");
3277                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P23DT7H12M54S}],includeInResults=false}]}}]}", request.toString());
3278                 } catch (Exception e) {
3279                         fail ("Failed convert from JSON to object: " + e);
3280                 }
3281                 
3282                 
3283                 // yearMonth duration - defaults to String
3284                 try {
3285                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3286                                 "\"Id\" : \"document-id\", " +
3287                                 "\"Value\"      : [ \"P165Y8M\",\"P165Y8M\",\"P165Y8M\" ] " +
3288                                         "}] } ] }}");
3289                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}],includeInResults=false}]}}]}", request.toString());
3290                 } catch (Exception e) {
3291                         fail ("Failed convert from JSON to object: " + e);
3292                 }
3293                 // AUTO-CONVERT
3294                 try {
3295                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3296                                 "\"Id\" : \"document-id\", " +
3297                                 "\"Value\"      : [ \"P165Y8M\",true,\"P165Y8M\" ] " +
3298                                         "}] } ] }}");
3299                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}],includeInResults=false}]}}]}", request.toString());
3300                 } catch (Exception e) {
3301                         fail ("Failed convert from JSON to object: " + e);
3302                 }
3303                 // AUTO-CONVERT
3304                 try {
3305                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3306                                 "\"Id\" : \"document-id\", " +
3307                                 "\"Value\"      : [ \"P165Y8M\",123,\"P165Y8M\" ] " +
3308                                         "}] } ] }}");
3309                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}],includeInResults=false}]}}]}", request.toString());
3310                 } catch (Exception e) {
3311                         fail ("Failed convert from JSON to object: " + e);
3312                 }
3313                 try {
3314                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3315                                 "\"Id\" : \"document-id\", " +
3316                                 "\"Value\"      : [ \"P165Y8M\",11.22,\"P165Y8M\" ] " +
3317                                         "}] } ] }}");
3318                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=P165Y8M}],includeInResults=false}]}}]}", request.toString());
3319                 } catch (Exception e) {
3320                         fail ("Failed convert from JSON to object: " + e);
3321                 }
3322                 
3323                 
3324                 // anyURI - defaults to String
3325                 try {
3326                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3327                                 "\"Id\" : \"document-id\", " +
3328                                 "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
3329                                         "}] } ] }}");
3330                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
3331                 } catch (Exception e) {
3332                         fail ("Failed convert from JSON to object: " + e);
3333                 }
3334                 // AUTO-CONVERT
3335                 try {
3336                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3337                                 "\"Id\" : \"document-id\", " +
3338                                 "\"Value\"      : [ \"aValue\",true,\"aValue\"] " +
3339                                         "}] } ] }}");
3340                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
3341                 } catch (Exception e) {
3342                         fail ("Failed convert from JSON to object: " + e);
3343                 }
3344                 // AUTO-CONVERT
3345                 try {
3346                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3347                                 "\"Id\" : \"document-id\", " +
3348                                 "\"Value\"      : [ \"aValue\",123,\"aValue\"] " +
3349                                         "}] } ] }}");
3350                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
3351                 } catch (Exception e) {
3352                         fail ("Failed convert from JSON to object: " + e);
3353                 }
3354                 // AUTO-CONVERT
3355                 try {
3356                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3357                                 "\"Id\" : \"document-id\", " +
3358                                 "\"Value\"      : [ \"aValue\",11.111,\"aValue\"] " +
3359                                         "}] } ] }}");
3360                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.111}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
3361                 } catch (Exception e) {
3362                         fail ("Failed convert from JSON to object: " + e);
3363                 }
3364                 
3365                 
3366                 // hexBinary - defaults to String
3367                 try {
3368                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3369                                 "\"Id\" : \"document-id\", " +
3370                                 "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\" ] " +
3371                                         "}] } ] }}");
3372                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}],includeInResults=false}]}}]}", request.toString());
3373                 } catch (Exception e) {
3374                         fail ("Failed convert from JSON to object: " + e);
3375                 }
3376                 // AUTO-CONVERT
3377                 try {
3378                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3379                                 "\"Id\" : \"document-id\", " +
3380                                 "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",true,\"012AEEF\" ] " +
3381                                         "}] } ] }}");
3382                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=012AEEF}],includeInResults=false}]}}]}", request.toString());
3383                 } catch (Exception e) {
3384                         fail ("Failed convert from JSON to object: " + e);
3385                 }
3386                 // AUTO-CONVERT
3387                 try {
3388                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3389                                 "\"Id\" : \"document-id\", " +
3390                                 "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",123,\"012AEEF\" ] " +
3391                                         "}] } ] }}");
3392                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=012AEEF}],includeInResults=false}]}}]}", request.toString());
3393                 } catch (Exception e) {
3394                         fail ("Failed convert from JSON to object: " + e);
3395                 }
3396                 // AUTO-CONVERT
3397                 try {
3398                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3399                                 "\"Id\" : \"document-id\", " +
3400                                 "\"Value\"      : [ \"FA027B7D12CC34DDD20012AEEF\",11.44,\"012AEEF\" ] " +
3401                                         "}] } ] }}");
3402                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=FA027B7D12CC34DDD20012AEEF}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.44}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=012AEEF}],includeInResults=false}]}}]}", request.toString());
3403                 } catch (Exception e) {
3404                         fail ("Failed convert from JSON to object: " + e);
3405                 }
3406                 
3407                 
3408                 // base64Binary - defaults to String
3409                 try {
3410                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3411                                 "\"Id\" : \"document-id\", " +
3412                                 "\"Value\"      : [ \"aG9y\",\"lvbj0iMS4xIj48YXV0aG9y\",\"lvbjIj48YXV0aG9y\" ] " +
3413                                         "}] } ] }}");
3414                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aG9y}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lvbj0iMS4xIj48YXV0aG9y}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lvbjIj48YXV0aG9y}],includeInResults=false}]}}]}", request.toString());
3415                 } catch (Exception e) {
3416                         fail ("Failed convert from JSON to object: " + e);
3417                 }
3418                 // AUTO-CONVERT
3419                 try {
3420                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3421                                 "\"Id\" : \"document-id\", " +
3422                                 "\"Value\"      : [ \"aG9y\",true,\"lvbjIj48YXV0aG9y\" ] " +
3423                                         "}] } ] }}");
3424                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aG9y}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lvbjIj48YXV0aG9y}],includeInResults=false}]}}]}", request.toString());
3425                 } catch (Exception e) {
3426                         fail ("Failed convert from JSON to object: " + e);
3427                 }
3428                 // AUTO-CONVERT
3429                 try {
3430                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3431                                 "\"Id\" : \"document-id\", " +
3432                                 "\"Value\"      : [ \"aG9y\",1123,\"lvbjIj48YXV0aG9y\" ] " +
3433                                         "}] } ] }}");
3434                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aG9y}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=1123}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lvbjIj48YXV0aG9y}],includeInResults=false}]}}]}", request.toString());
3435                 } catch (Exception e) {
3436                         fail ("Failed convert from JSON to object: " + e);
3437                 }
3438                 // AUTO-CONVERT
3439                 try {
3440                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3441                                 "\"Id\" : \"document-id\", " +
3442                                 "\"Value\"      : [ \"aG9y\",11.22,\"lvbjIj48YXV0aG9y\" ] " +
3443                                         "}] } ] }}");
3444                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aG9y}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=lvbjIj48YXV0aG9y}],includeInResults=false}]}}]}", request.toString());
3445                 } catch (Exception e) {
3446                         fail ("Failed convert from JSON to object: " + e);
3447                 }
3448                 
3449                 // RFC822 name - defaults to String
3450                 try {
3451                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3452                                 "\"Id\" : \"document-id\", " +
3453                                 "\"Value\"      : [ \"sne.else@A.COMPANY.com\",\"one.else@A.COMPANY.com\",\"someone.else@A.CONY.com\" ] " +
3454                                         "}] } ] }}");
3455                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=sne.else@A.COMPANY.com}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=one.else@A.COMPANY.com}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=someone.else@A.CONY.com}],includeInResults=false}]}}]}", request.toString());
3456                 } catch (Exception e) {
3457                         fail ("Failed convert from JSON to object: " + e);
3458                 }
3459                 // AUTO-CONVERT
3460                 try {
3461                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3462                                 "\"Id\" : \"document-id\", " +
3463                                 "\"Value\"      : [ \"sne.else@A.COMPANY.com\",true,\"someone.else@A.CONY.com\" ] " +
3464                                         "}] } ] }}");
3465                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=sne.else@A.COMPANY.com}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=someone.else@A.CONY.com}],includeInResults=false}]}}]}", request.toString());
3466                 } catch (Exception e) {
3467                         fail ("Failed convert from JSON to object: " + e);
3468                 }
3469                 // AUTO-CONVERT
3470                 try {
3471                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3472                                 "\"Id\" : \"document-id\", " +
3473                                 "\"Value\"      : [ \"sne.else@A.COMPANY.com\",111,\"someone.else@A.CONY.com\" ] " +
3474                                         "}] } ] }}");
3475                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=sne.else@A.COMPANY.com}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=111}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=someone.else@A.CONY.com}],includeInResults=false}]}}]}", request.toString());
3476                 } catch (Exception e) {
3477                         fail ("Failed convert from JSON to object: " + e);
3478                 }
3479                 // AUTO-CONVERT
3480                 try {
3481                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3482                                 "\"Id\" : \"document-id\", " +
3483                                 "\"Value\"      : [ \"sne.else@A.COMPANY.com\",11.22,\"someone.else@A.CONY.com\" ] " +
3484                                         "}] } ] }}");
3485                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=sne.else@A.COMPANY.com}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=someone.else@A.CONY.com}],includeInResults=false}]}}]}", request.toString());
3486                 } catch (Exception e) {
3487                         fail ("Failed convert from JSON to object: " + e);
3488                 }
3489                 
3490                 
3491                 // x500 - defaults to String
3492                 try {
3493                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3494                                 "\"Id\" : \"document-id\", " +
3495                                 "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\", \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
3496                                         "}] } ] }}");
3497                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}],includeInResults=false}]}}]}", request.toString());
3498                 } catch (Exception e) {
3499                         fail ("Failed convert from JSON to object: " + e);
3500                 }
3501                 // AUTO-CONVERT
3502                 try {
3503                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3504                                 "\"Id\" : \"document-id\", " +
3505                                 "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", true, \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
3506                                         "}] } ] }}");
3507                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}],includeInResults=false}]}}]}", request.toString());
3508                 } catch (Exception e) {
3509                         fail ("Failed convert from JSON to object: " + e);
3510                 }
3511                 // AUTO-CONVERT
3512                 try {
3513                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3514                                 "\"Id\" : \"document-id\", " +
3515                                 "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", 1111, \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
3516                                         "}] } ] }}");
3517                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=1111}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}],includeInResults=false}]}}]}", request.toString());
3518                 } catch (Exception e) {
3519                         fail ("Failed convert from JSON to object: " + e);
3520                 }
3521                 // AUTO-CONVERT
3522                 try {
3523                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3524                                 "\"Id\" : \"document-id\", " +
3525                                 "\"Value\"      : [ \"cn=Julius Hibbert, o=Medi Corporation, c=US\", 11.22, \"cn=Julius Hibbert, o=Medi Corporation, c=US\" ] " +
3526                                         "}] } ] }}");
3527                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=cn=Julius Hibbert, o=Medi Corporation, c=US}],includeInResults=false}]}}]}", request.toString());
3528                 } catch (Exception e) {
3529                         fail ("Failed convert from JSON to object: " + e);
3530                 }
3531                 
3532                 
3533                 // ipAddress - defaults to String
3534                 try {
3535                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3536                                 "\"Id\" : \"document-id\", " +
3537                                 "\"Value\"      : [ \"10.221.43.58:12345\",\"10.221.43.58:12345\",\"10.221.43.58:12345\" ] " +
3538                                         "}] } ] }}");
3539                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=10.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=10.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=10.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
3540                 } catch (Exception e) {
3541                         fail ("Failed convert from JSON to object: " + e);
3542                 }
3543                 // AUTO-CONVERT
3544                 try {
3545                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3546                                 "\"Id\" : \"document-id\", " +
3547                                 "\"Value\"      : [ \"10.221.43.58:12345\",true,\"10.221.43.58:12345\" ] " +
3548                                         "}] } ] }}");
3549                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=10.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=10.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
3550                 } catch (Exception e) {
3551                         fail ("Failed convert from JSON to object: " + e);
3552                 }
3553                 // AUTO-CONVERT
3554                 try {
3555                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3556                                 "\"Id\" : \"document-id\", " +
3557                                 "\"Value\"      : [ \"10.221.43.58:12345\",1111,\"10.221.43.58:12345\" ] " +
3558                                         "}] } ] }}");
3559                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=10.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=1111}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=10.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
3560                 } catch (Exception e) {
3561                         fail ("Failed convert from JSON to object: " + e);
3562                 }
3563                 // AUTO-CONVERT
3564                 try {
3565                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3566                                 "\"Id\" : \"document-id\", " +
3567                                 "\"Value\"      : [ \"10.221.43.58:12345\",11.22,\"10.221.43.58:12345\" ] " +
3568                                         "}] } ] }}");
3569                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=10.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=10.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
3570                 } catch (Exception e) {
3571                         fail ("Failed convert from JSON to object: " + e);
3572                 }
3573                 
3574                 
3575                 // dnsName - defaults to String
3576                 try {
3577                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3578                                 "\"Id\" : \"document-id\", " +
3579                                 "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
3580                                         "}] } ] }}");
3581                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
3582                 } catch (Exception e) {
3583                         fail ("Failed convert from JSON to object: " + e);
3584                 }
3585                 // AUTO-CONVERT
3586                 try {
3587                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3588                                 "\"Id\" : \"document-id\", " +
3589                                 "\"Value\"      : [ \"aValue\", true, \"aValue\" ] " +
3590                                         "}] } ] }}");
3591                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
3592                 } catch (Exception e) {
3593                         fail ("Failed convert from JSON to object: " + e);
3594                 }
3595                 // AUTO-CONVERT
3596                 try {
3597                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3598                                 "\"Id\" : \"document-id\", " +
3599                                 "\"Value\"      : [ \"aValue\", 1111, \"aValue\" ] " +
3600                                         "}] } ] }}");
3601                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=1111}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
3602                 } catch (Exception e) {
3603                         fail ("Failed convert from JSON to object: " + e);
3604                 }
3605                 // AUTO-CONVERT
3606                 try {
3607                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3608                                 "\"Id\" : \"document-id\", " +
3609                                 "\"Value\"      : [ \"aValue\", 11.22, \"aValue\" ] " +
3610                                         "}] } ] }}");
3611                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
3612                 } catch (Exception e) {
3613                         fail ("Failed convert from JSON to object: " + e);
3614                 }
3615                 
3616                 
3617                 // xPathExpression - defaults to String
3618                 try {
3619                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3620                                 "\"Id\" : \"document-id\", " +
3621                                 "\"Value\"      : [ \"aValue\", \"aValue\", \"aValue\" ] " +
3622                                         "}] } ] }}");
3623                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
3624                 } catch (Exception e) {
3625                         fail ("Failed convert from JSON to object: " + e);
3626                 }
3627                 // AUTO-CONVERT
3628                 try {
3629                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3630                                 "\"Id\" : \"document-id\", " +
3631                                 "\"Value\"      : [ \"aValue\", true, \"aValue\" ] " +
3632                                         "}] } ] }}");
3633                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
3634                 } catch (Exception e) {
3635                         fail ("Failed convert from JSON to object: " + e);
3636                 }
3637                 // AUTO-CONVERT
3638                 try {
3639                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3640                                 "\"Id\" : \"document-id\", " +
3641                                 "\"Value\"      : [ \"aValue\", 1111, \"aValue\" ] " +
3642                                         "}] } ] }}");
3643                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=1111}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
3644                 } catch (Exception e) {
3645                         fail ("Failed convert from JSON to object: " + e);
3646                 }
3647                 // AUTO-CONVERT
3648                 try {
3649                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3650                                 "\"Id\" : \"document-id\", " +
3651                                 "\"Value\"      : [ \"aValue\", 11.22, \"aValue\" ] " +
3652                                         "}] } ] }}");
3653                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]}}]}", request.toString());
3654                 } catch (Exception e) {
3655                         fail ("Failed convert from JSON to object: " + e);
3656                 }
3657                 
3658         }
3659         
3660         
3661
3662         
3663         @Test
3664         public void testXPathExpression() {
3665                 // Category Attribute with XPathExpression including XPathCategory and XPath
3666                 // Category Attribute with XPathExpression with Namespaces with/without Prefix
3667                 try {
3668                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3669                                 "\"Id\" : \"document-id\", " +
3670                                 "\"DataType\"   : \"xpathExpression\", " +
3671                                 "\"Value\"      : {" +
3672                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3673                                         "\"Namespaces\" : ["
3674                                           + "{ "+
3675                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
3676                                                 "}," +
3677                                                 "{ "+
3678                                                         "\"Prefix\" : \"lab\", " +
3679                                                         "\"Namespace\" : \"http://somewhere/uri.html\" " +
3680                                                 "}," +
3681                                                 "{" +
3682                                                         "\"Prefix\" : \"md\", " +
3683                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3684                                                 "}], "+
3685                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3686                         "}" +
3687                                         "}] } ] }}");
3688                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace={[{md,urn:example:med:schemas:record}{lab,http://somewhere/uri.html}{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}]},status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
3689                 } catch (Exception e) {
3690                         fail ("Failed convert from JSON to object: " + e);
3691                 }
3692                 
3693                 // Category Attribute with XPathExpression missing XPathCategory
3694                 try {
3695                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3696                                 "\"Id\" : \"document-id\", " +
3697                                 "\"DataType\"   : \"xpathExpression\", " +
3698                                 "\"Value\"      : {" +
3699                                         "\"Namespaces\" : [{ "+
3700                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
3701                                                 "}," +
3702                                                 "{" +
3703                                                         "\"Prefix\" : \"md\", " +
3704                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3705                                                 "}], "+
3706                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3707                         "}" +
3708                                         "}] } ] }}");
3709                         fail("Operation should throw exception");
3710                 } catch (JSONStructureException e) {
3711                         // correct response
3712                 } catch (Exception e) {
3713                         fail ("Failed convert from JSON to object: " + e);
3714                 }
3715                 
3716                 // Category Attribute with XPathExpression missing XPath
3717                 try {
3718                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3719                                 "\"Id\" : \"document-id\", " +
3720                                 "\"DataType\"   : \"xpathExpression\", " +
3721                                 "\"Value\"      : {" +
3722                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3723                                         "\"Namespaces\" : [{ "+
3724                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
3725                                                 "}," +
3726                                                 "{" +
3727                                                         "\"Prefix\" : \"md\", " +
3728                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3729                                                 "}] "+
3730                         "}" +
3731                                         "}] } ] }}");
3732                         fail("Operation should throw exception");
3733                 } catch (JSONStructureException e) {
3734                         // correct response
3735                 } catch (Exception e) {
3736                         fail ("Failed convert from JSON to object: " + e);
3737                 }
3738                 
3739                 // Category Attribute with XPathExpression without Namespaces
3740                 // (path does not contain namespace references)
3741                 try {
3742                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3743                                 "\"Id\" : \"document-id\", " +
3744                                 "\"DataType\"   : \"xpathExpression\", " +
3745                                 "\"Value\"      : {" +
3746                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3747                                         "\"XPath\" : \"record/patient/patientDoB\" "+
3748                         "}" +
3749                                         "}] } ] }}");
3750                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=record/patient/patientDoB,Namespace=null,status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
3751                 } catch (Exception e) {
3752                         fail ("Failed convert from JSON to object: " + e);
3753                 }
3754                 
3755                 // Category Attribute with XPathExpression with 0 Namespaces
3756                 try {
3757                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3758                                 "\"Id\" : \"document-id\", " +
3759                                 "\"DataType\"   : \"xpathExpression\", " +
3760                                 "\"Value\"      : {" +
3761                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3762                                         "\"Namespaces\" : [], "+
3763                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3764                         "}" +
3765                                         "}] } ] }}");
3766                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace=null,status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
3767                 } catch (Exception e) {
3768                         fail ("Failed convert from JSON to object: " + e);
3769                 }
3770                 
3771                 
3772                 // Category Attribute with XPathExpression with Namespaces without mandatory Namespace
3773                 try {
3774                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3775                                 "\"Id\" : \"document-id\", " +
3776                                 "\"DataType\"   : \"xpathExpression\", " +
3777                                 "\"Value\"      : {" +
3778                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3779                                         "\"Namespaces\" : [{ "+
3780                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
3781                                                 "}," +
3782                                                 "{" +
3783                                                         "\"Prefix\" : \"md\", " +
3784                                                 "}], "+
3785                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3786                         "}" +
3787                                         "}] } ] }}");
3788                         fail("Operation should throw exception");
3789                 } catch (JSONStructureException e) {
3790                         // correct response
3791                 } catch (Exception e) {
3792                         fail ("Failed convert from JSON to object: " + e);
3793                 }
3794                 
3795                 try {
3796                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3797                                 "\"Id\" : \"document-id\", " +
3798                                 "\"DataType\"   : \"xpathExpression\", " +
3799                                 "\"Value\"      : {" +
3800                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3801                                         "\"Namespaces\" : [{ "+
3802                                                 "}," +
3803                                                 "{" +
3804                                                         "\"Prefix\" : \"md\", " +
3805                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3806                                                 "}], "+
3807                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3808                         "}" +
3809                                         "}] } ] }}");
3810                         fail("Operation should throw exception");
3811                 } catch (JSONStructureException e) {
3812                         // correct response
3813                 } catch (Exception e) {
3814                         fail ("Failed convert from JSON to object: " + e);
3815                 }
3816                                 
3817                 // Category Attribute with XPathExpression with Namespaces with 2 namespaces using same prefix
3818                 try {
3819                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3820                                 "\"Id\" : \"document-id\", " +
3821                                 "\"DataType\"   : \"xpathExpression\", " +
3822                                 "\"Value\"      : {" +
3823                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3824                                         "\"Namespaces\" : [{ "+
3825                                                         "\"Prefix\" : \"md\", " +
3826                                                         "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
3827                                                 "}," +
3828                                                 "{" +
3829                                                         "\"Prefix\" : \"md\", " +
3830                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3831                                                 "}], "+
3832                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3833                         "}" +
3834                                         "}] } ] }}");
3835                         fail("Operation should throw exception");
3836                 } catch (JSONStructureException e) {
3837                         // correct response
3838                 } catch (Exception e) {
3839                         fail ("Failed convert from JSON to object: " + e);
3840                 }
3841                 
3842                 // Category Attribute with XPathExpression without Namespaces which are used within the XPathExpression (NOTE: Error is not syntactic and is not found by converter)
3843                 try {
3844                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3845                                 "\"Id\" : \"document-id\", " +
3846                                 "\"DataType\"   : \"xpathExpression\", " +
3847                                 "\"Value\"      : {" +
3848                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3849                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3850                         "}" +
3851                                         "}] } ] }}");
3852                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression,value={path=md:record/md:patient/md:patientDoB,Namespace=null,status=null,xpathExpressionWrapped=null},xpathCategory=urn:oasis:names:tc:xacml:3.0:attribute-category:resource}],includeInResults=false}]}}]}", request.toString());
3853                 } catch (Exception e) {
3854                         fail ("Failed convert from JSON to object: " + e);
3855                 }
3856                 
3857                 // Category Attribute with XPathExpression containing simple value (must be object)
3858                 try {
3859                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3860                                 "\"Id\" : \"document-id\", " +
3861                                 "\"DataType\"   : \"xpathExpression\", " +
3862                                 "\"Value\"      : \"simple Value\"" +
3863                                         "}] } ] }}");
3864                         fail("Operation should throw exception");
3865                 } catch (JSONStructureException e) {
3866                         // correct response
3867                 } catch (Exception e) {
3868                         fail ("Failed convert from JSON to object: " + e);
3869                 }
3870                 
3871                 // Category Attribute with Namespaces containing simple value (must be object)
3872                 try {
3873                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3874                                 "\"Id\" : \"document-id\", " +
3875                                 "\"DataType\"   : \"xpathExpression\", " +
3876                                 "\"Value\"      : {" +
3877                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3878                                         "\"Namespaces\" : [ \"simpleValue\"," +
3879                                                 "{" +
3880                                                         "\"Prefix\" : \"md\", " +
3881                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3882                                                 "}], "+
3883                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3884                         "}" +
3885                                         "}] } ] }}");
3886                         fail("Operation should throw exception");
3887                 } catch (JSONStructureException e) {
3888                         // correct response
3889                 } catch (Exception e) {
3890                         fail ("Failed convert from JSON to object: " + e);
3891                 }
3892                 
3893                 
3894                 // Category Attribute with Namespaces non-string Namespace
3895                 try {
3896                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3897                                 "\"Id\" : \"document-id\", " +
3898                                 "\"DataType\"   : \"xpathExpression\", " +
3899                                 "\"Value\"      : {" +
3900                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3901                                         "\"Namespaces\" : [ {" +
3902                                                         "\"Prefix\" : \"md\", " +
3903                                                         "\"Namespace\" : 123 " +
3904                                                 "}], "+
3905                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3906                         "}" +
3907                                         "}] } ] }}");
3908                         fail("Operation should throw exception");
3909                 } catch (JSONStructureException e) {
3910                         // correct response
3911                 } catch (Exception e) {
3912                         fail ("Failed convert from JSON to object: " + e);
3913                 }
3914                 
3915                 // Category Attribute with Namespaces non-string prefix
3916                 try {
3917                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3918                                 "\"Id\" : \"document-id\", " +
3919                                 "\"DataType\"   : \"xpathExpression\", " +
3920                                 "\"Value\"      : {" +
3921                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3922                                         "\"Namespaces\" : [ {" +
3923                                                         "\"Prefix\" : 123, " +
3924                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3925                                                 "}], "+
3926                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3927                         "}" +
3928                                         "}] } ] }}");
3929                         fail("Operation should throw exception");
3930                 } catch (JSONStructureException e) {
3931                         // correct response
3932                 } catch (Exception e) {
3933                         fail ("Failed convert from JSON to object: " + e);
3934                 }
3935                 
3936                 // Category Attribute with Namespaces non-string XPathCategory
3937                 try {
3938                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3939                                 "\"Id\" : \"document-id\", " +
3940                                 "\"DataType\"   : \"xpathExpression\", " +
3941                                 "\"Value\"      : {" +
3942                                         "\"XPathCategory\" : 123," +
3943                                         "\"Namespaces\" : [ {" +
3944                                                         "\"Prefix\" : \"md\", " +
3945                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3946                                                 "}], "+
3947                                         "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3948                         "}" +
3949                                         "}] } ] }}");
3950                         fail("Operation should throw exception");
3951                 } catch (JSONStructureException e) {
3952                         // correct response
3953                 } catch (Exception e) {
3954                         fail ("Failed convert from JSON to object: " + e);
3955                 }
3956                 
3957                 // Category Attribute with Namespaces non-string XPath
3958                 try {
3959                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3960                                 "\"Id\" : \"document-id\", " +
3961                                 "\"DataType\"   : \"xpathExpression\", " +
3962                                 "\"Value\"      : {" +
3963                                         "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3964                                         "\"Namespaces\" : [ {" +
3965                                                         "\"Prefix\" : \"md\", " +
3966                                                         "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3967                                                 "}], "+
3968                                         "\"XPath\" : 123 "+
3969                         "}" +
3970                                         "}] } ] }}");
3971                         fail("Operation should throw exception");
3972                 } catch (JSONStructureException e) {
3973                         // correct response
3974                 } catch (Exception e) {
3975                         fail ("Failed convert from JSON to object: " + e);
3976                 }
3977         }
3978
3979
3980         
3981         @Test
3982         public void testContent() {
3983
3984                 // Category with Content in XML, escaped properly
3985                 try {
3986                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3987                                 "\"Id\" : \"document-id\", " +
3988                                 "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
3989                                 "}]," +
3990                                         "\"Content\" : \"<?xml version=\\\"1.0\\\"?><catalog>" + 
3991                                                 "<book id=\\\"bk101\\\"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre>" +
3992                                                 "<price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description>"+
3993                                                 "</book></catalog>\"" +
3994                                         "} ] }}");
3995                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]},contentRoot=[catalog: null]}]}", request.toString());
3996                 } catch (Exception e) {
3997                         fail ("Failed convert from JSON to object: " + e);
3998                 }
3999                 
4000                 // Category with Content in XML, double quotes and back-slashes NOT escaped properly?
4001                 try {
4002                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4003                                 "\"Id\" : \"document-id\", " +
4004                                 "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
4005                                 "}]," +
4006                                         "\"Content\" : \"<?xml version=\\\"1.0\\\"?><catalog>" + 
4007                                                 "<book id=\"bk101\\\"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre>" +
4008                                                 "<price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description>"+
4009                                                 "</book></catalog>\"" +
4010                                         "} ] }}");
4011                         fail("Operation should throw exception");
4012                 } catch (JSONStructureException e) {
4013                         // correct response
4014                 } catch (Exception e) {
4015                         fail ("Failed convert from JSON to object: " + e);
4016                 }
4017                 
4018                 // Category with Content in Base64
4019                 try {
4020                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4021                                 "\"Id\" : \"document-id\", " +
4022                                 "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
4023                                 "}]," +
4024                                         "\"Content\" :  \"PD94bWwgdmVyc2lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9yPkdhbWJhcmRlbGxhLCBNYXR0aGV3PC9hdXRob3I+PHRpdGxlPlhNT" +
4025                                                         "CBEZXZlbG9wZXIncyBHdWlkZTwvdGl0bGU+PGdlbnJlPkNvbXB1dGVyPC9nZW5yZT48cHJpY2U+NDQuOTU8L3ByaWNlPjxwdWJsaXNoX2RhdGU+MjAwMC0xMC0wMTwvcHVibGlzaF"+
4026                                                         "9kYXRlPjxkZXNjcmlwdGlvbj5BbiBpbi1kZXB0aCBsb29rIGF0IGNyZWF0aW5nIGFwcGxpY2F0aW9ucyB3aXRoIFhNTC48L2Rlc2NyaXB0aW9uPjwvYm9vaz48L2NhdGFsb2c+\"" +
4027                                         "} ] }}");
4028                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=aValue}],includeInResults=false}]},contentRoot=[catalog: null]}]}", request.toString());
4029                 } catch (Exception e) {
4030                         fail ("Failed convert from JSON to object: " + e);
4031                 }
4032                 
4033                 // Category with Bad Content in Base64
4034                 try {
4035                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4036                                 "\"Id\" : \"document-id\", " +
4037                                 "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
4038                                 "}]," +
4039                                         "\"Content\" :  \"PD94bWwgdmV\"" +
4040                                         "} ] }}");
4041                         fail("Operation should throw exception");
4042                 } catch (JSONStructureException e) {
4043                         // correct response
4044                 } catch (Exception e) {
4045                         fail ("Failed convert from JSON to object: " + e);
4046                 }
4047         }
4048         
4049
4050         
4051         
4052         @Test
4053         public void testDuplicates() {
4054                 // duplicate of same element within Category array is ok
4055                 try {
4056                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4057                                 "\"Id\" : \"document-id\", " +
4058                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
4059                                 "\"Value\"      : \"abc\" " +
4060                                         "}] }, " +
4061                                         "{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4062                                                 "\"Id\" : \"document-id\", " +
4063                                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
4064                                                 "\"Value\"      : \"abc\" " +
4065                                                         "}] } "
4066                                         + "] }}");
4067                         assertEquals("{returnPolicyIdList=false,combinedDecision=false,requestAttributes=[{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}],includeInResults=false}]}}{super={category=custom-category,attributes=[{attributeId=document-id,category=custom-category,values=[{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=abc}],includeInResults=false}]}}]}", request.toString());
4068                 } catch (Exception e) {
4069                         fail ("Failed convert from JSON to object: " + e);
4070                 }
4071                 
4072                 // duplicate Attribute
4073                 try {
4074                         request = JSONRequest.load("{\"Request\" : {\"Category\": [" +
4075                                         "{\"CategoryId\" : \"custom-category\","
4076                                         + " \"Attribute\" : [{" +
4077                                                 "\"Id\" : \"document-id\", " +
4078                                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
4079                                                 "\"Value\"      : \"abc\" " +
4080                                                         "}], "
4081                                         + " \"Attribute\" : [{" +
4082                                                 "\"Id\" : \"document-id\", " +
4083                                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
4084                                                 "\"Value\"      : \"abc\" " +
4085                                                         "}] "
4086                                                         + "} "
4087                                         + " }}");
4088                         fail("Operation should throw exception");
4089                 } catch (JSONStructureException e) {
4090                         // correct response
4091                 } catch (Exception e) {
4092                         fail ("Failed convert from JSON to object: " + e);
4093                 }
4094                 
4095                 // dup id
4096                 try {
4097                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4098                                 "\"Id\" : \"document-id\", " +
4099                                 "\"Id\" : \"document-id\", " +
4100                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
4101                                 "\"Value\"      : \"abc\" " +
4102                                         "}] } " 
4103                                         + "] }}");
4104                         fail("Operation should throw exception");
4105                 } catch (JSONStructureException e) {
4106                         // correct response
4107                 } catch (Exception e) {
4108                         fail ("Failed convert from JSON to object: " + e);
4109                 }
4110                 
4111                 // dup DataType
4112                 try {
4113                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4114                                 "\"Id\" : \"document-id\", " +
4115                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
4116                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
4117                                 "\"Value\"      : \"abc\" " +
4118                                         "}] } " 
4119                                         + "] }}");
4120                         fail("Operation should throw exception");
4121                 } catch (JSONStructureException e) {
4122                         // correct response
4123                 } catch (Exception e) {
4124                         fail ("Failed convert from JSON to object: " + e);
4125                 }
4126                 
4127                 // dup Value
4128                 try {
4129                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4130                                 "\"Id\" : \"document-id\", " +
4131                                 "\"DataType\"   : \"http://www.w3.org/2001/XMLSchema#string\", " +
4132                                 "\"Value\"      : \"abc\" " +
4133                                 "\"Value\"      : \"abc\" " +
4134                                         "}] } " 
4135                                         + "] }}");
4136                         fail("Operation should throw exception");
4137                 } catch (JSONStructureException e) {
4138                         // correct response
4139                 } catch (Exception e) {
4140                         fail ("Failed convert from JSON to object: " + e);
4141                 }
4142                 
4143                 
4144                 // duplicate Content
4145                 try {
4146                         request = JSONRequest.load("{\"Request\" : {\"Category\": [{"
4147                                         + "\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4148                                         "\"Id\" : \"document-id\", " +
4149                                         "\"Value\"      : [ \"aValue\",\"aValue\",\"aValue\"] " +
4150                                         "}]," +
4151                                         "\"Content\" : \"<?xml version=\\\"1.0\\\"?><catalog>" + 
4152                                                         "<book id=\\\"bk101\\\"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre>" +
4153                                                         "<price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description>"+
4154                                                         "</book></catalog>\" , " +
4155                                                 "\"Content\" : \"<?xml version=\\\"1.0\\\"?><catalog>" + 
4156                                                         "<book id=\\\"bk101\\\"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre>" +
4157                                                         "<price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description>"+
4158                                                         "</book></catalog>\"" +
4159                                         "} ] }}");
4160                         fail("Operation should throw exception");
4161                 } catch (JSONStructureException e) {
4162                         // correct response
4163                 } catch (Exception e) {
4164                         fail ("Failed convert from JSON to object: " + e);
4165                 }
4166                 
4167         }
4168         
4169
4170         
4171 //TODO - Shorthand for CategoryId ????
4172         
4173         
4174 }