private void testCreateResourcesExistingUpgrade(Authentication authentication) throws Exception {
    Cluster cluster = createNiceMock(Cluster.class);

    expect(managementController.getClusters()).andReturn(clusters).anyTimes();
    expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();

    expect(clusters.getCluster(anyObject(String.class))).andReturn(cluster);

    UpgradeEntity upgrade = new UpgradeEntity();
    upgrade.setDirection(Direction.UPGRADE);

    expect(cluster.getClusterName()).andReturn("c1").atLeastOnce();
    expect(cluster.getClusterId()).andReturn(1L).anyTimes();
    expect(cluster.getUpgradeInProgress()).andReturn(upgrade).once();

    // replay
    replay(managementController, clusters, cluster);

    ResourceProvider provider = createProvider(managementController);
    injector.injectMembers(provider);

    // add the property map to a set for the request.  add more maps for multiple creates
    Set<Map<String, Object>> propertySet = new LinkedHashSet<>();

    Map<String, Object> properties = new LinkedHashMap<>();

    // add properties to the request map
    properties.put(ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
    properties.put(ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_REPOSITORY_VERSION_PROPERTY_ID, "2.2.0.1-885");
    properties.put(ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_STACK_PROPERTY_ID, "HDP");
    properties.put(ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID, "2.1.1");

    propertySet.add(properties);

    // create the request
    Request request = PropertyHelper.getCreateRequest(propertySet, null);

    SecurityContextHolder.getContext().setAuthentication(authentication);

    try {
      provider.createResources(request);
      Assert.fail("Expecting the create to fail due to an already installed version");
    } catch (IllegalArgumentException iae) {
      // !!! expected
      Assert.assertEquals("Cluster c1 upgrade is in progress.  Cannot install packages.", iae.getMessage());
    }

    verify(cluster);

  }
Tests that forcing the host versions into
{@link RepositoryVersionState#INSTALLED}

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java