Skip to content

Commit 47e556b

Browse files
committed
add test && add flow name include -
1 parent e7e32a3 commit 47e556b

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

platform-api/src/main/java/com/flow/platform/api/service/node/NodeServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ private Boolean checkFlowName(String flowName) {
287287
return false;
288288
}
289289

290-
if (!Pattern.compile("^\\w{4,20}$").matcher(flowName).matches()) {
290+
if (!Pattern.compile("^[^_^-][\\w-]{4,20}$").matcher(flowName).matches()) {
291291
return false;
292292
}
293293

platform-api/src/test/java/com/flow/platform/api/test/integration/ManualJobTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public void should_manual_create_job_with_failure_since_unable_to_create_session
5858
Map<String, String> envs = EnvUtil.build(GitEnvs.FLOW_GIT_BRANCH.name(), "master");
5959
jobService.createWithYmlLoad(
6060
flow.getPath(), JobCategory.MANUAL, envs, currentUser.get(), job -> {
61-
latch.countDown();
6261
wrapper.setInstance(job);
62+
latch.countDown();
6363
}
6464
);
6565

platform-api/src/test/java/com/flow/platform/api/test/service/NodeServiceTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.flow.platform.api.service.node.YmlService;
3030
import com.flow.platform.api.test.TestBase;
3131
import com.flow.platform.api.util.NodeUtil;
32+
import com.flow.platform.core.exception.FlowException;
3233
import com.flow.platform.core.exception.IllegalParameterException;
3334
import com.flow.platform.util.http.HttpURL;
3435
import java.nio.file.Files;
@@ -275,4 +276,23 @@ public void should_delete_flow() throws Throwable {
275276
// then: should return null if root node is not existed
276277
Assert.assertNull(ymlService.get(root));
277278
}
279+
280+
@Test
281+
public void should_create_flow_success() {
282+
Assert.assertNotNull(nodeService.createEmptyFlow("flow-test"));
283+
Assert.assertNotNull(nodeService.createEmptyFlow("flow_test"));
284+
Assert.assertNotNull(nodeService.createEmptyFlow("flow_12est"));
285+
}
286+
287+
@Test(expected = IllegalParameterException.class)
288+
public void should_create_flow_error() {
289+
// not start with _
290+
nodeService.createEmptyFlow("_flow-test");
291+
292+
// not start with -
293+
nodeService.createEmptyFlow("-flow-test");
294+
295+
// not include .
296+
nodeService.createEmptyFlow("flow.test");
297+
}
278298
}

platform-util-zk/src/test/java/com/flow/platform/util/zk/test/ZkClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void should_create_node_atom() throws Throwable {
8686
final AtomicInteger size = new AtomicInteger(0);
8787
final CountDownLatch latch = new CountDownLatch(5);
8888

89-
String agentNodePath = ZKPaths.makePath("/flow-agent", "flow-atom");
89+
String agentNodePath = ZKPaths.makePath("/", "flow-atom");
9090
zkClient.delete(agentNodePath, false);
9191

9292
for (int i = 0; i < 5; i++) {

0 commit comments

Comments
 (0)