|
| 1 | +package com.endava.cats.command; |
| 2 | + |
| 3 | +import io.quarkus.test.junit.QuarkusTest; |
| 4 | +import org.junit.jupiter.api.BeforeEach; |
| 5 | +import org.junit.jupiter.api.Test; |
| 6 | + |
| 7 | +import static org.mockito.Mockito.doNothing; |
| 8 | +import static org.mockito.Mockito.never; |
| 9 | +import static org.mockito.Mockito.spy; |
| 10 | +import static org.mockito.Mockito.verify; |
| 11 | + |
| 12 | +@QuarkusTest |
| 13 | +class ExplainCommandTest { |
| 14 | + private ExplainCommand explainCommand; |
| 15 | + |
| 16 | + @BeforeEach |
| 17 | + void setup() { |
| 18 | + explainCommand = spy(new ExplainCommand()); |
| 19 | + } |
| 20 | + |
| 21 | + @Test |
| 22 | + void testRun_FuzzerType_CallsDisplayFuzzerInfo() { |
| 23 | + explainCommand.type = ExplainCommand.Type.FUZZER; |
| 24 | + doNothing().when(explainCommand).displayFuzzerInfo(); |
| 25 | + explainCommand.run(); |
| 26 | + verify(explainCommand).displayFuzzerInfo(); |
| 27 | + verify(explainCommand, never()).displayMutatorInfo(); |
| 28 | + verify(explainCommand, never()).displayResponseCodeInfo(); |
| 29 | + verify(explainCommand, never()).displayErrorReason(); |
| 30 | + } |
| 31 | + |
| 32 | + @Test |
| 33 | + void testRun_MutatorType_CallsDisplayMutatorInfo() { |
| 34 | + explainCommand.type = ExplainCommand.Type.MUTATOR; |
| 35 | + doNothing().when(explainCommand).displayMutatorInfo(); |
| 36 | + explainCommand.run(); |
| 37 | + verify(explainCommand).displayMutatorInfo(); |
| 38 | + verify(explainCommand, never()).displayFuzzerInfo(); |
| 39 | + verify(explainCommand, never()).displayResponseCodeInfo(); |
| 40 | + verify(explainCommand, never()).displayErrorReason(); |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + void testRun_ResponseCodeType_CallsDisplayResponseCodeInfo() { |
| 45 | + explainCommand.type = ExplainCommand.Type.RESPONSE_CODE; |
| 46 | + doNothing().when(explainCommand).displayResponseCodeInfo(); |
| 47 | + explainCommand.run(); |
| 48 | + verify(explainCommand).displayResponseCodeInfo(); |
| 49 | + verify(explainCommand, never()).displayFuzzerInfo(); |
| 50 | + verify(explainCommand, never()).displayMutatorInfo(); |
| 51 | + verify(explainCommand, never()).displayErrorReason(); |
| 52 | + } |
| 53 | + |
| 54 | + @Test |
| 55 | + void testRun_ErrorReasonType_CallsDisplayErrorReason() { |
| 56 | + explainCommand.type = ExplainCommand.Type.ERROR_REASON; |
| 57 | + doNothing().when(explainCommand).displayErrorReason(); |
| 58 | + explainCommand.run(); |
| 59 | + verify(explainCommand).displayErrorReason(); |
| 60 | + verify(explainCommand, never()).displayFuzzerInfo(); |
| 61 | + verify(explainCommand, never()).displayMutatorInfo(); |
| 62 | + verify(explainCommand, never()).displayResponseCodeInfo(); |
| 63 | + } |
| 64 | +} |
0 commit comments