|
| 1 | +import 'package:flutter/cupertino.dart'; |
| 2 | +import 'package:flutter_code_editor/flutter_code_editor.dart'; |
| 3 | +import 'package:flutter_test/flutter_test.dart'; |
| 4 | +import 'package:highlight/languages/java.dart'; |
| 5 | + |
| 6 | +const _fullText = ''' |
| 7 | +/* |
| 8 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 9 | + * or more contributor license agreements. See the NOTICE file |
| 10 | + * distributed with this work for additional information |
| 11 | + * regarding copyright ownership. The ASF licenses this file |
| 12 | + * to you under the Apache License, Version 2.0 (the |
| 13 | + * "License"); you may not use this file except in compliance |
| 14 | + * with the License. You may obtain a copy of the License at |
| 15 | + * |
| 16 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 17 | + * |
| 18 | + * Unless required by applicable law or agreed to in writing, software |
| 19 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 20 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 21 | + * See the License for the specific language governing permissions and |
| 22 | + * limitations under the License. |
| 23 | + */ |
| 24 | +
|
| 25 | +package org.apache.beam.learning.katas.commontransforms.filter.filter; |
| 26 | +
|
| 27 | +
|
| 28 | +import org.apache.beam.learning.katas.util.Log; |
| 29 | +import org.apache.beam.sdk.Pipeline; |
| 30 | +import org.apache.beam.sdk.options.PipelineOptions; |
| 31 | +import org.apache.beam.sdk.options.PipelineOptionsFactory; |
| 32 | +import org.apache.beam.sdk.transforms.Create; |
| 33 | +import org.apache.beam.sdk.transforms.Filter; |
| 34 | +import org.apache.beam.sdk.values.PCollection; |
| 35 | +
|
| 36 | +public class Task { |
| 37 | +
|
| 38 | + public static void main(String[] args) { |
| 39 | + PipelineOptions options = PipelineOptionsFactory.fromArgs(args).create(); |
| 40 | + Pipeline pipeline = Pipeline.create(options); |
| 41 | +
|
| 42 | + PCollection<Integer> numbers = |
| 43 | + pipeline.apply(Create.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); |
| 44 | +
|
| 45 | + PCollection<Integer> output = applyTransform(numbers); |
| 46 | +
|
| 47 | + output.apply(Log.ofElements()); |
| 48 | +
|
| 49 | + pipeline.run(); |
| 50 | + } |
| 51 | +
|
| 52 | + static PCollection<Integer> applyTransform(PCollection<Integer> input) { |
| 53 | + return input.apply(Filter.by(number -> number % 2 == 0)); |
| 54 | + } |
| 55 | +
|
| 56 | +}'''; |
| 57 | + |
| 58 | +const _newValue = TextEditingValue( |
| 59 | + text: ''' |
| 60 | +public class MyClass { |
| 61 | + public static void main(String[] args) { |
| 62 | + System.out.print("OK"); |
| 63 | + } |
| 64 | +} |
| 65 | +''', |
| 66 | + selection: TextSelection.collapsed(offset: 100), |
| 67 | +); |
| 68 | + |
| 69 | +void main() { |
| 70 | + test('Issue 232', () { |
| 71 | + final controller = CodeController( |
| 72 | + language: java, |
| 73 | + ); |
| 74 | + |
| 75 | + controller.fullText = _fullText; |
| 76 | + controller.foldCommentAtLineZero(); |
| 77 | + controller.foldImports(); |
| 78 | + |
| 79 | + controller.value = _newValue; |
| 80 | + |
| 81 | + expect(controller.value, _newValue); |
| 82 | + }); |
| 83 | +} |
0 commit comments