Skip to content

Commit

Permalink
Merge branch 'master' into brig/v2-has-flow
Browse files Browse the repository at this point in the history
  • Loading branch information
brig authored Oct 9, 2023
2 parents ddb7733 + 0c6e705 commit 8e02153
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ private static FunctionMapper createFunctionMapper() {
functions.put("isDebug", IsDebugFunction.getMethod());
functions.put("throw", ThrowFunction.getMethod());
functions.put("hasFlow", HasFlowFunction.getMethod());
functions.put("uuid", UuidFunction.getMethod());
return new FunctionMapper(functions);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.walmartlabs.concord.runtime.v2.runner.el.functions;

/*-
* *****
* Concord
* -----
* Copyright (C) 2017 - 2023 Walmart Inc.
* -----
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =====
*/

import java.lang.reflect.Method;
import java.util.UUID;

public final class UuidFunction {

public static Method getMethod() {
try {
return UuidFunction.class.getMethod("uuid");
} catch (Exception e) {
throw new RuntimeException("Method not found");
}
}

public static String uuid() {
return UUID.randomUUID().toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,17 @@ public void testHasFlow() throws Exception {
assertLog(log, ".*myFlow: true.*");
}

@Test
public void testUuidFunc() throws Exception {
deploy("uuid");

save(ProcessConfiguration.builder()
.build());

byte[] log = run();
assertLog(log, ".*uuid: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}.*");
}

private void deploy(String resource) throws URISyntaxException, IOException {
Path src = Paths.get(MainTest.class.getResource(resource).toURI());
IOUtils.copy(src, workDir);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flows:
default:
- log: "uuid: ${uuid()}"

0 comments on commit 8e02153

Please sign in to comment.