### Question:
SessionRegistryDiagnosticService implements Diagnostic { public Map<DiagnosticAttribute, DiagnosticCallback> getDiagnosticData() { return new DiagnosticAttributeBuilder() .addDiagnosticAttribute(DiagnosticAttributeBuilder.TOTAL_LOGGED_IN_USERS, new DiagnosticCallback<Integer>() { @Override public Integer getDiagnosticAttributeValue() { return sessionRegistry.getAllPrincipals().size(); } }) .addDiagnosticAttribute(DiagnosticAttributeBuilder.TOTAL_SESSIONS_BY_USER, new DiagnosticCallback<Map<String, Integer>>() { @Override public Map<String, Integer> getDiagnosticAttributeValue() { Map<String, Integer> sessionsCountForUser = new HashMap<String, Integer>(); for (Object principle : sessionRegistry.getAllPrincipals()) { sessionsCountForUser.put(principle.toString(), sessionRegistry.getAllSessions(principle, false).size()); } return sessionsCountForUser; } }).build(); }  Map<DiagnosticAttribute, DiagnosticCallback> getDiagnosticData(); void setSessionRegistry(SessionRegistry sessionRegistry);  }### Answer:
@Test public void getDiagnosticDataTest() { Map<DiagnosticAttribute, DiagnosticCallback> resultDiagnosticData = sessionRegistryDiagnosticService.getDiagnosticData(); assertEquals(2, resultDiagnosticData.size()); assertEquals(3, resultDiagnosticData.get(new DiagnosticAttributeImpl( DiagnosticAttributeBuilder.TOTAL_LOGGED_IN_USERS, null, null)).getDiagnosticAttributeValue()); Map<String, Integer> sessionsCountByUserMap = (Map<String, Integer>)resultDiagnosticData. get(new DiagnosticAttributeImpl(DiagnosticAttributeBuilder.TOTAL_SESSIONS_BY_USER, null, null)).getDiagnosticAttributeValue(); assertEquals(3, sessionsCountByUserMap.size()); int sessionsForUser1 = sessionsCountByUserMap.get(user1); assertEquals(3, sessionsForUser1); int sessionsForUser2 = sessionsCountByUserMap.get(user2); assertEquals(2, sessionsForUser2); int sessionsForUser3 = sessionsCountByUserMap.get(user3); assertEquals(1, sessionsForUser3); }