mirror of https://github.com/dapr/java-sdk.git
Improve code coverage
Signed-off-by: Artur Ciocanu <ciocanu@adobe.com>
This commit is contained in:
parent
e7ab81812e
commit
eefffc01eb
|
|
@ -1,7 +1,6 @@
|
|||
package io.dapr.workflows.runtime;
|
||||
|
||||
import io.dapr.durabletask.TaskActivityContext;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
|
@ -11,36 +10,39 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
class DefaultWorkflowActivityContextTest {
|
||||
|
||||
private DefaultWorkflowActivityContext context;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
@Test
|
||||
void testDefaultWorkflowActivityContext() {
|
||||
TaskActivityContext mockInnerContext = mock(TaskActivityContext.class);
|
||||
context = new DefaultWorkflowActivityContext(mockInnerContext);
|
||||
DefaultWorkflowActivityContext context = new DefaultWorkflowActivityContext(mockInnerContext);
|
||||
|
||||
when(mockInnerContext.getName()).thenReturn("TestActivity");
|
||||
when(mockInnerContext.getInput(any())).thenReturn("TestInput");
|
||||
when(mockInnerContext.getTaskExecutionId()).thenReturn("TestExecutionId");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getLogger() {
|
||||
assertNotNull(context.getLogger());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getName() {
|
||||
assertEquals("TestActivity", context.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getInput() {
|
||||
String input = context.getInput(String.class);
|
||||
assertEquals("TestInput", input);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getTaskExecutionId() {
|
||||
assertEquals("TestInput", input);
|
||||
assertEquals("TestExecutionId", context.getTaskExecutionId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultWorkflowActivityContextWithNullContext() {
|
||||
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> {
|
||||
new DefaultWorkflowActivityContext(null);
|
||||
});
|
||||
assertEquals("Context cannot be null", exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultWorkflowActivityContextWithNullLogger() {
|
||||
TaskActivityContext mockInnerContext = mock(TaskActivityContext.class);
|
||||
|
||||
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> {
|
||||
new DefaultWorkflowActivityContext(mockInnerContext, null);
|
||||
});
|
||||
assertEquals("Logger cannot be null", exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue