use of com.hortonworks.streamline.common.exception.service.exception.request.BadRequestException in project streamline by hortonworks.
the class NamespaceCatalogResourceTest method testAddStreamingEngineWhenStreamingEngineAlreadyExistsViaMapServiceToClusterInNamespace.
@Test
public void testAddStreamingEngineWhenStreamingEngineAlreadyExistsViaMapServiceToClusterInNamespace() 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 newMapping = new NamespaceServiceClusterMap(testNamespaceId, TEST_STREAMING_ENGINE, 2L);
try {
namespaceCatalogResource.mapServiceToClusterInNamespace(testNamespaceId, newMapping, securityContext);
Assert.fail("Should throw BadRequestException");
} catch (BadRequestException e) {
// passed
}
new Verifications() {
{
environmentService.addOrUpdateServiceClusterMapping(withAny(new NamespaceServiceClusterMap()));
times = 0;
}
};
}
use of com.hortonworks.streamline.common.exception.service.exception.request.BadRequestException 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;
}
};
}
use of com.hortonworks.streamline.common.exception.service.exception.request.BadRequestException 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;
}
};
}
Aggregations