@Test
public void testMetricsLoaded() throws Exception {

  URL rootDirectoryURL = StackManagerTest.class.getResource("/");
  Assert.notNull(rootDirectoryURL);
  File resourcesDirectory = new File(new File(rootDirectoryURL.getFile()).getParentFile().getParentFile(), "src/main/resources");
  File stackRoot = new File(resourcesDirectory, "stacks");
  File commonServices = new File(resourcesDirectory, "common-services");
  File extensions = null;
  try {
       URL extensionsURL = ClassLoader.getSystemClassLoader().getResource("extensions");
    if (extensionsURL != null) {
      extensions = new File(extensionsURL.getPath().replace("test-classes","classes"));
    }
  }
  catch (Exception e) {}
  MetainfoDAO metaInfoDao = createNiceMock(MetainfoDAO.class);
  StackDAO stackDao = createNiceMock(StackDAO.class);
  ExtensionDAO extensionDao = createNiceMock(ExtensionDAO.class);
  ExtensionLinkDAO linkDao = createNiceMock(ExtensionLinkDAO.class);
  ActionMetadata actionMetadata = createNiceMock(ActionMetadata.class);
  Configuration config = createNiceMock(Configuration.class);
  ExtensionEntity extensionEntity = createNiceMock(ExtensionEntity.class);
  expect(config.getSharedResourcesDirPath()).andReturn(
          ClassLoader.getSystemClassLoader().getResource("").getPath()).anyTimes();
  expect(
      extensionDao.find(EasyMock.anyObject(String.class),
          EasyMock.anyObject(String.class))).andReturn(extensionEntity).atLeastOnce();
  List<ExtensionLinkEntity> list = Collections.emptyList();
  expect(
      linkDao.findByStack(EasyMock.anyObject(String.class),
          EasyMock.anyObject(String.class))).andReturn(list).atLeastOnce();
  replay(config, metaInfoDao, stackDao, extensionDao, linkDao, actionMetadata);
  OsFamily osFamily = new OsFamily(config);
  StackManager stackManager = new StackManager(stackRoot, commonServices, extensions,
          osFamily, false, metaInfoDao, actionMetadata, stackDao, extensionDao, linkDao);
  for (StackInfo stackInfo : stackManager.getStacks()) {
    for (ServiceInfo serviceInfo : stackInfo.getServices()) {
      Type type = new TypeToken<Map<String, Map<String, List<MetricDefinition>>>>() {
      }.getType();
      Gson gson = new Gson();
      Map<String, Map<String, List<MetricDefinition>>> map = null;
      if (serviceInfo.getMetricsFile() != null) {
        try {
          map = gson.fromJson(new FileReader(serviceInfo.getMetricsFile()), type);
        } catch (Exception e) {
          e.printStackTrace();
          throw new AmbariException("Failed to load metrics from file " + serviceInfo.getMetricsFile().getAbsolutePath());
        }
      }
    }
  }
}