add CLI interface and impl for category
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
cca611a1b0
commit
fa8b6a4377
3 changed files with 91 additions and 0 deletions
|
@ -0,0 +1,41 @@
|
|||
package cli.category;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class CategoryCommandsTest {
|
||||
|
||||
CategoryCliAdapter mockAdapter = mock(CategoryCliAdapter.class);
|
||||
|
||||
@Test
|
||||
void addCommandWorks() {
|
||||
var categoryName = "funStuff";
|
||||
ArgumentCaptor<String> valueCapture = ArgumentCaptor.forClass(String.class);
|
||||
doNothing().when(mockAdapter).addCategory(valueCapture.capture());
|
||||
var sut = new CategoryCommands(mockAdapter);
|
||||
|
||||
var returnValue = sut.executeSubcommand(new String[]{"add", categoryName});
|
||||
|
||||
assertEquals(categoryName, valueCapture.getValue());
|
||||
assertEquals("Added the new category", returnValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getCommandWorks() {
|
||||
var sut = new CategoryCommands(mockAdapter);
|
||||
when(mockAdapter.getCategories()).thenReturn(Set.of("funStuff", "workStuff"));
|
||||
var returnValue = sut.executeSubcommand(new String[]{"get"});
|
||||
|
||||
var expected =
|
||||
"Available Categories:" + System.lineSeparator() + "funStuff" + System.lineSeparator() + "workStuff";
|
||||
|
||||
assertEquals(expected, returnValue);
|
||||
}
|
||||
}
|
Reference in a new issue