// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.grid.graphql;

import org.openqa.selenium.Capabilities;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.json.Json;

import java.net.URI;
import java.util.Map;
import java.util.UUID;

public class Node {

  private final UUID id;
  private final URI uri;
  private final boolean isUp;
  private final int maxSession;
  private final String capabilities;
  private static final Json JSON = new Json();


  public Node(UUID id,
              URI uri,
              boolean isUp,
              int maxSession,
              Map<Capabilities, Integer> capabilities) {
    this.id = Require.nonNull("Node id", id);
    this.uri = Require.nonNull("Node uri", uri);
    this.isUp = isUp;
    this.maxSession = Require.nonNull("Node maxSession", maxSession);
    this.capabilities = Require.nonNull("Node capabilities", JSON.toJson(capabilities));
  }

  public UUID getId() {
    return id;
  }

  public URI getUri() {
    return uri;
  }

  public int getMaxSession() {
    return maxSession;
  }

  public String getStatus() {
    return isUp ? "UP" : "UNAVAILABLE";
  }
}

@@ -986,16 +986,93 @@
 et.URI;%0A
+import java.util.ArrayList;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0A
 import j
@@ -1081,24 +1081,24 @@
 a.util.Map;%0A
-
 import java.
@@ -1258,22 +1258,42 @@
 e final 
-String
+Map%3CCapabilities, Integer%3E
  capabil
@@ -1761,20 +1761,8 @@
 s%22, 
-JSON.toJson(
 capa
@@ -1770,17 +1770,16 @@
 ilities)
-)
 ;%0A  %7D%0A%0A 
@@ -1893,24 +1893,24 @@
 Session() %7B%0A
-
     return m
@@ -1921,24 +1921,424 @@
 ssion;%0A  %7D%0A%0A
+  public String getCapabilities() %7B%0A    List%3CMap%3E toReturn = new ArrayList%3C%3E();%0A%0A    for (Map.Entry%3CCapabilities, Integer%3E entry : capabilities.entrySet()) %7B%0A      Map%3CString, Object%3E details  = new HashMap%3C%3E();%0A      details.put(%22browserName%22, entry.getKey().getBrowserName());%0A      details.put(%22slots%22, entry.getValue());%0A      toReturn.add(details);%0A    %7D%0A%0A    return JSON.toJson(toReturn);%0A  %7D%0A%0A
   public Str

Correct getCapabilities output to be easier to consume (#8522)