StubModeEvaluator { public ResponseDescriptorDTO getResponseDescriptorForStubMode(final WilmaHttpRequest request, final OperationMode operationMode) { ResponseDescriptorDTO responseDescriptorDTOForStub = null; if (operationMode == OperationMode.STUB) { if (dialogDescriptorForStub == null) { dialogDescriptorForStub = dialogDescriptorFactory.createDialogDescriptorForStubMode(DIALOG_DESCRIPTOR_NAME_FOR_STUB_MODE); } responseDescriptorDTOForStub = responseDescriptorDtoFactory.createResponseDescriptorDTO(request.getBody(), dialogDescriptorForStub); responseDescriptorDtoFactory.modifyResponseDescriptorDTOForStubMode(request, responseDescriptorDTOForStub); } return responseDescriptorDTOForStub; }  ResponseDescriptorDTO getResponseDescriptorForStubMode(final WilmaHttpRequest request, final OperationMode operationMode);  }
@Test public void testGetResponseDescriptorForStubModeShouldReturnTheResponseDescriptorWhenOperationModeIsStub() { given(responseDescriptorDtoFactory.createResponseDescriptorDTO(DEFAULT_GROUPNAME, dialogDescriptor)).willReturn(responseDescriptorDTO); given(responseDescriptorDTO.getResponseDescriptor()).willReturn(responseDescriptor); given(responseDescriptor.getAttributes()).willReturn(responseDescriptorAttributes); given(template.getResource()).willReturn(resource); given(request.getBody()).willReturn(DEFAULT_GROUPNAME); ResponseDescriptorDTO result = underTest.getResponseDescriptorForStubMode(request, OperationMode.STUB); verify(responseDescriptorDtoFactory).modifyResponseDescriptorDTOForStubMode(request, responseDescriptorDTO); Assert.assertNotNull(result); }
@Test public void testGetResponseDescriptorForStubModeShouldReturnTheResponseDescriptorWhenOperationModeIsStubAndAtFirstCall() { Whitebox.setInternalState(underTest, "dialogDescriptorForStub", null); given(dialogDescriptorFactory.createDialogDescriptorForStubMode(DIALOG_DESCRIPTOR_NAME_FOR_STUB_MODE)).willReturn(dialogDescriptor); given(responseDescriptorDtoFactory.createResponseDescriptorDTO(DEFAULT_GROUPNAME, dialogDescriptor)).willReturn(responseDescriptorDTO); given(responseDescriptorDTO.getResponseDescriptor()).willReturn(responseDescriptor); given(responseDescriptor.getAttributes()).willReturn(responseDescriptorAttributes); given(template.getResource()).willReturn(resource); given(request.getBody()).willReturn(DEFAULT_GROUPNAME); ResponseDescriptorDTO result = underTest.getResponseDescriptorForStubMode(request, OperationMode.STUB); verify(responseDescriptorDtoFactory).modifyResponseDescriptorDTOForStubMode(request, responseDescriptorDTO); Assert.assertNotNull(result); }
@Test public void testGetResponseDescriptorForStubModeShouldReturnNullWhenOperationModeIsWilma() { ResponseDescriptorDTO result = underTest.getResponseDescriptorForStubMode(request, OperationMode.WILMA); Assert.assertNull(result); }
@Test public void testGetResponseDescriptorForStubModeShouldReturnNullWhenOperationModeIsProxy() { ResponseDescriptorDTO result = underTest.getResponseDescriptorForStubMode(request, OperationMode.PROXY); Assert.assertNull(result); }