AutocompletionAgent { public List<String> getSchemaGroupList(String lookupGroupName, List<String> groupList) { List<String> res = groupList; Collection<String> schemaGroups = client.getSchemaGroups(); schemaGroups.forEach(gName -> { if (!res.contains(gName) && gName.contains(lookupGroupName)) { res.add(gName); } }); return res; } AutocompletionAgent(String serviceName, Map<String, String> configs);  AutocompletionAgent(String serviceName, ISchemaRegistryClient client); HashMap<String, Object> connectionTest(); List<String> getSchemaGroupList(String lookupGroupName, List<String> groupList); List<String> getSchemaMetadataList(String lookupSchemaMetadataName,
                                              List<String> schemaGroupList,
                                              List<String> schemaMetadataList); List<String> getBranchList(String lookupBranchName,
                                      List<String> groupList,
                                      List<String> schemaList,
                                      List<String> branchList); @Override String toString();  }
@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); List<String> initialGroups = new ArrayList<>(); List<String> res = autocompletionAgent.getSchemaGroupList("tesSome", initialGroups); assertEquals(0, res.size()); 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 = 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 = 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)); }