### Question:
Run extends AbstractTask { String adjustMaxPermSizeToAtLeast(String mavenOpts, Integer valueInMegabytes) { return adjustParamToAtLeast(mavenOpts, "-XX:MaxPermSize=([0-9]+)([kKmMgG]?)", "-XX:MaxPermSize=" + valueInMegabytes + "m", valueInMegabytes); } Run();  Run(AbstractTask other);  Run(AbstractTask other, String serverId); void executeTask();  }### Answer:
@Test public void adjustMaxPermSizeToAtLeast_shouldOverwriteExistingValueInMegabytes() { String mavenOpts = "-XX:MaxPermSize=128m -Xmx128m"; String adjusted = new Run().adjustMaxPermSizeToAtLeast(mavenOpts, 512); assertThat(adjusted, is(equalTo("-XX:MaxPermSize=512m -Xmx128m"))); }
@Test public void adjustMaxPermSizeToAtLeast_shouldOverwriteExistingValueInGigabytes() { String mavenOpts = "-XX:MaxPermSize=1g -Xmx1g"; String adjusted = new Run().adjustMaxPermSizeToAtLeast(mavenOpts, 2000); assertThat(adjusted, is(equalTo("-XX:MaxPermSize=2000m -Xmx1g"))); }
@Test public void adjustMaxPermSizeToAtLeast_shouldOverwriteExistingValueInKilobytes() { String mavenOpts = "-XX:MaxPermSize=128k -Xmx100k"; String adjusted = new Run().adjustMaxPermSizeToAtLeast(mavenOpts, 128); assertThat(adjusted, is(equalTo("-XX:MaxPermSize=128m -Xmx100k"))); }
@Test public void adjustMaxPermSizeToAtLeast_shouldOverwriteExistingValueInBytes() { String mavenOpts = "-XX:MaxPermSize=128 -Xmx100"; String adjusted = new Run().adjustMaxPermSizeToAtLeast(mavenOpts, 256); assertThat(adjusted, is(equalTo("-XX:MaxPermSize=256m -Xmx100"))); }
@Test public void adjustMaxPermSizeToAtLeast_shouldSetValueIfMissing() { String mavenOpts = "-Xmx256m"; String adjusted = new Run().adjustMaxPermSizeToAtLeast(mavenOpts, 256); assertThat(adjusted, is(equalTo("-Xmx256m -XX:MaxPermSize=256m"))); }
@Test public void adjustMaxPermSizeToAtLeast_shouldSetValueIfMavenOptsEmpty() { String mavenOpts = ""; String adjusted = new Run().adjustMaxPermSizeToAtLeast(mavenOpts, 256); assertThat(adjusted, is(equalTo(" -XX:MaxPermSize=256m"))); }