ErrorLogHelper { @NonNull public static ErrorReport getErrorReportFromErrorLog(@NonNull ManagedErrorLog log, String stackTrace) { ErrorReport report = new ErrorReport(); report.setId(log.getId().toString()); report.setThreadName(log.getErrorThreadName()); report.setStackTrace(stackTrace); report.setAppStartTime(log.getAppLaunchTimestamp()); report.setAppErrorTime(log.getTimestamp()); report.setDevice(log.getDevice()); return report; }  @NonNull static ManagedErrorLog createErrorLog(@NonNull Context context, @NonNull final java.lang.Thread thread, @NonNull final Throwable throwable, @NonNull final Map<java.lang.Thread, StackTraceElement[]> allStackTraces, final long initializeTimestamp); @NonNull static ManagedErrorLog createErrorLog(@NonNull Context context, @NonNull final java.lang.Thread thread, @NonNull final Exception exception, @NonNull final Map<java.lang.Thread, StackTraceElement[]> allStackTraces, final long initializeTimestamp, boolean fatal); @NonNull static synchronized File getErrorStorageDirectory(); @NonNull static synchronized File getNewMinidumpDirectory(); @NonNull static synchronized File getNewMinidumpSubfolder(); @NonNull static synchronized File getNewMinidumpSubfolderWithContextData(Context context); @NonNull static synchronized File getPendingMinidumpDirectory(); @NonNull static File[] getStoredErrorLogFiles(); @NonNull static File[] getNewMinidumpFiles(); @Nullable static Device getStoredDeviceInfo(File logFolder); static void removeStaleMinidumpSubfolders(); static void removeMinidumpFolder(); @Nullable static File getLastErrorLogFile(); @Nullable static File getStoredThrowableFile(@NonNull UUID id); static void removeStoredThrowableFile(@NonNull UUID id); static void removeStoredErrorLogFile(@NonNull UUID id); @NonNull static ErrorReport getErrorReportFromErrorLog(@NonNull ManagedErrorLog log, String stackTrace); @NonNull static Exception getModelExceptionFromThrowable(@NonNull Throwable t); static Map<String, String> validateProperties(Map<String, String> properties, String logType); static void cleanPendingMinidumps(); @NonNull static UUID parseLogFolderUuid(File logFolder); @VisibleForTesting static void clearStaticState(); static final String DEVICE_INFO_FILE; static final String ERROR_LOG_FILE_EXTENSION; static final String THROWABLE_FILE_EXTENSION; @VisibleForTesting
    static final int FRAME_LIMIT; static final int MAX_PROPERTY_ITEM_LENGTH; static final String MINIDUMP_FILE_EXTENSION; }
@Test public void getErrorReportFromErrorLog() throws java.lang.Exception { Context mockContext = mock(Context.class); when(Process.myPid()).thenReturn(123); Device mockDevice = mock(Device.class); when(DeviceInfoHelper.getDeviceInfo(any(Context.class))).thenReturn(mockDevice); ActivityManager activityManager = mock(ActivityManager.class); RunningAppProcessInfo runningAppProcessInfo = new RunningAppProcessInfo(null, 0, null); runningAppProcessInfo.pid = 123; runningAppProcessInfo.processName = "right.process"; when(mockContext.getSystemService(Context.ACTIVITY_SERVICE)).thenReturn(activityManager); when(activityManager.getRunningAppProcesses()).thenReturn(Arrays.asList(mock(RunningAppProcessInfo.class), runningAppProcessInfo)); TestUtils.setInternalState(Build.VERSION.class, "SDK_INT", 23); TestUtils.setInternalState(Build.class, "SUPPORTED_ABIS", new String[]{"armeabi-v7a", "arm"}); ManagedErrorLog errorLog = ErrorLogHelper.createErrorLog(mockContext, java.lang.Thread.currentThread(), new RuntimeException(new TestCrashException()), java.lang.Thread.getAllStackTraces(), 900); assertNotNull(errorLog); String stackTrace = "Sample stack trace"; ErrorReport report = ErrorLogHelper.getErrorReportFromErrorLog(errorLog, stackTrace); assertNotNull(report); assertEquals(errorLog.getId().toString(), report.getId()); assertEquals(errorLog.getErrorThreadName(), report.getThreadName()); assertEquals(stackTrace, report.getStackTrace()); assertEquals(errorLog.getAppLaunchTimestamp(), report.getAppStartTime()); assertEquals(errorLog.getTimestamp(), report.getAppErrorTime()); assertEquals(errorLog.getDevice(), report.getDevice()); }