Неожиданный вызов метода в EasyMock - PullRequest
0 голосов
/ 25 января 2019

У меня есть кусок кода:

if (wfStepExDetails.isPresent()) {
            this.postInterruptActionsExecutor.takeActionAfterWFInterrupted(wfStepExDetails.get(), this.pAccId, interrupts, this.workflowStepDefinition);
        } 

Внутренний тестовый класс:

@Test
    public void testHandlePostInterruptActions() {
postInterruptActionsExecutor.takeActionAfterWFInterrupted(getWfStepExecutionDetails().get(0), pAccId, interrupt, wfStep);
        expectLastCall();
        replay(postInterruptActionsExecutor);
    orchestrator.handlePostInterruptActions(interrupt);
    EasyMock.verify(postInterruptActionsExecutor, orcDepProvider, pwaDAO, pdh);
}

Тест не пройден из-за несоответствия аргумента:

[junit]   Unexpected method call PostInterruptActionsExecutor.takeActionAfterWFInterrupted(WorkflowStepExecutionDetails(wfStepName=null, wfId=4c46f286-c368-49e7-a7db-30c39d72d1b8, planId=null, resultBranch=null, wfStepStatus=null, creationTime=null, workflowStepRequirements=null, attemptCount=null, parentWfStepId=null, wfStepType=null, wfStepDependencyResponseId=null), "81bd1b7e-7433-4116-bf46-52318b493e93", [com.amazon.verificationorchestration.plan.Interrupt@9e781b8e], com.amazon.verificationorchestration.plan.InitiateTokenVerificationWorkflowStep@860a7ec9):
[junit]     PostInterruptActionsExecutor.takeActionAfterWFInterrupted(WorkflowStepExecutionDetails(wfStepName=null, wfId=4c46f286-c368-49e7-a7db-30c39d72d1b8, planId=null, resultBranch=null, wfStepStatus=null, creationTime=null, workflowStepRequirements=null, attemptCount=null, parentWfStepId=null, wfStepType=null, wfStepDependencyResponseId=null), "81bd1b7e-7433-4116-bf46-52318b493e93", [com.amazon.verificationorchestration.plan.Interrupt@9e781b8e], com.amazon.verificationorchestration.plan.InitiateTokenVerificationWorkflowStep@860a7ec9): expected: 1, actual: 0

Несмотря на то, что ожидаемый и фактический вызов содержит тот же аргумент, проверка по-прежнему не выполняется. Есть ли что-то, что я здесь скучаю?

1 Ответ

0 голосов
/ 26 января 2019

Я думаю, что вы используете слегка старую версию EasyMock, в противном случае сообщение будет намного понятнее.Какая это версия?

EasyMock использует eq() в качестве сопоставителя по умолчанию.Здесь я подозреваю, что toString() для WorkflowStepExecutionDetails делает их похожими, но Object.equals, вероятно, не переопределяется.И так как это два разных случая, они не равны согласно Object.equals (то есть ==).

...