### Question:
Cache { public JobInstance getJobInstance(final Integer id) { JobInstance instance = activeJobConfigurations.get(id); if (instance == null) { instance = jobInstanceRepository.findOne(id); if (instance != null) { adjustPrefixes(instance); activeJobConfigurations.put(id, instance); } } return instance; }  String getAliadaClassFrom(final String crmClass); Pattern getStartPattern(final String regex); Pattern getEndPattern(final String regex); String getAliadaEventTypeClassFrom(final String crmClass); JobInstance getJobInstance(final Integer id); void removeJobInstance(final Integer jobId);  }### Answer:
@Test public void jobConfigurationInCache() { final JobInstance configuration = newJobConfiguration(); cut.activeJobConfigurations.put(configuration.getId(), configuration); assertSame(configuration, cut.getJobInstance(configuration.getId())); assertEquals(configuration.getId(), cut.getJobInstance(configuration.getId()).getId()); verifyZeroInteractions(repository); }
@Test public void jobConfigurationNotInCache() { final JobInstance configuration = newJobConfiguration(); assertNull(cut.activeJobConfigurations.get(configuration.getId())); when(repository.findOne(configuration.getId())).thenReturn(configuration); assertSame(configuration, cut.getJobInstance(configuration.getId())); assertEquals(configuration.getId(), cut.getJobInstance(configuration.getId()).getId()); }
@Test public void jobConfigurationNotFound() { final JobInstance configuration = newJobConfiguration(); assertNull(cut.activeJobConfigurations.get(configuration.getId())); when(repository.findOne(configuration.getId())).thenReturn(null); assertNull(cut.getJobInstance(configuration.getId())); }