本文整理匯總了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);
}