### Question:
BasicGadgetAdminStore implements GadgetAdminStore { public boolean checkFeatureAdminInfo(Gadget gadget) { String container = getSafeContainerFromGadget(gadget); String gadgetUrl = getSafeGadgetUrlFromGadget(gadget); if (container == null || gadgetUrl == null) { return false; } if (!isFeatureAdminEnabled(container)) { return true; } GadgetContext context = gadget.getContext(); try { FeatureRegistry featureRegistry = featureRegistryProvider.get(context.getRepository()); if (!hasGadgetAdminData(container, gadgetUrl)) { return false; } FeatureAdminData featureAdminData = this.getGadgetAdminData(container, gadgetUrl) .getFeatureAdminData(); Set<String> features = featureAdminData.getFeatures(); if(featureAdminData.getType() == Type.WHITELIST) { features = Sets.newHashSet(featureRegistry.getFeatures(features)); } List<String> gadgetFeatures = featureRegistry.getFeatures(getRequiredGadgetFeatures(gadget)); return areAllFeaturesAllowed(Sets.immutableSet(features), gadgetFeatures, featureAdminData); } catch (GadgetException e) { LOG.log(Level.WARNING, "Exception while getting the FeatureRegistry."); return false; } } @Inject  BasicGadgetAdminStore(FeatureRegistryProvider featureRegistryProvider,
          ContainerConfig config, ServerAdminData serverAdminData); void init(String store); GadgetAdminData getGadgetAdminData(String container, String gadgetUrl); void setGadgetAdminData(String container, String gadgetUrl, GadgetAdminData adminData); ContainerAdminData getContainerAdminData(String container); void setContainerAdminData(String container, ContainerAdminData containerAdminData); ServerAdminData getServerAdminData(); boolean checkFeatureAdminInfo(Gadget gadget); boolean isAllowedFeature(Feature feature, Gadget gadget); boolean isWhitelisted(String container, String gadgetUrl); Set<String> getAdditionalRpcServiceIds(Gadget gadget);  }### Answer:
@Test public void testFeatureAdminNullGadgetData() throws Exception { List<String> gadgetRequiredFeatureNames = Lists.newArrayList("foo3", "foo4"); List<Feature> allFeatures = Lists.newArrayList( createMockFeature(gadgetRequiredFeatureNames.get(0), true), createMockFeature(gadgetRequiredFeatureNames.get(1), true)); mockGadget(allFeatures, DEFAULT, "https: replay(); assertFalse(enabledStore.checkFeatureAdminInfo(mockGadget)); assertTrue(disabledStore.checkFeatureAdminInfo(mockGadget)); verify(); }
@Test public void testFeatureAdminNullContainerData() throws Exception { List<String> gadgetRequiredFeatureNames = Lists.newArrayList("foo3", "foo4"); List<Feature> allFeatures = Lists.newArrayList( createMockFeature(gadgetRequiredFeatureNames.get(0), true), createMockFeature(gadgetRequiredFeatureNames.get(1), true)); mockGadget(allFeatures, "foocontainer"); replay(); assertFalse(enabledStore.checkFeatureAdminInfo(mockGadget)); assertTrue(disabledStore.checkFeatureAdminInfo(mockGadget)); verify(); }