@Test
public void testMapEventToJobLog() {

  List<Event> applicationEvents = eventBuilder();
  yarnConf.unset("yarn.nodemanager.webapp.address");
  List<JobLog> jobEvents =
      ParserUtils.mapEventToJobLog(applicationEvents, new JobLogMetaData(yarnConf, "testuser"));
  yarnConf.set("yarn.nodemanager.webapp.address", "0.0.0.0:8042");
  assertEquals(jobEvents.get(0).getLogLink(), DEFAULT_VALUE_OF_CONTAINER_LOG_LINK);
  yarnConf.set("yarn.nodemanager.webapp.address", "0.0.0.0:8042");
  jobEvents = ParserUtils.mapEventToJobLog(applicationEvents, new JobLogMetaData(yarnConf, "testuser"));
  assertEquals(jobEvents.get(0).getLogLink(),
      "http://fakehost2:8042/node/containerlogs/fakecontainerID/testuser");
  assertEquals(jobEvents.get(1).getLogLink(),
      "http://fakehost3:8042/node/containerlogs/fakecontainerID1/testuser");
  yarnConf.set("yarn.nodemanager.webapp.address", "0.0.0.0");
  jobEvents = ParserUtils.mapEventToJobLog(applicationEvents, new JobLogMetaData(yarnConf, "testuser"));
  assertEquals(jobEvents.get(0).getLogLink(), DEFAULT_VALUE_OF_CONTAINER_LOG_LINK);
  jobEvents = ParserUtils.mapEventToJobLog(applicationEvents, new JobLogMetaData(null, null));
  assertEquals(jobEvents.get(0).getLogLink(), DEFAULT_VALUE_OF_CONTAINER_LOG_LINK);
  assertEquals(jobEvents.get(1).getLogLink(), DEFAULT_VALUE_OF_CONTAINER_LOG_LINK);
  assertEquals("fakecontainerID",
      JobLog.convertEventToJobLog(applicationEvents.get(0), new JobLogMetaData(yarnConf, "testuser"))
          .getContainerID());
  assertEquals("fakecontainerID1",
      JobLog.convertEventToJobLog(applicationEvents.get(1), new JobLogMetaData(yarnConf, "testuser"))
          .getContainerID());
  assertNull(JobLog.convertEventToJobLog(applicationEvents.get(2), new JobLogMetaData(yarnConf, "testuser"))
      .getContainerID());
  assertNull(JobLog.convertEventToJobLog(applicationEvents.get(3), new JobLogMetaData(yarnConf, "testuser"))
      .getContainerID());
  //mock(ApplicationMaster)
}