2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.policy.xacml.test.json;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.fail;
26 import org.junit.Test;
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;
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.
37 * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
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.
50 public class RequestCategoryTest {
52 // The request object output from each test conversion from JSON string
57 * Request that uses all fields with both single and multiple entries
59 String allFieldsRequest =
61 "\"ReturnPolicyIdList\" : true ," +
62 "\"CombinedDecision\" : true ," +
63 "\"XPathVersion\" : \"http://www.w3.org/TR/1999/REC-xpath-19991116\"," +
64 "\"MultiRequests\" : {" +
65 "\"RequestReference\": [" +
67 "\"ReferenceId\" : [\"foo1\",\"bar1\"]" +
70 "\"ReferenceId\" : [\"foo2\",\"bar1\"]" +
76 "\"CategoryId\": \"custom-category\", " +
77 "\"Id\" : \"customId\", " +
80 "\"AttributeId\" : \"document-id\", " +
81 "\"DataType\" : \"integer\", " +
85 "\"AttributeId\" : \"document-url\", " +
86 "\"DataType\" : \"anyURI\", " +
87 "\"Value\" : \"http://somewhere.over.the.com/rainbow\" " +
90 "\"AttributeId\" : \"page-list\", " +
91 "\"Value\" : [1, 2, 3, 4.5, 3, 2, 1] " +
96 "\"CategoryId\": \"another-custom-cat\", " +
97 "\"Id\" : \"anotherXmlId\", " +
98 "\"Attribute\" : []" +
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\" : []" +
111 "\"Content\" : \"PD94bWwgdmVyc2lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9yPkdhbWJhcmRlbGxhLCBNYXR0aGV3PC9hdXRob3I+PHRpdGxlPlhNT" +
112 "CBEZXZlbG9wZXIncyBHdWlkZTwvdGl0bGU+PGdlbnJlPkNvbXB1dGVyPC9nZW5yZT48cHJpY2U+NDQuOTU8L3ByaWNlPjxwdWJsaXNoX2RhdGU+MjAwMC0xMC0wMTwvcHVibGlzaF"+
113 "9kYXRlPjxkZXNjcmlwdGlvbj5BbiBpbi1kZXB0aCBsb29rIGF0IGNyZWF0aW5nIGFwcGxpY2F0aW9ucyB3aXRoIFhNTC48L2Rlc2NyaXB0aW9uPjwvYm9vaz48L2NhdGFsb2c+\"" +
122 * The following example comes directly from the JSON Profile Spec
124 String exampleFromSpec = "{ " +
126 "\"AccessSubject\" : { " +
127 "\"Attribute\": [ " +
129 "\"Id\" : \"subject-id\", " +
130 "\"Value\" : \"Andreas\" " +
133 "\"Id\" : \"location\", " +
134 "\"Value\" : \"Gamla Stan\" " +
141 "\"Id\" : \"action-id\", " +
142 "\"Value\" : \"http://www.xacml.eu/buy\", " +
143 "\"DataType\" : \"anyURI\" " +
146 "\"Resource\" : { " +
147 "\"Attribute\": [ " +
149 "\"Id\" : \"book-title\", " +
150 "\"Value\" : \"Learn German in 90 days\" " +
153 "\"Id\" : \"currency\", " +
154 "\"Value\" : \"SEK\" " +
157 "\"Id\" : \"price\", " +
158 "\"Value\" : 123.34 " +
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.
170 String xPathExampleFromSpec = "{ " +
172 "\"Resource\" : { " +
173 "\"Attribute\": [ " +
175 "\"Id\" : \"urn:oasis:names:tc:xacml:3.0:content-selector\", " +
176 "\"DataType\" : \"xpathExpression\", " +
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\" " +
183 "\"Prefix\" : \"md\", " +
184 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
187 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" " +
197 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
199 // Top-level of Category
201 public void testCategoryTopLevel() {
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);
213 request = JSONRequest.load("{\"Request\" : {\"Category\" }}");
214 fail("Operation should throw exception");
215 } catch (JSONStructureException e) {
217 } catch (Exception e) {
218 fail ("Failed convert from JSON to object: " + e);
222 request = JSONRequest.load("{\"Request\" : {\"Category\" : }}");
223 fail("Operation should throw exception");
224 } catch (JSONStructureException e) {
226 } catch (Exception e) {
227 fail ("Failed convert from JSON to object: " + e);
230 // Category without CategoryId
232 request = JSONRequest.load("{\"Request\" : {\"Category\": [{}] }}");
233 fail("Operation should throw exception");
234 } catch (JSONStructureException e) {
236 } catch (Exception e) {
237 fail ("Failed convert from JSON to object: " + e);
240 // Category with CategoryId value missing or =""
242 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\"] }}");
243 fail("Operation should throw exception");
244 } catch (JSONStructureException e) {
246 } catch (Exception e) {
247 fail ("Failed convert from JSON to object: " + e);
251 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : ] }}");
252 fail("Operation should throw exception");
253 } catch (JSONStructureException e) {
255 } catch (Exception e) {
256 fail ("Failed convert from JSON to object: " + e);
260 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"\" ] }}");
261 fail("Operation should throw exception");
262 } catch (JSONStructureException e) {
264 } catch (Exception e) {
265 fail ("Failed convert from JSON to object: " + e);
268 // CategoryId wrong type
270 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : true } ] }}");
271 fail("Operation should throw exception");
272 } catch (JSONStructureException e) {
274 } catch (Exception e) {
275 fail ("Failed convert from JSON to object: " + e);
278 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : 123 } ] }}");
279 fail("Operation should throw exception");
280 } catch (JSONStructureException e) {
282 } catch (Exception e) {
283 fail ("Failed convert from JSON to object: " + e);
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);
294 // Category with Id - wrong type
296 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Id\" : true } ] }}");
297 fail("Operation should throw exception");
298 } catch (JSONStructureException e) {
300 } catch (Exception e) {
301 fail ("Failed convert from JSON to object: " + e);
304 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Id\" : 123 } ] }}");
305 fail("Operation should throw exception");
306 } catch (JSONStructureException e) {
308 } catch (Exception e) {
309 fail ("Failed convert from JSON to object: " + e);
313 // Category without Id
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);
322 // Category with standard CategoryId
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);
330 // Category with extra unknown field
332 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", unknown } ] }}");
333 fail("Operation should throw exception");
334 } catch (JSONStructureException e) {
336 } catch (Exception e) {
337 fail ("Failed convert from JSON to object: " + e);
341 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"unknown\" : 123 } ] }}");
342 fail("Operation should throw exception");
343 } catch (JSONStructureException e) {
345 } catch (Exception e) {
346 fail ("Failed convert from JSON to object: " + e);
349 // Category with multiple sub-Category objects using same CategoryId
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);
361 // Tests related to Attributes
363 public void testCategoryAttributes() {
365 // Category with Attribute but none given ("Attribute" : [] )
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);
373 // Category Attribute with empty attribute (missing both AttributeId and Id)
375 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{}] } ] }}");
376 fail("Operation should throw exception");
377 } catch (JSONStructureException e) {
379 } catch (Exception e) {
380 fail ("Failed convert from JSON to object: " + e);
383 // Category Attribute with AttributeId and no Value
385 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
386 "\"AttributeId\" : \"document-id\" " +
388 fail("Operation should throw exception");
389 } catch (JSONStructureException e) {
391 } catch (Exception e) {
392 fail ("Failed convert from JSON to object: " + e);
395 // Category Attribute missing AttributeId but with Id
397 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
398 "\"AttributeId\" : \"document-id\", " +
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);
406 // Category Attribute missing AttributeId but with Id
408 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
409 "\"Id\" : \"document-id\", " +
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);
417 // Category Attribute including both AttributeId and Id with same value
419 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
420 "\"AttributeId\" : \"document-id\", " +
421 "\"Id\" : \"document-id\", " +
424 fail("Operation should throw exception");
425 } catch (JSONStructureException e) {
427 } catch (Exception e) {
428 fail ("Failed convert from JSON to object: " + e);
431 // Category Attribute missing both AttributeId and Id
433 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
436 fail("Operation should throw exception");
437 } catch (JSONStructureException e) {
439 } catch (Exception e) {
440 fail ("Failed convert from JSON to object: " + e);
443 // Category Attribute AttributeId not string
445 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
446 "\"AttributeId\" : true, " +
449 fail("Operation should throw exception");
450 } catch (JSONStructureException e) {
452 } catch (Exception e) {
453 fail ("Failed convert from JSON to object: " + e);
457 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
458 "\"AttributeId\" : 123, " +
461 fail("Operation should throw exception");
462 } catch (JSONStructureException e) {
464 } catch (Exception e) {
465 fail ("Failed convert from JSON to object: " + e);
468 // Category Attribute Id not string
470 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
474 fail("Operation should throw exception");
475 } catch (JSONStructureException e) {
477 } catch (Exception e) {
478 fail ("Failed convert from JSON to object: " + e);
482 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
486 fail("Operation should throw exception");
487 } catch (JSONStructureException e) {
489 } catch (Exception e) {
490 fail ("Failed convert from JSON to object: " + e);
494 // Category Attribute with DataType
496 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
497 "\"Id\" : \"document-id\", " +
498 "\"DataType\" : \"integer\", " +
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);
506 // Category Attribute with DataType not string (e.g. "DataType" : 55.5 )
508 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
509 "\"Id\" : \"document-id\", " +
510 "\"DataType\" : true, " +
513 fail("Operation should throw exception");
514 } catch (JSONStructureException e) {
516 } catch (Exception e) {
517 fail ("Failed convert from JSON to object: " + e);
520 // Category Attribute with unknown DataType
522 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
523 "\"Id\" : \"document-id\", " +
524 "\"DataType\" : \"no such data type\", " +
527 fail("Operation should throw exception");
528 } catch (JSONStructureException e) {
530 } catch (Exception e) {
531 fail ("Failed convert from JSON to object: " + e);
535 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
536 "\"Id\" : \"document-id\", " +
537 "\"DataType\" : 321, " +
540 fail("Operation should throw exception");
541 } catch (JSONStructureException e) {
543 } catch (Exception e) {
544 fail ("Failed convert from JSON to object: " + e);
547 // Category Attribute with multiple value array
549 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
550 "\"Id\" : \"document-id\", " +
551 "\"DataType\" : \"dayTimeDuration\", " +
552 "\"Value\" : [\"P3D\", \"P2DT12H34M\", \"PT15M\"] " +
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);
559 // Category Attribute multiple value with null in array
561 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
562 "\"Id\" : \"document-id\", " +
563 "\"DataType\" : \"dayTimeDuration\", " +
564 "\"Value\" : [\"P3D\", , \"P15M\"] " +
566 fail("Operation should throw exception");
567 } catch (JSONStructureException e) {
569 } catch (Exception e) {
570 fail ("Failed convert from JSON to object: " + e);
573 // Category Attribute with array value with no values ("Attribute": [ {"AttributeId" :"a", Value:[] } ] } )
575 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
576 "\"Id\" : \"document-id\", " +
577 "\"DataType\" : \"dayTimeDuration\", " +
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);
585 // Category Attribute with no DataType and array with no values
587 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
588 "\"Id\" : \"document-id\", " +
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);
596 // Category Attribute with Issuer
598 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
599 "\"Id\" : \"document-id\", " +
600 "\"Issuer\" : \"University Press\", " +
601 "\"DataType\" : \"integer\", " +
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);
609 // Category Attribute with Issuer not string
611 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
612 "\"Id\" : \"document-id\", " +
613 "\"Issuer\" : true, " +
614 "\"DataType\" : \"integer\", " +
617 fail("Operation should throw exception");
618 } catch (JSONStructureException e) {
620 } catch (Exception e) {
621 fail ("Failed convert from JSON to object: " + e);
625 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
626 "\"Id\" : \"document-id\", " +
627 "\"Issuer\" : 4.56, " +
628 "\"DataType\" : \"integer\", " +
631 fail("Operation should throw exception");
632 } catch (JSONStructureException e) {
634 } catch (Exception e) {
635 fail ("Failed convert from JSON to object: " + e);
638 // Category Attribute with includeInResult=true
640 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
641 "\"Id\" : \"document-id\", " +
642 "\"Value\" : 123, " +
643 "\"IncludeInResult\" : true " +
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);
650 // Category Attribute with includeInResult = false
652 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
653 "\"Id\" : \"document-id\", " +
654 "\"Value\" : 123, " +
655 "\"IncludeInResult\" : false " +
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);
662 // Category Attribute with includeInResult not boolean
664 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
665 "\"Id\" : \"document-id\", " +
666 "\"Value\" : 123, " +
667 "\"IncludeInResult\" : \"abc\" " +
669 fail("Operation should throw exception");
670 } catch (JSONStructureException e) {
672 } catch (Exception e) {
673 fail ("Failed convert from JSON to object: " + e);
677 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
678 "\"Id\" : \"document-id\", " +
679 "\"Value\" : 123, " +
680 "\"IncludeInResult\" : 123.45 " +
682 fail("Operation should throw exception");
683 } catch (JSONStructureException e) {
685 } catch (Exception e) {
686 fail ("Failed convert from JSON to object: " + e);
692 // Tests related to DataTypes within Attributes
694 public void testCategoryAttributesDataTypesSimple() {
696 // Category Attribute using full Identifier for each data type
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\" " +
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);
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 " +
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);
720 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
721 "\"Id\" : \"document-id\", " +
722 "\"DataType\" : \"http://www.w3.org/2001/XMLSchema#integer\", " +
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);
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 " +
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);
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\" " +
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);
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\" " +
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);
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\" " +
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);
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\" " +
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);
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\" " +
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);
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\" " +
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);
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\" " +
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);
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\" " +
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);
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\" " +
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);
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\" " +
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);
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\" : \"121.221.43.58:12345\" " +
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=121.221.43.58:12345-12345}],includeInResults=false}]}}]}", request.toString());
858 } catch (Exception e) {
859 fail ("Failed convert from JSON to object: " + e);
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\" " +
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);
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\", " +
878 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
881 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
884 "\"Prefix\" : \"md\", " +
885 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
887 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
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());
892 } catch (Exception e) {
893 fail ("Failed convert from JSON to object: " + e);
897 // Category Attribute shorthand notation for each data type
899 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
900 "\"Id\" : \"document-id\", " +
901 "\"DataType\" : \"string\", " +
902 "\"Value\" : \"abc\" " +
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);
910 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
911 "\"Id\" : \"document-id\", " +
912 "\"DataType\" : \"boolean\", " +
913 "\"Value\" : true " +
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);
921 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
922 "\"Id\" : \"document-id\", " +
923 "\"DataType\" : \"integer\", " +
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);
932 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
933 "\"Id\" : \"document-id\", " +
934 "\"DataType\" : \"double\", " +
935 "\"Value\" : 123.34 " +
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);
943 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
944 "\"Id\" : \"document-id\", " +
945 "\"DataType\" : \"time\", " +
946 "\"Value\" : \"12:00:00Z\" " +
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);
954 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
955 "\"Id\" : \"document-id\", " +
956 "\"DataType\" : \"date\", " +
957 "\"Value\" : \"2002-10-10\" " +
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);
965 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
966 "\"Id\" : \"document-id\", " +
967 "\"DataType\" : \"dateTime\", " +
968 "\"Value\" : \"2002-10-10T12:00:00Z\" " +
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);
976 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
977 "\"Id\" : \"document-id\", " +
978 "\"DataType\" : \"dayTimeDuration\", " +
979 "\"Value\" : \"P23DT7H12M54S\" " +
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);
987 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
988 "\"Id\" : \"document-id\", " +
989 "\"DataType\" : \"yearMonthDuration\", " +
990 "\"Value\" : \"P165Y8M\" " +
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);
998 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
999 "\"Id\" : \"document-id\", " +
1000 "\"DataType\" : \"anyURI\", " +
1001 "\"Value\" : \"aValue\" " +
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);
1009 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1010 "\"Id\" : \"document-id\", " +
1011 "\"DataType\" : \"hexBinary\", " +
1012 "\"Value\" : \"FA027B7D12CC34DDD20012AEEF\" " +
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);
1020 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1021 "\"Id\" : \"document-id\", " +
1022 "\"DataType\" : \"base64Binary\", " +
1023 "\"Value\" : \"lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9y\" " +
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);
1031 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1032 "\"Id\" : \"document-id\", " +
1033 "\"DataType\" : \"rfc822Name\", " +
1034 "\"Value\" : \"someone.else@A.COMPANY.com\" " +
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);
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\" " +
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);
1053 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1054 "\"Id\" : \"document-id\", " +
1055 "\"DataType\" : \"ipAddress\", " +
1056 "\"Value\" : \"121.221.43.58:12345\" " +
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=121.221.43.58:12345-12345}],includeInResults=false}]}}]}", request.toString());
1059 } catch (Exception e) {
1060 fail ("Failed convert from JSON to object: " + e);
1064 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1065 "\"Id\" : \"document-id\", " +
1066 "\"DataType\" : \"dnsName\", " +
1067 "\"Value\" : \"aValue\" " +
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);
1075 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1076 "\"Id\" : \"document-id\", " +
1077 "\"DataType\" : \"xpathExpression\", " +
1079 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
1080 "\"Namespaces\" : ["
1082 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
1085 "\"Prefix\" : \"md\", " +
1086 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
1088 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
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());
1093 } catch (Exception e) {
1094 fail ("Failed convert from JSON to object: " + e);
1099 // infer data type - only integer, boolean and double are distinguishable from strings; everything else is treated as a string
1101 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1102 "\"Id\" : \"document-id\", " +
1103 "\"Value\" : \"abc\" " +
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);
1111 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1112 "\"Id\" : \"document-id\", " +
1113 "\"Value\" : true " +
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);
1121 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1122 "\"Id\" : \"document-id\", " +
1123 "\"Value\" : 123 " +
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);
1131 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1132 "\"Id\" : \"document-id\", " +
1133 "\"Value\" : 123.34 " +
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);
1141 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1142 "\"Id\" : \"document-id\", " +
1143 "\"Value\" : \"12:00:00Z\" " +
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);
1151 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1152 "\"Id\" : \"document-id\", " +
1153 "\"Value\" : \"2002-10-10\" " +
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);
1161 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1162 "\"Id\" : \"document-id\", " +
1163 "\"Value\" : \"2002-10-10T12:00:00Z\" " +
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);
1171 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1172 "\"Id\" : \"document-id\", " +
1173 "\"Value\" : \"P23DT7H12M54S\" " +
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);
1181 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1182 "\"Id\" : \"document-id\", " +
1183 "\"Value\" : \"P165Y8M\" " +
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);
1191 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1192 "\"Id\" : \"document-id\", " +
1193 "\"Value\" : \"aValue\" " +
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);
1201 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1202 "\"Id\" : \"document-id\", " +
1203 "\"Value\" : \"FA027B7D12CC34DDD20012AEEF\" " +
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);
1211 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1212 "\"Id\" : \"document-id\", " +
1213 "\"Value\" : \"lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9y\" " +
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);
1221 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1222 "\"Id\" : \"document-id\", " +
1223 "\"Value\" : \"someone.else@A.COMPANY.com\" " +
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);
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\" " +
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);
1242 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1243 "\"Id\" : \"document-id\", " +
1244 "\"Value\" : \"121.221.43.58:12345\" " +
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=121.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
1247 } catch (Exception e) {
1248 fail ("Failed convert from JSON to object: " + e);
1252 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1253 "\"Id\" : \"document-id\", " +
1254 "\"Value\" : \"aValue\" " +
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);
1262 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1263 "\"Id\" : \"document-id\", " +
1264 "\"Value\" : \"aValue\" " +
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);
1272 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1273 "\"Id\" : \"document-id\", " +
1275 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
1276 "\"Namespaces\" : ["
1278 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
1281 "\"Prefix\" : \"md\", " +
1282 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
1284 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
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());
1290 } catch (Exception e) {
1291 fail ("Failed convert from JSON to object: " + e);
1298 public void testCategoryAttributesDataTypesNotMatchValue() {
1300 // Category Attribute with DataType not matching value type (JSON type derived from syntax)
1301 // AUTO-CONVERSION from Boolean to String!
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 " +
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);
1312 // SUCCESSFUL AUTO-CONVERT
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 " +
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);
1323 // SUCCESSFUL AUTO-CONVERT
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 " +
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);
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\" " +
1343 fail("Operation should throw exception");
1344 } catch (JSONStructureException e) {
1346 } catch (Exception e) {
1347 fail ("Failed convert from JSON to object: " + e);
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 " +
1356 fail("Operation should throw exception");
1357 } catch (JSONStructureException e) {
1359 } catch (Exception e) {
1360 fail ("Failed convert from JSON to object: " + e);
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 " +
1369 fail("Operation should throw exception");
1370 } catch (JSONStructureException e) {
1372 } catch (Exception e) {
1373 fail ("Failed convert from JSON to object: " + e);
1376 // SUCCESSFUL AUTO-CONVERT
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\" " +
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);
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 " +
1394 fail("Operation should throw exception");
1395 } catch (JSONStructureException e) {
1397 } catch (Exception e) {
1398 fail ("Failed convert from JSON to object: " + e);
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 " +
1407 fail("Operation should throw exception");
1408 } catch (JSONStructureException e) {
1410 } catch (Exception e) {
1411 fail ("Failed convert from JSON to object: " + e);
1415 // SUCCESSFUL AUTO-CONVERT
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\" " +
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);
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 " +
1433 fail("Operation should throw exception");
1434 } catch (JSONStructureException e) {
1436 } catch (Exception e) {
1437 fail ("Failed convert from JSON to object: " + e);
1440 // allow integer to auto-convert to double when DataType is given
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 " +
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);
1452 // special JavaScript values not allowed except for -0 (inappropriate requirement in spec - check it anyway)
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\" " +
1459 fail("Operation should throw exception");
1460 } catch (JSONStructureException e) {
1462 } catch (Exception e) {
1463 fail ("Failed convert from JSON to object: " + e);
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\" " +
1472 fail("Operation should throw exception");
1473 } catch (JSONStructureException e) {
1475 } catch (Exception e) {
1476 fail ("Failed convert from JSON to object: " + e);
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\" " +
1485 fail("Operation should throw exception");
1486 } catch (JSONStructureException e) {
1488 } catch (Exception e) {
1489 fail ("Failed convert from JSON to object: " + e);
1492 // JavaScript 0 and -0 are ok
1494 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1495 "\"Id\" : \"document-id\", " +
1496 "\"DataType\" : \"http://www.w3.org/2001/XMLSchema#integer\", " +
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);
1505 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1506 "\"Id\" : \"document-id\", " +
1507 "\"DataType\" : \"http://www.w3.org/2001/XMLSchema#integer\", " +
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);
1516 // All other data types are checked when we convert internally, so value must be syntactically correct
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\" " +
1524 fail("Operation should throw exception");
1525 } catch (JSONStructureException e) {
1527 } catch (Exception e) {
1528 fail ("Failed convert from JSON to object: " + e);
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\" " +
1537 fail("Operation should throw exception");
1538 } catch (JSONStructureException e) {
1540 } catch (Exception e) {
1541 fail ("Failed convert from JSON to object: " + e);
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\" " +
1550 fail("Operation should throw exception");
1551 } catch (JSONStructureException e) {
1553 } catch (Exception e) {
1554 fail ("Failed convert from JSON to object: " + e);
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\" " +
1563 fail("Operation should throw exception");
1564 } catch (JSONStructureException e) {
1566 } catch (Exception e) {
1567 fail ("Failed convert from JSON to object: " + e);
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\" " +
1576 fail("Operation should throw exception");
1577 } catch (JSONStructureException e) {
1579 } catch (Exception e) {
1580 fail ("Failed convert from JSON to object: " + e);
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\" " +
1589 fail("Operation should throw exception");
1590 } catch (JSONStructureException e) {
1592 } catch (Exception e) {
1593 fail ("Failed convert from JSON to object: " + e);
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\" " +
1602 fail("Operation should throw exception");
1603 } catch (JSONStructureException e) {
1605 } catch (Exception e) {
1606 fail ("Failed convert from JSON to object: " + e);
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.
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\" " +
1618 fail("Operation should throw exception");
1619 } catch (JSONStructureException e) {
1621 } catch (Exception e) {
1622 fail ("Failed convert from JSON to object: " + e);
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\" " +
1631 fail("Operation should throw exception");
1632 } catch (JSONStructureException e) {
1634 } catch (Exception e) {
1635 fail ("Failed convert from JSON to object: " + e);
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\" " +
1644 fail("Operation should throw exception");
1645 } catch (JSONStructureException e) {
1647 } catch (Exception e) {
1648 fail ("Failed convert from JSON to object: " + e);
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\" " +
1657 fail("Operation should throw exception");
1658 } catch (JSONStructureException e) {
1660 } catch (Exception e) {
1661 fail ("Failed convert from JSON to object: " + e);
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.
1672 public void testArrayDataTypes() {
1676 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1677 "\"Id\" : \"document-id\", " +
1678 "\"DataType\" : \"http://www.w3.org/2001/XMLSchema#string\", " +
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);
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)
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\"] " +
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);
1703 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1704 "\"Id\" : \"document-id\", " +
1705 "\"DataType\" : \"string\", " +
1706 "\"Value\" : [\"abc\", \"def\", \"hig\", \"lmn\"] " +
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);
1712 // SUCCESSFUL AUTO-CONVERT to DataType
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\"] " +
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);
1723 // SUCCESSFUL AUTO-CONVERT
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\"] " +
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);
1734 // SUCCESSFUL AUTO-CONVERT
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\"] " +
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);
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 ] " +
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);
1759 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1760 "\"Id\" : \"document-id\", " +
1761 "\"DataType\" : \"boolean\", " +
1762 "\"Value\" : [true, true, false, true, false ] " +
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);
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 ] " +
1774 fail("Operation should throw exception");
1775 } catch (JSONStructureException e) {
1777 } catch (Exception e) {
1778 fail ("Failed convert from JSON to object: " + e);
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 ] " +
1786 fail("Operation should throw exception");
1787 } catch (JSONStructureException e) {
1789 } catch (Exception e) {
1790 fail ("Failed convert from JSON to object: " + e);
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 ] " +
1798 fail("Operation should throw exception");
1799 } catch (JSONStructureException e) {
1801 } catch (Exception e) {
1802 fail ("Failed convert from JSON to object: " + e);
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] " +
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);
1819 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
1820 "\"Id\" : \"document-id\", " +
1821 "\"DataType\" : \"integer\", " +
1822 "\"Value\" : [123, 456, 765, 234] " +
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);
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] " +
1834 fail("Operation should throw exception");
1835 } catch (JSONStructureException e) {
1837 } catch (Exception e) {
1838 fail ("Failed convert from JSON to object: " + e);
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] " +
1846 fail("Operation should throw exception");
1847 } catch (JSONStructureException e) {
1849 } catch (Exception e) {
1850 fail ("Failed convert from JSON to object: " + e);
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] " +
1858 fail("Operation should throw exception");
1859 } catch (JSONStructureException e) {
1861 } catch (Exception e) {
1862 fail ("Failed convert from JSON to object: " + e);
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 ] " +
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);
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 ] " +
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);
1887 // special case - auto-convert integer to boolean
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 ] " +
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);
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 ] " +
1904 fail("Operation should throw exception");
1905 } catch (JSONStructureException e) {
1907 } catch (Exception e) {
1908 fail ("Failed convert from JSON to object: " + e);
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 ] " +
1916 fail("Operation should throw exception");
1917 } catch (JSONStructureException e) {
1919 } catch (Exception e) {
1920 fail ("Failed convert from JSON to object: " + e);
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\"] " +
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);
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\"] " +
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);
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\"] " +
1951 fail("Operation should throw exception");
1952 } catch (JSONStructureException e) {
1954 } catch (Exception e) {
1955 fail ("Failed convert from JSON to object: " + e);
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\"] " +
1963 fail("Operation should throw exception");
1964 } catch (JSONStructureException e) {
1966 } catch (Exception e) {
1967 fail ("Failed convert from JSON to object: " + e);
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\"] " +
1975 fail("Operation should throw exception");
1976 } catch (JSONStructureException e) {
1978 } catch (Exception e) {
1979 fail ("Failed convert from JSON to object: " + e);
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\"] " +
1987 fail("Operation should throw exception");
1988 } catch (JSONStructureException e) {
1990 } catch (Exception e) {
1991 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
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);
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\" ] " +
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);
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\" ] " +
2022 fail("Operation should throw exception");
2023 } catch (JSONStructureException e) {
2025 } catch (Exception e) {
2026 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2034 fail("Operation should throw exception");
2035 } catch (JSONStructureException e) {
2037 } catch (Exception e) {
2038 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2046 fail("Operation should throw exception");
2047 } catch (JSONStructureException e) {
2049 } catch (Exception e) {
2050 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2058 fail("Operation should throw exception");
2059 } catch (JSONStructureException e) {
2061 } catch (Exception e) {
2062 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
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);
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\" ] " +
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);
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\" ] " +
2093 fail("Operation should throw exception");
2094 } catch (JSONStructureException e) {
2096 } catch (Exception e) {
2097 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2105 fail("Operation should throw exception");
2106 } catch (JSONStructureException e) {
2108 } catch (Exception e) {
2109 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2117 fail("Operation should throw exception");
2118 } catch (JSONStructureException e) {
2120 } catch (Exception e) {
2121 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2129 fail("Operation should throw exception");
2130 } catch (JSONStructureException e) {
2132 } catch (Exception e) {
2133 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
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);
2149 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2150 "\"Id\" : \"document-id\", " +
2151 "\"DataType\" : \"dayTimeDuration\", " +
2152 "\"Value\" : [ \"P23DT7H12M54S\",\"P23DT7H12M54S\",\"P23DT7H12M54S\" ] " +
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);
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\" ] " +
2164 fail("Operation should throw exception");
2165 } catch (JSONStructureException e) {
2167 } catch (Exception e) {
2168 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2176 fail("Operation should throw exception");
2177 } catch (JSONStructureException e) {
2179 } catch (Exception e) {
2180 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2188 fail("Operation should throw exception");
2189 } catch (JSONStructureException e) {
2191 } catch (Exception e) {
2192 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2200 fail("Operation should throw exception");
2201 } catch (JSONStructureException e) {
2203 } catch (Exception e) {
2204 fail ("Failed convert from JSON to object: " + e);
2208 // yearMonth duration
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\" ] " +
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);
2220 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2221 "\"Id\" : \"document-id\", " +
2222 "\"DataType\" : \"yearMonthDuration\", " +
2223 "\"Value\" : [ \"P165Y8M\",\"P165Y8M\",\"P165Y8M\" ] " +
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);
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\" ] " +
2235 fail("Operation should throw exception");
2236 } catch (JSONStructureException e) {
2238 } catch (Exception e) {
2239 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2247 fail("Operation should throw exception");
2248 } catch (JSONStructureException e) {
2250 } catch (Exception e) {
2251 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2259 fail("Operation should throw exception");
2260 } catch (JSONStructureException e) {
2262 } catch (Exception e) {
2263 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2271 fail("Operation should throw exception");
2272 } catch (JSONStructureException e) {
2274 } catch (Exception e) {
2275 fail ("Failed convert from JSON to object: " + e);
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\"] " +
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);
2291 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2292 "\"Id\" : \"document-id\", " +
2293 "\"DataType\" : \"anyURI\", " +
2294 "\"Value\" : [ \"aValue\",\"aValue\",\"aValue\"] " +
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);
2300 // SUCCESSFUL AUTO-CONVERT
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\"] " +
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);
2311 // SUCCESSFUL AUTO-CONVERT
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\"] " +
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);
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\"] " +
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);
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\" ] " +
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);
2347 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2348 "\"Id\" : \"document-id\", " +
2349 "\"DataType\" : \"hexBinary\", " +
2350 "\"Value\" : [ \"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\" ] " +
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);
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\" ] " +
2362 fail("Operation should throw exception");
2363 } catch (JSONStructureException e) {
2365 } catch (Exception e) {
2366 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2374 fail("Operation should throw exception");
2375 } catch (JSONStructureException e) {
2377 } catch (Exception e) {
2378 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2386 fail("Operation should throw exception");
2387 } catch (JSONStructureException e) {
2389 } catch (Exception e) {
2390 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
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);
2406 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2407 "\"Id\" : \"document-id\", " +
2408 "\"DataType\" : \"base64Binary\", " +
2409 "\"Value\" : [ \"aG9y\",\"lvbj0iMS4xIj48YXV0aG9y\",\"lvbjIj48YXV0aG9y\" ] " +
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);
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\" ] " +
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);
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\" ] " +
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);
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\" ] " +
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);
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\" ] " +
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);
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\" ] " +
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);
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\" ] " +
2477 fail("Operation should throw exception");
2478 } catch (JSONStructureException e) {
2480 } catch (Exception e) {
2481 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2489 fail("Operation should throw exception");
2490 } catch (JSONStructureException e) {
2492 } catch (Exception e) {
2493 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2501 fail("Operation should throw exception");
2502 } catch (JSONStructureException e) {
2504 } catch (Exception e) {
2505 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2513 fail("Operation should throw exception");
2514 } catch (JSONStructureException e) {
2516 } catch (Exception e) {
2517 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
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);
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\" ] " +
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);
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\" ] " +
2548 fail("Operation should throw exception");
2549 } catch (JSONStructureException e) {
2551 } catch (Exception e) {
2552 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2560 fail("Operation should throw exception");
2561 } catch (JSONStructureException e) {
2563 } catch (Exception e) {
2564 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2572 fail("Operation should throw exception");
2573 } catch (JSONStructureException e) {
2575 } catch (Exception e) {
2576 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2584 fail("Operation should throw exception");
2585 } catch (JSONStructureException e) {
2587 } catch (Exception e) {
2588 fail ("Failed convert from JSON to object: " + e);
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\" : [ \"121.221.43.58:12345\",\"121.221.43.58:12345\",\"121.221.43.58:12345\" ] " +
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=121.221.43.58:12345-12345}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=121.221.43.58:12345-12345}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=121.221.43.58:12345-12345}],includeInResults=false}]}}]}", request.toString());
2600 } catch (Exception e) {
2601 fail ("Failed convert from JSON to object: " + e);
2604 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2605 "\"Id\" : \"document-id\", " +
2606 "\"DataType\" : \"ipAddress\", " +
2607 "\"Value\" : [ \"121.221.43.58:12345\",\"121.221.43.58:12345\",\"121.221.43.58:12345\" ] " +
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=121.221.43.58:12345-12345}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=121.221.43.58:12345-12345}{dataTypeId=urn:oasis:names:tc:xacml:2.0:data-type:ipAddress,value=121.221.43.58:12345-12345}],includeInResults=false}]}}]}", request.toString());
2610 } catch (Exception e) {
2611 fail ("Failed convert from JSON to object: " + e);
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\" : [ \"121.221.43.58:12345\",\"not an ip address\",\"121.221.43.58:12345\" ] " +
2619 fail("Operation should throw exception");
2620 } catch (JSONStructureException e) {
2622 } catch (Exception e) {
2623 fail ("Failed convert from JSON to object: " + e);
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\" : [ \"121.221.43.58:12345\",true,\"121.221.43.58:12345\" ] " +
2631 fail("Operation should throw exception");
2632 } catch (JSONStructureException e) {
2634 } catch (Exception e) {
2635 fail ("Failed convert from JSON to object: " + e);
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\" : [ \"121.221.43.58:12345\",1111,\"121.221.43.58:12345\" ] " +
2643 fail("Operation should throw exception");
2644 } catch (JSONStructureException e) {
2646 } catch (Exception e) {
2647 fail ("Failed convert from JSON to object: " + e);
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\" : [ \"121.221.43.58:12345\",11.22,\"121.221.43.58:12345\" ] " +
2655 fail("Operation should throw exception");
2656 } catch (JSONStructureException e) {
2658 } catch (Exception e) {
2659 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
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);
2675 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2676 "\"Id\" : \"document-id\", " +
2677 "\"DataType\" : \"dnsName\", " +
2678 "\"Value\" : [ \"aValue\", \"aValue\", \"aValue\" ] " +
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);
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\" ] " +
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);
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\" ] " +
2701 fail("Operation should throw exception");
2702 } catch (JSONStructureException e) {
2704 } catch (Exception e) {
2705 fail ("Failed convert from JSON to object: " + e);
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\" ] " +
2713 fail("Operation should throw exception");
2714 } catch (JSONStructureException e) {
2716 } catch (Exception e) {
2717 fail ("Failed convert from JSON to object: " + e);
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\", " +
2728 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2729 "\"Namespaces\" : ["
2731 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2734 "\"Prefix\" : \"md\", " +
2735 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2737 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2740 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2741 "\"Namespaces\" : ["
2743 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2746 "\"Prefix\" : \"md\", " +
2747 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2749 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2752 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2753 "\"Namespaces\" : ["
2755 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2758 "\"Prefix\" : \"md\", " +
2759 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2761 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
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);
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\", " +
2776 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2777 "\"Namespaces\" : ["
2779 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2782 "\"Prefix\" : \"md\", " +
2783 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2785 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2787 "\"simpleString\"," +
2789 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2790 "\"Namespaces\" : ["
2792 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2795 "\"Prefix\" : \"md\", " +
2796 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2798 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2802 fail("Operation should throw exception");
2803 } catch (JSONStructureException e) {
2805 } catch (Exception e) {
2806 fail ("Failed convert from JSON to object: " + e);
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\", " +
2814 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2815 "\"Namespaces\" : ["
2817 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2820 "\"Prefix\" : \"md\", " +
2821 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2823 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2827 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2828 "\"Namespaces\" : ["
2830 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2833 "\"Prefix\" : \"md\", " +
2834 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2836 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2840 fail("Operation should throw exception");
2841 } catch (JSONStructureException e) {
2843 } catch (Exception e) {
2844 fail ("Failed convert from JSON to object: " + e);
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\", " +
2852 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2853 "\"Namespaces\" : ["
2855 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2858 "\"Prefix\" : \"md\", " +
2859 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2861 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2865 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2866 "\"Namespaces\" : ["
2868 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2871 "\"Prefix\" : \"md\", " +
2872 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2874 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2878 fail("Operation should throw exception");
2879 } catch (JSONStructureException e) {
2881 } catch (Exception e) {
2882 fail ("Failed convert from JSON to object: " + e);
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\", " +
2890 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2891 "\"Namespaces\" : ["
2893 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2896 "\"Prefix\" : \"md\", " +
2897 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2899 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2903 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
2904 "\"Namespaces\" : ["
2906 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
2909 "\"Prefix\" : \"md\", " +
2910 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
2912 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
2916 fail("Operation should throw exception");
2917 } catch (JSONStructureException e) {
2919 } catch (Exception e) {
2920 fail ("Failed convert from JSON to object: " + e);
2933 public void testArrayNoDataTypes() {
2937 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2938 "\"Id\" : \"document-id\", " +
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);
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)
2951 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2952 "\"Id\" : \"document-id\", " +
2953 "\"Value\" : [\"abc\", \"def\", \"hig\", \"lmn\"] " +
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);
2959 // SUCCESSFUL AUTO-CONVERT to DataType
2961 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2962 "\"Id\" : \"document-id\", " +
2963 "\"Value\" : [\"abc\", true, \"hig\", \"lmn\"] " +
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);
2969 // SUCCESSFUL AUTO-CONVERT
2971 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2972 "\"Id\" : \"document-id\", " +
2973 "\"Value\" : [\"abc\",123, \"hig\", \"lmn\"] " +
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);
2979 // SUCCESSFUL AUTO-CONVERT
2981 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2982 "\"Id\" : \"document-id\", " +
2983 "\"Value\" : [\"abc\", 34.34, \"hig\", \"lmn\"] " +
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);
2993 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
2994 "\"Id\" : \"document-id\", " +
2995 "\"Value\" : [true, true, false, true, false ] " +
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);
3002 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3003 "\"Id\" : \"document-id\", " +
3004 "\"Value\" : [true, \"abc\", false, true, false ] " +
3006 fail("Operation should throw exception");
3007 } catch (JSONStructureException e) {
3009 } catch (Exception e) {
3010 fail ("Failed convert from JSON to object: " + e);
3013 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3014 "\"Id\" : \"document-id\", " +
3015 "\"Value\" : [true, 123, false, true, false ] " +
3017 fail("Operation should throw exception");
3018 } catch (JSONStructureException e) {
3020 } catch (Exception e) {
3021 fail ("Failed convert from JSON to object: " + e);
3024 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3025 "\"Id\" : \"document-id\", " +
3026 "\"Value\" : [true, 12.34, false, true, false ] " +
3028 fail("Operation should throw exception");
3029 } catch (JSONStructureException e) {
3031 } catch (Exception e) {
3032 fail ("Failed convert from JSON to object: " + e);
3039 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3040 "\"Id\" : \"document-id\", " +
3041 "\"Value\" : [123, 456, 765, 234] " +
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);
3048 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3049 "\"Id\" : \"document-id\", " +
3050 "\"Value\" : [123, \"abc\", 765, 234] " +
3052 fail("Operation should throw exception");
3053 } catch (JSONStructureException e) {
3055 } catch (Exception e) {
3056 fail ("Failed convert from JSON to object: " + e);
3059 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3060 "\"Id\" : \"document-id\", " +
3061 "\"Value\" : [123, true, 765, 234] " +
3063 fail("Operation should throw exception");
3064 } catch (JSONStructureException e) {
3066 } catch (Exception e) {
3067 fail ("Failed convert from JSON to object: " + e);
3074 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3075 "\"Id\" : \"document-id\", " +
3076 "\"Value\" : [ 123.34, 543.54, 3445.455, 4543,543 ] " +
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);
3082 // special case - auto-convert integer to boolean
3084 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3085 "\"Id\" : \"document-id\", " +
3086 "\"Value\" : [ 123.34, 111122, 3445.455, 4543,543 ] " +
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);
3093 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3094 "\"Id\" : \"document-id\", " +
3095 "\"Value\" : [ 123.34, true, 3445.455, 4543,543 ] " +
3097 fail("Operation should throw exception");
3098 } catch (JSONStructureException e) {
3100 } catch (Exception e) {
3101 fail ("Failed convert from JSON to object: " + e);
3104 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3105 "\"Id\" : \"document-id\", " +
3106 "\"Value\" : [ 123.34, \"abb\", 3445.455, 4543,543 ] " +
3108 fail("Operation should throw exception");
3109 } catch (JSONStructureException e) {
3111 } catch (Exception e) {
3112 fail ("Failed convert from JSON to object: " + e);
3116 // time - defaults to String
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\"] " +
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);
3126 // SUCCESSFUL AUTO-CONVERT
3128 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3129 "\"Id\" : \"document-id\", " +
3130 "\"Value\" : [ \"12:00:00Z\", true, \"12:00:00Z\"] " +
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);
3136 // SUCCESSFUL AUTO-CONVERT
3138 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3139 "\"Id\" : \"document-id\", " +
3140 "\"Value\" : [ \"12:00:00Z\", 123, \"12:00:00Z\"] " +
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);
3148 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3149 "\"Id\" : \"document-id\", " +
3150 "\"Value\" : [ \"12:00:00Z\", 12.34, \"12:00:00Z\"] " +
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);
3158 // date - defaults to String
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\" ] " +
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);
3170 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3171 "\"Id\" : \"document-id\", " +
3172 "\"Value\" : [\"2002-10-10\",true,\"2002-10-10\" ] " +
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);
3180 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3181 "\"Id\" : \"document-id\", " +
3182 "\"Value\" : [\"2002-10-10\",123,\"2002-10-10\" ] " +
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);
3190 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3191 "\"Id\" : \"document-id\", " +
3192 "\"Value\" : [\"2002-10-10\",123.45,\"2002-10-10\" ] " +
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);
3200 // dateTime - defaults to String
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\" ] " +
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);
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\" ] " +
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);
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\" ] " +
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);
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\" ] " +
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);
3242 // dayTimeDuration - defaults to String
3244 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3245 "\"Id\" : \"document-id\", " +
3246 "\"Value\" : [ \"P23DT7H12M54S\",\"P23DT7H12M54S\",\"P23DT7H12M54S\" ] " +
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);
3254 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3255 "\"Id\" : \"document-id\", " +
3256 "\"Value\" : [ \"P23DT7H12M54S\",true,\"P23DT7H12M54S\" ] " +
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);
3264 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3265 "\"Id\" : \"document-id\", " +
3266 "\"Value\" : [ \"P23DT7H12M54S\",123,\"P23DT7H12M54S\" ] " +
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);
3273 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3274 "\"Id\" : \"document-id\", " +
3275 "\"Value\" : [ \"P23DT7H12M54S\",11.22,\"P23DT7H12M54S\" ] " +
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);
3283 // yearMonth duration - defaults to String
3285 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3286 "\"Id\" : \"document-id\", " +
3287 "\"Value\" : [ \"P165Y8M\",\"P165Y8M\",\"P165Y8M\" ] " +
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);
3295 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3296 "\"Id\" : \"document-id\", " +
3297 "\"Value\" : [ \"P165Y8M\",true,\"P165Y8M\" ] " +
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);
3305 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3306 "\"Id\" : \"document-id\", " +
3307 "\"Value\" : [ \"P165Y8M\",123,\"P165Y8M\" ] " +
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);
3314 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3315 "\"Id\" : \"document-id\", " +
3316 "\"Value\" : [ \"P165Y8M\",11.22,\"P165Y8M\" ] " +
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);
3324 // anyURI - defaults to String
3326 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3327 "\"Id\" : \"document-id\", " +
3328 "\"Value\" : [ \"aValue\",\"aValue\",\"aValue\"] " +
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);
3336 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3337 "\"Id\" : \"document-id\", " +
3338 "\"Value\" : [ \"aValue\",true,\"aValue\"] " +
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);
3346 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3347 "\"Id\" : \"document-id\", " +
3348 "\"Value\" : [ \"aValue\",123,\"aValue\"] " +
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);
3356 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3357 "\"Id\" : \"document-id\", " +
3358 "\"Value\" : [ \"aValue\",11.111,\"aValue\"] " +
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);
3366 // hexBinary - defaults to String
3368 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3369 "\"Id\" : \"document-id\", " +
3370 "\"Value\" : [ \"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\",\"FA027B7D12CC34DDD20012AEEF\" ] " +
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);
3378 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3379 "\"Id\" : \"document-id\", " +
3380 "\"Value\" : [ \"FA027B7D12CC34DDD20012AEEF\",true,\"012AEEF\" ] " +
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);
3388 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3389 "\"Id\" : \"document-id\", " +
3390 "\"Value\" : [ \"FA027B7D12CC34DDD20012AEEF\",123,\"012AEEF\" ] " +
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);
3398 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3399 "\"Id\" : \"document-id\", " +
3400 "\"Value\" : [ \"FA027B7D12CC34DDD20012AEEF\",11.44,\"012AEEF\" ] " +
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);
3408 // base64Binary - defaults to String
3410 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3411 "\"Id\" : \"document-id\", " +
3412 "\"Value\" : [ \"aG9y\",\"lvbj0iMS4xIj48YXV0aG9y\",\"lvbjIj48YXV0aG9y\" ] " +
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);
3420 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3421 "\"Id\" : \"document-id\", " +
3422 "\"Value\" : [ \"aG9y\",true,\"lvbjIj48YXV0aG9y\" ] " +
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);
3430 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3431 "\"Id\" : \"document-id\", " +
3432 "\"Value\" : [ \"aG9y\",1123,\"lvbjIj48YXV0aG9y\" ] " +
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);
3440 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3441 "\"Id\" : \"document-id\", " +
3442 "\"Value\" : [ \"aG9y\",11.22,\"lvbjIj48YXV0aG9y\" ] " +
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);
3449 // RFC822 name - defaults to String
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\" ] " +
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);
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\" ] " +
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);
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\" ] " +
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);
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\" ] " +
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);
3491 // x500 - defaults to String
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\" ] " +
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);
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\" ] " +
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);
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\" ] " +
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);
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\" ] " +
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);
3533 // ipAddress - defaults to String
3535 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3536 "\"Id\" : \"document-id\", " +
3537 "\"Value\" : [ \"121.221.43.58:12345\",\"121.221.43.58:12345\",\"121.221.43.58:12345\" ] " +
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=121.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
3540 } catch (Exception e) {
3541 fail ("Failed convert from JSON to object: " + e);
3545 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3546 "\"Id\" : \"document-id\", " +
3547 "\"Value\" : [ \"121.221.43.58:12345\",true,\"121.221.43.58:12345\" ] " +
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=121.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=true}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
3550 } catch (Exception e) {
3551 fail ("Failed convert from JSON to object: " + e);
3555 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3556 "\"Id\" : \"document-id\", " +
3557 "\"Value\" : [ \"121.221.43.58:12345\",1111,\"121.221.43.58:12345\" ] " +
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=121.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=1111}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
3560 } catch (Exception e) {
3561 fail ("Failed convert from JSON to object: " + e);
3565 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3566 "\"Id\" : \"document-id\", " +
3567 "\"Value\" : [ \"121.221.43.58:12345\",11.22,\"121.221.43.58:12345\" ] " +
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=121.221.43.58:12345}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=11.22}{dataTypeId=http://www.w3.org/2001/XMLSchema#string,value=121.221.43.58:12345}],includeInResults=false}]}}]}", request.toString());
3570 } catch (Exception e) {
3571 fail ("Failed convert from JSON to object: " + e);
3575 // dnsName - defaults to String
3577 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3578 "\"Id\" : \"document-id\", " +
3579 "\"Value\" : [ \"aValue\", \"aValue\", \"aValue\" ] " +
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);
3587 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3588 "\"Id\" : \"document-id\", " +
3589 "\"Value\" : [ \"aValue\", true, \"aValue\" ] " +
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);
3597 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3598 "\"Id\" : \"document-id\", " +
3599 "\"Value\" : [ \"aValue\", 1111, \"aValue\" ] " +
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);
3607 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3608 "\"Id\" : \"document-id\", " +
3609 "\"Value\" : [ \"aValue\", 11.22, \"aValue\" ] " +
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);
3617 // xPathExpression - defaults to String
3619 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3620 "\"Id\" : \"document-id\", " +
3621 "\"Value\" : [ \"aValue\", \"aValue\", \"aValue\" ] " +
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);
3629 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3630 "\"Id\" : \"document-id\", " +
3631 "\"Value\" : [ \"aValue\", true, \"aValue\" ] " +
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);
3639 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3640 "\"Id\" : \"document-id\", " +
3641 "\"Value\" : [ \"aValue\", 1111, \"aValue\" ] " +
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);
3649 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3650 "\"Id\" : \"document-id\", " +
3651 "\"Value\" : [ \"aValue\", 11.22, \"aValue\" ] " +
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);
3664 public void testXPathExpression() {
3665 // Category Attribute with XPathExpression including XPathCategory and XPath
3666 // Category Attribute with XPathExpression with Namespaces with/without Prefix
3668 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3669 "\"Id\" : \"document-id\", " +
3670 "\"DataType\" : \"xpathExpression\", " +
3672 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3673 "\"Namespaces\" : ["
3675 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
3678 "\"Prefix\" : \"lab\", " +
3679 "\"Namespace\" : \"http://somewhere/uri.html\" " +
3682 "\"Prefix\" : \"md\", " +
3683 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3685 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
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);
3693 // Category Attribute with XPathExpression missing XPathCategory
3695 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3696 "\"Id\" : \"document-id\", " +
3697 "\"DataType\" : \"xpathExpression\", " +
3699 "\"Namespaces\" : [{ "+
3700 "\"Namespace\" : \"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" " +
3703 "\"Prefix\" : \"md\", " +
3704 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3706 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3709 fail("Operation should throw exception");
3710 } catch (JSONStructureException e) {
3712 } catch (Exception e) {
3713 fail ("Failed convert from JSON to object: " + e);
3716 // Category Attribute with XPathExpression missing XPath
3718 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3719 "\"Id\" : \"document-id\", " +
3720 "\"DataType\" : \"xpathExpression\", " +
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\" " +
3727 "\"Prefix\" : \"md\", " +
3728 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3732 fail("Operation should throw exception");
3733 } catch (JSONStructureException e) {
3735 } catch (Exception e) {
3736 fail ("Failed convert from JSON to object: " + e);
3739 // Category Attribute with XPathExpression without Namespaces
3740 // (path does not contain namespace references)
3742 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3743 "\"Id\" : \"document-id\", " +
3744 "\"DataType\" : \"xpathExpression\", " +
3746 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3747 "\"XPath\" : \"record/patient/patientDoB\" "+
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);
3755 // Category Attribute with XPathExpression with 0 Namespaces
3757 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3758 "\"Id\" : \"document-id\", " +
3759 "\"DataType\" : \"xpathExpression\", " +
3761 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3762 "\"Namespaces\" : [], "+
3763 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
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);
3772 // Category Attribute with XPathExpression with Namespaces without mandatory Namespace
3774 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3775 "\"Id\" : \"document-id\", " +
3776 "\"DataType\" : \"xpathExpression\", " +
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\" " +
3783 "\"Prefix\" : \"md\", " +
3785 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3788 fail("Operation should throw exception");
3789 } catch (JSONStructureException e) {
3791 } catch (Exception e) {
3792 fail ("Failed convert from JSON to object: " + e);
3796 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3797 "\"Id\" : \"document-id\", " +
3798 "\"DataType\" : \"xpathExpression\", " +
3800 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3801 "\"Namespaces\" : [{ "+
3804 "\"Prefix\" : \"md\", " +
3805 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3807 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3810 fail("Operation should throw exception");
3811 } catch (JSONStructureException e) {
3813 } catch (Exception e) {
3814 fail ("Failed convert from JSON to object: " + e);
3817 // Category Attribute with XPathExpression with Namespaces with 2 namespaces using same prefix
3819 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3820 "\"Id\" : \"document-id\", " +
3821 "\"DataType\" : \"xpathExpression\", " +
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\" " +
3829 "\"Prefix\" : \"md\", " +
3830 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3832 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3835 fail("Operation should throw exception");
3836 } catch (JSONStructureException e) {
3838 } catch (Exception e) {
3839 fail ("Failed convert from JSON to object: " + e);
3842 // Category Attribute with XPathExpression without Namespaces which are used within the XPathExpression (NOTE: Error is not syntactic and is not found by converter)
3844 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3845 "\"Id\" : \"document-id\", " +
3846 "\"DataType\" : \"xpathExpression\", " +
3848 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3849 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
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);
3857 // Category Attribute with XPathExpression containing simple value (must be object)
3859 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3860 "\"Id\" : \"document-id\", " +
3861 "\"DataType\" : \"xpathExpression\", " +
3862 "\"Value\" : \"simple Value\"" +
3864 fail("Operation should throw exception");
3865 } catch (JSONStructureException e) {
3867 } catch (Exception e) {
3868 fail ("Failed convert from JSON to object: " + e);
3871 // Category Attribute with Namespaces containing simple value (must be object)
3873 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3874 "\"Id\" : \"document-id\", " +
3875 "\"DataType\" : \"xpathExpression\", " +
3877 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3878 "\"Namespaces\" : [ \"simpleValue\"," +
3880 "\"Prefix\" : \"md\", " +
3881 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3883 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3886 fail("Operation should throw exception");
3887 } catch (JSONStructureException e) {
3889 } catch (Exception e) {
3890 fail ("Failed convert from JSON to object: " + e);
3894 // Category Attribute with Namespaces non-string Namespace
3896 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3897 "\"Id\" : \"document-id\", " +
3898 "\"DataType\" : \"xpathExpression\", " +
3900 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3901 "\"Namespaces\" : [ {" +
3902 "\"Prefix\" : \"md\", " +
3903 "\"Namespace\" : 123 " +
3905 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3908 fail("Operation should throw exception");
3909 } catch (JSONStructureException e) {
3911 } catch (Exception e) {
3912 fail ("Failed convert from JSON to object: " + e);
3915 // Category Attribute with Namespaces non-string prefix
3917 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3918 "\"Id\" : \"document-id\", " +
3919 "\"DataType\" : \"xpathExpression\", " +
3921 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3922 "\"Namespaces\" : [ {" +
3923 "\"Prefix\" : 123, " +
3924 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3926 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3929 fail("Operation should throw exception");
3930 } catch (JSONStructureException e) {
3932 } catch (Exception e) {
3933 fail ("Failed convert from JSON to object: " + e);
3936 // Category Attribute with Namespaces non-string XPathCategory
3938 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3939 "\"Id\" : \"document-id\", " +
3940 "\"DataType\" : \"xpathExpression\", " +
3942 "\"XPathCategory\" : 123," +
3943 "\"Namespaces\" : [ {" +
3944 "\"Prefix\" : \"md\", " +
3945 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3947 "\"XPath\" : \"md:record/md:patient/md:patientDoB\" "+
3950 fail("Operation should throw exception");
3951 } catch (JSONStructureException e) {
3953 } catch (Exception e) {
3954 fail ("Failed convert from JSON to object: " + e);
3957 // Category Attribute with Namespaces non-string XPath
3959 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3960 "\"Id\" : \"document-id\", " +
3961 "\"DataType\" : \"xpathExpression\", " +
3963 "\"XPathCategory\" : \"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\"," +
3964 "\"Namespaces\" : [ {" +
3965 "\"Prefix\" : \"md\", " +
3966 "\"Namespace\" : \"urn:example:med:schemas:record\" " +
3971 fail("Operation should throw exception");
3972 } catch (JSONStructureException e) {
3974 } catch (Exception e) {
3975 fail ("Failed convert from JSON to object: " + e);
3982 public void testContent() {
3984 // Category with Content in XML, escaped properly
3986 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
3987 "\"Id\" : \"document-id\", " +
3988 "\"Value\" : [ \"aValue\",\"aValue\",\"aValue\"] " +
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>\"" +
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);
4000 // Category with Content in XML, double quotes and back-slashes NOT escaped properly?
4002 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4003 "\"Id\" : \"document-id\", " +
4004 "\"Value\" : [ \"aValue\",\"aValue\",\"aValue\"] " +
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>\"" +
4011 fail("Operation should throw exception");
4012 } catch (JSONStructureException e) {
4014 } catch (Exception e) {
4015 fail ("Failed convert from JSON to object: " + e);
4018 // Category with Content in Base64
4020 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4021 "\"Id\" : \"document-id\", " +
4022 "\"Value\" : [ \"aValue\",\"aValue\",\"aValue\"] " +
4024 "\"Content\" : \"PD94bWwgdmVyc2lvbj0iMS4wIj8+PGNhdGFsb2c+PGJvb2sgaWQ9ImJrMTAxIj48YXV0aG9yPkdhbWJhcmRlbGxhLCBNYXR0aGV3PC9hdXRob3I+PHRpdGxlPlhNT" +
4025 "CBEZXZlbG9wZXIncyBHdWlkZTwvdGl0bGU+PGdlbnJlPkNvbXB1dGVyPC9nZW5yZT48cHJpY2U+NDQuOTU8L3ByaWNlPjxwdWJsaXNoX2RhdGU+MjAwMC0xMC0wMTwvcHVibGlzaF"+
4026 "9kYXRlPjxkZXNjcmlwdGlvbj5BbiBpbi1kZXB0aCBsb29rIGF0IGNyZWF0aW5nIGFwcGxpY2F0aW9ucyB3aXRoIFhNTC48L2Rlc2NyaXB0aW9uPjwvYm9vaz48L2NhdGFsb2c+\"" +
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);
4033 // Category with Bad Content in Base64
4035 request = JSONRequest.load("{\"Request\" : {\"Category\": [{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4036 "\"Id\" : \"document-id\", " +
4037 "\"Value\" : [ \"aValue\",\"aValue\",\"aValue\"] " +
4039 "\"Content\" : \"PD94bWwgdmV\"" +
4041 fail("Operation should throw exception");
4042 } catch (JSONStructureException e) {
4044 } catch (Exception e) {
4045 fail ("Failed convert from JSON to object: " + e);
4053 public void testDuplicates() {
4054 // duplicate of same element within Category array is ok
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\" " +
4061 "{\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4062 "\"Id\" : \"document-id\", " +
4063 "\"DataType\" : \"http://www.w3.org/2001/XMLSchema#string\", " +
4064 "\"Value\" : \"abc\" " +
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);
4072 // duplicate Attribute
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\" " +
4081 + " \"Attribute\" : [{" +
4082 "\"Id\" : \"document-id\", " +
4083 "\"DataType\" : \"http://www.w3.org/2001/XMLSchema#string\", " +
4084 "\"Value\" : \"abc\" " +
4088 fail("Operation should throw exception");
4089 } catch (JSONStructureException e) {
4091 } catch (Exception e) {
4092 fail ("Failed convert from JSON to object: " + e);
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\" " +
4104 fail("Operation should throw exception");
4105 } catch (JSONStructureException e) {
4107 } catch (Exception e) {
4108 fail ("Failed convert from JSON to object: " + e);
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\" " +
4120 fail("Operation should throw exception");
4121 } catch (JSONStructureException e) {
4123 } catch (Exception e) {
4124 fail ("Failed convert from JSON to object: " + e);
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\" " +
4136 fail("Operation should throw exception");
4137 } catch (JSONStructureException e) {
4139 } catch (Exception e) {
4140 fail ("Failed convert from JSON to object: " + e);
4144 // duplicate Content
4146 request = JSONRequest.load("{\"Request\" : {\"Category\": [{"
4147 + "\"CategoryId\" : \"custom-category\", \"Attribute\" : [{" +
4148 "\"Id\" : \"document-id\", " +
4149 "\"Value\" : [ \"aValue\",\"aValue\",\"aValue\"] " +
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>\"" +
4160 fail("Operation should throw exception");
4161 } catch (JSONStructureException e) {
4163 } catch (Exception e) {
4164 fail ("Failed convert from JSON to object: " + e);