@Test
  public void testGetResources() throws Exception {
    RequestStatus status = testCreateResources();

    Set<Resource> createdResources = status.getAssociatedResources();
    assertEquals(1, createdResources.size());
    Resource res = createdResources.iterator().next();
    Long id = (Long) res.getPropertyValue("Upgrade/request_id");
    assertNotNull(id);
    assertEquals(Long.valueOf(1), id);

    // upgrade
    Set<String> propertyIds = new HashSet<>();
    propertyIds.add("Upgrade");

    Predicate predicate = new PredicateBuilder()
        .property(UpgradeResourceProvider.UPGRADE_REQUEST_ID).equals("1").and()
        .property(UpgradeResourceProvider.UPGRADE_CLUSTER_NAME).equals("c1")
        .toPredicate();
    Request request = PropertyHelper.getReadRequest(propertyIds);

    ResourceProvider upgradeResourceProvider = createProvider(amc);
    Set<Resource> resources = upgradeResourceProvider.getResources(request, predicate);

    assertEquals(1, resources.size());
    res = resources.iterator().next();
    assertNotNull(res.getPropertyValue("Upgrade/progress_percent"));
    assertNotNull(res.getPropertyValue(UpgradeResourceProvider.UPGRADE_DIRECTION));
    assertEquals(Direction.UPGRADE, res.getPropertyValue(UpgradeResourceProvider.UPGRADE_DIRECTION));
    assertEquals(false, res.getPropertyValue(UpgradeResourceProvider.UPGRADE_SKIP_FAILURES));
    assertEquals(false, res.getPropertyValue(UpgradeResourceProvider.UPGRADE_SKIP_SC_FAILURES));
    assertEquals(UpgradeType.ROLLING, res.getPropertyValue(UpgradeResourceProvider.UPGRADE_TYPE));

    // upgrade groups
    propertyIds.clear();
    propertyIds.add("UpgradeGroup");

    predicate = new PredicateBuilder()
        .property(UpgradeGroupResourceProvider.UPGRADE_REQUEST_ID).equals("1").and()
        .property(UpgradeGroupResourceProvider.UPGRADE_CLUSTER_NAME).equals("c1")
        .toPredicate();
    request = PropertyHelper.getReadRequest(propertyIds);

    ResourceProvider upgradeGroupResourceProvider = new UpgradeGroupResourceProvider(amc);
    resources = upgradeGroupResourceProvider.getResources(request, predicate);

    assertEquals(3, resources.size());
    res = resources.iterator().next();
    assertNotNull(res.getPropertyValue("UpgradeGroup/status"));
    assertNotNull(res.getPropertyValue("UpgradeGroup/group_id"));
    assertNotNull(res.getPropertyValue("UpgradeGroup/total_task_count"));
    assertNotNull(res.getPropertyValue("UpgradeGroup/in_progress_task_count"));
    assertNotNull(res.getPropertyValue("UpgradeGroup/completed_task_count"));

    // upgrade items
    propertyIds.clear();
    propertyIds.add("UpgradeItem");

    predicate = new PredicateBuilder()
        .property(UpgradeItemResourceProvider.UPGRADE_GROUP_ID).equals("1").and()
        .property(UpgradeItemResourceProvider.UPGRADE_REQUEST_ID).equals("1").and()
        .property(UpgradeItemResourceProvider.UPGRADE_CLUSTER_NAME).equals("c1")
        .toPredicate();
    request = PropertyHelper.getReadRequest(propertyIds);

    ResourceProvider upgradeItemResourceProvider = new UpgradeItemResourceProvider(amc);
    resources = upgradeItemResourceProvider.getResources(request, predicate);

    assertEquals(2, resources.size());

    res = resources.iterator().next();
    assertNotNull(res.getPropertyValue("UpgradeItem/status"));

    // !!! check for manual stage vs item text
    propertyIds.clear();
    propertyIds.add("UpgradeItem");

    predicate = new PredicateBuilder()
        .property(UpgradeItemResourceProvider.UPGRADE_GROUP_ID).equals("3").and()
        .property(UpgradeItemResourceProvider.UPGRADE_REQUEST_ID).equals("1").and()
        .property(UpgradeItemResourceProvider.UPGRADE_CLUSTER_NAME).equals("c1")
        .toPredicate();
    request = PropertyHelper.getReadRequest(propertyIds);

    upgradeItemResourceProvider = new UpgradeItemResourceProvider(amc);
    resources = upgradeItemResourceProvider.getResources(request, predicate);
    assertEquals(2, resources.size());
    res = resources.iterator().next();

    assertEquals("Confirm Finalize", res.getPropertyValue("UpgradeItem/context"));
    String msgStr = res.getPropertyValue("UpgradeItem/text").toString();
    JsonParser parser = new JsonParser();
    JsonArray msgArray = (JsonArray) parser.parse(msgStr);
    JsonObject msg = (JsonObject) msgArray.get(0);

    assertTrue(msg.get("message").getAsString().startsWith("Please confirm"));
  }
Obtain request id from the {@code RequestStatus}

@param requestStatus reqult of the {@code createResources}
@return id of the request
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java