public static List<String> resolveCompsDependency(Service service) {
    List<String> components = new ArrayList<String>();
    for (Component component : service.getComponents()) {
      int depSize = component.getDependencies().size();
      if (!components.contains(component.getName())) {
        components.add(component.getName());
      }
      if (depSize != 0) {
        for (String depComp : component.getDependencies()) {
          if (!components.contains(depComp)) {
            components.add(0, depComp);
          }
        }
      }
    }
    return components;
  }
@Test
  public void testResolveNoCompsDependency() {
    Service service = createExampleApplication();
    Component compa = createComponent("compa");
    Component compb = createComponent("compb");
    service.addComponent(compa);
    service.addComponent(compb);
    List<String> order = ServiceApiUtil.resolveCompsDependency(service);
    List<String> expected = new ArrayList<String>();
    expected.add("compa");
    expected.add("compb");
    for (int i = 0; i < expected.size(); i++) {
      Assert.assertEquals("Components are not equal.", expected.get(i),
          order.get(i));
    }
  }