### Question:
WorkerRegistryV2 implements WorkerRegistry, WorkerEventSubscriber { @Override public Optional<Long> getAcceptedAt(WorkerId workerId) { if(logger.isDebugEnabled()) { logger.debug("In getAcceptedAt for worker {}", workerId); } Optional<JobId> jId = JobId.fromId(workerId.getJobId()); if(!jId.isPresent()) { return Optional.empty(); } List<IMantisWorkerMetadata> mantisWorkerMetadataList = jobToWorkerInfoMap.get(jId.get()); if(mantisWorkerMetadataList != null) { Optional<IMantisWorkerMetadata> mantisWorkerMetadata = mantisWorkerMetadataList.stream().filter(mData -> mData.getWorkerId().equals(workerId)).findAny(); if (mantisWorkerMetadata.isPresent()) { logger.info("Found worker {} return acceptedAt {}", workerId, mantisWorkerMetadata.get().getAcceptedAt()); return Optional.of(mantisWorkerMetadata.get().getAcceptedAt()); } } return Optional.empty(); } WorkerRegistryV2(); static Props props(); void clearState(); @Override int getNumRunningWorkers(); @Override Set<WorkerId> getAllRunningWorkers(); @Override Map<WorkerId, String> getAllRunningWorkerSlaveIdMappings(); @Override boolean isWorkerValid(WorkerId workerId); @Override Optional<Long> getAcceptedAt(WorkerId workerId); @Override void process(LifecycleEventsProto.WorkerListChangedEvent event); @Override void process(LifecycleEventsProto.JobStatusEvent statusEvent); static final WorkerRegistryV2 INSTANCE; }### Answer:
@Test public void testGetAcceptedAt() { WorkerRegistryV2 workerRegistryV2 = new WorkerRegistryV2(); initRegistryWithWorkers(workerRegistryV2,"testGetAcceptedAt-1", 5); Optional<Long> acceptedAt = workerRegistryV2.getAcceptedAt(new WorkerId("testGetAcceptedAt-1", 0, 5)); assertTrue(acceptedAt.isPresent()); assertEquals(new Long(0), acceptedAt.get()); acceptedAt = workerRegistryV2.getAcceptedAt(new WorkerId("testGetAcceptedAt-1",10,1)); assertFalse(acceptedAt.isPresent()); }