Exemple #1
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.
    }
  }
Exemple #2
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)
    }
  }
Exemple #3
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.
    }
  }
Exemple #4
0
  @Test
  public void withNullConfiguration_BasicAccessors() throws Exception {
    Dependency nullDep = Dependency.withNullConfiguration(Label.parseAbsolute("//a"));

    assertThat(nullDep.getLabel()).isEqualTo(Label.parseAbsolute("//a"));
    assertThat(nullDep.hasStaticConfiguration()).isTrue();
    assertThat(nullDep.getConfiguration()).isNull();
    assertThat(nullDep.getAspects()).isEmpty();
    assertThat(nullDep.getAspectConfigurations()).isEmpty();

    try {
      nullDep.getTransition();
      fail("withNullConfiguration-created Dependencies should throw ISE on getTransition()");
    } catch (IllegalStateException ex) {
      // good. expected.
    }
  }
Exemple #5
0
 @Override
 public ConfiguredTargetKey apply(Dependency input) {
   return new ConfiguredTargetKey(input.getLabel(), input.getConfiguration());
 }