@Test public void shouldHandleDataSegment() { Segment segment = mock(Segment.class); when(segment.isDataSegment()).thenReturn(true); Backend backend = mock(Backend.class); when(backend.getSegment("s")).thenReturn(Optional.of(segment)); assertEquals(DataSegmentNode.class, SegmentNode.newSegmentNode(backend, "s").getClass()); }
static NodeState newSegmentNode(Backend backend, String segmentId) { return backend.getSegment(segmentId) .map(segment -> newSegmentNode(backend, segmentId, segment)) .orElseGet(() -> newMissingSegment(segmentId)); }
SegmentNode { static NodeState newSegmentNode(Backend backend, String segmentId) { return backend.getSegment(segmentId) .map(segment -> newSegmentNode(backend, segmentId, segment)) .orElseGet(() -> newMissingSegment(segmentId)); } }
SegmentNode { static NodeState newSegmentNode(Backend backend, String segmentId) { return backend.getSegment(segmentId) .map(segment -> newSegmentNode(backend, segmentId, segment)) .orElseGet(() -> newMissingSegment(segmentId)); } private  SegmentNode(); }
SegmentNode { static NodeState newSegmentNode(Backend backend, String segmentId) { return backend.getSegment(segmentId) .map(segment -> newSegmentNode(backend, segmentId, segment)) .orElseGet(() -> newMissingSegment(segmentId)); } private  SegmentNode();  }
SegmentNode { static NodeState newSegmentNode(Backend backend, String segmentId) { return backend.getSegment(segmentId) .map(segment -> newSegmentNode(backend, segmentId, segment)) .orElseGet(() -> newMissingSegment(segmentId)); } private  SegmentNode();   }