StubResourceHolderUpdater { public void initializeTemporaryResourceHolder() { temporaryStubResourceHolder.setConditionCheckers(new ArrayList<>(internalResourceHolder.getConditionCheckers())); temporaryStubResourceHolder.setResponseFormatters(new ArrayList<>(internalResourceHolder.getResponseFormatters())); initializeRequestInterceptors(); initializeResponseInterceptors(); temporaryStubResourceHolder.setSequenceHandlers(new ArrayList<>(internalResourceHolder.getSequenceHandlers())); }  void updateResourceHolder(); void clearTemporaryResourceHolder(); void addDocumentToResourceHolder(final String groupName, final Document document); void addDocumentToResourceHolder(final String groupName, final JSONObject jsonObject); void initializeTemporaryResourceHolder();  }
@Test public void testInitializeTemporaryResourceHolderShouldInitializeResources() { List<ConditionChecker> conditionCheckers = new ArrayList<>(); List<ResponseFormatter> responseFormatters = new ArrayList<>(); List<RequestInterceptor> requestInterceptors = new ArrayList<>(); List<ResponseInterceptor> responseInterceptors = new ArrayList<>(); List<SequenceHandler> sequenceHandlers = new ArrayList<>(); given(internalResourceHolder.getConditionCheckers()).willReturn(conditionCheckers); given(internalResourceHolder.getResponseFormatters()).willReturn(responseFormatters); given(internalResourceHolder.getRequestInterceptors()).willReturn(requestInterceptors); given(internalResourceHolder.getResponseInterceptors()).willReturn(responseInterceptors); given(internalResourceHolder.getSequenceHandlers()).willReturn(sequenceHandlers); underTest.initializeTemporaryResourceHolder(); verify(temporaryStubResourceHolder).setConditionCheckers(conditionCheckers); verify(temporaryStubResourceHolder).setResponseFormatters(responseFormatters); verify(temporaryStubResourceHolder).setRequestInterceptors(requestInterceptors); verify(temporaryStubResourceHolder).setResponseInterceptors(responseInterceptors); verify(temporaryStubResourceHolder).setSequenceHandlers(sequenceHandlers); }
@Test public void testInitializeTemporaryResourceHolderWhenNoInterceptorsShouldNotInitializeResources() { List<ConditionChecker> conditionCheckers = new ArrayList<>(); List<ResponseFormatter> templateFormatters = new ArrayList<>(); List<SequenceHandler> sequenceHandlers = new ArrayList<>(); given(internalResourceHolder.getConditionCheckers()).willReturn(conditionCheckers); given(internalResourceHolder.getResponseFormatters()).willReturn(templateFormatters); given(internalResourceHolder.getRequestInterceptors()).willReturn(null); given(internalResourceHolder.getResponseInterceptors()).willReturn(null); given(internalResourceHolder.getSequenceHandlers()).willReturn(sequenceHandlers); underTest.initializeTemporaryResourceHolder(); verify(temporaryStubResourceHolder).setConditionCheckers(conditionCheckers); verify(temporaryStubResourceHolder).setResponseFormatters(templateFormatters); verify(temporaryStubResourceHolder, BDDMockito.never()).setRequestInterceptors(null); verify(temporaryStubResourceHolder, BDDMockito.never()).setResponseInterceptors(null); verify(temporaryStubResourceHolder).setSequenceHandlers(sequenceHandlers); }