### Question:
AbstractNiFiProcessGroupsRestClient implements NiFiProcessGroupsRestClient { @Nonnull protected Optional<ProcessGroupDTO> deleteWithRetries(@Nonnull final ProcessGroupDTO processGroup, final int retries, final int timeout, @Nonnull final TimeUnit timeUnit) { schedule(processGroup.getId(), processGroup.getParentGroupId(), NiFiComponentState.STOPPED); Exception lastError = null; for (int count = 0; count <= retries; ++count) { try { return doDelete(processGroup); } catch (final WebApplicationException e) { if (e.getResponse().getStatus() == 409) { lastError = e; Uninterruptibles.sleepUninterruptibly(timeout, timeUnit); } else { throw new NifiClientRuntimeException(e); } } } throw new NifiClientRuntimeException("Unable to delete process group: " + processGroup.getId(), lastError); } 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 deleteWithRetries() { final ProcessGroupDTO group = new ProcessGroupDTO(); group.setId("d526adec-1f33-463b-8570-e9cf3e6c8703"); group.setParentGroupId("93b1abbb-f805-4f52-8a9e-ffdab224dc44"); final AbstractNiFiProcessGroupsRestClient client = Mockito.mock(AbstractNiFiProcessGroupsRestClient.class, Mockito.CALLS_REAL_METHODS); Mockito.when(client.doDelete(group)).thenThrow(new ClientErrorException(409)).thenReturn(Optional.empty()); Assert.assertEquals(Optional.empty(), client.deleteWithRetries(group, 1, 0, TimeUnit.NANOSECONDS)); }