Search in sources :

Example 26 with NamespaceServiceClusterMap

use of com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap in project streamline by hortonworks.

the class NamespaceCatalogResourceTest method testUnmapStreamingEngineWhenTopologyIsRunningViaUnmapAllServiceToClusterInNamespace.

@Test
public void testUnmapStreamingEngineWhenTopologyIsRunningViaUnmapAllServiceToClusterInNamespace() throws Exception {
    Long testNamespaceId = 1L;
    Namespace testNamespace = createTestNamespace(testNamespaceId, TEST_STREAMING_ENGINE, TEST_TIME_SERIES_DB);
    Collection<NamespaceServiceClusterMap> existingMappings = createTestMappingsForExisting(testNamespaceId);
    setupExpectationForSimulatingTopologyIsRunning(testNamespaceId, testNamespace, existingMappings);
    try {
        namespaceCatalogResource.unmapAllServicesToClusterInNamespace(testNamespaceId, securityContext);
        Assert.fail("Should throw BadRequestException");
    } catch (BadRequestException e) {
    // passed
    }
    new Verifications() {

        {
            environmentService.removeServiceClusterMapping(testNamespaceId, anyString, anyLong);
            times = 0;
        }
    };
}
Also used : BadRequestException(com.hortonworks.streamline.common.exception.service.exception.request.BadRequestException) Verifications(mockit.Verifications) NamespaceServiceClusterMap(com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap) Namespace(com.hortonworks.streamline.streams.cluster.catalog.Namespace) Test(org.junit.Test)

Example 27 with NamespaceServiceClusterMap

use of com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap in project streamline by hortonworks.

the class NamespaceCatalogResourceTest method testOverwriteSameTimeSeriesDBMappingViaMapServiceToClusterInNamespace.

@Test
public void testOverwriteSameTimeSeriesDBMappingViaMapServiceToClusterInNamespace() 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;
        }
    };
    NamespaceServiceClusterMap existingTimeSeriesDBMapping = existingMappings.stream().filter(m -> m.getServiceName().equals(TEST_TIME_SERIES_DB)).findAny().get();
    namespaceCatalogResource.mapServiceToClusterInNamespace(testNamespaceId, existingTimeSeriesDBMapping, securityContext);
    new Verifications() {

        {
            environmentService.addOrUpdateServiceClusterMapping(withAny(new NamespaceServiceClusterMap()));
            times = 1;
        }
    };
}
Also used : Expectations(mockit.Expectations) Verifications(mockit.Verifications) NamespaceServiceClusterMap(com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap) Namespace(com.hortonworks.streamline.streams.cluster.catalog.Namespace) Test(org.junit.Test)

Example 28 with NamespaceServiceClusterMap

use of com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap in project streamline by hortonworks.

the class NamespaceCatalogResourceTest method testUnmapStreamingEngineWhenTopologyIsRunningViaUnmapServiceToClusterInNamespace.

@Test
public void testUnmapStreamingEngineWhenTopologyIsRunningViaUnmapServiceToClusterInNamespace() throws Exception {
    Long testNamespaceId = 1L;
    Namespace testNamespace = createTestNamespace(testNamespaceId, TEST_STREAMING_ENGINE, TEST_TIME_SERIES_DB);
    Collection<NamespaceServiceClusterMap> existingMappings = createTestMappingsForExisting(testNamespaceId);
    setupExpectationForSimulatingTopologyIsRunning(testNamespaceId, testNamespace, existingMappings);
    try {
        namespaceCatalogResource.unmapServiceToClusterInNamespace(testNamespaceId, TEST_STREAMING_ENGINE, 1L, securityContext);
        Assert.fail("Should throw BadRequestException");
    } catch (BadRequestException e) {
    // passed
    }
    new Verifications() {

        {
            environmentService.removeServiceClusterMapping(testNamespaceId, TEST_STREAMING_ENGINE, 1L);
            times = 0;
        }
    };
}
Also used : BadRequestException(com.hortonworks.streamline.common.exception.service.exception.request.BadRequestException) Verifications(mockit.Verifications) NamespaceServiceClusterMap(com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap) Namespace(com.hortonworks.streamline.streams.cluster.catalog.Namespace) Test(org.junit.Test)

Aggregations

NamespaceServiceClusterMap (com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap)28 Namespace (com.hortonworks.streamline.streams.cluster.catalog.Namespace)21 Test (org.junit.Test)13 Expectations (mockit.Expectations)11 Verifications (mockit.Verifications)11 BadRequestException (com.hortonworks.streamline.common.exception.service.exception.request.BadRequestException)10 Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)8 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)8 Topology (com.hortonworks.streamline.streams.catalog.Topology)7 Timed (com.codahale.metrics.annotation.Timed)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)6 List (java.util.List)6 Path (javax.ws.rs.Path)6 StreamCatalogService (com.hortonworks.streamline.streams.catalog.service.StreamCatalogService)5 QueryParam (com.hortonworks.registries.common.QueryParam)4 TopologyActionsService (com.hortonworks.streamline.streams.actions.topology.service.TopologyActionsService)4 TopologyNotAliveException (com.hortonworks.streamline.streams.exception.TopologyNotAliveException)4 StreamlineAuthorizer (com.hortonworks.streamline.streams.security.StreamlineAuthorizer)4