Package com.google.collide.dto

Examples of com.google.collide.dto.WorkspaceInfo


     * their associated tree nodes.
     */
    final JsonStringMap<WorkspaceNode> idToNode = JsonCollections.createMap();
    final JsonArray<WorkspaceNode> rootNodes = JsonCollections.createArray();
    for (int i = 0; i < workspaces.size(); i++) {
      WorkspaceInfo value = workspaces.get(i);
      WorkspaceNode node = new WorkspaceNode(value);
      rootNodes.add(node);
      idToNode.put(value.getId(), node);
    }

    /*
     * Iterate over the list of workspaces and add each workspace as a child of
     * its parent.
     */
    int count = rootNodes.size();
    for (int i = 0; i < count; i++) {
      WorkspaceNode node = rootNodes.get(i);
      WorkspaceInfo workspace = node.getWorkspace();
      WorkspaceNode parentNode = idToNode.get(workspace.getParentId());
      if (parentNode != null) {
        parentNode.addChild(node);

        // This node has a parent, so it is not a root node.
        rootNodes.remove(i);
View Full Code Here


public class WorkspaceUtilsTests extends TestCase {

  public void testGetWorkspaceHierarchy() {
    // Create a list of workspaces.
    JsonArray<WorkspaceInfo> workspaces = JsonCollections.createArray();
    WorkspaceInfo a = makeWorkspace("a", null);
    WorkspaceInfo b = makeWorkspace("b", null);
    WorkspaceInfo aa = makeWorkspace("aa", a);
    WorkspaceInfo ab = makeWorkspace("ab", a);
    WorkspaceInfo ac = makeWorkspace("ac", a);
    WorkspaceInfo aaa = makeWorkspace("aaa", aa);
    WorkspaceInfo aab = makeWorkspace("aab", aa);
    WorkspaceInfo aac = makeWorkspace("aac", aa);
    workspaces.add(aa);
    workspaces.add(ab);
    workspaces.add(aab);
    workspaces.add(ac);
    workspaces.add(aac);
    workspaces.add(b);
    workspaces.add(aaa);
    workspaces.add(a);

    // Add an element with a parent that is not mapped.
    WorkspaceInfo zaa = makeWorkspace("zaa", makeWorkspace("unmapped", null));
    workspaces.add(zaa);

    // Create an unsorted hierarchy.
    JsonArray<WorkspaceNode> roots =
        WorkspaceUtils.getWorkspaceHierarchy(workspaces, new Comparator<WorkspaceInfo>() {
View Full Code Here

   * Test {@link WorkspaceUtils#getWorkspaceHierarchy} if one of
   * the workspaces refers to a parent that is not mapped.
   */
  public void testGetWorkspaceHierarchyNonExistentParent() {
    JsonArray<WorkspaceInfo> workspaces = JsonCollections.createArray();
    WorkspaceInfo unmapped = makeWorkspace("unmapped", null);
    workspaces.add(makeWorkspace("b", unmapped));
    workspaces.add(makeWorkspace("a", null));
    workspaces.add(makeWorkspace("c", null));

    JsonArray<WorkspaceNode> roots = WorkspaceUtils.getWorkspaceHierarchy(workspaces);
View Full Code Here

  }

  public void testGetWorkspaceHierarchySorted() {
    // Create a list of workspaces.
    JsonArray<WorkspaceInfo> workspaces = JsonCollections.createArray();
    WorkspaceInfo a = makeWorkspace("a", null);
    WorkspaceInfo b = makeWorkspace("b", null);
    WorkspaceInfo aa = makeWorkspace("aa", a);
    WorkspaceInfo ab = makeWorkspace("ab", a);
    WorkspaceInfo ac = makeWorkspace("ac", a);
    WorkspaceInfo aaa = makeWorkspace("aaa", aa);
    WorkspaceInfo aab = makeWorkspace("aab", aa);
    WorkspaceInfo aac = makeWorkspace("aac", aa);
    workspaces.add(aa);
    workspaces.add(ab);
    workspaces.add(aab);
    workspaces.add(ac);
    workspaces.add(aac);
    workspaces.add(b);
    workspaces.add(aaa);
    workspaces.add(a);

    // Add an element with a parent that is not mapped.
    WorkspaceInfo zaa = makeWorkspace("zaa", makeWorkspace("unmapped", null));
    workspaces.add(zaa);

    // Create a sorted hierarchy.
    JsonArray<WorkspaceNode> roots =
        WorkspaceUtils.getWorkspaceHierarchy(workspaces, new Comparator<WorkspaceInfo>() {
View Full Code Here

   * sorts the root nodes.
   */
  public void testGetWorkspaceHierarchySortedRoots() {
    // Create a list of workspaces.
    JsonArray<WorkspaceInfo> workspaces = JsonCollections.createArray();
    WorkspaceInfo a = makeWorkspace("a", null);
    WorkspaceInfo b = makeWorkspace("b", null);
    WorkspaceInfo c = makeWorkspace("c", null);
    workspaces.add(b);
    workspaces.add(a);
    workspaces.add(c);

    // Create a sorted hierarchy.
View Full Code Here

  public void testWorkspaceNodeAddChild() {
    WorkspaceNode parentNode = makeWorkspaceNode("parent", null);
    assertEquals(0, parentNode.getChildCount());

    WorkspaceInfo child0 = makeWorkspace("child0", parentNode.getWorkspace());
    WorkspaceNode childNode0 = new WorkspaceNode(child0);
    parentNode.addChild(childNode0);
    assertEquals(1, parentNode.getChildCount());
    assertEquals(childNode0, parentNode.getChild(0));

    WorkspaceInfo child1 = makeWorkspace("child1", parentNode.getWorkspace());
    WorkspaceNode childNode1 = new WorkspaceNode(child1);
    parentNode.addChild(childNode1);
    assertEquals(2, parentNode.getChildCount());
    assertEquals(childNode0, parentNode.getChild(0));
    assertEquals(childNode1, parentNode.getChild(1));
View Full Code Here

    int size = expected.length;
    assertEquals("Size mismatch", size, node.getChildCount());

    // Check the values.
    for (int i = 0; i < size; i++) {
      WorkspaceInfo toFind = expected[i];
      boolean found = false;
      for (int j = 0; j < size; j++) {
        if (node.getChild(i).getWorkspace() == toFind) {
          found = true;
          break;
View Full Code Here

    }
    return ws;
  }

  private WorkspaceNode makeWorkspaceNode(String id, WorkspaceNode parent) {
    WorkspaceInfo parentWs = (parent == null) ? null : parent.getWorkspace();
    WorkspaceInfo ws = makeWorkspace(id, parentWs);
    WorkspaceNode node = new WorkspaceNode(ws);
    if (parent != null) {
      parent.addChild(node);
    }
    return node;
View Full Code Here

TOP

Related Classes of com.google.collide.dto.WorkspaceInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.