Java Code Examples for io.vertx.core.json.JsonObject#fieldNames()

The following examples show how to use io.vertx.core.json.JsonObject#fieldNames() . 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: EventBusBridgeImpl.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
private static boolean structureMatches(JsonObject match, Object bodyObject) {
  if (match == null || bodyObject == null) return true;

  // Can send message other than JSON too - in which case we can't do deep matching on structure of message
  if (bodyObject instanceof JsonObject) {
    JsonObject body = (JsonObject) bodyObject;
    for (String fieldName : match.fieldNames()) {
      Object mv = match.getValue(fieldName);
      Object bv = body.getValue(fieldName);
      // Support deep matching
      if (mv instanceof JsonObject) {
        if (!structureMatches((JsonObject) mv, bv)) {
          return false;
        }
      } else if (!match.getValue(fieldName).equals(body.getValue(fieldName))) {
        return false;
      }
    }
    return true;
  }

  return false;
}
 
Example 2
Source File: JsonRpcTestHelper.java    From besu with Apache License 2.0 6 votes vote down vote up
protected void assertValidJsonRpcError(
    final JsonObject json, final Object id, final int errorCode, final String errorMessage)
    throws Exception {
  // Check all expected fieldnames are set
  final Set<String> fieldNames = json.fieldNames();
  assertThat(fieldNames.size()).isEqualTo(3);
  assertThat(fieldNames.contains("id")).isTrue();
  assertThat(fieldNames.contains("jsonrpc")).isTrue();
  assertThat(fieldNames.contains("error")).isTrue();

  // Check standard field values
  assertIdMatches(json, id);
  assertThat(json.getString("jsonrpc")).isEqualTo("2.0");

  // Check error format
  final JsonObject error = json.getJsonObject("error");
  final Set<String> errorFieldNames = error.fieldNames();
  assertThat(errorFieldNames.size()).isEqualTo(2);
  assertThat(errorFieldNames.contains("code")).isTrue();
  assertThat(errorFieldNames.contains("message")).isTrue();

  // Check error field values
  assertThat(error.getInteger("code")).isEqualTo(errorCode);
  assertThat(error.getString("message")).isEqualTo(errorMessage);
}
 
Example 3
Source File: GetResult.java    From vertx-elasticsearch-service with Apache License 2.0 6 votes vote down vote up
public GetResult(JsonObject jsonObject) {
    this.index = jsonObject.getString(JSON_FIELD_INDEX);
    this.type = jsonObject.getString(JSON_FIELD_TYPE);
    this.id = jsonObject.getString(JSON_FIELD_ID);
    this.version = jsonObject.getLong(JSON_FIELD_VERSION);
    this.exists = jsonObject.getBoolean(JSON_FIELD_EXISTS);
    this.source = jsonObject.getJsonObject(JSON_FIELD_SOURCE);

    final JsonObject jsonFields = jsonObject.getJsonObject(JSON_FIELD_FIELDS);
    if (jsonFields != null) {
        for (String fieldName : jsonFields.fieldNames()) {
            final List<Object> fieldValues = new LinkedList<>();
            jsonFields.getJsonArray(fieldName).stream().forEach(e -> fieldValues.add(e));
            this.fields.put(fieldName, fieldValues);
        }
    }
}
 
Example 4
Source File: Hit.java    From vertx-elasticsearch-service with Apache License 2.0 6 votes vote down vote up
public Hit(JsonObject jsonObject) {
    this.index = jsonObject.getString(JSON_FIELD_INDEX);
    this.type = jsonObject.getString(JSON_FIELD_TYPE);
    this.id = jsonObject.getString(JSON_FIELD_ID);
    this.score = jsonObject.getFloat(JSON_FIELD_SCORE);
    this.version = jsonObject.getLong(JSON_FIELD_VERSION);
    this.source = jsonObject.getJsonObject(JSON_FIELD_SOURCE);

    final JsonObject jsonFields = jsonObject.getJsonObject(JSON_FIELD_FIELDS);
    if (jsonFields != null) {
        for (String fieldName : jsonFields.fieldNames()) {
            final List<Object> fieldValues = new LinkedList<>();
            jsonFields.getJsonArray(fieldName).stream().forEach(e -> fieldValues.add(e));
            this.fields.put(fieldName, fieldValues);
        }
    }
}
 
Example 5
Source File: KeycloakAuthorizationImpl.java    From vertx-auth with Apache License 2.0 6 votes vote down vote up
private static void extractApplicationRoles(JsonObject accessToken, Set<Authorization> authorizations) {
  JsonObject resourceAccess = accessToken
    .getJsonObject("resource_access", EMPTY_JSON);

  for (String resource : resourceAccess.fieldNames()) {
    JsonArray appRoles = resourceAccess
      // locate the right resource
      .getJsonObject(resource, EMPTY_JSON)
      // locate the role list
      .getJsonArray("roles");

    if (appRoles != null && appRoles.size() >= 0) {
      for (Object el : appRoles) {
        // convert to the authorization type
        authorizations.add(
          RoleBasedAuthorization
            .create((String) el)
            // fix it to the right resource
            .setResource(resource));
      }
    }
  }
}
 
Example 6
Source File: SimpleAuthProvider.java    From sfs with Apache License 2.0 6 votes vote down vote up
@Override
public Observable<Void> open(VertxContext<Server> vertxContext) {
    JsonObject config = vertxContext.verticle().config();
    JsonObject jsonObject = config.getJsonObject("auth");
    if (jsonObject != null) {
        for (String roleName : jsonObject.fieldNames()) {
            Role role = fromValueIfExists(roleName);
            checkState(role != null, "%s is not a valid role", roleName);
            JsonArray jsonUsers = jsonObject.getJsonArray(roleName);
            if (jsonUsers != null) {
                for (Object o : jsonUsers) {
                    JsonObject jsonUser = (JsonObject) o;
                    String id = getField(jsonUser, "id");
                    String username = getField(jsonUser, "username");
                    String password = getField(jsonUser, "password");
                    roles.put(role, new User(id, username, password));
                }
            }
        }
    } else {
        roles.clear();
    }
    return aVoid();
}
 
Example 7
Source File: UserConverter.java    From vertx-auth with Apache License 2.0 6 votes vote down vote up
public static User decode(JsonObject json) throws IllegalArgumentException {
  Objects.requireNonNull(json);

  JsonObject principal = json.getJsonObject(FIELD_PRINCIPAL);
  User user = User.create(principal);
  // authorizations
  JsonObject jsonAuthorizations = json.getJsonObject(FIELD_AUTHORIZATIONS);
  for (String fieldName: jsonAuthorizations.fieldNames()) {
    JsonArray jsonAuthorizationByProvider = jsonAuthorizations.getJsonArray(fieldName);
    for (int i=0; i<jsonAuthorizationByProvider.size(); i++) {
      JsonObject jsonAuthorization = jsonAuthorizationByProvider.getJsonObject(i);
      user.authorizations().add(fieldName, AuthorizationConverter.decode(jsonAuthorization));
    }
  }
  return user;
}
 
Example 8
Source File: OpenAPIHolderImpl.java    From vertx-web with Apache License 2.0 5 votes vote down vote up
private void deepGetAllRefs(Object obj, List<JsonObject> refsList) {
  if (obj instanceof JsonObject) {
    JsonObject jsonObject = (JsonObject) obj;
    if (jsonObject.containsKey("$ref"))
      refsList.add(jsonObject);
    else
      for (String keys : jsonObject.fieldNames()) deepGetAllRefs(jsonObject.getValue(keys), refsList);
  }
  if (obj instanceof JsonArray) {
    for (Object in : ((JsonArray) obj)) deepGetAllRefs(in, refsList);
  }
}
 
Example 9
Source File: OpenAPI3Utils.java    From vertx-web with Apache License 2.0 5 votes vote down vote up
public static JsonObject generateFakeSchema(JsonObject schema, OpenAPIHolder holder) {
  JsonObject fakeSchema = holder.solveIfNeeded(schema).copy();
  String combinatorKeyword = fakeSchema.containsKey("allOf") ? "allOf" : fakeSchema.containsKey("anyOf") ? "anyOf" : fakeSchema.containsKey("oneOf") ? "oneOf" : null;
  if (combinatorKeyword != null) {
    JsonArray schemasArray = fakeSchema.getJsonArray(combinatorKeyword);
    JsonArray processedSchemas = new JsonArray();
    for (int i = 0; i < schemasArray.size(); i++) {
      JsonObject innerSchema = holder.solveIfNeeded(schemasArray.getJsonObject(i));
      processedSchemas.add(innerSchema.copy());
      schemasArray.getJsonObject(i).mergeIn(innerSchema);
      if ("object".equals(innerSchema.getString("type")) || innerSchema.containsKey("properties"))
        fakeSchema = fakeSchema.mergeIn(innerSchema, true);
    }
    fakeSchema.remove(combinatorKeyword);
    fakeSchema.put("x-" + combinatorKeyword, processedSchemas);
  }
  if (fakeSchema.containsKey("properties")) {
    JsonObject propsObj = fakeSchema.getJsonObject("properties");
    for (String key : propsObj.fieldNames()) {
      propsObj.put(key, holder.solveIfNeeded(propsObj.getJsonObject(key)));
    }
  }
  if (fakeSchema.containsKey("items")) {
    fakeSchema.put("items", holder.solveIfNeeded(fakeSchema.getJsonObject("items")));
  }

  return fakeSchema;

}
 
Example 10
Source File: HelpFunc.java    From df_data_service with Apache License 2.0 5 votes vote down vote up
/**
 * Utility to extract HashMap from json for DFPOPJ
 * @param jo
 * @return
 */
public static HashMap<String, String> mapToHashMapFromJson( JsonObject jo) {
    HashMap<String, String> hm = new HashMap();
    for (String key : jo.fieldNames()) {
        hm.put(key, jo.getValue(key).toString()); // JsonArray will convert to [{"method":1},{"method":2}]
    }
    return hm;
}
 
Example 11
Source File: MongoUtil.java    From okapi with Apache License 2.0 5 votes vote down vote up
public void encode(JsonObject j, String id) {
  if (id != null) {
    j.put("_id", id);
  }
  JsonObject o = j.getJsonObject("enabled");
  if (o != null) {
    JsonObject repl = new JsonObject();
    for (String m : o.fieldNames()) {
      String n = m.replace(".", "__");
      repl.put(n, o.getBoolean(m));
    }
    j.put("enabled", repl);
  }
}
 
Example 12
Source File: Auth.java    From okapi with Apache License 2.0 5 votes vote down vote up
/**
 * Fake some module permissions.
 * Generates silly tokens with the module name as the tenant, and a list
 * of permissions as the user. These are still valid tokens, although it is
 * not possible to extract the user or tenant from them.
 */
private String moduleTokens(RoutingContext ctx) {
  String modPermJson = ctx.request().getHeader(XOkapiHeaders.MODULE_PERMISSIONS);
  logger.debug("test-auth: moduleTokens: trying to decode '{}'", modPermJson);
  HashMap<String, String> tokens = new HashMap<>();
  if (modPermJson != null && !modPermJson.isEmpty()) {
    JsonObject jo = new JsonObject(modPermJson);
    StringBuilder permstr = new StringBuilder();
    for (String mod : jo.fieldNames()) {
      JsonArray ja = jo.getJsonArray(mod);
      for (int i = 0; i < ja.size(); i++) {
        String p = ja.getString(i);
        if (permstr.length() > 0) {
          permstr.append(",");
        }
        permstr.append(p);
      }
      tokens.put(mod, token(mod, permstr.toString()));
    }
  }
  if (!tokens.isEmpty()) { // return also a 'clean' token
    tokens.put("_", ctx.request().getHeader(XOkapiHeaders.TOKEN));
  }
  String alltokens = Json.encode(tokens);
  logger.debug("test-auth: module tokens for {}: {}", modPermJson, alltokens);
  return alltokens;
}
 
Example 13
Source File: PipelineExecutioner.java    From konduit-serving with Apache License 2.0 5 votes vote down vote up
/**
 * Perform json inference using the given {@link JsonObject}
 *  containing 2 objects: a schema and values
 *  and if a {@link RoutingContext} is provided, it will also
 *  write the result as a response
 * @param jsonBody the input
 * @param ctx the context
 */
public Record[] doJsonInference(JsonObject jsonBody,RoutingContext ctx) {
    JsonObject schema = jsonBody.getJsonObject("schema");
    JsonObject values = jsonBody.getJsonObject("values");
    Preconditions.checkState(schema.fieldNames().equals(values.fieldNames()),"Schema and Values must be the same field names!");
    Record[] pipelineInput = new Record[schema.fieldNames().size()];
    int count = 0;
    for(String key : schema.fieldNames()) {
        JsonObject schemaJson = schema.getJsonObject(key);
        JsonObject recordAsJson = values.getJsonObject(key);
        Record record = JsonSerdeUtils.createRecordFromJson(recordAsJson, schemaJson);
        pipelineInput[count] = record;
        count++;
    }


    Preconditions.checkNotNull(pipeline,"Pipeline must not be null!");
    Record[] records = pipeline.doPipeline(pipelineInput);
    JsonObject writeJson = JsonSerdeUtils.convertRecords(records,outputNames());
    if(ctx != null) {
        ctx.response().putHeader("Content-Type", "application/json");
        Buffer buffer = writeJson.toBuffer();
        ctx.response().putHeader("Content-Length", String.valueOf(buffer.length()));
        ctx.response().end(buffer);
    }

    return records;
}
 
Example 14
Source File: JsonRpcTestHelper.java    From besu with Apache License 2.0 5 votes vote down vote up
protected void assertValidJsonRpcResult(final JsonObject json, final Object id) {
  // Check all expected fieldnames are set
  final Set<String> fieldNames = json.fieldNames();
  assertThat(fieldNames.size()).isEqualTo(3);
  assertThat(fieldNames.contains("id")).isTrue();
  assertThat(fieldNames.contains("jsonrpc")).isTrue();
  assertThat(fieldNames.contains("result")).isTrue();

  // Check standard field values
  assertIdMatches(json, id);
  assertThat(json.getString("jsonrpc")).isEqualTo("2.0");
}
 
Example 15
Source File: AbstractSearchOptions.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
public AbstractSearchOptions(JsonObject json) {

        types = json.getJsonArray(JSON_FIELD_TYPES, new JsonArray()).getList();
        scroll = json.getString(JSON_FIELD_SCROLL);
        timeoutInMillis = json.getLong(JSON_FIELD_TIMEOUT_IN_MILLIS);
        terminateAfter = json.getInteger(JSON_FIELD_TERMINATE_AFTER);
        routing = json.getString(JSON_FIELD_ROUTING);
        preference = json.getString(JSON_FIELD_PREFERENCE);
        query = json.getJsonObject(JSON_FIELD_QUERY);
        postFilter = json.getJsonObject(JSON_FIELD_POST_FILTER);
        minScore = json.getFloat(JSON_FIELD_MIN_SCORE);
        size = json.getInteger(JSON_FIELD_SIZE);
        from = json.getInteger(JSON_FIELD_FROM);
        explain = json.getBoolean(JSON_FIELD_EXPLAIN);
        version = json.getBoolean(JSON_FIELD_VERSION);
        fetchSource = json.getBoolean(JSON_FIELD_FETCH_SOURCE);
        sourceIncludes = json.getJsonArray(JSON_FIELD_SOURCE_INCLUDES, new JsonArray()).getList();
        sourceExcludes = json.getJsonArray(JSON_FIELD_SOURCE_EXCLUDES, new JsonArray()).getList();
        trackScores = json.getBoolean(JSON_FIELD_TRACK_SCORES);
        storedFields = json.getJsonArray(JSON_FIELD_STORED_FIELDS, new JsonArray()).getList();
        indicesOptions = Optional.ofNullable(json.getJsonObject(JSON_FIELD_INDICES_OPTIONS)).map(IndicesOptions::new).orElse(null);

        JsonArray aggregationsJson = json.getJsonArray(JSON_FIELD_AGGREGATIONS);
        if (aggregationsJson != null) {
            for (int i = 0; i < aggregationsJson.size(); i++) {
                aggregations.add(new AggregationOption(aggregationsJson.getJsonObject(i)));
            }
        }

        searchType = Optional.ofNullable(json.getString(JSON_FIELD_SEARCH_TYPE)).map(SearchType::valueOf).orElse(null);
        JsonArray fieldSortOptionsJson = json.getJsonArray(JSON_FIELD_SORTS);
        if (fieldSortOptionsJson != null) {
            for (int i = 0; i < fieldSortOptionsJson.size(); i++) {
                sorts.add(BaseSortOption.parseJson(fieldSortOptionsJson.getJsonObject(i)));
            }
        }

        JsonObject scriptFieldOptionsJson = json.getJsonObject(JSON_FIELD_SCRIPT_FIELDS);
        if (scriptFieldOptionsJson != null) {
            for (String scriptFieldName : scriptFieldOptionsJson.fieldNames()) {
                scriptFields.put(scriptFieldName, new ScriptFieldOption(scriptFieldOptionsJson.getJsonObject(scriptFieldName)));
            }
        }

        final JsonObject suggestOptionsJson = json.getJsonObject(JSON_FIELD_SUGGESTIONS);
        if (suggestOptionsJson != null) {
            for (String suggestionName : suggestOptionsJson.fieldNames()) {
                suggestions.put(suggestionName, BaseSuggestOption.parseJson(suggestOptionsJson.getJsonObject(suggestionName)));
            }
        }
    }
 
Example 16
Source File: SchemaTypeUtils.java    From konduit-serving with Apache License 2.0 4 votes vote down vote up
/**
 * Create a {@link Schema} from a {@link JsonObject}
 *  schema descriptor. The schema descriptor contains a json object of keys
 *  of type {@link ColumnType} values in the form of:
 *  name : {@link ColumnType} value
 *
 * There are 2 exceptions to this rule.
 * {@link ColumnType#NDArray} and {@link ColumnType#Categorical}
 * both are json objects.
 * {@link ColumnType#NDArray} has the form:
 * {name : shape: [], serialization type: "json" | "b64"}
 * {@link ColumnType#Categorical} has the form:
 * {categories: []}
 * {@link ColumnType#Time} has the form:
 * {timeZoneId: timeZoneId}
 *
 *
 * @param schemaDescriptor a {@link JsonObject} with the form
 *                         described above
 * @return the equivalent {@link Schema} derived from the given descriptor
 */
public static Schema schemaFromDynamicSchemaDefinition(JsonObject schemaDescriptor) {
    Schema.Builder schemaBuilder = new Builder();
    for(String key : schemaDescriptor.fieldNames()) {
        JsonObject fieldInfo = schemaDescriptor.getJsonObject(key);
        JsonObject fieldInfoObject = fieldInfo.getJsonObject("fieldInfo");
        if(fieldInfoObject == null) {
            throw new IllegalArgumentException("Unable to find object fieldInfo!");
        }

        if(!fieldInfoObject.containsKey("type")) {
            throw new IllegalArgumentException("Illegal field info. Missing key type for identifying type of field");
        }
        //convert image to bytes and let user pre process accordingly
        String type = fieldInfoObject.getString("type");
        if(type.equals("Image")) {
            type = "Bytes";
        }
        switch(ColumnType.valueOf(type)) {
            case Boolean:
                schemaBuilder.addColumnBoolean(key);
                break;
            case Double:
                schemaBuilder.addColumnDouble(key);
                break;
            case Float:
                schemaBuilder.addColumnFloat(key);
                break;
            case Long:
                schemaBuilder.addColumnLong(key);
                break;
            case String:
                schemaBuilder.addColumnString(key);
                break;
            case Integer:
                schemaBuilder.addColumnInteger(key);
                break;
            case NDArray:
                JsonArray shapeArr = fieldInfoObject.getJsonArray("shape");
                long[] shape = new long[shapeArr.size()];
                for(int i = 0; i < shape.length; i++) {
                    shape[i] = shapeArr.getLong(i);
                }
                schemaBuilder.addColumnNDArray(key,shape);
                break;
            case Categorical:
                JsonArray jsonArray = fieldInfoObject.getJsonArray("categories");
                String[] categories = new String[jsonArray.size()];
                for(int i = 0; i < categories.length; i++) {
                    categories[i] = jsonArray.getString(i);
                }
                schemaBuilder.addColumnCategorical(key,categories);
                break;
            case Bytes:
                ColumnMetaData columnMetaData = new BinaryMetaData(key);
                schemaBuilder.addColumn(columnMetaData);
                break;
            case Time:
                TimeZone zoneById = TimeZone.getTimeZone(fieldInfoObject.getString("timeZoneId"));
                schemaBuilder.addColumnTime(key,zoneById);
                break;

        }
    }

    return schemaBuilder.build();
}
 
Example 17
Source File: JsonSerdeUtils.java    From konduit-serving with Apache License 2.0 4 votes vote down vote up
/**
 * De serializes a schema using the
 * {@link JsonObject} methods
 * where schemaValues is just a set of field name -> json value
 * @param schemaValues the values of the schema
 * @param schemaTypes the schema types
 * @return a map of de serialized objects
 */
public static Map<String,Object> deSerializeSchemaValues(JsonObject schemaValues, Map<String, SchemaType> schemaTypes) {
    Preconditions.checkState(schemaValues.fieldNames().equals(schemaTypes.keySet()),"Schema value key names are not the same as the schema types!");
    Map<String,Object> ret = new LinkedHashMap<>();
    for(String fieldName : schemaValues.fieldNames()) {
        SchemaType schemaType = schemaTypes.get(fieldName);
        switch (schemaType) {
            case NDArray:
                JsonObject jsonObject = schemaValues.getJsonObject(fieldName);
                try {
                    INDArray arr =  JsonMappers.getMapper().readValue(jsonObject.toString(), NDArrayOutput.class).getNdArray();
                    ret.put(fieldName,arr);
                } catch (JsonProcessingException e) {
                    e.printStackTrace();
                }
                break;
            case Boolean:
                ret.put(fieldName,schemaValues.getBoolean(fieldName));
                break;
            case Long:
                ret.put(fieldName,schemaValues.getLong(fieldName));
                break;
            case Float:
                ret.put(fieldName,schemaValues.getFloat(fieldName));
                break;
            case Image:
            case Bytes:
                ret.put(fieldName,schemaValues.getBinary(fieldName));
                break;
            case Integer:
                ret.put(fieldName,schemaValues.getInteger(fieldName));
                break;
            case Double:
                ret.put(fieldName,schemaValues.getDouble(fieldName));
                break;
            case Time:
                ret.put(fieldName,schemaValues.getInstant(fieldName));
                break;
            case String:
            case Categorical:
                ret.put(fieldName,schemaValues.getString(fieldName));
                break;

        }
    }

    return ret;
}
 
Example 18
Source File: KubeAuthApi.java    From enmasse with Apache License 2.0 4 votes vote down vote up
@Override
public TokenReview performTokenReview(String token) {
    if (client.isAdaptable(OkHttpClient.class)) {
        JsonObject body = new JsonObject();

        body.put("kind", "TokenReview");
        body.put("apiVersion", "authentication.k8s.io/v1");

        JsonObject spec = new JsonObject();
        spec.put("token", token);
        body.put("spec", spec);

        log.debug("Token review request: {}", body);
        JsonObject responseBody= doRawHttpRequest("/apis/authentication.k8s.io/v1/tokenreviews", "POST", body, false);
        log.debug("Token review response: {}", responseBody);
        JsonObject status = responseBody.getJsonObject("status");
        boolean authenticated = false;
        String userName = null;
        String userId = null;
        Set<String> groups = null;
        Map<String, List<String>> extra = null;
        if (status != null) {
            Boolean auth = status.getBoolean("authenticated");
            authenticated = auth == null ? false : auth;
            JsonObject user = status.getJsonObject("user");
            if (user != null) {
                userName = user.getString("username");
                userId = user.getString("uid");
                JsonArray groupArray = user.getJsonArray("groups");
                if (groupArray != null) {
                    groups = new HashSet<>();
                    for (int i = 0; i < groupArray.size(); i++) {
                        groups.add(groupArray.getString(i));
                    }
                }

                JsonObject extraObject = user.getJsonObject("extra");
                if (extraObject != null) {
                    extra = new HashMap<>();
                    for (String field : extraObject.fieldNames()) {
                        JsonArray extraValues = extraObject.getJsonArray(field);
                        List<String> extraValuesList = new ArrayList<>();
                        for (int i = 0; i < extraValues.size(); i++) {
                            extraValuesList.add(extraValues.getString(i));
                        }
                        extra.put(field, extraValuesList);
                    }
                }

            }
        }
        return new TokenReview(userName, userId, groups, extra, authenticated);
    } else {
        return new TokenReview(null, null, null, null, false);
    }
}
 
Example 19
Source File: GraphQLTestHelper.java    From besu with Apache License 2.0 4 votes vote down vote up
void assertValidGraphQLError(final JsonObject json) {
  // Check all expected fieldnames are set
  final Set<String> fieldNames = json.fieldNames();
  Assertions.assertThat(fieldNames.size()).isEqualTo(1);
  Assertions.assertThat(fieldNames.contains("errors")).isTrue();
}
 
Example 20
Source File: GraphQLTestHelper.java    From besu with Apache License 2.0 4 votes vote down vote up
void assertValidGraphQLResult(final JsonObject json) {
  // Check all expected fieldnames are set
  final Set<String> fieldNames = json.fieldNames();
  Assertions.assertThat(fieldNames.size()).isEqualTo(1);
  Assertions.assertThat(fieldNames.contains("data")).isTrue();
}