本文整理汇总了Java中graphql.schema.CoercingParseValueException类的典型用法代码示例。如果您正苦于以下问题:Java CoercingParseValueException类的具体用法?Java CoercingParseValueException怎么用?Java CoercingParseValueException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CoercingParseValueException类属于graphql.schema包,在下文中一共展示了CoercingParseValueException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseValue
import graphql.schema.CoercingParseValueException; //导入依赖的package包/类
@Override
public Date parseValue(Object o) {
// Expects epoch millis:
Long timeValue;
if (o instanceof String) {
try {
timeValue = Long.parseLong((String) o);
} catch (NumberFormatException e) {
log.debug("Failed to convert string to epoch time for date conversion", e);
throw new CoercingParseValueException(ERROR_BAD_EPOCH);
}
} else if (o instanceof Number) {
timeValue = ((Number) o).longValue();
} else {
log.debug("Input value {} was not valid epoch millis type", o);
throw new CoercingParseValueException(ERROR_BAD_EPOCH);
}
return Date.from(Instant.ofEpochMilli(timeValue));
}
示例2: testOrderByInvalidEnumValue
import graphql.schema.CoercingParseValueException; //导入依赖的package包/类
@Test(expectedExceptions = CoercingParseValueException.class, expectedExceptionsMessageRegExp = "Invalid input for Enum 'OrderBy'.*")
public void testOrderByInvalidEnumValue() throws Exception {
Map<String, Object> vars = buildVariableMap(ORDERED_TYPE_NAME);
vars.put("orderBy", "");
fetchUpdateDates(vars);
}
示例3: testOrderByDirectionInvalidEnumValue
import graphql.schema.CoercingParseValueException; //导入依赖的package包/类
@Test(expectedExceptions = CoercingParseValueException.class, expectedExceptionsMessageRegExp = "Invalid input for Enum 'OrderByDirection'.*")
public void testOrderByDirectionInvalidEnumValue() throws Exception {
Map<String, Object> vars = buildVariableMap(ORDERED_TYPE_NAME);
vars.put("orderByDirection", "bad value");
fetchUpdateDates(vars);
}
示例4: parseLiteral
import graphql.schema.CoercingParseValueException; //导入依赖的package包/类
@Override
public Date parseLiteral(Object o) {
Object input;
if (o instanceof IntValue) {
input = ((IntValue) o).getValue().longValue();
} else if (o instanceof StringValue) {
input = ((StringValue) o).getValue();
} else {
throw new CoercingParseValueException(ERROR_BAD_EPOCH_TYPE);
}
return parseValue(input);
}