AutocompletionAgent { public List<String> getBranchList(String lookupBranchName, List<String> groupList, List<String> schemaList, List<String> branchList) { List<String> res = branchList; List<String> expandedSchemaList = schemaList.stream().flatMap( schemaName -> expandSchemaMetadataNameRegex(groupList, schemaName).stream()) .collect(Collectors.toList()); expandedSchemaList.forEach(schemaMetadataName -> { Collection<String> branches = client.getSchemaBranches(schemaMetadataName); branches.forEach(bName -> { if (!res.contains(bName) && bName.contains(lookupBranchName)) { res.add(bName); } }); }); 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 getBranchList() { ISchemaRegistryClient client = new DefaultSchemaRegistryClientForTesting(){ public List<String> getSchemaBranches(String schemaMetadataName) { if(!schemaMetadataName.equals("Schema1")) { return new ArrayList<>(); } List<String> branches = new ArrayList<>(); branches.add("testBranch"); return branches; } public List<String> getSchemaNames(List<String> schemaGroup) { if(!schemaGroup.contains("Group1")) { return new ArrayList<>(); } List<String> schemas = new ArrayList<>(); schemas.add("Schema1"); return schemas; } }; AutocompletionAgent autocompletionAgent = new AutocompletionAgent("schema-registry", client); List<String> schemaList = new ArrayList<>(); schemaList.add("Schema1"); schemaList.add("Schema2"); List<String> groups = new ArrayList<>(); groups.add("Group1"); List<String> res = autocompletionAgent.getBranchList("tes", groups, schemaList, new ArrayList<>()); List<String> expected = new ArrayList<>(); expected.add("testBranch"); assertEquals(1, res.size()); assertThat(res, is(expected)); res = autocompletionAgent.getSchemaMetadataList("tesSome", schemaList, new ArrayList<>()); assertEquals(0, res.size()); }