@Test
public void findByName() {

    // Mock process groups
    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);
    // Mock NiFi Process Groups REST client
    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));
    // Test finding process group by name
    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());
}