@Test
public void testOverwriteExistingStreamingEngineMappingViaSetServicesToClusterInNamespace() throws Exception {

    Long testNamespaceId = 1L;
    Namespace testNamespace = createTestNamespace(testNamespaceId, TEST_STREAMING_ENGINE, TEST_TIME_SERIES_DB);
    Collection<NamespaceServiceClusterMap> existingMappings = createTestMappingsForExisting(testNamespaceId);
    new Expectations() {{
        environmentService.getNamespace(testNamespaceId);
        result = testNamespace;
        environmentService.listServiceClusterMapping(testNamespaceId);
        result = existingMappings;
    }};
    namespaceCatalogResource.setServicesToClusterInNamespace(testNamespaceId, new ArrayList<>(existingMappings), securityContext);
    new Verifications() {{
        catalogService.listTopologies();
        times = 0;
        topologyActionsService.getRuntimeTopologyId(withAny(new Topology()), anyString);
        times = 0;
        environmentService.removeServiceClusterMapping(testNamespaceId, anyString, anyLong);
        times = existingMappings.size();
        environmentService.addOrUpdateServiceClusterMapping(withAny(new NamespaceServiceClusterMap()));
        times = existingMappings.size();
    }};
}