### Question:
Cache { public String getAliadaClassFrom(final String crmClass) { String uri = null; if (crmClass != null) { uri = crm2AliadaClasses.get(crmClass); if (uri == null) { uri = rdfStore.crm2AliadaClass(crmClass); } } return uri != null ? uri : DEFAULT_ALIADA_CLASS; }  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 crmClassFoundInCache() { final String aClassThatIsInCache = cut.crm2AliadaClasses.keySet().iterator().next(); final String expectedResult = cut.crm2AliadaClasses.get(aClassThatIsInCache); assertEquals( expectedResult, cut.getAliadaClassFrom(aClassThatIsInCache)); verifyZeroInteractions(dao); }
@Test public void crmClassNotFoundInCacheButFoundInRDFStore() { final String aClassThatIsNotInCache = randomString(); final String expectedResult = randomString(); when(dao.crm2AliadaClass(aClassThatIsNotInCache)).thenReturn(expectedResult); assertEquals( expectedResult, cut.getAliadaClassFrom(aClassThatIsNotInCache)); verify(dao).crm2AliadaClass(aClassThatIsNotInCache); }
@Test public void crmClassNotFound() { final String aClassThatIsNotInCache = randomString(); when(dao.crm2AliadaClass(aClassThatIsNotInCache)).thenReturn(null); assertEquals( Cache.DEFAULT_ALIADA_CLASS, cut.getAliadaClassFrom(aClassThatIsNotInCache)); verify(dao).crm2AliadaClass(aClassThatIsNotInCache); }