@Test
@SneakyThrows
public void shouldGroupJobsBySource() {

  Store store =
      DataGenerator.createStore(
          "test", Store.StoreType.REDIS, ImmutableList.of(Triple.of("project1", "*", false)));
  Source source1 = DataGenerator.createSource("servers:9092", "topic");
  Source source2 = DataGenerator.createSource("others.servers:9092", "topic");
  FeatureSet featureSet1 = DataGenerator.createFeatureSet(source1, "project1", "fs1");
  FeatureSet featureSet2 = DataGenerator.createFeatureSet(source2, "project1", "fs2");
  when(specService.listFeatureSets(
          CoreServiceProto.ListFeatureSetsRequest.newBuilder()
              .setFilter(
                  Filter.newBuilder().setFeatureSetName("*").setProject("project1").build())
              .build()))
      .thenReturn(
          ListFeatureSetsResponse.newBuilder()
              .addAllFeatureSets(Lists.newArrayList(featureSet1, featureSet2))
              .build());
  when(specService.listStores(any()))
      .thenReturn(ListStoresResponse.newBuilder().addStore(store).build());
  ArrayList<Pair<Source, Set<Store>>> pairs =
      Lists.newArrayList(controllerWithConsolidation.getSourceToStoreMappings());
  assertThat(pairs, hasSize(2));
  assertThat(pairs, hasItem(Pair.of(source1, Sets.newHashSet(store))));
  assertThat(pairs, hasItem(Pair.of(source2, Sets.newHashSet(store))));
}