Skip to content

Commit

Permalink
Minor code refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: Siddhartha Bingi <[email protected]>
  • Loading branch information
Siddhartha Bingi committed Jan 22, 2025
1 parent 98644bd commit 16e2f2d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,7 @@ void checkMaxWorkflows(TimeValue requestTimeOut, Integer maxWorkflow, ActionList

private void validateWorkflows(Template template) throws Exception {
for (Workflow workflow : template.workflows().values()) {
List<ProcessNode> sortedNodes = workflowProcessSorter.sortProcessNodes(
workflow,
null,
Collections.emptyMap(),
"fakeTenantId");
List<ProcessNode> sortedNodes = workflowProcessSorter.sortProcessNodes(workflow, null, Collections.emptyMap(), "fakeTenantId");
workflowProcessSorter.validate(sortedNodes, pluginsService);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ public TimeValue nodeTimeout() {
* Returns the tenantId value for this node in the workflow.
* @return The node's tenantId value
*/
public String tenantId() { return tenantId; }
public String tenantId() {
return tenantId;

Check warning on line 156 in src/main/java/org/opensearch/flowframework/workflow/ProcessNode.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/flowframework/workflow/ProcessNode.java#L156

Added line #L156 was not covered by tests
}

/**
* Execute this node in the sequence.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

import org.mockito.ArgumentCaptor;

import static org.mockito.ArgumentMatchers.nullable;
import static org.opensearch.flowframework.common.CommonValue.ALLOW_DELETE;
import static org.opensearch.flowframework.common.CommonValue.DEPROVISION_WORKFLOW_THREAD_POOL;
import static org.opensearch.flowframework.common.CommonValue.FLOW_FRAMEWORK_THREAD_POOL_PREFIX;
Expand All @@ -61,6 +60,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyMap;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
Expand Down Expand Up @@ -166,7 +166,8 @@ public void testDeprovisionWorkflow() throws Exception {

PlainActionFuture<WorkflowData> future = PlainActionFuture.newFuture();
future.onResponse(WorkflowData.EMPTY);
when(this.deleteConnectorStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class))).thenReturn(future);
when(this.deleteConnectorStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class)))
.thenReturn(future);

CountDownLatch latch = new CountDownLatch(1);
LatchedActionListener<WorkflowResponse> latchedActionListener = new LatchedActionListener<>(listener, latch);
Expand Down Expand Up @@ -198,7 +199,8 @@ public void testFailToDeprovision() throws Exception {

PlainActionFuture<WorkflowData> future = PlainActionFuture.newFuture();
future.onFailure(new RuntimeException("rte"));
when(this.undeployModelStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class))).thenReturn(future);
when(this.undeployModelStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class)))
.thenReturn(future);

CountDownLatch latch = new CountDownLatch(1);
LatchedActionListener<WorkflowResponse> latchedActionListener = new LatchedActionListener<>(listener, latch);
Expand Down Expand Up @@ -275,7 +277,8 @@ public void testAllowDeleteRequired() throws Exception {

PlainActionFuture<WorkflowData> future = PlainActionFuture.newFuture();
future.onResponse(WorkflowData.EMPTY);
when(this.deleteIndexStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class))).thenReturn(future);
when(this.deleteIndexStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class)))
.thenReturn(future);

latch = new CountDownLatch(1);
latchedActionListener = new LatchedActionListener<>(listener, latch);
Expand Down Expand Up @@ -313,7 +316,8 @@ public void testFailToDeprovisionAndAllowDeleteRequired() throws Exception {

PlainActionFuture<WorkflowData> future = PlainActionFuture.newFuture();
future.onFailure(new RuntimeException("rte"));
when(this.undeployModelStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class))).thenReturn(future);
when(this.undeployModelStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class)))
.thenReturn(future);

CountDownLatch latch = new CountDownLatch(1);
LatchedActionListener<WorkflowResponse> latchedActionListener = new LatchedActionListener<>(listener, latch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void testNoOpStepParse() throws IOException {

Exception ex = assertThrows(
WorkflowStepException.class,
() -> noopStep.execute("nodeId", delayData, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(),null)
() -> noopStep.execute("nodeId", delayData, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), null)
);
assertEquals("failed to parse setting [delay] with value [foo] as a time value: unit is missing or unrecognized", ex.getMessage());
}
Expand Down

0 comments on commit 16e2f2d

Please sign in to comment.