use of mockit.Verifications in project streamline by hortonworks.
the class NamespaceCatalogResourceTest method testChangeMappingOfStreamingEngineViaSetServicesToClusterInNamespace.
@Test
public void testChangeMappingOfStreamingEngineViaSetServicesToClusterInNamespace() 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);
List<NamespaceServiceClusterMap> mappingsToApply = existingMappings.stream().filter(m -> !m.getServiceName().equals(TEST_STREAMING_ENGINE)).collect(toList());
// change the mapping of streaming engine to cluster id 2
mappingsToApply.add(new NamespaceServiceClusterMap(testNamespaceId, TEST_STREAMING_ENGINE, 2L));
try {
namespaceCatalogResource.setServicesToClusterInNamespace(testNamespaceId, mappingsToApply, securityContext);
Assert.fail("Should throw BadRequestException");
} catch (BadRequestException e) {
// passed
}
new Verifications() {
{
// request fails before removing existing mappings
environmentService.removeServiceClusterMapping(testNamespaceId, anyString, anyLong);
times = 0;
}
};
}
use of mockit.Verifications in project streamline by hortonworks.
the class NamespaceCatalogResourceTest method testMappingMultipleStreamingEngineViaSetServicesToClusterInNamespace.
@Test
public void testMappingMultipleStreamingEngineViaSetServicesToClusterInNamespace() 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_STREAMING_ENGINE, 2L), new NamespaceServiceClusterMap(testNamespaceId, TEST_TIME_SERIES_DB, 1L), 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;
}
};
}
use of mockit.Verifications in project streamline by hortonworks.
the class NamespaceCatalogResourceTest method testOverwriteSameStreamingEngineMappingViaMapServiceToClusterInNamespace.
@Test
public void testOverwriteSameStreamingEngineMappingViaMapServiceToClusterInNamespace() 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 existingStreamingEngineMapping = existingMappings.stream().filter(m -> m.getServiceName().equals(TEST_STREAMING_ENGINE)).findAny().get();
namespaceCatalogResource.mapServiceToClusterInNamespace(testNamespaceId, existingStreamingEngineMapping, securityContext);
new Verifications() {
{
environmentService.addOrUpdateServiceClusterMapping(withAny(new NamespaceServiceClusterMap()));
times = 1;
}
};
}
use of mockit.Verifications in project streamline by hortonworks.
the class NamespaceCatalogResourceTest method testMappingMultipleTimeSeriesDBViaSetServicesToClusterInNamespace.
@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;
}
};
}
use of mockit.Verifications in project streamline by hortonworks.
the class EventLoggingSpoutOutputCollectorTest method emit.
@Test
public void emit() throws Exception {
String testStreamId = "testStreamId";
final Values tuple = new Values(INPUT_STREAMLINE_EVENT);
String messageId = "testMessageId";
List<Integer> expectedTasks = Lists.newArrayList(TASK_1, TASK_2);
Set<String> expectedStormComponents = Sets.newHashSet(TEST_TARGET_COMPONENT_FOR_TASK_1, TEST_TARGET_COMPONENT_FOR_TASK_2);
setupExpectationsForTopologyContextEmit();
sut = new EventLoggingSpoutOutputCollector(mockedTopologyContext, mockedOutputCollector, mockedEventLogger);
// String streamId, List<Object> tuple
new Expectations() {
{
mockedOutputCollector.emit(testStreamId, tuple);
this.result = expectedTasks;
}
};
List<Integer> tasks = sut.emit(testStreamId, tuple);
assertEquals(expectedTasks, tasks);
new Verifications() {
{
mockedOutputCollector.emit(testStreamId, tuple);
}
};
verifyEventsAreWrittenProperly(INPUT_STREAMLINE_EVENT, expectedStormComponents);
// List<Object> tuple
new Expectations() {
{
mockedOutputCollector.emit(tuple);
result = expectedTasks;
}
};
tasks = sut.emit(tuple);
assertEquals(expectedTasks, tasks);
new Verifications() {
{
mockedOutputCollector.emit(tuple);
}
};
verifyEventsAreWrittenProperly(INPUT_STREAMLINE_EVENT, expectedStormComponents);
// String streamId, List<Object> tuple, Object messageId
new Expectations() {
{
mockedOutputCollector.emit(testStreamId, tuple, messageId);
result = expectedTasks;
}
};
tasks = sut.emit(testStreamId, tuple, messageId);
assertEquals(expectedTasks, tasks);
new Verifications() {
{
mockedOutputCollector.emit(testStreamId, tuple, messageId);
}
};
verifyEventsAreWrittenProperly(INPUT_STREAMLINE_EVENT, expectedStormComponents);
// List<Object> tuple, Object messageId
new Expectations() {
{
mockedOutputCollector.emit(tuple, messageId);
result = expectedTasks;
}
};
tasks = sut.emit(tuple, messageId);
assertEquals(expectedTasks, tasks);
new Verifications() {
{
mockedOutputCollector.emit(tuple, messageId);
}
};
verifyEventsAreWrittenProperly(INPUT_STREAMLINE_EVENT, expectedStormComponents);
}
Aggregations