test_class.file: plugins/cameraserver/src/test/java/edu/wpi/first/shuffleboard/plugin/cameraserver/source/CameraUrlGeneratorTest.java
test_class.identifier: CameraUrlGeneratorTest
test_case.body: @Test
    public void testGenerateHttpParams() {
      Map<String, String> commands = new HashMap<>();
      String baseUrl = "http://myCode:1111";
      String params = CameraUrlGenerator.addHttpParams(baseUrl, commands);
      assertEquals(baseUrl, params);
  
      commands.put("foo", "bar");
      params = CameraUrlGenerator.addHttpParams(baseUrl, commands);
      assertEquals(baseUrl + "?foo=bar", params);
  
      commands.put("baz", "buq");
      params = CameraUrlGenerator.addHttpParams(baseUrl, commands);
      assertEquals(baseUrl + "?foo=bar&baz=buq", params);
    }
test_case.class_method_signature: CameraUrlGeneratorTest.testGenerateHttpParams()
test_case.full_signature: @Test public void testGenerateHttpParams()
test_case.identifier: testGenerateHttpParams
test_case.invocations: addHttpParams assertEquals put addHttpParams assertEquals put addHttpParams assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGenerateHttpParams()
focal_class.declarator: source
focal_class.modifier: private final
focal_class.original_string: private final CameraServerSource source;
focal_class.type: CameraServerSource
focal_class.var_name: source
focal_class.file: plugins/cameraserver/src/main/java/edu/wpi/first/shuffleboard/plugin/cameraserver/source/CameraUrlGenerator.java
focal_class.identifier: CameraUrlGenerator
focal_class.class_method_signature: CameraUrlGenerator.CameraUrlGenerator(CameraServerSource source)
focal_class.full_signature: public  CameraUrlGenerator(CameraServerSource source)
focal_class.identifier: CameraUrlGenerator
focal_class.modifiers: public
focal_class.parameters: (CameraServerSource source)
focal_class.signature:  CameraUrlGenerator(CameraServerSource source)
focal_class.class_method_signature: CameraUrlGenerator.generateUrls(String[] baseUrls)
focal_class.full_signature: public String[] generateUrls(String[] baseUrls)
focal_class.identifier: generateUrls
focal_class.modifiers: public
focal_class.parameters: (String[] baseUrls)
focal_class.return: String[]
focal_class.signature: String[] generateUrls(String[] baseUrls)
focal_class.class_method_signature: CameraUrlGenerator.generateUrls(Map<String, String> commands, String[] baseUrls)
focal_class.full_signature: @VisibleForTesting static String[] generateUrls(Map<String, String> commands, String[] baseUrls)
focal_class.identifier: generateUrls
focal_class.modifiers: @VisibleForTesting static
focal_class.parameters: (Map<String, String> commands, String[] baseUrls)
focal_class.return: String[]
focal_class.signature: String[] generateUrls(Map<String, String> commands, String[] baseUrls)
focal_class.class_method_signature: CameraUrlGenerator.addHttpParams(String input, Map<String, String> commands)
focal_class.full_signature: @VisibleForTesting static String addHttpParams(String input, Map<String, String> commands)
focal_class.identifier: addHttpParams
focal_class.modifiers: @VisibleForTesting static
focal_class.parameters: (String input, Map<String, String> commands)
focal_class.return: String
focal_class.signature: String addHttpParams(String input, Map<String, String> commands)
focal_class.class_method_signature: CameraUrlGenerator.encodeUri(URI uri, String queryStr)
focal_class.full_signature: private static String encodeUri(URI uri, String queryStr)
focal_class.identifier: encodeUri
focal_class.modifiers: private static
focal_class.parameters: (URI uri, String queryStr)
focal_class.return: String
focal_class.signature: String encodeUri(URI uri, String queryStr)
focal_class.class_method_signature: CameraUrlGenerator.httpUrlEncode(Map.Entry<String, String> rawCommand)
focal_class.full_signature: private static String httpUrlEncode(Map.Entry<String, String> rawCommand)
focal_class.identifier: httpUrlEncode
focal_class.modifiers: private static
focal_class.parameters: (Map.Entry<String, String> rawCommand)
focal_class.return: String
focal_class.signature: String httpUrlEncode(Map.Entry<String, String> rawCommand)
focal_method.body: @VisibleForTesting
    static String addHttpParams(String input, Map<String, String> commands) {
      if (commands.isEmpty()) {
        return input;
      }
      // Parse the URI
      URI uri;
      try {
        uri = new URI(input);
      } catch (URISyntaxException ex) {
        return input;
      }
  
      String query = uri.getQuery();
  
      if (query != null) {
        // Handle the NI special case
        String niName = commands.get("name");
  
        String[] existingCommands = query.split("&");
        for (String command : existingCommands) {
          String[] commandSplit = command.split("=");
          if (commandSplit.length != 2) {
            continue;
          }
          commands.put(URLDecoder.decode(commandSplit[0], StandardCharsets.UTF_8),
                       URLDecoder.decode(commandSplit[1], StandardCharsets.UTF_8));
        }
        if (niName != null) {
          commands.put("name", niName);
        }
      }
  
      var queryStr = commands.entrySet().stream()
          .map(CameraUrlGenerator::httpUrlEncode)
          .collect(Collectors.joining("&"));
      return encodeUri(uri, queryStr);
  
    }
focal_method.class_method_signature: CameraUrlGenerator.addHttpParams(String input, Map<String, String> commands)
focal_method.full_signature: @VisibleForTesting static String addHttpParams(String input, Map<String, String> commands)
focal_method.identifier: addHttpParams
focal_method.invocations: isEmpty getQuery get split split put decode decode put collect map stream entrySet joining encodeUri
focal_method.modifiers: @VisibleForTesting static
focal_method.parameters: (String input, Map<String, String> commands)
focal_method.return: String
focal_method.signature: String addHttpParams(String input, Map<String, String> commands)