### Question:
Context { public static <T> List<T> getRegisteredComponents(Class<T> type) { return getServiceContext().getRegisteredComponents(type); } Context(); void setContextDAO(ContextDAO dao); static void setDAO(ContextDAO dao); static Class<?> loadClass(String className); static void setUserContext(UserContext ctx); static void clearUserContext(); static UserContext getUserContext(); void setServiceContext(ServiceContext ctx); static void setContext(ServiceContext ctx); static void authenticate(String username, String password); static void refreshAuthenticatedUser(); static void becomeUser(String systemId); static Properties getRuntimeProperties(); static void setRuntimeProperties(Properties props); static ConceptService getConceptService(); static EncounterService getEncounterService(); static LocationService getLocationService(); static ObsService getObsService(); static PatientService getPatientService(); static CohortService getCohortService(); static PersonService getPersonService(); static ConditionService getConditionService(); static DiagnosisService getDiagnosisService(); static HL7Service getHL7Service(); static UserService getUserService(); static OrderService getOrderService(); static OrderSetService getOrderSetService(); static FormService getFormService(); static SerializationService getSerializationService(); static LogicService getLogicService(); static AdministrationService getAdministrationService(); static MessageSourceService getMessageSourceService(); static SchedulerService getSchedulerService(); static AlertService getAlertService(); static ProgramWorkflowService getProgramWorkflowService(); static MessageService getMessageService(); static User getAuthenticatedUser(); static boolean isAuthenticated(); static void logout(); static Set<Role> getAllRoles(User user); static boolean hasPrivilege(String privilege); static void requirePrivilege(String privilege); static void addProxyPrivilege(String privilege); static void removeProxyPrivilege(String privilege); static void setLocale(Locale locale); static Locale getLocale(); static void openSession(); static void closeSession(); static void openSessionWithCurrentUser(); static void closeSessionWithCurrentUser(); static void clearSession(); static void flushSession(); static boolean isSessionOpen(); static void refreshEntity(Object obj); static void evictFromSession(Object obj); static synchronized void startup(Properties props); static synchronized void startup(String url, String username, String password, Properties properties); static void shutdown(); static T getService(Class<? extends T> cls); static void addAdvisor(Class cls, Advisor advisor); static void addAdvice(Class cls, Advice advice); static void removeAdvisor(Class cls, Advisor advisor); static void removeAdvice(Class cls, Advice advice); static void checkCoreDataset(); static void updateDatabase(Map<String, Object> userInput); static SimpleDateFormat getDateFormat(); static SimpleDateFormat getTimeFormat(); static SimpleDateFormat getDateTimeFormat(); static boolean isRefreshingContext(); static List<T> getRegisteredComponents(Class<T> type); static T getRegisteredComponent(String beanName, Class<T> type); static List<OpenmrsService> getModuleOpenmrsServices(String modulePackage); static VisitService getVisitService(); static ProviderService getProviderService(); static DatatypeService getDatatypeService(); static void addConfigProperty(Object key, Object value); static void removeConfigProperty(Object key); static Properties getConfigProperties(); static void updateSearchIndex(); static Future<?> updateSearchIndexAsync(); static void updateSearchIndexForType(Class<?> type); static void updateSearchIndexForObject(Object object); static void setUseSystemClassLoader(boolean useSystemClassLoader); static boolean isUseSystemClassLoader();  }### Answer:
@Test public void getRegisteredComponents_shouldReturnAListOfAllRegisteredBeansOfThePassedType() { List<Validator> validators = Context.getRegisteredComponents(Validator.class); Assert.assertTrue(validators.size() > 0); Assert.assertTrue(Validator.class.isAssignableFrom(validators.iterator().next().getClass())); }
@Test public void getRegisteredComponents_shouldReturnAnEmptyListIfNoBeansHaveBeenRegisteredOfThePassedType() { List<Location> l = Context.getRegisteredComponents(Location.class); Assert.assertNotNull(l); Assert.assertEquals(0, l.size()); }