Java Code Examples for com.eclipsesource.json.Json#value()

The following examples show how to use com.eclipsesource.json.Json#value() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonCharEscaperTest.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void minimalJsonString() {
    final String rawString = "";
    final JsonValue jsonValue = Json.value(rawString);

    final String actualOwn = ImmutableJsonString.of(rawString).toString();
    final String actual = jsonValue.toString();

    assertThat(actualOwn).isEqualTo(actual);
}
 
Example 2
Source File: PeriodJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void percentageJsonRuleShouldPassOnValidYearPeriod() {
  JsonValue oneYear = Json.value("1 year");
  JsonValue twoYears = Json.value("2 years");
  periodJsonRule.validate(oneYear);
  periodJsonRule.validate(twoYears);
}
 
Example 3
Source File: ArrayJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void arrayJsonRuleShouldFailNonArrayType() {
  JsonValue jsonValue = Json.value(true);
  arrayJsonRule.validate(jsonValue);
}
 
Example 4
Source File: IdJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test
public void idJsonRuleShouldPassNumberChar() {
  JsonValue jsonValue = Json.value("1");
  idJsonRule.validate(jsonValue);
}
 
Example 5
Source File: NumberJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test
public void numberJsonRuleShouldPassNumberType() {
  JsonValue jsonValue = Json.value(1);
  numberJsonRule.validate(jsonValue);
}
 
Example 6
Source File: IdJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void idJsonRuleShouldFailLowercaseChar() {
  JsonValue jsonValue = Json.value("mONSTER");
  idJsonRule.validate(jsonValue);
}
 
Example 7
Source File: OptionalJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test
public void optionalJsonRuleShouldValidateNonNullValue() {
  JsonValue jsonValue = Json.value(1);
  optionalJsonRule.validate(jsonValue);
  Mockito.verify(jsonRuleStub, only()).validate(jsonValue);
}
 
Example 8
Source File: BoundIntegerJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void boundIntegerJsonRuleShouldFailWhenValueOutOfLowerBound() {
  final int lowerThanLowerBound = 1;
  JsonValue jsonValue = Json.value(lowerThanLowerBound);
  boundIntegerJsonRule.validate(jsonValue);
}
 
Example 9
Source File: PeriodJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void periodJsonRuleShouldFailOnInvalidPeriodFormat() {
  JsonValue jsonValue = Json.value("1 monthss");
  periodJsonRule.validate(jsonValue);
}
 
Example 10
Source File: BoundDoubleJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void boundDoubleJsonRuleShouldFailValueOutOfUpperBound() {
  final double greaterThanUpperBound = 5.0;
  JsonValue jsonValue = Json.value(greaterThanUpperBound);
  boundDoubleJsonRule.validate(jsonValue);
}
 
Example 11
Source File: IntegerJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test
public void integerJsonRuleShouldPassValidType() {
  JsonValue jsonValue = Json.value(1);
  integerJsonRule.validate(jsonValue);
}
 
Example 12
Source File: FixedArrayJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void fixedStringIntegerArrayRuleShouldFailOnNonArrayType() {
  JsonValue jsonValue = Json.value(true);
  stringIntegerArrayRule.validate(jsonValue);
}
 
Example 13
Source File: PercentageJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void percentageJsonRuleShouldFailOnValueAboveValidRange() {
  JsonValue jsonValue = Json.value("101.0%");
  percentJsonRule.validate(jsonValue);
}
 
Example 14
Source File: BoundIntegerJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void boundIntegerJsonRuleShouldFailWhenValueOutOfUpperBound() {
  final int greaterThanUpperBound = 6;
  JsonValue jsonValue = Json.value(greaterThanUpperBound);
  boundIntegerJsonRule.validate(jsonValue);
}
 
Example 15
Source File: DropDownSetting.java    From Cubes with MIT License 4 votes vote down vote up
@Override
public JsonValue toJson() {
  return Json.value(selected);
}
 
Example 16
Source File: StringJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void stringJsonRuleShouldFailNonStringType() {
  JsonValue jsonValue = Json.value(true);
  stringJsonRule.validate(jsonValue);
}
 
Example 17
Source File: StringLengthJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void stringLengthJsonRuleShouldFailLowerLength() {
  String ltRequired = "a";
  JsonValue jsonValue = Json.value(ltRequired);
  stringLengthJsonRule.validate(jsonValue);
}
 
Example 18
Source File: BooleanSetting.java    From Cubes with MIT License 4 votes vote down vote up
@Override
public JsonValue toJson() {
  return Json.value(this.b);
}
 
Example 19
Source File: StringJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test
public void stringJsonRuleShouldPassStringType() {
  JsonValue jsonValue = Json.value("string");
  stringJsonRule.validate(jsonValue);
}
 
Example 20
Source File: EnumJsonRuleTest.java    From dungeon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void enumJsonRuleShouldFailOnNonStringValue() {
  JsonValue jsonValue = Json.value(true);
  enumJsonRule.validate(jsonValue);
}