@Test public void testExecuteWithParitialResponseFromMapperAndNoDecoratedMapper() { DecoratedPartialResponseDomainMapper<Object, Object> sut = new DecoratedPartialResponseDomainMapper<Object, Object>(partialMapper, null, resultsCombiner, refreshStrategy); final Object request = new Object(); final Object response = new Object(); final PartialMapperResponse<Object, Object> partialResponse = new PartialMapperResponse<Object, Object>( response, new Object()); final Object combinedResponse = new Object(); context.checking(new Expectations() { { oneOf(partialMapper).execute(request); will(returnValue(partialResponse)); oneOf(resultsCombiner).combine(partialResponse, null, request); will(returnValue(combinedResponse)); } }); assertSame(combinedResponse, sut.execute(request)); context.assertIsSatisfied(); }
public Response execute(final Request request) { PartialMapperResponse<Request, Response> partialResponse = partialMapper.execute(request); if (!partialResponse.hasUnhandledRequest()) { if (log.isInfoEnabled()) { log.info("Found complete response with partial response mapper - " + partialMapper.getClass()); } return partialResponse.getResponse(); } if (log.isInfoEnabled()) { if (partialResponse.getResponse() != null) { log.info("Found partial response with partial response mapper - " + partialMapper.getClass()); } else { log.info("Found no response with partial response mapper - " + partialMapper.getClass()); } } Response decoratedResponse = null; if (decoratedMapper != null) { if (log.isInfoEnabled()) { log.info("Trying to complete response with decorated mapper - " + decoratedMapper.getClass()); } decoratedResponse = decoratedMapper.execute(partialResponse.getUnhandledRequest()); if (log.isInfoEnabled()) { if (decoratedResponse != null) { log.info("Found response with decorated response mapper - " + decoratedMapper.getClass()); } else { log.info("Found no response with decorated response mapper - " + decoratedMapper.getClass()); } } refreshStrategy.refresh(partialResponse.getUnhandledRequest(), decoratedResponse); } else { if (log.isInfoEnabled()) { log.info("No decorated mapper to try."); } } log.info("Combining partial response mapper and decorated mapper responses."); return resultsCombiner.combine(partialResponse, decoratedResponse, request); }
DecoratedPartialResponseDomainMapper implements DomainMapper<Request, Response> { public Response execute(final Request request) { PartialMapperResponse<Request, Response> partialResponse = partialMapper.execute(request); if (!partialResponse.hasUnhandledRequest()) { if (log.isInfoEnabled()) { log.info("Found complete response with partial response mapper - " + partialMapper.getClass()); } return partialResponse.getResponse(); } if (log.isInfoEnabled()) { if (partialResponse.getResponse() != null) { log.info("Found partial response with partial response mapper - " + partialMapper.getClass()); } else { log.info("Found no response with partial response mapper - " + partialMapper.getClass()); } } Response decoratedResponse = null; if (decoratedMapper != null) { if (log.isInfoEnabled()) { log.info("Trying to complete response with decorated mapper - " + decoratedMapper.getClass()); } decoratedResponse = decoratedMapper.execute(partialResponse.getUnhandledRequest()); if (log.isInfoEnabled()) { if (decoratedResponse != null) { log.info("Found response with decorated response mapper - " + decoratedMapper.getClass()); } else { log.info("Found no response with decorated response mapper - " + decoratedMapper.getClass()); } } refreshStrategy.refresh(partialResponse.getUnhandledRequest(), decoratedResponse); } else { if (log.isInfoEnabled()) { log.info("No decorated mapper to try."); } } log.info("Combining partial response mapper and decorated mapper responses."); return resultsCombiner.combine(partialResponse, decoratedResponse, request); } }
DecoratedPartialResponseDomainMapper implements DomainMapper<Request, Response> { public Response execute(final Request request) { PartialMapperResponse<Request, Response> partialResponse = partialMapper.execute(request); if (!partialResponse.hasUnhandledRequest()) { if (log.isInfoEnabled()) { log.info("Found complete response with partial response mapper - " + partialMapper.getClass()); } return partialResponse.getResponse(); } if (log.isInfoEnabled()) { if (partialResponse.getResponse() != null) { log.info("Found partial response with partial response mapper - " + partialMapper.getClass()); } else { log.info("Found no response with partial response mapper - " + partialMapper.getClass()); } } Response decoratedResponse = null; if (decoratedMapper != null) { if (log.isInfoEnabled()) { log.info("Trying to complete response with decorated mapper - " + decoratedMapper.getClass()); } decoratedResponse = decoratedMapper.execute(partialResponse.getUnhandledRequest()); if (log.isInfoEnabled()) { if (decoratedResponse != null) { log.info("Found response with decorated response mapper - " + decoratedMapper.getClass()); } else { log.info("Found no response with decorated response mapper - " + decoratedMapper.getClass()); } } refreshStrategy.refresh(partialResponse.getUnhandledRequest(), decoratedResponse); } else { if (log.isInfoEnabled()) { log.info("No decorated mapper to try."); } } log.info("Combining partial response mapper and decorated mapper responses."); return resultsCombiner.combine(partialResponse, decoratedResponse, request); } DecoratedPartialResponseDomainMapper(
            final DomainMapper<Request, PartialMapperResponse<Request, Response>> inPartialMapper,
            final DomainMapper<Request, Response> inDecoratedMapper,
            final ResultsCombinerStrategy<Request, Response> inResultsCombiner,
            final RefreshStrategy<Request, Response> inRefreshStrategy); }
DecoratedPartialResponseDomainMapper implements DomainMapper<Request, Response> { public Response execute(final Request request) { PartialMapperResponse<Request, Response> partialResponse = partialMapper.execute(request); if (!partialResponse.hasUnhandledRequest()) { if (log.isInfoEnabled()) { log.info("Found complete response with partial response mapper - " + partialMapper.getClass()); } return partialResponse.getResponse(); } if (log.isInfoEnabled()) { if (partialResponse.getResponse() != null) { log.info("Found partial response with partial response mapper - " + partialMapper.getClass()); } else { log.info("Found no response with partial response mapper - " + partialMapper.getClass()); } } Response decoratedResponse = null; if (decoratedMapper != null) { if (log.isInfoEnabled()) { log.info("Trying to complete response with decorated mapper - " + decoratedMapper.getClass()); } decoratedResponse = decoratedMapper.execute(partialResponse.getUnhandledRequest()); if (log.isInfoEnabled()) { if (decoratedResponse != null) { log.info("Found response with decorated response mapper - " + decoratedMapper.getClass()); } else { log.info("Found no response with decorated response mapper - " + decoratedMapper.getClass()); } } refreshStrategy.refresh(partialResponse.getUnhandledRequest(), decoratedResponse); } else { if (log.isInfoEnabled()) { log.info("No decorated mapper to try."); } } log.info("Combining partial response mapper and decorated mapper responses."); return resultsCombiner.combine(partialResponse, decoratedResponse, request); } DecoratedPartialResponseDomainMapper(
            final DomainMapper<Request, PartialMapperResponse<Request, Response>> inPartialMapper,
            final DomainMapper<Request, Response> inDecoratedMapper,
            final ResultsCombinerStrategy<Request, Response> inResultsCombiner,
            final RefreshStrategy<Request, Response> inRefreshStrategy); Response execute(final Request request); }
DecoratedPartialResponseDomainMapper implements DomainMapper<Request, Response> { public Response execute(final Request request) { PartialMapperResponse<Request, Response> partialResponse = partialMapper.execute(request); if (!partialResponse.hasUnhandledRequest()) { if (log.isInfoEnabled()) { log.info("Found complete response with partial response mapper - " + partialMapper.getClass()); } return partialResponse.getResponse(); } if (log.isInfoEnabled()) { if (partialResponse.getResponse() != null) { log.info("Found partial response with partial response mapper - " + partialMapper.getClass()); } else { log.info("Found no response with partial response mapper - " + partialMapper.getClass()); } } Response decoratedResponse = null; if (decoratedMapper != null) { if (log.isInfoEnabled()) { log.info("Trying to complete response with decorated mapper - " + decoratedMapper.getClass()); } decoratedResponse = decoratedMapper.execute(partialResponse.getUnhandledRequest()); if (log.isInfoEnabled()) { if (decoratedResponse != null) { log.info("Found response with decorated response mapper - " + decoratedMapper.getClass()); } else { log.info("Found no response with decorated response mapper - " + decoratedMapper.getClass()); } } refreshStrategy.refresh(partialResponse.getUnhandledRequest(), decoratedResponse); } else { if (log.isInfoEnabled()) { log.info("No decorated mapper to try."); } } log.info("Combining partial response mapper and decorated mapper responses."); return resultsCombiner.combine(partialResponse, decoratedResponse, request); } DecoratedPartialResponseDomainMapper(
            final DomainMapper<Request, PartialMapperResponse<Request, Response>> inPartialMapper,
            final DomainMapper<Request, Response> inDecoratedMapper,
            final ResultsCombinerStrategy<Request, Response> inResultsCombiner,
            final RefreshStrategy<Request, Response> inRefreshStrategy); Response execute(final Request request);  }