### Question:
ConnectionHandler extends BaseHandler implements Lister<ConnectionOverview>, Getter<ConnectionOverview>, Creator<Connection>, Deleter<Connection>, Updater<Connection>, Validating<Connection> { @Override public void delete(String id) { final DataManager dataManager = getDataManager(); dataManager.fetchIdsByPropertyValue(ConnectionBulletinBoard.class, "targetResourceId", id) .forEach(cbbId -> dataManager.delete(ConnectionBulletinBoard.class, cbbId)); Deleter.super.delete(id); } ConnectionHandler(final DataManager dataMgr, final Validator validator, final Credentials credentials,
                             final ClientSideState state, final MetadataConfigurationProperties config, final EncryptionComponent encryptionComponent); @Override Kind resourceKind(); @Override ListResult<ConnectionOverview> list(int page, int perPage); @Override ConnectionOverview get(final String id); @Override @SuppressWarnings("JdkObsolete") Connection create(@Context SecurityContext sec, final Connection connection); @Override void delete(String id); @Override @SuppressWarnings("JdkObsolete") void update(final String id, final Connection connection); @Path("/{id}/actions") ConnectionActionHandler metadata(@NotNull @PathParam("id") @Parameter(required = true, example = "my-connection") final String connectionId); @GET @Produces(MediaType.APPLICATION_JSON) @Path(value = "/{id}/bulletins") ConnectionBulletinBoard getBulletins(@NotNull @PathParam("id") @Parameter(required = true) String id); @Override Validator getValidator();  }### Answer:
@Test public void shouldDeleteConnectionsAndDeletingAssociatedResources() { String id = "to-delete"; Connection connection = new Connection.Builder().id(id).build(); when(dataManager.fetch(Connection.class, id)).thenReturn(connection); Set<String> cbbIds = new HashSet<>(); for (int i = 1; i <= 2; ++i) { cbbIds.add(id + "-cbb" + i); } when(dataManager.fetchIdsByPropertyValue(ConnectionBulletinBoard.class, "targetResourceId", id)) .thenReturn(cbbIds); for (String cbbId : cbbIds) { when(dataManager.delete(ConnectionBulletinBoard.class, cbbId)).thenReturn(true); } when(dataManager.delete(Connection.class, id)).thenReturn(true); handler.delete(id); verify(dataManager).delete(Connection.class, id); for (String cbbId : cbbIds) { verify(dataManager).delete(ConnectionBulletinBoard.class, cbbId); } }