@Test
public void testMappingMultipleTimeSeriesDBViaSetServicesToClusterInNamespace() 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;
    }};
    List<NamespaceServiceClusterMap> mappingsToApply = Lists.newArrayList(
            new NamespaceServiceClusterMap(testNamespaceId, TEST_STREAMING_ENGINE, 1L),
            new NamespaceServiceClusterMap(testNamespaceId, TEST_TIME_SERIES_DB, 1L),
            new NamespaceServiceClusterMap(testNamespaceId, TEST_TIME_SERIES_DB, 2L),
            new NamespaceServiceClusterMap(testNamespaceId, "KAFKA", 1L)
    );
    try {
        namespaceCatalogResource.setServicesToClusterInNamespace(testNamespaceId, mappingsToApply, securityContext);
        Assert.fail("Should throw BadRequestException");
    } catch (BadRequestException e) {
        // passed
    }
    new Verifications() {{
        catalogService.listTopologies();
        times = 0;
        topologyActionsService.getRuntimeTopologyId(withAny(new Topology()), anyString);
        times = 0;
        // request fails before removing existing mappings
        environmentService.removeServiceClusterMapping(testNamespaceId, anyString, anyLong);
        times = 0;
    }};
}