gluu
公開メンバ関数 | 静的非公開メンバ関数 | 全メンバ一覧
org.xdi.oxauth.model.uma.JsonLogicTest クラス
org.xdi.oxauth.model.uma.JsonLogicTest 連携図
Collaboration graph

公開メンバ関数

void testJsEngine () throws ScriptException, NoSuchMethodException
 
void testJsonLogic () throws ScriptException, NoSuchMethodException
 
void umaSimulation () throws ScriptException
 

静的非公開メンバ関数

static void assertResult (String script, Boolean expectedResult) throws ScriptException
 
static void assertTrue (String script) throws ScriptException
 
static void assertFalse (String script) throws ScriptException
 

詳解

著者
yuriyz

関数詳解

◆ assertFalse()

static void org.xdi.oxauth.model.uma.JsonLogicTest.assertFalse ( String  script) throws ScriptException
inlinestaticprivate
67  {
68  assertResult(script, Boolean.FALSE);
69  }
static void assertResult(String script, Boolean expectedResult)
Definition: JsonLogicTest.java:59

◆ assertResult()

static void org.xdi.oxauth.model.uma.JsonLogicTest.assertResult ( String  script,
Boolean  expectedResult 
) throws ScriptException
inlinestaticprivate
59  {
60  Assert.assertEquals(JsonLogic.eval(script), expectedResult);
61  }

◆ assertTrue()

static void org.xdi.oxauth.model.uma.JsonLogicTest.assertTrue ( String  script) throws ScriptException
inlinestaticprivate
63  {
64  assertResult(script, Boolean.TRUE);
65  }
static void assertResult(String script, Boolean expectedResult)
Definition: JsonLogicTest.java:59

◆ testJsEngine()

void org.xdi.oxauth.model.uma.JsonLogicTest.testJsEngine ( ) throws ScriptException, NoSuchMethodException
inline
14  {
15  JsonLogic.eval("var fun1 = function(name) {\n" +
16  " print('Hi there from Javascript, ' + name);\n" +
17  " return \"greetings from javascript\";\n" +
18  "};");
19  Object result = JsonLogic.invokeFunction("fun1", "");
20  Assert.assertEquals(result, "greetings from javascript");
21  }

◆ testJsonLogic()

void org.xdi.oxauth.model.uma.JsonLogicTest.testJsonLogic ( ) throws ScriptException, NoSuchMethodException
inline
24  {
25  assertTrue("jsonLogic.apply( { \"==\" : [1, 1] } );");
26  assertFalse("jsonLogic.apply( { \"==\" : [1, 0] } );");
27 
28  Assert.assertTrue(JsonLogic.apply("{ \"==\" : [1, 1] }"));
29  Assert.assertFalse(JsonLogic.apply("{ \"==\" : [1, 0] }"));
30 
31  assertTrue("jsonLogic.apply(\n" +
32  " {\"and\" : [\n" +
33  " { \">\" : [3,1] },\n" +
34  " { \"<\" : [1,3] }\n" +
35  " ] }\n" +
36  ");");
37  }
static void assertTrue(String script)
Definition: JsonLogicTest.java:63
static void assertFalse(String script)
Definition: JsonLogicTest.java:67

◆ umaSimulation()

void org.xdi.oxauth.model.uma.JsonLogicTest.umaSimulation ( ) throws ScriptException
inline
40  {
41  String rule = "{" +
42  " \"and\": [ {" +
43  " \"or\": [" +
44  " {\"var\": 0 }," +
45  " {\"var\": 1 }" +
46  " ]" +
47  " }," +
48  " {\"var\": 2 }" +
49  " ]}";
50  Assert.assertTrue(JsonLogic.apply(rule, "[true, true, true]"));
51  Assert.assertTrue(JsonLogic.apply(rule, "[true, false, true]"));
52  Assert.assertTrue(JsonLogic.apply(rule, "[false, true, true]"));
53 
54  Assert.assertFalse(JsonLogic.apply(rule, "[false, false, false]"));
55  Assert.assertFalse(JsonLogic.apply(rule, "[false, false, true]"));
56  Assert.assertFalse(JsonLogic.apply(rule, "[true, true, false]"));
57  }

このクラス詳解は次のファイルから抽出されました: