### Question:
LogSearchConfigFactory { public static LogSearchConfigServer createLogSearchConfigServer(Map<String, String> properties, Class<? extends LogSearchConfigServer> defaultClass, boolean init) throws Exception { try { LogSearchConfigServer logSearchConfig = null; String configClassName = properties.get("logsearch.config.server.class"); if (configClassName != null && !"".equals(configClassName.trim())) { Class<?> clazz = Class.forName(configClassName); if (LogSearchConfigServer.class.isAssignableFrom(clazz)) { logSearchConfig = (LogSearchConfigServer) clazz.newInstance(); } else { throw new IllegalArgumentException("Class " + configClassName + " does not implement the interface " + LogSearchConfigServer.class.getName()); } } else { logSearchConfig = defaultClass.newInstance(); } if (init) { logSearchConfig.init(properties); } return logSearchConfig; } catch (Exception e) { LOG.error("Could not initialize logsearch config.", e); throw e; } }  static LogSearchConfigServer createLogSearchConfigServer(Map<String, String> properties,
      Class<? extends LogSearchConfigServer> defaultClass, boolean init); static LogSearchConfigLogFeeder createLogSearchConfigLogFeeder(Map<String, String> properties, String clusterName,
      Class<? extends LogSearchConfigLogFeeder> defaultClass, boolean init); static LogSearchConfigServer createLogSearchConfigServer(Map<String, String> properties,
                                                                  Class<? extends LogSearchConfigServer> defaultClass); static LogSearchConfigLogFeeder createLogSearchConfigLogFeeder(Map<String, String> properties, String clusterName,
      Class<? extends LogSearchConfigLogFeeder> defaultClass);  }### Answer:
@Test public void testDefaultConfigServer() throws Exception { LogSearchConfigServer config = LogSearchConfigFactory.createLogSearchConfigServer( Collections.<String, String> emptyMap(), LogSearchConfigServerClass1.class); Assert.assertSame(config.getClass(), LogSearchConfigServerClass1.class); }
@Test public void testCustomConfigServer() throws Exception { Map<String, String> logsearchConfClassMap = new HashMap<>(); logsearchConfClassMap.put("logsearch.config.server.class", "org.apache.ambari.logsearch.config.api.LogSearchConfigServerClass2"); LogSearchConfig config = LogSearchConfigFactory.createLogSearchConfigServer(logsearchConfClassMap, LogSearchConfigServerClass1.class); Assert.assertSame(config.getClass(), LogSearchConfigServerClass2.class); }
@Test(expected = IllegalArgumentException.class) public void testNonConfigClassServer() throws Exception { Map<String, String> logsearchConfClassMap = new HashMap<>(); logsearchConfClassMap.put("logsearch.config.server.class", "org.apache.ambari.logsearch.config.api.NonLogSearchConfigClass"); LogSearchConfigFactory.createLogSearchConfigServer(logsearchConfClassMap, LogSearchConfigServerClass1.class); }