@Test
 public void shouldInstanciateDependency() {
   MainActivityComponent component = DaggerMainActivityComponent.create();
   Dependency dependency = component.dependency();
   assertThat(dependency).isNotNull();
   assertThat(dependency.which()).isEqualTo("anonymous");
 }
  public WikiName next() {
    Dependency result = _next;

    skip();

    return result.getWikiName();
  }
Example #3
0
  private Map<String, List<Dependency>> specifyDeps(List<CloudApplication> apps) {
    Map<String, List<Dependency>> deps = new HashMap<String, List<Dependency>>();

    Scanner reader = new Scanner(System.in);

    while (true) {
      // System.out.println("Specify Dependency Using format A->B  (A depends on B)?(Y/N)");
      // FIXME: more robust input handling
      String line = reader.nextLine();
      if (line.isEmpty()) {
        break;
      }
      String[] ab = line.split("->");

      Dependency dep = new Dependency();
      CloudApplication sourceApp = apps.get(Integer.parseInt(ab[0]) - 1);

      dep.setSource(sourceApp);
      dep.setTarget(apps.get(Integer.parseInt(ab[1]) - 1));

      List<Dependency> list = deps.get(sourceApp.getName());
      if (list == null) {
        list = new ArrayList<Dependency>();
        deps.put(sourceApp.getName(), list);
      }
      list.add(dep);
      System.out.println(
          "Generate the depends-on relationship in application model according to the manually-defined dependency");
    }

    return deps;
  }
Example #4
0
 @Override
 public int compareTo(Dependency o) {
   int compare = getName().compareTo(o.getName());
   if (compare == 0) {
     compare = getShuffleType().compareTo(o.getShuffleType());
   }
   return compare;
 }
  public Collection<String> getBuildDependencyPatterns() {

    Collection<String> dependencies = new ArrayList<String>();
    for (Dependency buildDependency : buildDependencies) {
      dependencies.add(buildDependency.getPattern());
    }
    return dependencies;
  }
Example #6
0
 public boolean canExecute() {
   for (Dependency dependency : dependencies) {
     if (!dependency.canExecute()) {
       return false;
     }
   }
   return true;
 }
  /** Format deadlock displaying to a user. */
  public static String prettyFormat(Collection<Dependency> deadlock) {
    StringBuilder text = new StringBuilder();
    LinkedHashSet<LocalThread> threads = new LinkedHashSet<LocalThread>();

    Set<Object> seenDependers = new HashSet<>();
    Object lastDependsOn = text;
    Object lastDepender = text;

    for (Dependency dep : deadlock) {
      Object depender = dep.getDepender();
      Object dependsOn = dep.getDependsOn();

      String dependerString;
      if (lastDependsOn.equals(depender)) {
        dependerString = "which";
      } else if (lastDepender.equals(depender)) {
        dependerString = "and";
      } else {
        dependerString = String.valueOf(depender);
      }
      lastDepender = depender;
      lastDependsOn = dependsOn;

      String also = seenDependers.contains(depender) ? " also" : "";
      seenDependers.add(depender);

      if (depender instanceof LocalThread) {
        text.append(dependerString)
            .append(" is")
            .append(also)
            .append(" waiting on ")
            .append(dependsOn)
            .append("\n");
        threads.add((LocalThread) depender);
      } else if (dependsOn instanceof LocalThread) {
        text.append(dependerString).append(" is held by thread ").append(dependsOn).append("\n");
        threads.add((LocalThread) dependsOn);
      } else {
        text.append(dependerString)
            .append(" is")
            .append(also)
            .append(" waiting for ")
            .append(dependsOn)
            .append("\n");
      }
      text.append("\n");
    }

    text.append("\nStack traces for involved threads\n");
    for (LocalThread threadInfo : threads) {
      text.append(threadInfo.getLocatility())
          .append(":")
          .append(threadInfo.getThreadStack())
          .append("\n\n");
    }

    return text.toString();
  }
Example #8
0
 public List<Dependency> getUnsatisfiedDependencies(String plugin) {
   List<Dependency> deps = new ArrayList<Dependency>();
   for (Dependency dep : getDependencies(plugin)) {
     if (!dep.isInstalled() || dep.isUpgrade()) {
       deps.add(dep);
     }
   }
   return deps;
 }
  @Test
  public void importMockInReusableVerificationBlock() {
    new ReusableExpectations() {};

    dependency.notifyBeforeSave();
    dependency.save();

    new ReusableVerifications() {};
  }
Example #10
0
 private <T> void addDependency(ServiceBuilder<?> builder, Dependency<T> dependency) {
   final ServiceName name = dependency.getName();
   final Injector<T> injector = dependency.getInjector();
   if (injector != null) {
     builder.addDependency(name, dependency.getType(), injector);
   } else {
     builder.addDependency(name);
   }
 }
Example #11
0
 @Override
 protected List<Dependency> constructDependencies() {
   final List<Dependency> dependencies = constructDynamicChildrenDependencies();
   for (Dependency dependency : dependencies) {
     if (dependency.getOther() == getTarget()) {
       dependency.setMandatory(true);
     }
   }
   return dependencies;
 }
Example #12
0
  @Test
  public void testConstructWithCustomTypeAndScope() {
    // Set up
    final Dependency dependency =
        new Dependency(
            DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, DEPENDENCY_VERSION, ZIP, PROVIDED);

    // Invoke and check
    assertEquals(ZIP, dependency.getType());
    assertEquals(PROVIDED, dependency.getScope());
  }
 @Test
 public void shouldInstanciateAnotherDependency() {
   Dependency dependency =
       DaggerMainActivityComponent.builder()
           .mainActivityModule(new TestModule())
           .build()
           .controller()
           .getDependency();
   assertThat(dependency).isNotNull();
   assertThat(dependency.which()).isEqualTo("impl");
 }
  @Test(expected = UnexpectedInvocation.class)
  public void verifyAllWithUnverifiedReplayOnSameInstance(final Dependency mock2) {
    mock.editABunchMoreStuff();
    mock2.editABunchMoreStuff();

    new FullVerifications(mock2) {
      {
        mock.editABunchMoreStuff();
      }
    };
  }
Example #15
0
 private void genAppDepRelation(AppModel model, Map<String, List<Dependency>> deps) {
   for (List<Dependency> list : deps.values()) {
     for (Dependency dep : list) {
       Relationship r = new Relationship();
       r.setSourceNode(dep.getSource().getName());
       r.setTargetNode(dep.getTarget().getName());
       r.setType(RelationshipType.dependsOn);
       model.addRelationship(r);
     }
   }
 }
Example #16
0
 @Test
 public void withTransitionAndAspects_AllowsEmptyAspectSet() throws Exception {
   update();
   Dependency dep =
       Dependency.withTransitionAndAspects(
           Label.parseAbsolute("//a"),
           ConfigurationTransition.HOST,
           ImmutableSet.<AspectDescriptor>of());
   // Here we're also checking that this doesn't throw an exception. No boom? OK. Good.
   assertThat(dep.getAspects()).isEmpty();
 }
Example #17
0
 public void addDC(Dependency d) {
   if (!(d.getConclusion() instanceof NullFormula)) {
     throw new ParserException("DC must have no conclusion");
   }
   IDatabase source = task.getSource();
   List<String> sourceTables = source.getTableNames();
   IDatabase target = task.getTarget();
   List<String> targetTables = target.getTableNames();
   checkAtomsForDCs(sourceTables, targetTables, d.getPremise());
   this.dcs.add(d);
 }
Example #18
0
 public Dependency getDependency(String artifactId) {
   if (this.dependencies == null || this.dependencies.size() == 0) {
     return null;
   }
   for (Dependency depend : this.dependencies) {
     if (artifactId.equals(depend.getArtifactId())) {
       return depend;
     }
   }
   return null;
 }
Example #19
0
 @Test
 public void withConfiguredAspects_AllowsEmptyAspectMap() throws Exception {
   update();
   Dependency dep =
       Dependency.withConfiguredAspects(
           Label.parseAbsolute("//a"),
           getTargetConfiguration(),
           ImmutableMap.<AspectDescriptor, BuildConfiguration>of());
   // Here we're also checking that this doesn't throw an exception. No boom? OK. Good.
   assertThat(dep.getAspects()).isEmpty();
   assertThat(dep.getAspectConfigurations()).isEmpty();
 }
 public List<String> buildProject(List<ProjectType> projects, List<Dependency> dependencies) {
   List<String> incompatibilities = new ArrayList<String>();
   for (Dependency dep : dependencies) {
     for (ProjectType type : projects) {
       dep.getDependencies(type);
       incompatibilities.addAll(dep.getIncompatibilities(type));
     }
   }
   this.modules = projects;
   this.dependencies = dependencies;
   return incompatibilities;
 }
Example #21
0
  @Test
  public void testNullDependencyDoesNotHaveSameCoordinates() {
    // Set up
    final Dependency dependency =
        new Dependency(DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, DEPENDENCY_VERSION);

    // Invoke
    final boolean same = dependency.hasSameCoordinates(null);

    // Check
    assertFalse(same);
  }
Example #22
0
  @Test
  public void testGetElementForMinimalDependency() {
    // Set up
    final Dependency dependency =
        new Dependency(DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, DEPENDENCY_VERSION);

    // Invoke
    final Element element = dependency.getElement(DOCUMENT_BUILDER.newDocument());

    // Check
    assertXmlEquals(EXPECTED_ELEMENT_FOR_MINIMAL_DEPENDENCY, element);
  }
Example #23
0
 public boolean isDepended(String artifactId, String version) {
   if (this.dependencies == null || this.dependencies.size() == 0) {
     return false;
   }
   for (Dependency depend : this.dependencies) {
     if (artifactId.equals(depend.getArtifactId())) {
       if (version == null || version.equals(depend.getVersion())) {
         return true;
       }
     }
   }
   return false;
 }
 @Test
 public void shouldUseMockDependency() {
   Dependency mock = Mockito.mock(Dependency.class);
   when(mock.which()).thenReturn("mock");
   Dependency dependency =
       DaggerMainActivityComponent.builder()
           .mainActivityModule(new TestModule(mock))
           .build()
           .controller()
           .getDependency();
   assertThat(dependency).isNotNull();
   assertThat(dependency.which()).isEqualTo("mock");
 }
Example #25
0
  @Test
  public void testAddExclusion() {
    // Set up
    final Dependency dependency =
        new Dependency(DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, DEPENDENCY_VERSION);
    final int originalExclusionCount = dependency.getExclusions().size();

    // Invoke
    dependency.addExclusion(EXCLUSION_GROUP_ID, EXCLUSION_ARTIFACT_ID);

    // Check
    assertEquals(originalExclusionCount + 1, dependency.getExclusions().size());
  }
Example #26
0
  @Test
  public void withConfigurationAndAspects_BasicAccessors() throws Exception {
    update();
    AspectDescriptor simpleAspect = new AspectDescriptor(TestAspects.SIMPLE_ASPECT);
    AspectDescriptor attributeAspect = new AspectDescriptor(TestAspects.ATTRIBUTE_ASPECT);
    ImmutableSet<AspectDescriptor> twoAspects = ImmutableSet.of(simpleAspect, attributeAspect);
    Dependency targetDep =
        Dependency.withConfigurationAndAspects(
            Label.parseAbsolute("//a"), getTargetConfiguration(), twoAspects);

    assertThat(targetDep.getLabel()).isEqualTo(Label.parseAbsolute("//a"));
    assertThat(targetDep.hasStaticConfiguration()).isTrue();
    assertThat(targetDep.getConfiguration()).isEqualTo(getTargetConfiguration());
    assertThat(targetDep.getAspects()).containsExactlyElementsIn(twoAspects);
    assertThat(targetDep.getAspectConfigurations())
        .containsExactlyEntriesIn(
            ImmutableMap.of(
                simpleAspect, getTargetConfiguration(),
                attributeAspect, getTargetConfiguration()));

    try {
      targetDep.getTransition();
      fail("withConfigurationAndAspects-created Dependencies should throw ISE on getTransition()");
    } catch (IllegalStateException ex) {
      // good. that's what I WANTED to happen.
    }
  }
Example #27
0
  @Test
  public void withTransitionAndAspects_BasicAccessors() throws Exception {
    AspectDescriptor simpleAspect = new AspectDescriptor(TestAspects.SIMPLE_ASPECT);
    AspectDescriptor attributeAspect = new AspectDescriptor(TestAspects.ATTRIBUTE_ASPECT);
    ImmutableSet<AspectDescriptor> twoAspects = ImmutableSet.of(simpleAspect, attributeAspect);
    Dependency hostDep =
        Dependency.withTransitionAndAspects(
            Label.parseAbsolute("//a"), ConfigurationTransition.HOST, twoAspects);

    assertThat(hostDep.getLabel()).isEqualTo(Label.parseAbsolute("//a"));
    assertThat(hostDep.hasStaticConfiguration()).isFalse();
    assertThat(hostDep.getAspects()).containsExactlyElementsIn(twoAspects);
    assertThat(hostDep.getTransition()).isEqualTo(ConfigurationTransition.HOST);

    try {
      hostDep.getConfiguration();
      fail("withTransitionAndAspects-created Dependencies should throw ISE on getConfiguration()");
    } catch (IllegalStateException ex) {
      // good. I knew you would do that.
    }

    try {
      hostDep.getAspectConfigurations();
      fail(
          "withTransitionAndAspects-created Dependencies should throw ISE on "
              + "getAspectConfigurations()");
    } catch (IllegalStateException ex) {
      // good. you're so predictable.
    }
  }
Example #28
0
  @Test
  public void withConfiguredAspects_BasicAccessors() throws Exception {
    update();
    AspectDescriptor simpleAspect = new AspectDescriptor(TestAspects.SIMPLE_ASPECT);
    AspectDescriptor attributeAspect = new AspectDescriptor(TestAspects.ATTRIBUTE_ASPECT);
    ImmutableMap<AspectDescriptor, BuildConfiguration> twoAspectMap =
        ImmutableMap.of(
            simpleAspect, getTargetConfiguration(), attributeAspect, getHostConfiguration());
    Dependency targetDep =
        Dependency.withConfiguredAspects(
            Label.parseAbsolute("//a"), getTargetConfiguration(), twoAspectMap);

    assertThat(targetDep.getLabel()).isEqualTo(Label.parseAbsolute("//a"));
    assertThat(targetDep.hasStaticConfiguration()).isTrue();
    assertThat(targetDep.getConfiguration()).isEqualTo(getTargetConfiguration());
    assertThat(targetDep.getAspects())
        .containsExactlyElementsIn(ImmutableSet.of(simpleAspect, attributeAspect));
    assertThat(targetDep.getAspectConfigurations()).containsExactlyEntriesIn(twoAspectMap);

    try {
      targetDep.getTransition();
      fail("withConfiguredAspects-created Dependencies should throw ISE on getTransition()");
    } catch (IllegalStateException ex) {
      // good. all according to keikaku. (TL note: keikaku means plan)
    }
  }
Example #29
0
  @Test
  public void getDbModule() {
    final Module module = DataModelFactory.createModule("root", "1.0.0-SNAPSHOT");
    final Artifact artifact =
        DataModelFactory.createArtifact(
            "com.axway.root", "artifact1", "1.0.0-SNAPSHOT", "win", "component", "jar");
    module.addArtifact(artifact);

    final Artifact thirdparty =
        DataModelFactory.createArtifact("org.apache", "all", "6.8.0-5426", "", "", "jar");
    final Dependency dependency = DataModelFactory.createDependency(thirdparty, Scope.COMPILE);
    module.addDependency(dependency);

    final Module submodule = DataModelFactory.createModule("sub1", "1.0.0-SNAPSHOT");
    final Artifact artifact2 =
        DataModelFactory.createArtifact(
            "com.axway.root.sub1", "artifactSub1", "1.0.0-SNAPSHOT", "", "", "jar");
    submodule.addArtifact(artifact2);
    final Artifact thirdparty2 =
        DataModelFactory.createArtifact("org.lol", "all", "1.2.3-4", "", "", "jar");
    final Dependency dependency2 = DataModelFactory.createDependency(thirdparty2, Scope.PROVIDED);
    submodule.addDependency(dependency2);
    module.addSubmodule(submodule);

    final ModelMapper modelMapper = new ModelMapper(mock(RepositoryHandler.class));
    final DbModule dbModule = modelMapper.getDbModule(module);
    assertEquals(module.getName(), dbModule.getName());
    assertEquals(module.getVersion(), dbModule.getVersion());
    assertEquals(1, dbModule.getArtifacts().size());
    assertEquals(artifact.getGavc(), dbModule.getArtifacts().get(0));
    assertEquals(1, dbModule.getDependencies().size());
    assertEquals(thirdparty.getGavc(), dbModule.getDependencies().get(0).getTarget());
    assertEquals(
        DbModule.generateID(module.getName(), module.getVersion()),
        dbModule.getDependencies().get(0).getSource());
    assertEquals(dependency.getScope(), dbModule.getDependencies().get(0).getScope());
    assertEquals(1, dbModule.getSubmodules().size());

    final DbModule dbSubmodule = dbModule.getSubmodules().get(0);
    assertEquals(submodule.getName(), dbSubmodule.getName());
    assertEquals(submodule.getVersion(), dbSubmodule.getVersion());
    assertEquals(1, dbSubmodule.getArtifacts().size());
    assertEquals(artifact2.getGavc(), dbSubmodule.getArtifacts().get(0));
    assertEquals(1, dbSubmodule.getDependencies().size());
    assertEquals(thirdparty2.getGavc(), dbSubmodule.getDependencies().get(0).getTarget());
    assertEquals(
        DbModule.generateID(submodule.getName(), submodule.getVersion()),
        dbSubmodule.getDependencies().get(0).getSource());
    assertEquals(dependency2.getScope(), dbSubmodule.getDependencies().get(0).getScope());
  }
Example #30
0
  private static void updateDependencies(
      final DependencyStructure other,
      final UnifyingSubstitution substitution,
      final Set<UnresolvedDependency> newUnresolvedDependencies,
      final List<UnlabelledDependency> newResolvedDependencies) {
    for (final UnresolvedDependency dep : other.unresolvedDependencies) {
      final Dependency updated = substitution.applyTo(dep);

      if (updated.isResolved()) {
        newResolvedDependencies.add((UnlabelledDependency) updated);
      } else {
        newUnresolvedDependencies.add((UnresolvedDependency) updated);
      }
    }
  }