Skip to content

Commit 6554359

Browse files
段晓雄cursoragent
andcommitted
refactor(flink-test): call task.getScript() directly, remove ForTest subclasses
Same package allows direct access to protected getScript() Ref: PR #17987 review Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 53ba5da commit 6554359

File tree

2 files changed

+8
-30
lines changed
  • dolphinscheduler-task-plugin

2 files changed

+8
-30
lines changed

dolphinscheduler-task-plugin/dolphinscheduler-task-flink-stream/src/test/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkStreamTaskTest.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ public void testParameterReplacementInScript() throws Exception {
6363
context.setTaskAppId(taskAppId);
6464
context.setPrepareParamsMap(prepareParamsMap);
6565

66-
FlinkStreamTaskForTest task = new FlinkStreamTaskForTest(context);
66+
FlinkStreamTask task = new FlinkStreamTask(context);
6767
task.init();
68-
task.callGetScript();
68+
task.getScript();
6969

7070
String initScriptPath = String.format("%s/%s_init.sql", executePath, taskAppId);
7171
String nodeScriptPath = String.format("%s/%s_node.sql", executePath, taskAppId);
@@ -102,25 +102,14 @@ public void testParameterReplacementTimePlaceholder() throws Exception {
102102
context.setTaskAppId(taskAppId);
103103
context.setPrepareParamsMap(prepareParamsMap);
104104

105-
FlinkStreamTaskForTest task = new FlinkStreamTaskForTest(context);
105+
FlinkStreamTask task = new FlinkStreamTask(context);
106106
task.init();
107-
task.callGetScript();
107+
task.getScript();
108108

109109
String nodeScriptPath = String.format("%s/%s_node.sql", executePath, taskAppId);
110110
String nodeContent = Files.readString(Path.of(nodeScriptPath), StandardCharsets.UTF_8);
111111

112112
Assertions.assertTrue(nodeContent.contains("dt = '20210815'"),
113113
"Expected $[yyyyMMdd] to be replaced with 20210815, got: " + nodeContent);
114114
}
115-
116-
private static class FlinkStreamTaskForTest extends FlinkStreamTask {
117-
118-
FlinkStreamTaskForTest(TaskExecutionContext context) {
119-
super(context);
120-
}
121-
122-
String callGetScript() {
123-
return getScript();
124-
}
125-
}
126115
}

dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/test/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkTaskTest.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ public void testParameterReplacementInScript() throws Exception {
6363
context.setTaskAppId(taskAppId);
6464
context.setPrepareParamsMap(prepareParamsMap);
6565

66-
FlinkTaskForTest task = new FlinkTaskForTest(context);
66+
FlinkTask task = new FlinkTask(context);
6767
task.init();
68-
task.callGetScript();
68+
task.getScript();
6969

7070
String initScriptPath = String.format("%s/%s_init.sql", executePath, taskAppId);
7171
String nodeScriptPath = String.format("%s/%s_node.sql", executePath, taskAppId);
@@ -97,24 +97,13 @@ public void testParameterReplacementWithNullParamsMap() throws Exception {
9797
context.setTaskAppId(taskAppId);
9898
context.setPrepareParamsMap(null);
9999

100-
FlinkTaskForTest task = new FlinkTaskForTest(context);
100+
FlinkTask task = new FlinkTask(context);
101101
task.init();
102-
String script = task.callGetScript();
102+
String script = task.getScript();
103103

104104
String nodeScriptPath = String.format("%s/%s_node.sql", executePath, taskAppId);
105105
String nodeContent = Files.readString(Path.of(nodeScriptPath), StandardCharsets.UTF_8);
106106
Assertions.assertEquals("SELECT 1;", nodeContent.trim());
107107
Assertions.assertNotNull(script);
108108
}
109-
110-
private static class FlinkTaskForTest extends FlinkTask {
111-
112-
FlinkTaskForTest(TaskExecutionContext context) {
113-
super(context);
114-
}
115-
116-
String callGetScript() {
117-
return getScript();
118-
}
119-
}
120109
}

0 commit comments

Comments
 (0)