@Test
public void testGetAvailable() throws Exception {

  AmbariMetaInfo ami = injector.getInstance(AmbariMetaInfo.class);
  // ensure that all of the latest repo retrieval tasks have completed
  StackManager sm = ami.getStackManager();
  int maxWait = 15000;
  int waitTime = 0;
  while (waitTime < maxWait && ! sm.haveAllRepoUrlsBeenResolved()) {
    Thread.sleep(5);
    waitTime += 5;
  }
  if (waitTime >= maxWait) {
    fail("Latest Repo tasks did not complete");
  }
  Authentication authentication = TestAuthenticationFactory.createAdministrator();
  SecurityContextHolder.getContext().setAuthentication(authentication);
  final ResourceProvider versionProvider = new VersionDefinitionResourceProvider();
  Request getRequest = PropertyHelper.getReadRequest("VersionDefinition");
  Predicate predicate = new PredicateBuilder().property(
      VersionDefinitionResourceProvider.SHOW_AVAILABLE).equals("true").toPredicate();
  Set<Resource> results = versionProvider.getResources(getRequest, predicate);
  Assert.assertEquals(2, results.size());
  boolean found1 = false;
  boolean found2 = false;
  for (Resource res : results) {
    if ("HDP-2.2.0-2.2.1.0".equals(res.getPropertyValue("VersionDefinition/id"))) {
      Assert.assertEquals(Boolean.FALSE, res.getPropertyValue("VersionDefinition/stack_default"));
      found1 = true;
    } else if ("HDP-2.2.0".equals(res.getPropertyValue("VersionDefinition/id"))) {
      Assert.assertEquals(Boolean.TRUE, res.getPropertyValue("VersionDefinition/stack_default"));
      VersionDefinitionXml vdf = ami.getVersionDefinition("HDP-2.2.0");
      Assert.assertNotNull(vdf);
      Assert.assertEquals(2, vdf.repositoryInfo.getOses().size());
      String family1 = vdf.repositoryInfo.getOses().get(0).getFamily();
      String family2 = vdf.repositoryInfo.getOses().get(1).getFamily();
      Assert.assertFalse(family1.equals(family2));
      Assert.assertTrue(Sets.newHashSet("suse11", "redhat6").contains(family1));
      Assert.assertTrue(Sets.newHashSet("suse11", "redhat6").contains(family2));
      found2 = true;
    }
  }
  Assert.assertTrue(found1);
  Assert.assertTrue(found2);
}