Search in sources :

Example 1 with RuleKeyFactory

use of com.facebook.buck.rules.keys.RuleKeyFactory in project buck by facebook.

the class RuleKeyTest method subclassWithNoopSetter.

@Test
public void subclassWithNoopSetter() {
    class NoopSetterRuleKeyBuilder extends UncachedRuleKeyBuilder {

        public NoopSetterRuleKeyBuilder(SourcePathRuleFinder ruleFinder, SourcePathResolver pathResolver, FileHashCache hashCache, RuleKeyFactory<RuleKey> defaultRuleKeyFactory) {
            super(ruleFinder, pathResolver, hashCache, defaultRuleKeyFactory);
        }

        @Override
        protected NoopSetterRuleKeyBuilder setSourcePath(SourcePath sourcePath) {
            return this;
        }
    }
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    FileHashCache hashCache = new FakeFileHashCache(ImmutableMap.of());
    RuleKeyFactory<RuleKey> ruleKeyFactory = new DefaultRuleKeyFactory(0, hashCache, pathResolver, ruleFinder);
    RuleKey nullRuleKey = new NoopSetterRuleKeyBuilder(ruleFinder, pathResolver, hashCache, ruleKeyFactory).build();
    RuleKey noopRuleKey = new NoopSetterRuleKeyBuilder(ruleFinder, pathResolver, hashCache, ruleKeyFactory).setReflectively("key", new FakeSourcePath("value")).build();
    assertThat(noopRuleKey, is(equalTo(nullRuleKey)));
}
Also used : NullFileHashCache(com.facebook.buck.util.cache.NullFileHashCache) FakeFileHashCache(com.facebook.buck.testutil.FakeFileHashCache) DefaultFileHashCache(com.facebook.buck.util.cache.DefaultFileHashCache) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) FileHashCache(com.facebook.buck.util.cache.FileHashCache) DefaultRuleKeyFactory(com.facebook.buck.rules.keys.DefaultRuleKeyFactory) FakeFileHashCache(com.facebook.buck.testutil.FakeFileHashCache) UncachedRuleKeyBuilder(com.facebook.buck.rules.keys.UncachedRuleKeyBuilder) DefaultRuleKeyFactory(com.facebook.buck.rules.keys.DefaultRuleKeyFactory) RuleKeyFactory(com.facebook.buck.rules.keys.RuleKeyFactory) Test(org.junit.Test)

Aggregations

DefaultRuleKeyFactory (com.facebook.buck.rules.keys.DefaultRuleKeyFactory)1 RuleKeyFactory (com.facebook.buck.rules.keys.RuleKeyFactory)1 UncachedRuleKeyBuilder (com.facebook.buck.rules.keys.UncachedRuleKeyBuilder)1 FakeFileHashCache (com.facebook.buck.testutil.FakeFileHashCache)1 DefaultFileHashCache (com.facebook.buck.util.cache.DefaultFileHashCache)1 FileHashCache (com.facebook.buck.util.cache.FileHashCache)1 NullFileHashCache (com.facebook.buck.util.cache.NullFileHashCache)1 StackedFileHashCache (com.facebook.buck.util.cache.StackedFileHashCache)1 Test (org.junit.Test)1