GCStat { static String collector(String collectorName) { if (collectorName.contains("Young")) return "young"; if (collectorName.contains("Old")) return "old"; if (collectorName.contains("Scavenge")) return "young"; if (collectorName.contains("MarkSweep")) return "old"; return null; } private  GCStat(GarbageCollectorMXBean bean, String name);   }
@Test void collector() { assertThat(GCStat.collector("G1 Young Generation")).isEqualTo("young"); assertThat(GCStat.collector("G1 Old Generation")).isEqualTo("old"); assertThat(GCStat.collector("PS Scavenge")).isEqualTo("young"); assertThat(GCStat.collector("PS MarkSweep")).isEqualTo("old"); assertThat(GCStat.collector("Copy")).isNull(); }