Statistics { public static void report(final InfoComponent info, final ProjectComponent projects, final Event event) { requireNonNull(info); requireNonNull(projects); requireNonNull(event); if (TestSettings.isTestMode()) { return; } final Project project = projects.getProject(); final Map<String, Object> ping = new HashMap<>(); ping.put("userId", InternalEmailUtil.getUserId().toString()); ping.put("appId", project.getAppId()); ping.put("eventType", event.eventName); ping.put("productName", info.getTitle()); ping.put("productVersion", info.getImplementationVersion()); ping.put("databases", project.dbmses() .map(Dbms::getTypeName) .distinct() .collect(toList()) ); ping.put("emailAddress", InternalEmailUtil.getEmail()); ping.put("computerName", HOST_NAME); ping.put("dateStarted", STARTED); sendPostRequest(PING_URL, Json.toJson(ping)); } private  Statistics(); static void report(final InfoComponent info,
                              final ProjectComponent projects,
                              final Event event);  }
@TestFactory Stream<DynamicTest> report(MockServerClient client) throws ReflectiveOperationException { client .when(request() .withPath("/stats") .withMethod("POST") .withContentType(MediaType.APPLICATION_JSON_UTF_8)) .respond(response() .withStatusCode(200)); setStaticFinalField(Statistics.class, "PING_URL", "http: final Project project = mock(Project.class); when(project.getAppId()).thenReturn("app-id"); final InfoComponent infoComponent = mock(InfoComponent.class); when(infoComponent.getTitle()).thenReturn("title"); when(infoComponent.getImplementationVersion()).thenReturn("3.2.9"); final ProjectComponent projectComponent = mock(ProjectComponent.class); when(projectComponent.getProject()).thenReturn(project); return Arrays.stream(Event.values()).map(event -> dynamicTest(event.name(), () -> { when(project.dbmses()).thenReturn(Stream.empty()); assertDoesNotThrow(() -> Statistics.report(infoComponent, projectComponent, event)); })); }