### Question:
Run extends AbstractTask { String adjustXmxToAtLeast(String input, Integer valueInMegabytes) { return adjustParamToAtLeast(input, "-Xmx([0-9]+)([kKmMgG]?)", "-Xmx" + valueInMegabytes + "m", valueInMegabytes); } Run();  Run(AbstractTask other);  Run(AbstractTask other, String serverId); void executeTask();  }### Answer:
@Test public void adjustXmxToAtLeast_shouldOverwriteExistingValueInMegabytes() { String mavenOpts = "-XX:MaxPermSize=128m -Xmx128m"; String adjusted = new Run().adjustXmxToAtLeast(mavenOpts, 512); assertThat(adjusted, is(equalTo("-XX:MaxPermSize=128m -Xmx512m"))); }
@Test public void adjustXmxToAtLeast_shouldOverwriteExistingValueInGigabytes() { String mavenOpts = "-XX:MaxPermSize=128m -Xmx1g"; String adjusted = new Run().adjustXmxToAtLeast(mavenOpts, 2000); assertThat(adjusted, is(equalTo("-XX:MaxPermSize=128m -Xmx2000m"))); }
@Test public void adjustXmxToAtLeast_shouldOverwriteExistingValueInKilobytes() { String mavenOpts = "-XX:MaxPermSize=128m -Xmx100k"; String adjusted = new Run().adjustXmxToAtLeast(mavenOpts, 128); assertThat(adjusted, is(equalTo("-XX:MaxPermSize=128m -Xmx128m"))); }
@Test public void adjustXmxToAtLeast_shouldOverwriteExistingValueInBytes() { String mavenOpts = "-XX:MaxPermSize=128m -Xmx100"; String adjusted = new Run().adjustXmxToAtLeast(mavenOpts, 256); assertThat(adjusted, is(equalTo("-XX:MaxPermSize=128m -Xmx256m"))); }
@Test public void adjustXmxToAtLeast_shouldSetValueIfMissing() { String mavenOpts = "-XX:MaxPermSize=128m"; String adjusted = new Run().adjustXmxToAtLeast(mavenOpts, 256); assertThat(adjusted, is(equalTo("-XX:MaxPermSize=128m -Xmx256m"))); }