### Question:
GuidePostsCacheProvider { @VisibleForTesting GuidePostsCacheFactory loadAndGetGuidePostsCacheFactory(String classString) { Preconditions.checkNotNull(classString); if (guidePostsCacheFactory == null) { try { Class clazz = Class.forName(classString); if (!GuidePostsCacheFactory.class.isAssignableFrom(clazz)) { String msg = String.format( "Could not load/instantiate class %s is not an instance of GuidePostsCacheFactory", classString); LOGGER.error(msg); throw new PhoenixNonRetryableRuntimeException(msg); } List<GuidePostsCacheFactory> factoryList = InstanceResolver.get(GuidePostsCacheFactory.class, null); for (GuidePostsCacheFactory factory : factoryList) { if (clazz.isInstance(factory)) { guidePostsCacheFactory = factory; LOGGER.info(String.format("Sucessfully loaded class for GuidePostsCacheFactor of type: %s", classString)); break; } } if (guidePostsCacheFactory == null) { String msg = String.format("Could not load/instantiate class %s", classString); LOGGER.error(msg); throw new PhoenixNonRetryableRuntimeException(msg); } } catch (ClassNotFoundException e) { LOGGER.error(String.format("Could not load/instantiate class %s", classString), e); throw new PhoenixNonRetryableRuntimeException(e); } } return guidePostsCacheFactory; }  GuidePostsCacheWrapper getGuidePostsCache(String classStr, ConnectionQueryServices queryServices,
            Configuration config);  }### Answer:
@Test(expected = java.lang.NullPointerException.class) public void loadAndGetGuidePostsCacheFactoryNullStringFailure(){ helper.loadAndGetGuidePostsCacheFactory(null); }
@Test(expected = PhoenixNonRetryableRuntimeException.class) public void loadAndGetGuidePostsCacheFactoryBadStringFailure(){ helper.loadAndGetGuidePostsCacheFactory("not a class"); }
@Test(expected = PhoenixNonRetryableRuntimeException.class) public void loadAndGetGuidePostsCacheFactoryNonImplementingClassFailure(){ helper.loadAndGetGuidePostsCacheFactory(Object.class.getTypeName()); }
@Test public void loadAndGetGuidePostsCacheFactoryTestFactory(){ GuidePostsCacheFactory factory = helper.loadAndGetGuidePostsCacheFactory( TestGuidePostsCacheFactory.class.getTypeName()); assertTrue(factory instanceof TestGuidePostsCacheFactory); }
@Test public void getSingletonSimpleTest(){ GuidePostsCacheFactory factory1 = helper.loadAndGetGuidePostsCacheFactory( TestGuidePostsCacheFactory.class.getTypeName()); assertTrue(factory1 instanceof TestGuidePostsCacheFactory); GuidePostsCacheFactory factory2 = helper.loadAndGetGuidePostsCacheFactory( TestGuidePostsCacheFactory.class.getTypeName()); assertTrue(factory2 instanceof TestGuidePostsCacheFactory); assertEquals(factory1,factory2); assertEquals(1,TestGuidePostsCacheFactory.count); }