Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ class DefaultWorkflowActivityContext implements WorkflowActivityContext {
* @throws IllegalArgumentException if context is null
*/
public DefaultWorkflowActivityContext(TaskActivityContext context) throws IllegalArgumentException {
this(context, LoggerFactory.getLogger(WorkflowActivityContext.class));
this(context, WorkflowActivityContext.class);
}

/**
* Constructor for WorkflowActivityContext.
*
* @param context TaskActivityContext
* @param clazz Class to use for logger
* @throws IllegalArgumentException if context is null
*/
public DefaultWorkflowActivityContext(TaskActivityContext context, Class<?> clazz) throws IllegalArgumentException {
Comment thread
artur-ciocanu marked this conversation as resolved.
this(context, LoggerFactory.getLogger(clazz));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,28 @@ public class DefaultWorkflowContext implements WorkflowContext {
private final Logger logger;

/**
* Constructor for DaprWorkflowContextImpl.
* Constructor for DefaultWorkflowContext.
*
* @param context TaskOrchestrationContext
* @throws IllegalArgumentException if context is null
*/
public DefaultWorkflowContext(TaskOrchestrationContext context) throws IllegalArgumentException {
this(context, LoggerFactory.getLogger(WorkflowContext.class));
this(context, WorkflowContext.class);
}

/**
Comment thread
artur-ciocanu marked this conversation as resolved.
* Constructor for DaprWorkflowContextImpl.
* Constructor for DefaultWorkflowContext.
*
* @param context TaskOrchestrationContext
* @param clazz Class to use for logger
* @throws IllegalArgumentException if context is null
*/
public DefaultWorkflowContext(TaskOrchestrationContext context, Class<?> clazz) throws IllegalArgumentException {
this(context, LoggerFactory.getLogger(clazz));
}

/**
* Constructor for DefaultWorkflowContext.
*
* @param context TaskOrchestrationContext
* @param logger Logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public TaskActivity create() {
String.format("Unable to instantiate instance of activity class '%s'", this.name), e);
}

result = activity.run(new DefaultWorkflowActivityContext(ctx));
result = activity.run(new DefaultWorkflowActivityContext(ctx, activity.getClass()));
return result;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ public String getName() {

@Override
public TaskActivity create() {
return ctx -> activity.run(new DefaultWorkflowActivityContext(ctx));
return ctx -> activity.run(new DefaultWorkflowActivityContext(ctx, activity.getClass()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public TaskOrchestration create() {
);
}

workflow.run(new DefaultWorkflowContext(ctx));
workflow.run(new DefaultWorkflowContext(ctx, workflow.getClass()));
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public String getName() {

@Override
public TaskOrchestration create() {
return ctx -> workflow.run(new DefaultWorkflowContext(ctx));
return ctx -> workflow.run(new DefaultWorkflowContext(ctx, workflow.getClass()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@

public class DefaultWorkflowContextTest {
private DefaultWorkflowContext context;
private DefaultWorkflowContext contextWithClass;
private TaskOrchestrationContext mockInnerContext;
private WorkflowContext testWorkflowContext;

@BeforeEach
public void setUp() {
mockInnerContext = mock(TaskOrchestrationContext.class);
context = new DefaultWorkflowContext(mockInnerContext);
testWorkflowContext = new WorkflowContext() {
@Override
public Logger getLogger() {
Expand Down Expand Up @@ -141,6 +141,8 @@ public void setCustomStatus(Object status) {

}
};
context = new DefaultWorkflowContext(mockInnerContext);
contextWithClass = new DefaultWorkflowContext(mockInnerContext, testWorkflowContext.getClass());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.dapr.durabletask.TaskActivityContext;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -34,7 +35,7 @@ void shouldSuccessfullyCreateContextAndReturnCorrectValuesForAllMethods() {
@DisplayName("Should throw IllegalArgumentException when context parameter is null")
void shouldThrowIllegalArgumentExceptionWhenContextParameterIsNull() {
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> {
new DefaultWorkflowActivityContext(null);
new DefaultWorkflowActivityContext(null, TaskActivityContext.class);
});
assertEquals("Context cannot be null", exception.getMessage());
}
Expand All @@ -45,7 +46,7 @@ void shouldThrowIllegalArgumentExceptionWhenLoggerParameterIsNull() {
TaskActivityContext mockInnerContext = mock(TaskActivityContext.class);

IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> {
new DefaultWorkflowActivityContext(mockInnerContext, null);
new DefaultWorkflowActivityContext(mockInnerContext, (Logger) null);
});
assertEquals("Logger cannot be null", exception.getMessage());
}
Expand Down