Utils { public static List<String> getArgNameValuePairs(JoinPoint jp) { List<String> list = new ArrayList<String>(); Object[] argValues = jp.getArgs(); if (argValues == null || argValues.length == 0) { return list; } Object[] argNames = getParameterNames(argValues, jp); for (int i = 0; i < argValues.length; i++) { String argName = (argNames[i] == null) ? "" + i : argNames[i].toString(); list.add("" + argName + ": " + toStringWithLimit(argValues[i])); } return list; }  static Map<Throwable, AutomonExpirable> createExceptionMap(); static String getLabel(Throwable throwable); static String getLabel(JoinPoint.StaticPart jp); static String formatExceptionForToolsWithLimitedCharacterSet(String exceptionLabel); static List<String> getArgNameValuePairs(JoinPoint jp); static String argNameValuePairsToString(List<String> args); static String toStringWithLimit(Object parameter); static String getExceptionTrace(Throwable exception); static String[] tokenize(String string, String splitOn); static String stripFileScheme(String fileName); static AutomonMXBean getAutomonMxBean(Object aspect); static void registerWithJmx(Object aspect, AutomonMXBean mxBean); static void unregisterWithJmx(Object aspect); static boolean hasPackageName(String className); static T createFirst(String... classNames); static void removeClassNames(List<String> list); static final String LINE_SEPARATOR; }
@Test public void testArgNameValuePairs_Empty() throws Exception { JoinPoint jp = mock(JoinPoint.class); assertThat(Utils.getArgNameValuePairs(jp)).isEmpty(); }
@Test public void testArgNameValuePairs_ArgValueNoArgName() throws Exception { JoinPoint jp = mock(JoinPoint.class); when(jp.getArgs()).thenReturn(new Object[]{"Steve"}); assertThat(Utils.getArgNameValuePairs(jp)).containsExactly("0: Steve"); }
@Test public void testArgNameValuePairs_ArgValueNoArgName_multiple() throws Exception { JoinPoint jp = mock(JoinPoint.class); when(jp.getArgs()).thenReturn(new Object[]{"Steve", 20}); assertThat(Utils.getArgNameValuePairs(jp)).containsExactly("0: Steve", "1: 20"); }