### Question:
AbstractNiFiProcessGroupsRestClient implements NiFiProcessGroupsRestClient { @Nonnull @Override public Optional<ProcessGroupDTO> findByName(@Nonnull final String parentGroupId, @Nonnull final String groupName, final boolean recursive, final boolean verbose) { final Set<ProcessGroupDTO> children = findAll(parentGroupId); final ProcessGroupDTO group = NifiProcessUtil.findFirstProcessGroupByName(children, groupName); if (group != null && verbose) { return findById(group.getId(), recursive, true); } else { return Optional.ofNullable(group); } } AbstractNiFiProcessGroupsRestClient(NiFiRestClient client); @Nonnull @Override Optional<ProcessGroupDTO> delete(@Nonnull final ProcessGroupDTO processGroup); @Nonnull @Override Optional<ProcessGroupDTO> findByName(@Nonnull final String parentGroupId, @Nonnull final String groupName, final boolean recursive, final boolean verbose); boolean isRoot(String processGroupId); @Nonnull @Override ProcessGroupDTO findRoot();  }### Answer:
@Test public void findByName() { final ProcessGroupDTO group1 = new ProcessGroupDTO(); group1.setId("b179527b-0a7a-4ba8-9817-60f7a9ffb9d5"); group1.setName("group1"); final ProcessGroupDTO group2 = new ProcessGroupDTO(); group2.setId("7ba659c2-6ddd-4215-8709-1eafff04851d"); group2.setName("group2"); final ProcessGroupDTO group3 = new ProcessGroupDTO(); group3.setId("2dbcc8ce-a0e7-455c-9e3d-f4f82d08acc3"); group3.setName("group3"); final ProcessGroupDTO fullGroup2 = new ProcessGroupDTO(); fullGroup2.setId("7ba659c2-6ddd-4215-8709-1eafff04851d"); fullGroup2.setName("group2"); fullGroup2.setRunningCount(8); fullGroup2.setStoppedCount(0); final NiFiProcessGroupsRestClient client = Mockito.mock(AbstractNiFiProcessGroupsRestClient.class, Mockito.CALLS_REAL_METHODS); Mockito.when(client.findAll("parent")).thenReturn(ImmutableSet.of(group1, group2, group3)); Mockito.when(client.findById(group2.getId(), true, true)).thenReturn(Optional.of(fullGroup2)); Assert.assertEquals(group2, client.findByName("parent", "group2", false, false).get()); Assert.assertEquals(fullGroup2, client.findByName("parent", "group2", true, true).get()); Assert.assertFalse(client.findByName("parent", "invalid", false, false).isPresent()); Assert.assertFalse(client.findByName("parent", "invalid", true, true).isPresent()); }