@Test
public void getSchemaGroupList() {

    ISchemaRegistryClient client = new DefaultSchemaRegistryClientForTesting(){
        public List<String> getSchemaGroups() {
            List<String> groups = new ArrayList<>();
            groups.add("testGroup");
            return groups;
        }
    };
    AutocompletionAgent autocompletionAgent =
            new AutocompletionAgent("schema-registry", client);
    // Empty initialGroups and the list of groups returned by ISchemaRegistryClient
    // doesn't contain any groups that starts with 'tesSome'
    List<String> initialGroups = new ArrayList<>();
    List<String> res = autocompletionAgent.getSchemaGroupList("tesSome", initialGroups);
    assertEquals(0, res.size());
    // Empty initialGroups and the list of groups returned by ISchemaRegistryClient
    // contains a group that starts with 'tes'
    initialGroups = new ArrayList<>();
    res = autocompletionAgent.getSchemaGroupList("tes", initialGroups);
    List<String>  expected = new ArrayList<>();
    expected.add("testGroup");
    assertEquals(1, res.size());
    assertThat(res, is(expected));
    // initialGroups contains one element, list of the groups returned by ISchemaRegistryClient
    // contains the same values that are already present in initialGroups
    initialGroups = new ArrayList<>();
    initialGroups.add("testGroup");
    res = autocompletionAgent.getSchemaGroupList("tes", initialGroups);
    expected = new ArrayList<>();
    expected.add("testGroup");
    assertEquals(1, res.size());
    assertThat(res, is(expected));
    // initialGroups contains one element, list of the groups returned by ISchemaRegistryClient
    // contains one element too, that is not equal to the element in initialGroups
    initialGroups = new ArrayList<>();
    initialGroups.add("testGroup2");
    res = autocompletionAgent.getSchemaGroupList("tes", initialGroups);
    expected = new ArrayList<>();
    expected.add("testGroup2");
    expected.add("testGroup");
    assertEquals(2, res.size());
    assertThat(res, is(expected));
}