@Test public void testFindResponseDescriptorWhenConditionThrowsExceptionShouldLogError() { NullPointerException nullPointerException = new NullPointerException(); given(stubDescriptor.getDialogDescriptors()).willReturn(dialogDescriptors); given(dialogDescriptor.getConditionDescriptor()).willReturn(conditionDescriptor); given(dialogDescriptor.getAttributes().getName()).willReturn(DIALOG_DESCRIPTOR_NAME); given(conditionDescriptor.getCondition()).willReturn(condition); given(conditionEvaluator.evaluate(condition, clonedRequest)).willThrow(nullPointerException); given(stackTraceConverter.getStackTraceAsString(nullPointerException)).willReturn("error"); Whitebox.setInternalState(underTest, "logger", logger); underTest.findResponseDescriptor(stubDescriptors, request); verify(logger).error(Mockito.eq("Error during condition evaluation in the dialog descriptor 'dialog-descriptor'!"), Mockito.any(NullPointerException.class)); }
public ResponseDescriptorDTO findResponseDescriptor(final Map<String, StubDescriptor> stubDescriptors, final WilmaHttpRequest request) { ResponseDescriptorDTO responseDescriptorDTO = null; for (StubDescriptor stubDescriptor : stubDescriptors.values()) { StubDescriptorAttributes attributes = stubDescriptor.getAttributes(); if (attributes.isActive()) { Iterator<DialogDescriptor> iterator = stubDescriptor.getDialogDescriptors().iterator(); while (iterator.hasNext() && responseDescriptorDTO == null) { DialogDescriptor dialogDescriptor = iterator.next(); responseDescriptorDTO = evaluateDialogDescriptor(request, dialogDescriptor); } } } return responseDescriptorDTO; }
StubDescriptorEvaluator { public ResponseDescriptorDTO findResponseDescriptor(final Map<String, StubDescriptor> stubDescriptors, final WilmaHttpRequest request) { ResponseDescriptorDTO responseDescriptorDTO = null; for (StubDescriptor stubDescriptor : stubDescriptors.values()) { StubDescriptorAttributes attributes = stubDescriptor.getAttributes(); if (attributes.isActive()) { Iterator<DialogDescriptor> iterator = stubDescriptor.getDialogDescriptors().iterator(); while (iterator.hasNext() && responseDescriptorDTO == null) { DialogDescriptor dialogDescriptor = iterator.next(); responseDescriptorDTO = evaluateDialogDescriptor(request, dialogDescriptor); } } } return responseDescriptorDTO; } }
StubDescriptorEvaluator { public ResponseDescriptorDTO findResponseDescriptor(final Map<String, StubDescriptor> stubDescriptors, final WilmaHttpRequest request) { ResponseDescriptorDTO responseDescriptorDTO = null; for (StubDescriptor stubDescriptor : stubDescriptors.values()) { StubDescriptorAttributes attributes = stubDescriptor.getAttributes(); if (attributes.isActive()) { Iterator<DialogDescriptor> iterator = stubDescriptor.getDialogDescriptors().iterator(); while (iterator.hasNext() && responseDescriptorDTO == null) { DialogDescriptor dialogDescriptor = iterator.next(); responseDescriptorDTO = evaluateDialogDescriptor(request, dialogDescriptor); } } } return responseDescriptorDTO; }  }
StubDescriptorEvaluator { public ResponseDescriptorDTO findResponseDescriptor(final Map<String, StubDescriptor> stubDescriptors, final WilmaHttpRequest request) { ResponseDescriptorDTO responseDescriptorDTO = null; for (StubDescriptor stubDescriptor : stubDescriptors.values()) { StubDescriptorAttributes attributes = stubDescriptor.getAttributes(); if (attributes.isActive()) { Iterator<DialogDescriptor> iterator = stubDescriptor.getDialogDescriptors().iterator(); while (iterator.hasNext() && responseDescriptorDTO == null) { DialogDescriptor dialogDescriptor = iterator.next(); responseDescriptorDTO = evaluateDialogDescriptor(request, dialogDescriptor); } } } return responseDescriptorDTO; }  ResponseDescriptorDTO findResponseDescriptor(final Map<String, StubDescriptor> stubDescriptors, final WilmaHttpRequest request); }
StubDescriptorEvaluator { public ResponseDescriptorDTO findResponseDescriptor(final Map<String, StubDescriptor> stubDescriptors, final WilmaHttpRequest request) { ResponseDescriptorDTO responseDescriptorDTO = null; for (StubDescriptor stubDescriptor : stubDescriptors.values()) { StubDescriptorAttributes attributes = stubDescriptor.getAttributes(); if (attributes.isActive()) { Iterator<DialogDescriptor> iterator = stubDescriptor.getDialogDescriptors().iterator(); while (iterator.hasNext() && responseDescriptorDTO == null) { DialogDescriptor dialogDescriptor = iterator.next(); responseDescriptorDTO = evaluateDialogDescriptor(request, dialogDescriptor); } } } return responseDescriptorDTO; }  ResponseDescriptorDTO findResponseDescriptor(final Map<String, StubDescriptor> stubDescriptors, final WilmaHttpRequest request);  }