@Test public void testPrefixAbsentCollection() { KeyedDistribution keyedDistribution = reportCollectionFactory.createReportCollection( KeyedDistribution.class, false, null, ImmutableMap.of("a", "fooval", "b", "with\"quote", "c", "with,comma", "d", "with\\backslash") ); SomeObject someObject = keyedDistribution.add("value", false); ArgumentCaptor<String> stringCaptor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<SomeObject> reportCaptor = ArgumentCaptor.forClass(SomeObject.class); verify(reportExporter).export(reportCaptor.capture(), eq(false), stringCaptor.capture(), tagCaptor.capture()); assertEquals(stringCaptor.getValue(), "Add"); assertEquals(tagCaptor.getValue(), ImmutableMap.builder() .put("a", "fooval") .put("b", "with\"quote") .put("c", "with,comma") .put("d", "with\\backslash") .put("foo", "value") .put("bar", "false") .build()); assertSame(reportCaptor.getValue(), someObject); }
@SuppressWarnings("unchecked") public <T> T createReportCollection(Class<T> aClass) { requireNonNull(aClass, "class is null"); return (T) newProxyInstance(aClass.getClassLoader(), new Class[]{aClass}, new StatInvocationHandler(aClass, false, Optional.of(aClass.getSimpleName()), ImmutableMap.of())); }
ReportCollectionFactory { @SuppressWarnings("unchecked") public <T> T createReportCollection(Class<T> aClass) { requireNonNull(aClass, "class is null"); return (T) newProxyInstance(aClass.getClassLoader(), new Class[]{aClass}, new StatInvocationHandler(aClass, false, Optional.of(aClass.getSimpleName()), ImmutableMap.of())); } }
ReportCollectionFactory { @SuppressWarnings("unchecked") public <T> T createReportCollection(Class<T> aClass) { requireNonNull(aClass, "class is null"); return (T) newProxyInstance(aClass.getClassLoader(), new Class[]{aClass}, new StatInvocationHandler(aClass, false, Optional.of(aClass.getSimpleName()), ImmutableMap.of())); } @Inject  ReportCollectionFactory(ReportExporter reportExporter); protected  ReportCollectionFactory(ReportExporter reportExporter, Ticker ticker); }
ReportCollectionFactory { @SuppressWarnings("unchecked") public <T> T createReportCollection(Class<T> aClass) { requireNonNull(aClass, "class is null"); return (T) newProxyInstance(aClass.getClassLoader(), new Class[]{aClass}, new StatInvocationHandler(aClass, false, Optional.of(aClass.getSimpleName()), ImmutableMap.of())); } @Inject  ReportCollectionFactory(ReportExporter reportExporter); protected  ReportCollectionFactory(ReportExporter reportExporter, Ticker ticker); @SuppressWarnings("unchecked") T createReportCollection(Class<T> aClass); @SuppressWarnings("unchecked") T createReportCollection(Class<T> aClass, boolean applicationPrefix, @Nullable String namePrefix, Map<String, String> tags); @Deprecated @SuppressWarnings("unchecked") T createReportCollection(Class<T> aClass, String name); }
ReportCollectionFactory { @SuppressWarnings("unchecked") public <T> T createReportCollection(Class<T> aClass) { requireNonNull(aClass, "class is null"); return (T) newProxyInstance(aClass.getClassLoader(), new Class[]{aClass}, new StatInvocationHandler(aClass, false, Optional.of(aClass.getSimpleName()), ImmutableMap.of())); } @Inject  ReportCollectionFactory(ReportExporter reportExporter); protected  ReportCollectionFactory(ReportExporter reportExporter, Ticker ticker); @SuppressWarnings("unchecked") T createReportCollection(Class<T> aClass); @SuppressWarnings("unchecked") T createReportCollection(Class<T> aClass, boolean applicationPrefix, @Nullable String namePrefix, Map<String, String> tags); @Deprecated @SuppressWarnings("unchecked") T createReportCollection(Class<T> aClass, String name);  }