@Test
public void testSummaryTreeNodeWithAndWithoutSources() throws Exception {

  DetailsTypes.PlatformDetailsType platformDetailsType = AndroidSdkHandler.getRepositoryModule().createLatestFactory()
    .createPlatformDetailsType();
  FakePackage.FakeRemotePackage platformPackage = new FakePackage.FakeRemotePackage("platform");
  FakePackage.FakeLocalPackage localPlatfromPackage = new FakePackage.FakeLocalPackage("platform");
  platformPackage.setTypeDetails((TypeDetails)platformDetailsType);
  localPlatfromPackage.setTypeDetails((TypeDetails)platformDetailsType);
  UpdatablePackage updatablePlatformPackage = new UpdatablePackage(localPlatfromPackage, platformPackage);
  DetailsTreeNode platformNode = new DetailsTreeNode(new PackageNodeModel(updatablePlatformPackage), null,
                                                     myConfigurable);
  Set<UpdaterTreeNode> nodes = ImmutableSet.of(platformNode);
  SummaryTreeNode node = SummaryTreeNode.createNode(new AndroidVersion(17, null), nodes);
  assertEquals("Installed", node.getStatusString());
  // Now create the sources node and add it without a local package - should imply partial installation status.
  DetailsTypes.SourceDetailsType sourceDetailsType = AndroidSdkHandler.getRepositoryModule().createLatestFactory()
    .createSourceDetailsType();
  FakePackage.FakeRemotePackage sourcesPackage = new FakePackage.FakeRemotePackage("sources");
  sourcesPackage.setTypeDetails((TypeDetails)sourceDetailsType);
  UpdatablePackage updatableSourcesPackage = new UpdatablePackage(sourcesPackage);
  DetailsTreeNode sourcesNode = new DetailsTreeNode(new PackageNodeModel(updatableSourcesPackage), null, myConfigurable);
  nodes = ImmutableSet.of(platformNode, sourcesNode);
  node = SummaryTreeNode.createNode(new AndroidVersion(17, null), nodes);
  assertEquals("Partially installed", node.getStatusString());
  // Now test that both platform and sources installed imply the full installation status.
  FakePackage.FakeLocalPackage localSourcesPackage = new FakePackage.FakeLocalPackage("sources");
  localSourcesPackage.setTypeDetails((TypeDetails)sourceDetailsType);
  updatableSourcesPackage = new UpdatablePackage(localSourcesPackage, sourcesPackage);
  sourcesNode = new DetailsTreeNode(new PackageNodeModel(updatableSourcesPackage), null, myConfigurable);
  nodes = ImmutableSet.of(platformNode, sourcesNode);
  node = SummaryTreeNode.createNode(new AndroidVersion(17, null), nodes);
  assertEquals("Installed", node.getStatusString());
}