Program: 110583
Project: 110583
Buggy source:
@Test public void testFilterLocalAndTransitive() throws Exception {
  Artifact localResourceToKeep=getResource("String_Node_Str");
  Artifact localResourceToDiscard=getResource("String_Node_Str");
  Artifact directResourceToKeep=getResource("String_Node_Str");
  Artifact directResourceToDiscard=getResource("String_Node_Str");
  Artifact transitiveResourceToKeep=getResource("String_Node_Str");
  Artifact transitiveResourceToDiscard=getResource("String_Node_Str");
  AndroidResources localResources=AndroidResources.forResources(errorConsumer,ImmutableList.of(localResourceToKeep,localResourceToDiscard),"String_Node_Str");
  ResourceDependencies resourceDependencies=ResourceDependencies.empty().withResources(getResourceContainers(ImmutableList.of(transitiveResourceToDiscard),ImmutableList.of(transitiveResourceToKeep)),getResourceContainers(ImmutableList.of(directResourceToDiscard),ImmutableList.of(directResourceToKeep)),new NestedSetBuilder<Artifact>(Order.NAIVE_LINK_ORDER).add(directResourceToDiscard).add(directResourceToKeep).addTransitive(NestedSetBuilder.create(Order.NAIVE_LINK_ORDER,transitiveResourceToDiscard,transitiveResourceToKeep)).build());
  ResourceFilterFactory resourceFilterFactory=makeResourceFilter("String_Node_Str","String_Node_Str",true);
  ResourceFilter filter=resourceFilterFactory.getResourceFilter(errorConsumer,resourceDependencies,localResources);
  assertThat(localResources.filterLocalResources(filter).getResources()).containsExactly(localResourceToKeep);
  ResourceDependencies filteredResourceDeps=resourceDependencies.filter(filter);
  assertThat(resourceDependencies.getTransitiveResources()).containsAllOf(directResourceToKeep,transitiveResourceToKeep).inOrder();
  assertThat(filteredResourceDeps.getTransitiveResources()).containsExactly(directResourceToKeep,transitiveResourceToKeep).inOrder();
  List<ResourceContainer> directContainers=filteredResourceDeps.getDirectResourceContainers().toList();
  assertThat(directContainers).hasSize(2);
  AndroidResources directToDiscard=directContainers.get(0).getResources();
  assertThat(directToDiscard.getResources()).isEmpty();
  assertThat(directToDiscard.getResourceRoots()).isEmpty();
  AndroidResources directToKeep=directContainers.get(1).getResources();
  assertThat(directToKeep.getResources()).containsExactly(directResourceToKeep);
  assertThat(directToKeep.getResourceRoots()).containsExactly(directResourceToKeep.getExecPath().getParentDirectory().getParentDirectory());
  List<ResourceContainer> transitiveContainers=filteredResourceDeps.getTransitiveResourceContainers().toList();
  assertThat(transitiveContainers).hasSize(2);
  AndroidResources transitiveToDiscard=transitiveContainers.get(0).getResources();
  assertThat(transitiveToDiscard.getResources()).isEmpty();
  assertThat(transitiveToDiscard.getResourceRoots()).isEmpty();
  AndroidResources transitiveToKeep=transitiveContainers.get(1).getResources();
  assertThat(transitiveToKeep.getResources()).containsExactly(transitiveResourceToKeep);
  assertThat(transitiveToKeep.getResourceRoots()).containsExactly(transitiveResourceToKeep.getExecPath().getParentDirectory().getParentDirectory());
  assertThat(resourceFilterFactory.getResourcesToIgnoreInExecution()).containsExactly("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Test public void testFilterLocalAndTransitive() throws Exception {
  Artifact localResourceToKeep=getResource("String_Node_Str");
  Artifact localResourceToDiscard=getResource("String_Node_Str");
  Artifact directResourceToKeep=getResource("String_Node_Str");
  Artifact directResourceToDiscard=getResource("String_Node_Str");
  Artifact transitiveResourceToKeep=getResource("String_Node_Str");
  Artifact transitiveResourceToDiscard=getResource("String_Node_Str");
  AndroidResources localResources=AndroidResources.forResources(errorConsumer,ImmutableList.of(localResourceToKeep,localResourceToDiscard),"String_Node_Str");
  ResourceDependencies resourceDependencies=ResourceDependencies.empty().withResources(getResourceContainers(ImmutableList.of(transitiveResourceToDiscard),ImmutableList.of(transitiveResourceToKeep)),getResourceContainers(ImmutableList.of(directResourceToDiscard),ImmutableList.of(directResourceToKeep)),new NestedSetBuilder<Artifact>(Order.NAIVE_LINK_ORDER).add(directResourceToDiscard).add(directResourceToKeep).addTransitive(NestedSetBuilder.create(Order.NAIVE_LINK_ORDER,transitiveResourceToDiscard,transitiveResourceToKeep)).build());
  ResourceFilterFactory resourceFilterFactory=makeResourceFilter("String_Node_Str","String_Node_Str",true);
  ResourceFilter filter=resourceFilterFactory.getResourceFilter(errorConsumer,resourceDependencies,localResources);
  assertThat(localResources.filterLocalResources(errorConsumer,filter).getResources()).containsExactly(localResourceToKeep);
  ResourceDependencies filteredResourceDeps=resourceDependencies.filter(errorConsumer,filter);
  assertThat(resourceDependencies.getTransitiveResources()).containsAllOf(directResourceToKeep,transitiveResourceToKeep).inOrder();
  assertThat(filteredResourceDeps.getTransitiveResources()).containsExactly(directResourceToKeep,transitiveResourceToKeep).inOrder();
  List<ResourceContainer> directContainers=filteredResourceDeps.getDirectResourceContainers().toList();
  assertThat(directContainers).hasSize(2);
  AndroidResources directToDiscard=directContainers.get(0).getResources();
  assertThat(directToDiscard.getResources()).isEmpty();
  assertThat(directToDiscard.getResourceRoots()).isEmpty();
  AndroidResources directToKeep=directContainers.get(1).getResources();
  assertThat(directToKeep.getResources()).containsExactly(directResourceToKeep);
  assertThat(directToKeep.getResourceRoots()).containsExactly(directResourceToKeep.getExecPath().getParentDirectory().getParentDirectory());
  List<ResourceContainer> transitiveContainers=filteredResourceDeps.getTransitiveResourceContainers().toList();
  assertThat(transitiveContainers).hasSize(2);
  AndroidResources transitiveToDiscard=transitiveContainers.get(0).getResources();
  assertThat(transitiveToDiscard.getResources()).isEmpty();
  assertThat(transitiveToDiscard.getResourceRoots()).isEmpty();
  AndroidResources transitiveToKeep=transitiveContainers.get(1).getResources();
  assertThat(transitiveToKeep.getResources()).containsExactly(transitiveResourceToKeep);
  assertThat(transitiveToKeep.getResourceRoots()).containsExactly(transitiveResourceToKeep.getExecPath().getParentDirectory().getParentDirectory());
  assertThat(resourceFilterFactory.getResourcesToIgnoreInExecution()).containsExactly("String_Node_Str","String_Node_Str");
}