### Question:
SQRBuildService extends CommandLineBuildService { protected static void addSQRArg(@NotNull final List<String> argList, @NotNull final String key, @Nullable final String value, @NotNull final OSType osType) { if (!Util.isEmpty(value)) { final String paramValue = key + "=" + value; argList.add(osType == WINDOWS ? StringUtil.doubleQuote(StringUtil.escapeQuotes(paramValue)) : paramValue); } } SQRBuildService(@NotNull final SonarProcessListener sonarProcessListener,
                           @NotNull final OSType osType); @NotNull @Override ProgramCommandLine makeProgramCommandLine();  }### Answer:
@Test public void testAddSQRArg() { final List<String> res = new LinkedList<String>(); SQRBuildService.addSQRArg(res, "-Dkey", null, OSType.UNIX); assertTrue(res.isEmpty(), "Null values should not be passed to the resulting list. List: " + Arrays.toString(res.toArray())); SQRBuildService.addSQRArg(res, "-Dkey", "value", OSType.UNIX); assertTrue(!res.isEmpty(), "'-Dkey=value' pair should be added to the resulting list. Nothing was added."); assertEquals(res.get(0), "-Dkey=value", "'-Dkey=value' pair should be added to the resulting list. List: " + Arrays.toString(res.toArray())); assertTrue(res.size() == 1, "Only '-Dkey=value' pair should be added to the resulting list. List: " + Arrays.toString(res.toArray())); SQRBuildService.addSQRArg(res, "-Dkey", "value", OSType.UNIX); assertEquals(res.get(0), "-Dkey=value", "'-Dkey=value' pair should be added to the resulting list. List: " + Arrays.toString(res.toArray())); assertEquals(res.get(1), "-Dkey=value", "'-Dkey=value' pair should be added to the resulting list. List: " + Arrays.toString(res.toArray())); assertTrue(res.size() == 2, "Second '-Dkey=value' pair should be added to the resulting list. List: " + Arrays.toString(res.toArray())); }
@Test public void testAddSQRArgWin() { final List<String> res = new LinkedList<String>(); SQRBuildService.addSQRArg(res, "-Dkey", null, OSType.WINDOWS); assertTrue(res.isEmpty(), "Null values should not be passed to the resulting list. List: " + Arrays.toString(res.toArray())); SQRBuildService.addSQRArg(res, "-Dkey", "value", OSType.WINDOWS); assertTrue(!res.isEmpty(), "'-Dkey=value' pair should be added to the resulting list. Nothing was added."); assertEquals(res.get(0), "\"-Dkey=value\"", "'-Dkey=value' pair should be added to the resulting list. List: " + Arrays.toString(res.toArray())); assertTrue(res.size() == 1, "Only '-Dkey=value' pair should be added to the resulting list. List: " + Arrays.toString(res.toArray())); SQRBuildService.addSQRArg(res, "-Dkey", "value", OSType.WINDOWS); assertEquals(res.get(0), "\"-Dkey=value\"", "'-Dkey=value' pair should be added to the resulting list. List: " + Arrays.toString(res.toArray())); assertEquals(res.get(1), "\"-Dkey=value\"", "'-Dkey=value' pair should be added to the resulting list. List: " + Arrays.toString(res.toArray())); assertTrue(res.size() == 2, "Second '-Dkey=value' pair should be added to the resulting list. List: " + Arrays.toString(res.toArray())); }