### Question:
JobDescFactoryBase { public String getAppId(Configuration jobConf) { if (jobConf == null) { return Constants.UNKNOWN; } String appId = jobConf.get(Constants.APP_NAME_CONF_KEY); if (StringUtils.isBlank(appId)) { appId = jobConf.get(Constants.JOB_NAME_CONF_KEY); if (StringUtils.isNotBlank(appId)) { appId = getAppIdFromJobName(appId); } else { appId = jobConf.get(Constants.JOB_NAME_HADOOP2_CONF_KEY); if (StringUtils.isNotBlank(appId)) { appId = getAppIdFromJobName(appId); } } } return cleanAppId(appId); } JobDescFactoryBase(); String getAppId(Configuration jobConf);  }### Answer:
@Test public void testgetAppId() { Configuration conf = new Configuration(); conf.set(Constants.APP_NAME_CONF_KEY, UNSAFE_NAME); assertEquals(SAFE_NAME, getAppId(conf)); }
@Test public void testgetAppIdHadoop2() { Configuration conf = new Configuration(); conf.set(Constants.JOB_NAME_CONF_KEY, ""); conf.set(Constants.APP_NAME_CONF_KEY, ""); conf.set(Constants.JOB_NAME_HADOOP2_CONF_KEY, "abc.def.xyz"); assertEquals("abc.def.xyz", getAppId(conf)); }