public void testUpdateModuleInstances() throws Exception {
    // Update modules API in behaviour will return a
    // CloudFoundryApplicationModule for an existing Cloud application in
    // the Cloud Space. This associated update modules for the Cloud Foundry
    // Server
    // which the behaviour uses is tested separately in a different test
    // case

    String prefix = "testUpdateModuleInstances";
    String expectedAppName = harness.getDefaultWebAppName(prefix);

    // Create the app externally AFTER the server connects in the setup to
    // ensure the tools did not pick up the Cloud application during refresh
    CloudFoundryOperations client = harness.createExternalClient();
    client.login();

    List<String> urls = new ArrayList<String>();
    urls.add(harness.getExpectedDefaultURL(prefix));
    client.createApplication(
        expectedAppName, new Staging(), CloudUtil.DEFAULT_MEMORY, urls, new ArrayList<String>());

    CloudFoundryApplicationModule appModule = cloudServer.getExistingCloudModule(expectedAppName);
    // Tooling has not yet been updated so there is no corresponding
    // appModule even though the app exists in the Cloud space
    assertNull(appModule);

    // This will tell the behaviour to fetch the Cloud application from the
    // Cloud space and generate a module
    CloudFoundryApplicationModule updateModule =
        serverBehavior.updateCloudModuleWithInstances(expectedAppName, new NullProgressMonitor());
    assertEquals(expectedAppName, updateModule.getDeployedApplicationName());
    assertEquals(
        updateModule.getDeployedApplicationName(), updateModule.getApplication().getName());

    // Check the mapping is correct
    assertEquals(updateModule.getName(), updateModule.getApplication().getName());
    assertEquals(CloudUtil.DEFAULT_MEMORY, updateModule.getApplication().getMemory());
    assertEquals(
        updateModule.getDeploymentInfo().getMemory(), updateModule.getApplication().getMemory());
    assertEquals(1, updateModule.getInstanceCount());

    // There is one instance, but since the app was created EXTERNALLY and
    // not started, there should
    // be no instance info
    assertEquals(0, updateModule.getApplicationStats().getRecords().size());
    assertNull(updateModule.getInstancesInfo());

    updateModule =
        serverBehavior.updateCloudModuleWithInstances((String) null, new NullProgressMonitor());
    assertNull(updateModule);

    updateModule =
        serverBehavior.updateCloudModuleWithInstances("wrongName", new NullProgressMonitor());
    assertNull(updateModule);

    updateModule =
        serverBehavior.updateCloudModuleWithInstances((IModule) null, new NullProgressMonitor());
    assertNull(updateModule);
  }