graphql.Assert.assertTrue()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(211)

本文整理了Java中graphql.Assert.assertTrue()方法的一些代码示例,展示了Assert.assertTrue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertTrue()方法的具体详情如下:
包路径:graphql.Assert
类名称:Assert
方法名:assertTrue

Assert.assertTrue介绍

暂无

代码示例

代码示例来源:origin: graphql-java/graphql-java

void setChildrenContexts(Map<String, List<TraverserContext<T>>> children) {
  assertTrue(this.children == null, "children already set");
  this.children = children;
}

代码示例来源:origin: graphql-java/graphql-java

StringPathSegment(String value) {
  assertTrue(value != null && !value.isEmpty(), "empty path component");
  this.value = value;
}

代码示例来源:origin: graphql-java/graphql-java

public DefaultConnectionCursor(String value) {
  Assert.assertTrue(value != null && !value.isEmpty(), "connection value cannot be null or empty");
  this.value = value;
}

代码示例来源:origin: graphql-java/graphql-java

public NodeMultiZipper<T> withReplacedZipper(NodeZipper<T> oldZipper, NodeZipper<T> newZipper) {
  int index = zippers.indexOf(oldZipper);
  assertTrue(index >= 0, "oldZipper not found");
  List<NodeZipper<T>> newZippers = new ArrayList<>(zippers);
  newZippers.set(index, newZipper);
  return new NodeMultiZipper<>(commonRoot, newZippers, this.nodeAdapter);
}

代码示例来源:origin: graphql-java/graphql-java

public SimpleListConnection(List<T> data, String prefix) {
  this.data = assertNotNull(data, " data cannot be null");
  assertTrue(prefix != null && !prefix.isEmpty(), "prefix cannot be null or empty");
  this.prefix = prefix;
}

代码示例来源:origin: graphql-java/graphql-java

private String node(Node node, Class startClass) {
  if (startClass != null) {
    assertTrue(startClass.isInstance(node), "The starting class must be in the inherit tree");
  }
  StringWriter sw = new StringWriter();
  PrintWriter out = new PrintWriter(sw);
  NodePrinter<Node> printer = _findPrinter(node, startClass);
  printer.print(out, node);
  return sw.toString();
}

代码示例来源:origin: graphql-java/graphql-java

private void assertNonNullWrapping(GraphQLType wrappedType) {
  assertTrue(!GraphQLTypeUtil.isNonNull(wrappedType), String.format("A non null type cannot wrap an existing non null type '%s'",
      GraphQLTypeUtil.simplePrint(wrappedType)));
}

代码示例来源:origin: graphql-java/graphql-java

@Internal
public NodeParentTree(Deque<T> nodeStack) {
  assertNotNull(nodeStack, "You MUST have a non null stack of nodes");
  assertTrue(!nodeStack.isEmpty(), "You MUST have a non empty stack of nodes");
  Deque<T> copy = new ArrayDeque<>(nodeStack);
  path = mkPath(copy);
  node = copy.pop();
  if (!copy.isEmpty()) {
    parent = Optional.of(new NodeParentTree<T>(copy));
  } else {
    parent = Optional.empty();
  }
}

代码示例来源:origin: graphql-java/graphql-java

/**
   * The exception to the general rule is the system __xxxx Introspection fields which have no parent type and
   * are able to be specified on any type
   *
   * @param fieldName the name of the system field which MUST start with __
   *
   * @return the coordinates
   */
  public static FieldCoordinates systemCoordinates(String fieldName) {
    assertTrue(fieldName.startsWith("__"), "Only __ system fields can be addressed without a parent type");
    assertValidName(fieldName);
    return new FieldCoordinates(null, fieldName);
  }
}

代码示例来源:origin: graphql-java/graphql-java

private CompletableFuture<Publisher<Object>> createSourceEventStream(ExecutionContext executionContext, ExecutionStrategyParameters parameters) {
  ExecutionStrategyParameters newParameters = firstFieldOfSubscriptionSelection(parameters);
  CompletableFuture<FetchedValue> fieldFetched = fetchField(executionContext, newParameters);
  return fieldFetched.thenApply(fetchedValue -> {
    Object publisher = fetchedValue.getFetchedValue();
    if (publisher != null) {
      assertTrue(publisher instanceof Publisher, "You data fetcher must return a Publisher of events when using graphql subscriptions");
    }
    //noinspection unchecked
    return (Publisher<Object>) publisher;
  });
}

代码示例来源:origin: graphql-java/graphql-java

@SuppressWarnings("unchecked")
InterfaceTypeDefinition createInterface(Map<String, Object> input) {
  assertTrue(input.get("kind").equals("INTERFACE"), "wrong input");
  InterfaceTypeDefinition.Builder interfaceTypeDefinition = InterfaceTypeDefinition.newInterfaceTypeDefinition().name((String) input.get("name"));
  interfaceTypeDefinition.comments(toComment((String) input.get("description")));
  List<Map<String, Object>> fields = (List<Map<String, Object>>) input.get("fields");
  interfaceTypeDefinition.definitions(createFields(fields));
  return interfaceTypeDefinition.build();
}

代码示例来源:origin: graphql-java/graphql-java

@SuppressWarnings("unchecked")
InputObjectTypeDefinition createInputObject(Map<String, Object> input) {
  assertTrue(input.get("kind").equals("INPUT_OBJECT"), "wrong input");
  InputObjectTypeDefinition.Builder inputObjectTypeDefinition = InputObjectTypeDefinition.newInputObjectDefinition()
      .name((String) input.get("name"))
      .comments(toComment((String) input.get("description")));
  List<Map<String, Object>> fields = (List<Map<String, Object>>) input.get("inputFields");
  List<InputValueDefinition> inputValueDefinitions = createInputValueDefinitions(fields);
  inputObjectTypeDefinition.inputValueDefinitions(inputValueDefinitions);
  return inputObjectTypeDefinition.build();
}

代码示例来源:origin: graphql-java/graphql-java

@SuppressWarnings("unchecked")
UnionTypeDefinition createUnion(Map<String, Object> input) {
  assertTrue(input.get("kind").equals("UNION"), "wrong input");
  UnionTypeDefinition.Builder unionTypeDefinition = UnionTypeDefinition.newUnionTypeDefinition();
  unionTypeDefinition.name((String) input.get("name"));
  unionTypeDefinition.comments(toComment((String) input.get("description")));
  List<Map<String, Object>> possibleTypes = (List<Map<String, Object>>) input.get("possibleTypes");
  for (Map<String, Object> possibleType : possibleTypes) {
    TypeName typeName = TypeName.newTypeName().name((String) possibleType.get("name")).build();
    unionTypeDefinition.memberType(typeName);
  }
  return unionTypeDefinition.build();
}

代码示例来源:origin: graphql-java/graphql-java

/**
 * Called to place system data fetchers (eg Introspection fields) into the mix
 *
 * @param coordinates the field coordinates
 * @param dataFetcher the data fetcher code for that field
 *
 * @return this builder
 */
public Builder systemDataFetcher(FieldCoordinates coordinates, DataFetcher<?> dataFetcher) {
  assertNotNull(dataFetcher);
  assertNotNull(coordinates);
  assertTrue(coordinates.getFieldName().startsWith("__"), "Only __ system fields can be used here");
  systemDataFetcherMap.put(coordinates.getFieldName(), DataFetcherFactories.useDataFetcher(dataFetcher));
  return this;
}

代码示例来源:origin: graphql-java/graphql-java

private static Map<String, Object> introspect(GraphQLSchema schema) {
    GraphQL gql = GraphQL.newGraphQL(schema).build();
    ExecutionResult result = gql.execute(IntrospectionQuery.INTROSPECTION_QUERY);
    Assert.assertTrue(result.getErrors().size() == 0, "The schema has errors during Introspection");
    return result.getData();
  }
}

代码示例来源:origin: graphql-java/graphql-java

@SuppressWarnings("unchecked")
EnumTypeDefinition createEnum(Map<String, Object> input) {
  assertTrue(input.get("kind").equals("ENUM"), "wrong input");
  EnumTypeDefinition.Builder enumTypeDefinition = EnumTypeDefinition.newEnumTypeDefinition().name((String) input.get("name"));
  enumTypeDefinition.comments(toComment((String) input.get("description")));
  List<Map<String, Object>> enumValues = (List<Map<String, Object>>) input.get("enumValues");
  for (Map<String, Object> enumValue : enumValues) {
    EnumValueDefinition.Builder enumValueDefinition = EnumValueDefinition.newEnumValueDefinition().name((String) enumValue.get("name"));
    enumValueDefinition.comments(toComment((String) enumValue.get("description")));
    createDeprecatedDirective(enumValue, enumValueDefinition);
    enumTypeDefinition.enumValueDefinition(enumValueDefinition.build());
  }
  return enumTypeDefinition.build();
}

代码示例来源:origin: graphql-java/graphql-java

private CompletableFuture<List<NodeZipper<ExecutionResultNode>>> fetchAndAnalyze(ExecutionContext executionContext, List<NodeZipper<ExecutionResultNode>> unresolvedNodes) {
  assertTrue(unresolvedNodes.size() > 0, "unresolvedNodes can't be empty");
  List<FieldSubSelection> fieldSubSelections = map(unresolvedNodes,
      node -> util.createFieldSubSelection(executionContext, node.getCurNode().getFetchedValueAnalysis()));
  //constrain: all fieldSubSelections have the same mergedSelectionSet
  MergedSelectionSet mergedSelectionSet = fieldSubSelections.get(0).getMergedSelectionSet();
  List<CompletableFuture<List<FetchedValueAnalysis>>> fetchedValues = batchFetchForEachSubField(executionContext, fieldSubSelections, mergedSelectionSet);
  return mapBatchedResultsBack(unresolvedNodes, fetchedValues);
}

代码示例来源:origin: graphql-java/graphql-java

public ExecutionPath sibling(String siblingField) {
  Assert.assertTrue(!ROOT_PATH.equals(this), "You MUST not call this with the root path");
  return new ExecutionPath(this.parent, new StringPathSegment(siblingField));
}

代码示例来源:origin: graphql-java/graphql-java

@Override
  public TraversalControl visitGraphQLUnionType(GraphQLUnionType node, TraverserContext<GraphQLType> context) {
    TypeResolver typeResolver = node.getTypeResolver();
    if (typeResolver != null) {
      codeRegistry.typeResolverIfAbsent(node, typeResolver);
    }
    assertTrue(codeRegistry.getTypeResolver(node) != null, "You MUST provide a type resolver for the union type '" + node.getName() + "'");
    return CONTINUE;
  }
}

代码示例来源:origin: graphql-java/graphql-java

@Override
public TraversalControl visitGraphQLInterfaceType(GraphQLInterfaceType node, TraverserContext<GraphQLType> context) {
  TypeResolver typeResolver = node.getTypeResolver();
  if (typeResolver != null) {
    codeRegistry.typeResolverIfAbsent(node, typeResolver);
  }
  assertTrue(codeRegistry.getTypeResolver(node) != null, "You MUST provide a type resolver for the interface type '" + node.getName() + "'");
  return CONTINUE;
}

相关文章