MINOR: Remove redundant instantitation of utility class

Fixes #7649
This commit is contained in:
Armin 2017-07-11 17:54:02 +02:00 committed by Armin Braun
parent 13341b66cc
commit 396fc14a6c
3 changed files with 9 additions and 5 deletions

View file

@ -11,7 +11,11 @@ import java.util.Map;
/**
* Based on code created by purbon on 13/12/15.
*/
public class MemoryMonitor {
public final class MemoryMonitor {
private MemoryMonitor() {
//Utility Class
}
public enum Type {
All, Heap, NonHeap

View file

@ -25,7 +25,7 @@ public class MemoryReport {
}
private static MemoryMonitor.Report generateReport(MemoryMonitor.Type type) {
return new MemoryMonitor().detect(type);
return MemoryMonitor.detect(type);
}
}

View file

@ -15,19 +15,19 @@ public class MemoryMonitorTest {
@Test
public void testEachHeapSpaceRepresented() {
Map<String, Map<String, Object>> heap = new MemoryMonitor().detect(MemoryMonitor.Type.All).getHeap();
Map<String, Map<String, Object>> heap = MemoryMonitor.detect(MemoryMonitor.Type.All).getHeap();
assertThat(heap, notNullValue());
assertThat(heap.keySet(), hasItems("PS Survivor Space", "PS Old Gen", "PS Eden Space"));
}
@Test
public void testAllStatsAreAvailableForHeap(){
testAllStatsAreAvailable(new MemoryMonitor().detect(MemoryMonitor.Type.All).getHeap());
testAllStatsAreAvailable(MemoryMonitor.detect(MemoryMonitor.Type.All).getHeap());
}
@Test
public void testAllStatsAreAvailableForNonHeap(){
testAllStatsAreAvailable(new MemoryMonitor().detect(MemoryMonitor.Type.All).getNonHeap());
testAllStatsAreAvailable(MemoryMonitor.detect(MemoryMonitor.Type.All).getNonHeap());
}
private void testAllStatsAreAvailable(Map<String, Map<String, Object>> stats){