### Question:
RestAuthCallbackHandlerFactory { public <T extends Callback> RestAuthCallbackHandler getRestAuthCallbackHandler(Class<T> callbackClass) throws RestAuthException { if (HiddenValueCallback.class.isAssignableFrom(callbackClass)) { return new RestAuthHiddenValueCallbackHandler(); } else if (NameCallback.class.isAssignableFrom(callbackClass)) { return new RestAuthNameCallbackHandler(); } else if (PasswordCallback.class.isAssignableFrom(callbackClass)) { return new RestAuthPasswordCallbackHandler(); } else if (ChoiceCallback.class.isAssignableFrom(callbackClass)) { return new RestAuthChoiceCallbackHandler(); } else if (ConfirmationCallback.class.isAssignableFrom(callbackClass)) { return new RestAuthConfirmationCallbackHandler(); } else if (HttpCallback.class.isAssignableFrom(callbackClass)) { return new RestAuthHttpCallbackHandler(); } else if (LanguageCallback.class.isAssignableFrom(callbackClass)) { return new RestAuthLanguageCallbackHandler(); } else if (RedirectCallback.class.isAssignableFrom(callbackClass)) { return new RestAuthRedirectCallbackHandler(); } else if (TextInputCallback.class.isAssignableFrom(callbackClass)) { return new RestAuthTextInputCallbackHandler(); } else if (TextOutputCallback.class.isAssignableFrom(callbackClass)) { return new RestAuthTextOutputCallbackHandler(); } else if (X509CertificateCallback.class.isAssignableFrom(callbackClass)) { return new RestAuthX509CallbackHandler(); } DEBUG.error(MessageFormat.format("Unsupported Callback, {0}", callbackClass.getSimpleName())); throw new RestAuthException(ResourceException.INTERNAL_ERROR, MessageFormat.format("Unsupported Callback, {0}", callbackClass.getSimpleName())); } @Inject private  RestAuthCallbackHandlerFactory(); static RestAuthCallbackHandlerFactory getInstance(); RestAuthCallbackHandler getRestAuthCallbackHandler(Class<T> callbackClass);  }### Answer:
@Test public void shouldGetNameRestAuthCallbackHandler() throws RestAuthException { RestAuthCallbackHandler restAuthCallbackHandler = restAuthCallbackHandlerFactory.getRestAuthCallbackHandler( NameCallback.class); assertEquals(restAuthCallbackHandler.getClass(), RestAuthNameCallbackHandler.class); }
@Test public void shouldGetPasswordRestAuthCallbackHandler() throws RestAuthException { RestAuthCallbackHandler restAuthCallbackHandler = restAuthCallbackHandlerFactory.getRestAuthCallbackHandler( PasswordCallback.class); assertEquals(restAuthCallbackHandler.getClass(), RestAuthPasswordCallbackHandler.class); }
@Test (expectedExceptions = RestAuthException.class) public void shouldThrowExceptionWithUnknownCallback() throws RestAuthException { restAuthCallbackHandlerFactory.getRestAuthCallbackHandler(UnknownCallback.class); fail(); }