### Question:
LogSearchConfigFactory { public static LogSearchConfigLogFeeder createLogSearchConfigLogFeeder(Map<String, String> properties, String clusterName, Class<? extends LogSearchConfigLogFeeder> defaultClass, boolean init) throws Exception { try { LogSearchConfigLogFeeder logSearchConfig = null; String configClassName = properties.get("logsearch.config.logfeeder.class"); if (configClassName != null && !"".equals(configClassName.trim())) { Class<?> clazz = Class.forName(configClassName); if (LogSearchConfig.class.isAssignableFrom(clazz)) { logSearchConfig = (LogSearchConfigLogFeeder) clazz.newInstance(); } else { throw new IllegalArgumentException("Class " + configClassName + " does not implement the interface " + LogSearchConfigLogFeeder.class.getName()); } } else { logSearchConfig = defaultClass.newInstance(); } if (init) { logSearchConfig.init(properties, clusterName == null ? "null" : clusterName.toLowerCase()); } return logSearchConfig; } catch (Exception e) { logger.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 testDefaultConfigLogFeeder() throws Exception { LogSearchConfigLogFeeder config = LogSearchConfigFactory.createLogSearchConfigLogFeeder( Collections.<String, String> emptyMap(), null, LogSearchConfigLogFeederClass1.class); Assert.assertSame(config.getClass(), LogSearchConfigLogFeederClass1.class); }
@Test public void testCustomConfigLogFeeder() throws Exception { Map<String, String> logsearchConfClassMap = new HashMap<>(); logsearchConfClassMap.put("logsearch.config.logfeeder.class", "org.apache.ambari.logsearch.config.api.LogSearchConfigLogFeederClass2"); LogSearchConfigLogFeeder config = LogSearchConfigFactory.createLogSearchConfigLogFeeder(logsearchConfClassMap, null, LogSearchConfigLogFeederClass1.class); Assert.assertSame(config.getClass(), LogSearchConfigLogFeederClass2.class); }
@Test(expected = IllegalArgumentException.class) public void testNonConfigClassLogFeeder() throws Exception { Map<String, String> logsearchConfClassMap = new HashMap<>(); logsearchConfClassMap.put("logsearch.config.logfeeder.class", "org.apache.ambari.logsearch.config.api.NonLogSearchConfigClass"); LogSearchConfigFactory.createLogSearchConfigLogFeeder(logsearchConfClassMap, null, LogSearchConfigLogFeederClass1.class); }