Program: 52994
Project: 52994
Buggy source:
@Test public void testCacheStoresAndFetchHits() throws IOException {
  Path cacheDir=tmpDir.newFolder();
  Path fileX=tmpDir.newFile("String_Node_Str");
  Path fileY=tmpDir.newFile("String_Node_Str");
  Path fileZ=tmpDir.newFile("String_Node_Str");
  fileHashCache=new FakeFileHashCache(ImmutableMap.of(fileX,HashCode.fromInt(0),fileY,HashCode.fromInt(1),fileZ,HashCode.fromInt(2)));
  dirArtifactCache=new DirArtifactCache("String_Node_Str",new ProjectFilesystem(cacheDir),Paths.get("String_Node_Str"),true,Optional.empty());
  Files.write(fileX,"String_Node_Str".getBytes(UTF_8));
  Files.write(fileY,"String_Node_Str".getBytes(UTF_8));
  Files.write(fileZ,"String_Node_Str".getBytes(UTF_8));
  BuildRule inputRuleX=new BuildRuleForTest(fileX);
  BuildRule inputRuleY=new BuildRuleForTest(fileY);
  BuildRule inputRuleZ=new BuildRuleForTest(fileZ);
  assertFalse(inputRuleX.equals(inputRuleY));
  assertFalse(inputRuleX.equals(inputRuleZ));
  assertFalse(inputRuleY.equals(inputRuleZ));
  BuildRuleResolver ruleResolver=new BuildRuleResolver(TargetGraph.EMPTY,new DefaultTargetNodeToBuildRuleTransformer());
  ruleResolver.addToIndex(inputRuleX);
  ruleResolver.addToIndex(inputRuleY);
  ruleResolver.addToIndex(inputRuleZ);
  SourcePathRuleFinder ruleFinder=new SourcePathRuleFinder(ruleResolver);
  SourcePathResolver resolver=new SourcePathResolver(ruleFinder);
  DefaultRuleKeyFactory fakeRuleKeyFactory=new DefaultRuleKeyFactory(0,fileHashCache,resolver,ruleFinder);
  RuleKey ruleKeyX=fakeRuleKeyFactory.build(inputRuleX);
  RuleKey ruleKeyY=fakeRuleKeyFactory.build(inputRuleY);
  RuleKey ruleKeyZ=fakeRuleKeyFactory.build(inputRuleZ);
  assertEquals(CacheResultType.MISS,dirArtifactCache.fetch(ruleKeyX,LazyPath.ofInstance(fileX)).getType());
  assertEquals(CacheResultType.MISS,dirArtifactCache.fetch(ruleKeyY,LazyPath.ofInstance(fileY)).getType());
  assertEquals(CacheResultType.MISS,dirArtifactCache.fetch(ruleKeyZ,LazyPath.ofInstance(fileZ)).getType());
  dirArtifactCache.store(ArtifactInfo.builder().addRuleKeys(ruleKeyX).build(),BorrowablePath.notBorrowablePath(fileX));
  dirArtifactCache.store(ArtifactInfo.builder().addRuleKeys(ruleKeyY).build(),BorrowablePath.notBorrowablePath(fileY));
  dirArtifactCache.store(ArtifactInfo.builder().addRuleKeys(ruleKeyZ).build(),BorrowablePath.notBorrowablePath(fileZ));
  Files.delete(fileX);
  Files.delete(fileY);
  Files.delete(fileZ);
  assertEquals(CacheResultType.HIT,dirArtifactCache.fetch(ruleKeyX,LazyPath.ofInstance(fileX)).getType());
  assertEquals(CacheResultType.HIT,dirArtifactCache.fetch(ruleKeyY,LazyPath.ofInstance(fileY)).getType());
  assertEquals(CacheResultType.HIT,dirArtifactCache.fetch(ruleKeyZ,LazyPath.ofInstance(fileZ)).getType());
  assertEquals(inputRuleX,new BuildRuleForTest(fileX));
  assertEquals(inputRuleY,new BuildRuleForTest(fileY));
  assertEquals(inputRuleZ,new BuildRuleForTest(fileZ));
  ImmutableList<Path> cachedFiles=ImmutableList.copyOf(dirArtifactCache.getAllFilesInCache());
  assertEquals(6,cachedFiles.size());
  ImmutableSet<String> filenames=cachedFiles.stream().map(input -> input.getFileName().toString()).collect(MoreCollectors.toImmutableSet());
  for (  RuleKey ruleKey : ImmutableSet.of(ruleKeyX,ruleKeyY,ruleKeyZ)) {
    filenames.contains(ruleKey.toString());
    filenames.contains(ruleKey.toString() + "String_Node_Str");
  }
}

Fixed version (ground truth):
@Test public void testCacheStoresAndFetchHits() throws IOException {
  Path cacheDir=tmpDir.newFolder();
  Path fileX=tmpDir.newFile("String_Node_Str");
  Path fileY=tmpDir.newFile("String_Node_Str");
  Path fileZ=tmpDir.newFile("String_Node_Str");
  fileHashCache=new FakeFileHashCache(ImmutableMap.of(fileX,HashCode.fromInt(0),fileY,HashCode.fromInt(1),fileZ,HashCode.fromInt(2)));
  dirArtifactCache=new DirArtifactCache("String_Node_Str",new ProjectFilesystem(cacheDir),Paths.get("String_Node_Str"),true,Optional.empty());
  Files.write(fileX,"String_Node_Str".getBytes(UTF_8));
  Files.write(fileY,"String_Node_Str".getBytes(UTF_8));
  Files.write(fileZ,"String_Node_Str".getBytes(UTF_8));
  BuildRule inputRuleX=new BuildRuleForTest(fileX);
  BuildRule inputRuleY=new BuildRuleForTest(fileY);
  BuildRule inputRuleZ=new BuildRuleForTest(fileZ);
  assertFalse(inputRuleX.equals(inputRuleY));
  assertFalse(inputRuleX.equals(inputRuleZ));
  assertFalse(inputRuleY.equals(inputRuleZ));
  BuildRuleResolver ruleResolver=new BuildRuleResolver(TargetGraph.EMPTY,new DefaultTargetNodeToBuildRuleTransformer());
  ruleResolver.addToIndex(inputRuleX);
  ruleResolver.addToIndex(inputRuleY);
  ruleResolver.addToIndex(inputRuleZ);
  SourcePathRuleFinder ruleFinder=new SourcePathRuleFinder(ruleResolver);
  SourcePathResolver resolver=new SourcePathResolver(ruleFinder);
  DefaultRuleKeyFactory fakeRuleKeyFactory=new DefaultRuleKeyFactory(0,fileHashCache,resolver,ruleFinder);
  RuleKey ruleKeyX=fakeRuleKeyFactory.build(inputRuleX);
  RuleKey ruleKeyY=fakeRuleKeyFactory.build(inputRuleY);
  RuleKey ruleKeyZ=fakeRuleKeyFactory.build(inputRuleZ);
  assertEquals(CacheResultType.MISS,dirArtifactCache.fetch(ruleKeyX,LazyPath.ofInstance(fileX)).getType());
  assertEquals(CacheResultType.MISS,dirArtifactCache.fetch(ruleKeyY,LazyPath.ofInstance(fileY)).getType());
  assertEquals(CacheResultType.MISS,dirArtifactCache.fetch(ruleKeyZ,LazyPath.ofInstance(fileZ)).getType());
  dirArtifactCache.store(ArtifactInfo.builder().addRuleKeys(ruleKeyX).build(),BorrowablePath.notBorrowablePath(fileX));
  dirArtifactCache.store(ArtifactInfo.builder().addRuleKeys(ruleKeyY).build(),BorrowablePath.notBorrowablePath(fileY));
  dirArtifactCache.store(ArtifactInfo.builder().addRuleKeys(ruleKeyZ).build(),BorrowablePath.notBorrowablePath(fileZ));
  Files.delete(fileX);
  Files.delete(fileY);
  Files.delete(fileZ);
  assertEquals(CacheResultType.HIT,dirArtifactCache.fetch(ruleKeyX,LazyPath.ofInstance(fileX)).getType());
  assertEquals(CacheResultType.HIT,dirArtifactCache.fetch(ruleKeyY,LazyPath.ofInstance(fileY)).getType());
  assertEquals(CacheResultType.HIT,dirArtifactCache.fetch(ruleKeyZ,LazyPath.ofInstance(fileZ)).getType());
  assertEquals(inputRuleX,new BuildRuleForTest(fileX));
  assertEquals(inputRuleY,new BuildRuleForTest(fileY));
  assertEquals(inputRuleZ,new BuildRuleForTest(fileZ));
  ImmutableList<Path> cachedFiles=ImmutableList.copyOf(dirArtifactCache.getAllFilesInCache());
  assertEquals(6,cachedFiles.size());
  ImmutableSet<String> filenames=cachedFiles.stream().map(input -> input.getFileName().toString()).collect(MoreCollectors.toImmutableSet());
  for (  RuleKey ruleKey : ImmutableSet.of(ruleKeyX,ruleKeyY,ruleKeyZ)) {
    assertThat(filenames,Matchers.hasItem(ruleKey.toString()));
    assertThat(filenames,Matchers.hasItem(ruleKey.toString() + "String_Node_Str"));
  }
}