use of io.pravega.client.stream.StreamCut in project pravega by pravega.
the class ControllerImplTest method testGetSegmentsWithValidStreamCut.
/*
Segment mapping of stream8 used for the below tests.
+-------+------+-------
| | 8 |
| 2 +------|
| | 7 | 10
+-------+ -----|
| | 6 |
| 1 +------+-------
| | 5 |
+-------+------|
| | 4 | 9
| 0 +------|
| | 3 |
+-------+------+--------
*/
@Test
public void testGetSegmentsWithValidStreamCut() throws Exception {
String scope = "scope1";
String stream = "stream8";
Stream s = new StreamImpl(scope, stream);
Map<Segment, Long> startSegments = new HashMap<>();
startSegments.put(new Segment(scope, stream, 0), 4L);
startSegments.put(new Segment(scope, stream, 1), 6L);
startSegments.put(new Segment(scope, stream, 7), 6L);
startSegments.put(new Segment(scope, stream, 8), 6L);
StreamCut cut = new StreamCutImpl(s, startSegments);
Map<Segment, Long> endSegments = new HashMap<>();
endSegments.put(new Segment(scope, stream, 3), 10L);
endSegments.put(new Segment(scope, stream, 4), 10L);
endSegments.put(new Segment(scope, stream, 5), 10L);
endSegments.put(new Segment(scope, stream, 10), 10L);
StreamCut endSC = new StreamCutImpl(s, endSegments);
Set<Segment> segments = controllerClient.getSegments(cut, endSC).get().getSegments();
assertEquals(ImmutableSet.of(new Segment(scope, stream, 0), new Segment(scope, stream, 1), new Segment(scope, stream, 8), new Segment(scope, stream, 7), new Segment(scope, stream, 3), new Segment(scope, stream, 4), new Segment(scope, stream, 5), new Segment(scope, stream, 10), new Segment(scope, stream, 6)), segments);
}
Aggregations