LegacyAllocationConverter { @NotNull public CallStack addCallStack(@NotNull List<StackTraceElement> stackTraceElements) { CallStack result; if (!myAllocationStacks.containsKey(stackTraceElements)) { result = new CallStack(stackTraceElements); myAllocationStacks.put(stackTraceElements, result); } else { result = myAllocationStacks.get(stackTraceElements); } return result; }  int addClassName(@NotNull String className); @NotNull CallStack addCallStack(@NotNull List<StackTraceElement> stackTraceElements); void resetAllocations(); void addAllocation(@NotNull Allocation allocationInfo); List<AllocationEvent.Allocation> getAllocationEvents(); List<AllocationStack> getAllocationStacks(); List<AllocatedClass> getClassNames(); void parseDump(@NotNull byte[] dumpData);  }
@Test public void testCallStackFramesDuplicatedInsert() { LegacyAllocationConverter converter = new LegacyAllocationConverter(); List<StackTraceElement> stackTraceElementList = new ArrayList<>(); stackTraceElementList.add(new StackTraceElement(CLASS_NAME, METHOD_NAME, FILE_NAME, LINE_NUMBER)); LegacyAllocationConverter.CallStack callStack = converter.addCallStack(stackTraceElementList); assertThat(converter.addCallStack(stackTraceElementList)).isEqualTo(callStack); }
@Test public void testCallstackHashcode() { LegacyAllocationConverter converter = new LegacyAllocationConverter(); List<StackTraceElement> stackTraceElementList = new ArrayList<>(); stackTraceElementList.add(new StackTraceElement(CLASS_NAME, METHOD_NAME, FILE_NAME, LINE_NUMBER)); LegacyAllocationConverter.CallStack callStack = converter.addCallStack(stackTraceElementList); assertThat(callStack.hashCode()).isEqualTo(stackTraceElementList.hashCode()); }