@Override
    public void delete(PipelineDao nativeEntity) {
        final Set<PipelineConnections> pipelineConnections = connectionsService.loadByPipelineId(nativeEntity.id());
        for (PipelineConnections connections : pipelineConnections) {
            final Set<String> pipelineIds = connections.pipelineIds().stream()
                    .filter(pipelineId -> !pipelineId.equals(nativeEntity.id()))
                    .collect(Collectors.toSet());

            if (pipelineIds.isEmpty()) {
                LOG.trace("Removing pipeline connections for stream {}", connections.streamId());
                connectionsService.delete(connections.streamId());
            } else {
                final PipelineConnections newConnections = connections.toBuilder()
                        .pipelineIds(pipelineIds)
                        .build();
                LOG.trace("Saving updated pipeline connections: {}", newConnections);
                connectionsService.save(newConnections);
            }
        }

        pipelineService.delete(nativeEntity.id());
    }
@Test
    @MongoDBFixtures("PipelineFacadeTest/pipelines.json")
    public void delete() throws NotFoundException {
        final PipelineDao pipelineDao = pipelineService.load("5a85c4854b900afd5d662be3");

        assertThat(pipelineService.loadAll()).hasSize(1);
        facade.delete(pipelineDao);
        assertThat(pipelineService.loadAll()).isEmpty();

        assertThatThrownBy(() -> pipelineService.load("5a85c4854b900afd5d662be3"))
                .isInstanceOf(NotFoundException.class);
    }