### Question:
JobDetails implements Comparable<JobDetails> { Long getCounterValueAsLong(final CounterMap counters, final String counterGroupName, final String counterName) { Counter c1 = counters.getCounter(counterGroupName, counterName); if (c1 != null) { return c1.getValue(); } else { return 0L; } } @JsonCreator  JobDetails(@JsonProperty("jobKey") JobKey key); @Override boolean equals(Object other); @Override int compareTo(JobDetails otherJob); @Override int hashCode(); JobKey getJobKey(); String getJobId(); void setJobId(String jobId); String getJobName(); void setJobName(String jobName); String getUser(); void setUser(String user); String getPriority(); void setPriority(String priority); String getStatus(); void setStatus(String status); String getVersion(); void setVersion(String version); HadoopVersion getHadoopVersion(); void setHadoopVersion(String hadoopVersion); long getSubmitTime(); void setSubmitTime(long submitTime); Date getSubmitDate(); long getLaunchTime(); void setLaunchTime(long launchTime); Date getLaunchDate(); long getFinishTime(); void setFinishTime(long finishTime); Date getFinishDate(); long getRunTime(); long getTotalMaps(); void setTotalMaps(long totalMaps); long getTotalReduces(); void setTotalReduces(long totalReduces); long getFinishedMaps(); void setFinishedMaps(long finishedMaps); long getFinishedReduces(); void setFinishedReduces(long finishedReduces); long getFailedMaps(); void setFailedMaps(long failedMaps); long getFailedReduces(); void setFailedReduces(long failedReduces); long getMapFileBytesRead(); void setMapFileBytesRead(long mapFileBytesRead); long getMapFileBytesWritten(); void setMapFileBytesWritten(long mapBytesWritten); long getHdfsBytesRead(); long getMapSlotMillis(); void setMapSlotMillis(long mapSlotMillis); long getReduceSlotMillis(); void setReduceSlotMillis(long reduceSlotMillis); long getReduceShuffleBytes(); void setReduceShuffleBytes(long reduceShuffleBytes); long getReduceFileBytesRead(); void setReduceFileBytesRead(long reduceFileBytesRead); long getHdfsBytesWritten(); void setHdfsBytesWritten(long hdfsBytesWritten); void setHdfsBytesRead(long hdfsBytesRead); long getMegabyteMillis(); void setMegabyteMillis(long megabyteMillis); double getCost(); void setCost(double cost); void addTask(TaskDetails task); void addTasks(List<TaskDetails> tasks); List<TaskDetails> getTasks(); String getQueue(); void setQueue(String queue); Configuration getConfiguration(); CounterMap getCounters(); CounterMap getMapCounters(); CounterMap getReduceCounters(); @Deprecated void setTasks(List<TaskDetails> newTasks); void populate(Result result);  }### Answer:
@Test public void testGetCounterValueAsLong() { CounterMap cm = new CounterMap(); String cg = Constants.FILESYSTEM_COUNTERS; String cname = Constants.FILES_BYTES_READ; Long expValue = 1234L; Counter c1 = new Counter(cg, cname, expValue); cm.add(c1); JobDetails jd = new JobDetails(null); assertEquals(expValue, jd.getCounterValueAsLong(cm, cg, cname)); Long zeroValue = 0L; assertEquals(zeroValue, jd.getCounterValueAsLong(cm, Constants.JOB_COUNTER_HADOOP2, Constants.SLOTS_MILLIS_MAPS)); }