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;
|
package io.dapr.workflows.runtime;
|
||||||
|
|
||||||
import io.dapr.durabletask.TaskActivityContext;
|
import io.dapr.durabletask.TaskActivityContext;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
@ -11,36 +10,39 @@ import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
class DefaultWorkflowActivityContextTest {
|
class DefaultWorkflowActivityContextTest {
|
||||||
|
|
||||||
private DefaultWorkflowActivityContext context;
|
@Test
|
||||||
|
void testDefaultWorkflowActivityContext() {
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
TaskActivityContext mockInnerContext = mock(TaskActivityContext.class);
|
TaskActivityContext mockInnerContext = mock(TaskActivityContext.class);
|
||||||
context = new DefaultWorkflowActivityContext(mockInnerContext);
|
DefaultWorkflowActivityContext context = new DefaultWorkflowActivityContext(mockInnerContext);
|
||||||
|
|
||||||
when(mockInnerContext.getName()).thenReturn("TestActivity");
|
when(mockInnerContext.getName()).thenReturn("TestActivity");
|
||||||
when(mockInnerContext.getInput(any())).thenReturn("TestInput");
|
when(mockInnerContext.getInput(any())).thenReturn("TestInput");
|
||||||
when(mockInnerContext.getTaskExecutionId()).thenReturn("TestExecutionId");
|
when(mockInnerContext.getTaskExecutionId()).thenReturn("TestExecutionId");
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void getLogger() {
|
|
||||||
assertNotNull(context.getLogger());
|
assertNotNull(context.getLogger());
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void getName() {
|
|
||||||
assertEquals("TestActivity", context.getName());
|
assertEquals("TestActivity", context.getName());
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void getInput() {
|
|
||||||
String input = context.getInput(String.class);
|
String input = context.getInput(String.class);
|
||||||
assertEquals("TestInput", input);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
assertEquals("TestInput", input);
|
||||||
void getTaskExecutionId() {
|
|
||||||
assertEquals("TestExecutionId", context.getTaskExecutionId());
|
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